|
|
|
@ -17,8 +17,92 @@
|
|
|
|
|
import os
|
|
|
|
|
import re
|
|
|
|
|
import cl_overriding
|
|
|
|
|
import operator
|
|
|
|
|
from cl_vars_share import varsShare
|
|
|
|
|
from os import path
|
|
|
|
|
from cl_distr import DistributiveRepository
|
|
|
|
|
|
|
|
|
|
class fillVars(object, varsShare):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def get_os_assemble_linux_shortname(self):
|
|
|
|
|
"""Get short system name"""
|
|
|
|
|
if self.Get('cl_action') == 'configure':
|
|
|
|
|
return self.Get('os_linux_shortname')
|
|
|
|
|
else:
|
|
|
|
|
systemRoot = self.Get('cl_assemble_path')
|
|
|
|
|
return self.getShortnameByMakeprofile(systemRoot) or \
|
|
|
|
|
self.getShortnameByIni(systemRoot) or \
|
|
|
|
|
self.detectOtherShortname(systemRoot) or \
|
|
|
|
|
"Linux"
|
|
|
|
|
|
|
|
|
|
def get_os_assemble_linux_name(self):
|
|
|
|
|
"""Get full system name"""
|
|
|
|
|
linuxShortName = self.Get("os_assemble_linux_shortname")
|
|
|
|
|
return self.dictLinuxName.get(linuxShortName,"Linux")
|
|
|
|
|
|
|
|
|
|
def get_os_assemble_linux_subname(self):
|
|
|
|
|
"""Get posfix name of system"""
|
|
|
|
|
linuxShortName = self.Get("os_assemble_linux_shortname")
|
|
|
|
|
return self.dictLinuxSubName.get(linuxShortName,"")
|
|
|
|
|
|
|
|
|
|
def get_os_assemble_linux_ver(self):
|
|
|
|
|
"""Get system version"""
|
|
|
|
|
imagename = self.getImage(self.Get('cl_assemble_image_path'),
|
|
|
|
|
self.Get('os_assemble_arch_machine'),
|
|
|
|
|
self.Get('os_assemble_linux_shortname'))
|
|
|
|
|
res = DistributiveRepository.reDistName.search(imagename)
|
|
|
|
|
if res:
|
|
|
|
|
return res.groupdict()['ver']
|
|
|
|
|
elif path.isdir(imagename):
|
|
|
|
|
d = DistributiveRepository()._getdistrinfo(imagename)
|
|
|
|
|
if "linuxver" in d:
|
|
|
|
|
return d['linuxver']
|
|
|
|
|
else:
|
|
|
|
|
if self.Get('os_assemble_linux_shortname') == \
|
|
|
|
|
self.Get('os_linux_shortname'):
|
|
|
|
|
return self.Get('os_linux_ver')
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
def get_os_assemble_arch_machine(self):
|
|
|
|
|
"""Marching architecture for assembling"""
|
|
|
|
|
return self.Get('os_arch_machine')
|
|
|
|
|
|
|
|
|
|
def get_cl_assemble_image_path(self):
|
|
|
|
|
if self.Get('cl_action') == 'configure':
|
|
|
|
|
return ['/var/calculate/remote/linux',
|
|
|
|
|
'/var/calculate/linux',
|
|
|
|
|
'/usr/calculate/share/linux',
|
|
|
|
|
'/var/calculate/remote/stages/',
|
|
|
|
|
'/usr/calculate/share/stages/']
|
|
|
|
|
|
|
|
|
|
def get_os_assemble_linux_system(self):
|
|
|
|
|
"""Get assemble linux system (server or desktop)"""
|
|
|
|
|
shortName = self.Get('os_assemble_linux_shortname')
|
|
|
|
|
return self.dictNameSystem.get(shortName,"")
|
|
|
|
|
|
|
|
|
|
def getImage(self,imagePath,archMachine,
|
|
|
|
|
shortName,linuxVer=None):
|
|
|
|
|
"""Get image by parameters"""
|
|
|
|
|
distRep = DistributiveRepository(self.Get('cl_assemble_image_path'))
|
|
|
|
|
convert = {'desktop':'cls',
|
|
|
|
|
'server':'css'}
|
|
|
|
|
shortname = convert.get(self.Get('os_assemble_linux_system'),"")
|
|
|
|
|
if self.Get('os_assemble_linux_shortname').lower() in convert.values():
|
|
|
|
|
shortname = ""
|
|
|
|
|
if shortname:
|
|
|
|
|
distr = distRep.getBestDistributive(march=archMachine,
|
|
|
|
|
shortname=shortname,
|
|
|
|
|
discardType=[],
|
|
|
|
|
version=linuxVer,
|
|
|
|
|
op_compare=operator.ge)
|
|
|
|
|
else:
|
|
|
|
|
distr = ""
|
|
|
|
|
return distr or distRep.getBestStage(march=archMachine)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_cl_assemble_image(self):
|
|
|
|
|
"""Get image file from distributive repository"""
|
|
|
|
|
return self.getImage(self.Get('cl_assemble_image_path'),
|
|
|
|
|
self.Get('os_assemble_arch_machine'),
|
|
|
|
|
self.Get('os_assemble_linux_shortname'),
|
|
|
|
|
self.Get('os_assemble_linux_ver'))
|
|
|
|
|