|
|
|
@ -24,8 +24,11 @@ from os import path
|
|
|
|
|
from os import readlink,access,R_OK
|
|
|
|
|
from cl_utils import isMount,typeFile,getTupleVersion,pathJoin,isFstabMount,\
|
|
|
|
|
listDirectory, getAvailableVideo, getUUIDDict, \
|
|
|
|
|
getUdevDeviceInfo, getPartitionDevice, getPartitionSize, \
|
|
|
|
|
isPkgInstalled, process, checkUtils, readLinesFile, \
|
|
|
|
|
lspci, getPartitionSize, getInstalledVideo
|
|
|
|
|
FStab, lspci, getInstalledVideo,getDeviceType, \
|
|
|
|
|
getPartitionType, getOsProberHash, getProgPath, \
|
|
|
|
|
getRaidPartitions, getLvmPartitions, getLvmGroups
|
|
|
|
|
from cl_distr import DistributiveRepository,PartitionDistributive
|
|
|
|
|
from cl_fill import clLocale
|
|
|
|
|
from operator import itemgetter
|
|
|
|
@ -45,6 +48,8 @@ class fillVars(object, glob_attr):
|
|
|
|
|
"/opt", "/proc", "/sbin",
|
|
|
|
|
"/sys", "/usr", "/var"]
|
|
|
|
|
|
|
|
|
|
reWrongDevice = re.compile("|".join(['^fd','^ram','^loop']))
|
|
|
|
|
|
|
|
|
|
def removeFloppy(self):
|
|
|
|
|
"""Remove floopy device and return floppyData"""
|
|
|
|
|
floppyPath = '/dev/fd1'
|
|
|
|
@ -225,6 +230,10 @@ class fillVars(object, glob_attr):
|
|
|
|
|
listInterfacesInfo))
|
|
|
|
|
|
|
|
|
|
def get_os_device_hash(self):
|
|
|
|
|
def onlyDisk(devpath):
|
|
|
|
|
prop = getUdevDeviceInfo(devpath)
|
|
|
|
|
return prop.get("ID_TYPE","")=="disk" and \
|
|
|
|
|
prop.get("DEVTYPE","")=="disk"
|
|
|
|
|
diskIdPath = '/dev/disk/by-id'
|
|
|
|
|
if path.exists(diskIdPath):
|
|
|
|
|
usbdevices = \
|
|
|
|
@ -232,34 +241,23 @@ class fillVars(object, glob_attr):
|
|
|
|
|
filter(lambda x: x.startswith('usb-'),listDirectory(diskIdPath)))
|
|
|
|
|
else:
|
|
|
|
|
usbdevices = []
|
|
|
|
|
reWrongDevice = re.compile("|".join(['sr','fd','ram','loop']))
|
|
|
|
|
devices = filter( lambda x: not reWrongDevice.search(x),
|
|
|
|
|
listDirectory('/sys/block'))
|
|
|
|
|
sysBlockPath = '/sys/block'
|
|
|
|
|
devices = map(lambda x:path.join(sysBlockPath,x),
|
|
|
|
|
filter(lambda x: onlyDisk(path.join(sysBlockPath,x)),
|
|
|
|
|
filter(lambda x: not self.reWrongDevice.search(x),
|
|
|
|
|
listDirectory(sysBlockPath))))
|
|
|
|
|
device_hash = {}
|
|
|
|
|
execParted = self.getProgPath("/usr/sbin/parted")
|
|
|
|
|
if not execParted:
|
|
|
|
|
cl_overriding.printERROR(_("Command not found '%s'")%"parted")
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
for mapnum,device in enumerate(sorted(devices,key=self.separateDevice)):
|
|
|
|
|
if device.startswith('cciss'):
|
|
|
|
|
device = device.replace('!','/')
|
|
|
|
|
props = getUdevDeviceInfo(device)
|
|
|
|
|
if not "DEVNAME" in props:
|
|
|
|
|
continue
|
|
|
|
|
device = props['DEVNAME']
|
|
|
|
|
device_hash[device] = {}
|
|
|
|
|
device_hash[device]['table'] = props.get('ID_PART_TABLE_TYPE','')
|
|
|
|
|
device_hash[device]['map'] = mapnum
|
|
|
|
|
device_hash[device]['table'] = None
|
|
|
|
|
execStr = '%(prog)s %(device)s print'% \
|
|
|
|
|
{'prog':execParted,
|
|
|
|
|
'device':"/dev/%s"%device}
|
|
|
|
|
floppyData = self.removeFloppy()
|
|
|
|
|
res = self._runos(execStr,env={"LANG":"C"})
|
|
|
|
|
self.restoreFloppy(floppyData)
|
|
|
|
|
if res:
|
|
|
|
|
res = map(lambda x:x.rpartition("Partition Table:")[2],
|
|
|
|
|
filter(lambda x:x.startswith("Partition Table:"),
|
|
|
|
|
res))
|
|
|
|
|
if res:
|
|
|
|
|
device_hash[device]['table'] = res[-1].strip()
|
|
|
|
|
if device in usbdevices:
|
|
|
|
|
removablePath = '/sys/block/%s/removable'%device
|
|
|
|
|
|
|
|
|
|
if path.basename(device) in usbdevices:
|
|
|
|
|
removablePath = '/sys/block/%s/removable'%path.basename(device)
|
|
|
|
|
if os.access(removablePath,R_OK) and \
|
|
|
|
|
open(removablePath,'r').read().strip() == "1":
|
|
|
|
|
devtype = "flash"
|
|
|
|
@ -271,170 +269,80 @@ class fillVars(object, glob_attr):
|
|
|
|
|
return device_hash
|
|
|
|
|
|
|
|
|
|
def get_os_disk_hash(self):
|
|
|
|
|
# check command existing
|
|
|
|
|
for util in ("/sbin/fdisk","/usr/sbin/gdisk","/sbin/blkid",
|
|
|
|
|
"/usr/sbin/parted"):
|
|
|
|
|
utilPath = self.getProgPath(util)
|
|
|
|
|
if not utilPath:
|
|
|
|
|
cl_overriding.printERROR(_("Command not found '%s'")%
|
|
|
|
|
path.basename(util))
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
|
|
|
|
|
reSdaPart = \
|
|
|
|
|
re.compile("^/dev/(sd[a-z])(\d+)|/dev/(cciss/c\dd\d+)p(\d+)$")
|
|
|
|
|
"""Get information about disk, which use for installation"""
|
|
|
|
|
def selfOrPartition(devpath):
|
|
|
|
|
"""Return self device or partitions if it has them"""
|
|
|
|
|
# search partition in device
|
|
|
|
|
partitions = \
|
|
|
|
|
filter(lambda x:x.startswith(path.basename(devpath)),
|
|
|
|
|
listDirectory(devpath))
|
|
|
|
|
if partitions:
|
|
|
|
|
return filter(lambda x:x,
|
|
|
|
|
map(lambda x:selfOrPartition(path.join(devpath,x)),
|
|
|
|
|
partitions))
|
|
|
|
|
else:
|
|
|
|
|
return devpath
|
|
|
|
|
|
|
|
|
|
# refresh LVM
|
|
|
|
|
vgscan = getProgPath('/sbin/vgscan')
|
|
|
|
|
vgchange = getProgPath('/sbin/vgchange')
|
|
|
|
|
lvchange = getProgPath('/sbin/lvchange')
|
|
|
|
|
if vgscan and vgchange and lvchange:
|
|
|
|
|
process(vgscan).success()
|
|
|
|
|
process(vgchange,'-ay','--refresh').success()
|
|
|
|
|
for group in getLvmGroups():
|
|
|
|
|
process(lvchange,'-ay','--refresh',group).success()
|
|
|
|
|
devicesHash = self.Get('os_device_hash')
|
|
|
|
|
devices = devicesHash.keys()
|
|
|
|
|
disksDevs = reduce( lambda x,y: x +
|
|
|
|
|
map( lambda x: ["/dev/%s"%x.replace('!','/'),y],
|
|
|
|
|
filter(lambda x: y in x.replace('!','/'),
|
|
|
|
|
listDirectory('/sys/block/%s'%y.replace('/','!')))),
|
|
|
|
|
devices, [] )
|
|
|
|
|
disks = map(lambda x:x[0],disksDevs)
|
|
|
|
|
|
|
|
|
|
disksDevs = dict(disksDevs)
|
|
|
|
|
sysBlockPath = '/sys/block'
|
|
|
|
|
new_disks = reduce(lambda x,y:x+ ([y] if type(y) == str else y),
|
|
|
|
|
map(lambda x:selfOrPartition(path.join(sysBlockPath,x)),
|
|
|
|
|
filter(lambda x: not self.reWrongDevice.search(x),
|
|
|
|
|
listDirectory(sysBlockPath))),[])
|
|
|
|
|
disk_hash = {}
|
|
|
|
|
# fill grub info
|
|
|
|
|
for dev in sorted(disks):
|
|
|
|
|
disk_hash[dev] = {}
|
|
|
|
|
match = reSdaPart.match(dev)
|
|
|
|
|
if match:
|
|
|
|
|
if match.groups()[0] and match.groups()[0] in devicesHash:
|
|
|
|
|
disk_hash[dev]['grub'] = "%d,%d" % \
|
|
|
|
|
(int(devicesHash[match.groups()[0]]['map']),
|
|
|
|
|
int(match.groups()[1])-1)
|
|
|
|
|
elif match.groups()[2] in devicesHash:
|
|
|
|
|
disk_hash[dev]['grub'] = "%d,%d" % \
|
|
|
|
|
(int(devicesHash[match.groups()[2]]['map']),
|
|
|
|
|
int(match.groups()[3])-1)
|
|
|
|
|
curDevice = None
|
|
|
|
|
|
|
|
|
|
execFdisk = self.getProgPath("/sbin/fdisk")
|
|
|
|
|
execGdisk = self.getProgPath("/usr/sbin/gdisk")
|
|
|
|
|
# getting id
|
|
|
|
|
for device in devices:
|
|
|
|
|
if devicesHash[device]['table'] == 'msdos':
|
|
|
|
|
execStr = '%s -l %s'%(execFdisk,"/dev/%s"%device)
|
|
|
|
|
res = self._runos(execStr,env={"LANG":"C"})
|
|
|
|
|
if res is False:
|
|
|
|
|
cl_overriding.printERROR(_("Cann't execute '%s'")%execStr)
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
partedLines = filter(lambda x: x.startswith('/dev/'),res or [] )
|
|
|
|
|
partedMatrix = map(lambda x: filter(lambda y: y and y!="*",
|
|
|
|
|
x.split())[:6],
|
|
|
|
|
partedLines)
|
|
|
|
|
for part,nm,nm,nm,sysid,nm in \
|
|
|
|
|
filter(lambda x:len(x)>5,partedMatrix):
|
|
|
|
|
if not part in disk_hash:
|
|
|
|
|
disk_hash[part] = {}
|
|
|
|
|
disk_hash[part]['id'] = sysid
|
|
|
|
|
disk_hash[part]['table'] = 'msdos'
|
|
|
|
|
elif devicesHash[device]['table'] == 'gpt':
|
|
|
|
|
execStr = '%s -l %s'%(execGdisk,"/dev/%s"%device)
|
|
|
|
|
res = self._runos(execStr,env={"LANG":"C"})
|
|
|
|
|
if res is False:
|
|
|
|
|
cl_overriding.printERROR(_("Cann't execute '%s'")%execStr)
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
partTemplate = "/dev/%sp%s" if "cciss" in device else "/dev/%s%s"
|
|
|
|
|
for dev,partid in filter(lambda x:x[0] in disk_hash,
|
|
|
|
|
map(lambda x:[partTemplate%(device,x[0]),x[1]],
|
|
|
|
|
map(lambda x:x.split()[0:6:5],
|
|
|
|
|
reduce(lambda x,y:x+[y] \
|
|
|
|
|
if x or y.startswith("Number") else x,
|
|
|
|
|
res,[])[1:]))):
|
|
|
|
|
disk_hash[dev]['id'] = partid
|
|
|
|
|
disk_hash[dev]['table'] = 'gpt'
|
|
|
|
|
|
|
|
|
|
# parse all parted lines started with Disk and started with number
|
|
|
|
|
floppyData = self.removeFloppy()
|
|
|
|
|
execProg = self.getProgPath("/usr/sbin/parted")
|
|
|
|
|
execStr = '%s -l'%execProg
|
|
|
|
|
res = self._runos(execStr,env={"LANG":"C"})
|
|
|
|
|
self.restoreFloppy(floppyData)
|
|
|
|
|
|
|
|
|
|
if res is False:
|
|
|
|
|
cl_overriding.printERROR(_("Cann't execute '%s'")%execStr)
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
partedLines = filter(lambda x: x.startswith("Disk") or
|
|
|
|
|
x.strip()[:1].isdigit(), res )
|
|
|
|
|
for line in partedLines:
|
|
|
|
|
# split data
|
|
|
|
|
parts = filter(lambda x: x, line.strip().split(' '))
|
|
|
|
|
# if start device description
|
|
|
|
|
if parts[0] == "Disk":
|
|
|
|
|
curDevice = parts[1][:-1]
|
|
|
|
|
|
|
|
|
|
fstab = FStab('/etc/fstab')
|
|
|
|
|
raidUsedDisks = []
|
|
|
|
|
lvmUsedDisks = []
|
|
|
|
|
for disk in new_disks:
|
|
|
|
|
props = getUdevDeviceInfo(disk)
|
|
|
|
|
if not "DEVNAME" in props:
|
|
|
|
|
continue
|
|
|
|
|
# if first part is number then it is partition description
|
|
|
|
|
if parts[0].isdigit():
|
|
|
|
|
# part name it is devicename + partition number
|
|
|
|
|
if "cciss" in curDevice:
|
|
|
|
|
partition = "%sp%s"%(curDevice,parts[0])
|
|
|
|
|
else:
|
|
|
|
|
partition = curDevice + parts[0]
|
|
|
|
|
# create entry if hash hasn't it
|
|
|
|
|
if not partition in disk_hash:
|
|
|
|
|
disk_hash[partition] = {}
|
|
|
|
|
if disk_hash[partition].get('table',None) == "gpt":
|
|
|
|
|
disk_hash[partition]['part'] = "gpt"
|
|
|
|
|
if len(parts)>4 and "swap" in parts[4]:
|
|
|
|
|
disk_hash[partition]['format'] = 'swap'
|
|
|
|
|
else:
|
|
|
|
|
disk_hash[partition]['part'] = parts[4]
|
|
|
|
|
if len(parts)>5 and "swap" in parts[5]:
|
|
|
|
|
disk_hash[partition]['format'] = 'swap'
|
|
|
|
|
disk_hash[partition]['size'] = getPartitionSize(partition)
|
|
|
|
|
# fill format, name and uuid
|
|
|
|
|
execStr = self.getProgPath('/sbin/blkid')
|
|
|
|
|
res = self._runos(execStr)
|
|
|
|
|
if res is False:
|
|
|
|
|
cl_overriding.printERROR(_("Cann't execute '%s'")%execStr)
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
# map attribute name of blkid to disk_hash
|
|
|
|
|
blkid_hash = {'LABEL':'name',
|
|
|
|
|
'UUID':'uuid',
|
|
|
|
|
'TYPE':'format'}
|
|
|
|
|
for line in res:
|
|
|
|
|
# split line and discard empty elements
|
|
|
|
|
parts = filter(lambda x: x, line.strip().split(' '))
|
|
|
|
|
if len(parts)>1 and parts[0][:-1] in disks:
|
|
|
|
|
dev = parts[0][:-1]
|
|
|
|
|
for i in parts[1:]:
|
|
|
|
|
key,op,value = i.partition('=')
|
|
|
|
|
if key in blkid_hash:
|
|
|
|
|
key = blkid_hash[key]
|
|
|
|
|
disk_hash[dev][key] = value[1:-1]
|
|
|
|
|
mapUuidDev = getUUIDDict()
|
|
|
|
|
mapDevUuid = dict(zip(mapUuidDev.values(),mapUuidDev.keys()))
|
|
|
|
|
mountOptionsList = \
|
|
|
|
|
filter(lambda x: x.strip() and not x.strip().startswith('#'),
|
|
|
|
|
open("/etc/fstab").readlines())
|
|
|
|
|
# split all string by columns and discard string which has less that 4
|
|
|
|
|
# columns
|
|
|
|
|
mountOptionsList = \
|
|
|
|
|
map(lambda x:[mapUuidDev.get(x[0],x[0])]+x[1:4],
|
|
|
|
|
filter(lambda x: len(x)>=4,
|
|
|
|
|
map(lambda x: filter(lambda x: x ,
|
|
|
|
|
x.replace('\t',' ').split(' ')),
|
|
|
|
|
mountOptionsList)))
|
|
|
|
|
# get dev which has ntfs filesystem
|
|
|
|
|
mountFormatList = \
|
|
|
|
|
filter(lambda x: x[0] in disk_hash.keys() \
|
|
|
|
|
and x[1] in ("ntfs","ntfs-3g"),
|
|
|
|
|
map(lambda y: (y[0],y[2]), mountOptionsList))
|
|
|
|
|
# split options and discard rw opt
|
|
|
|
|
mountOptionsList = \
|
|
|
|
|
filter(lambda x: x[0] in disk_hash.keys(),
|
|
|
|
|
map(lambda y: (y[0],filter(lambda z: z!="rw",
|
|
|
|
|
y[3].split(','))),
|
|
|
|
|
mountOptionsList))
|
|
|
|
|
|
|
|
|
|
dictOptionList = dict(mountOptionsList)
|
|
|
|
|
dictFormatList = dict(mountFormatList)
|
|
|
|
|
for dev in disk_hash.keys():
|
|
|
|
|
if dev in dictOptionList:
|
|
|
|
|
disk_hash[dev]['options'] = ",".join(dictOptionList[dev])
|
|
|
|
|
if dev in dictFormatList and "format" in disk_hash[dev] and \
|
|
|
|
|
disk_hash[dev]['format'] in ("ntfs","ntfs-3g"):
|
|
|
|
|
disk_hash[dev]['format'] = dictFormatList[dev]
|
|
|
|
|
devName = props['DEVNAME']
|
|
|
|
|
dev_hash = {}
|
|
|
|
|
dev_hash['uuid'] = props.get('ID_FS_UUID','')
|
|
|
|
|
dev_hash['format'] = props.get('FSTAB_TYPE') or \
|
|
|
|
|
fstab.getBy(what=fstab.TYPE,eq=devName) or \
|
|
|
|
|
props.get('ID_FS_TYPE','')
|
|
|
|
|
dev_hash['name'] = props.get('ID_FS_LABEL','')
|
|
|
|
|
dev_hash['table'] = props.get('ID_PART_ENTRY_SCHEME','')
|
|
|
|
|
dev_hash['type'] = getDeviceType(disk)
|
|
|
|
|
dev_hash['id'] =props.get('ID_PART_ENTRY_TYPE','').partition("x")[2]
|
|
|
|
|
devParent = getPartitionDevice(disk)
|
|
|
|
|
dev_hash['parent'] = devParent
|
|
|
|
|
dev_hash['part'] = getPartitionType(props)
|
|
|
|
|
dev_hash['options'] = fstab.getBy(what=fstab.OPTS,eq=devName) or ""
|
|
|
|
|
dev_hash['size'] = getPartitionSize(disk)
|
|
|
|
|
if devParent in devicesHash and 'ID_PART_ENTRY_NUMBER' in props:
|
|
|
|
|
dev_hash['grub'] = "%s,%d"%(devicesHash[devParent]['map'],
|
|
|
|
|
int(props['ID_PART_ENTRY_NUMBER'])-1)
|
|
|
|
|
else:
|
|
|
|
|
dev_hash['grub'] = ""
|
|
|
|
|
disk_hash[devName] = dev_hash
|
|
|
|
|
if "raid" in dev_hash['type']:
|
|
|
|
|
raidUsedDisks.extend(map(lambda x:(devName,x),getRaidPartitions(disk)))
|
|
|
|
|
if dev_hash['type'].endswith("lvm"):
|
|
|
|
|
prop = getUdevDeviceInfo(path=disk)
|
|
|
|
|
lvmUsedDisks.extend(map(lambda x:(devName,x),
|
|
|
|
|
getLvmPartitions(prop.get('DM_VG_NAME',''),
|
|
|
|
|
prop.get('DM_LV_NAME',''))))
|
|
|
|
|
for disk,part in raidUsedDisks:
|
|
|
|
|
if part in disk_hash:
|
|
|
|
|
disk_hash[part]['type'] = "%s-raidmember(%s)"%(
|
|
|
|
|
disk_hash[part]['type'],disk)
|
|
|
|
|
for disk,part in lvmUsedDisks:
|
|
|
|
|
if part in disk_hash:
|
|
|
|
|
disk_hash[part]['type'] = "%s-lvmmember(%s)"%(
|
|
|
|
|
disk_hash[part]['type'],disk)
|
|
|
|
|
return disk_hash
|
|
|
|
|
|
|
|
|
|
def separateDevice(self,device):
|
|
|
|
@ -456,7 +364,7 @@ class fillVars(object, glob_attr):
|
|
|
|
|
"""List id for partition after installation"""
|
|
|
|
|
diskHash = self.Get('os_disk_hash')
|
|
|
|
|
def getIdByFS(fs,parttable,oldid):
|
|
|
|
|
if parttable == "msdos":
|
|
|
|
|
if parttable == "dos":
|
|
|
|
|
return PartitionDistributive.formatId.get(fs,oldid)
|
|
|
|
|
elif parttable == "gpt":
|
|
|
|
|
return PartitionDistributive.formatIdGpt.get(fs,oldid)
|
|
|
|
@ -489,18 +397,10 @@ class fillVars(object, glob_attr):
|
|
|
|
|
return self.Get('os_disk_dev')
|
|
|
|
|
|
|
|
|
|
def get_os_install_disk_uuid(self):
|
|
|
|
|
"""List uudi for partition devices"""
|
|
|
|
|
devuuid = '/dev/disk/by-uuid'
|
|
|
|
|
"""List uuid for partition devices"""
|
|
|
|
|
diskDev = self.Get('os_disk_dev')
|
|
|
|
|
if path.exists(devuuid):
|
|
|
|
|
hashUUID = dict(
|
|
|
|
|
map(lambda x:(path.normpath(path.join(devuuid,os.readlink(x))),
|
|
|
|
|
path.basename(x)),
|
|
|
|
|
filter(path.islink,
|
|
|
|
|
map(lambda x:path.join(devuuid,x),
|
|
|
|
|
listDirectory(devuuid)))))
|
|
|
|
|
return map(lambda x:hashUUID.get(x,""),diskDev)
|
|
|
|
|
return [""]*len(diskDev)
|
|
|
|
|
hashUUID = getUUIDDict(revers=True)
|
|
|
|
|
return map(lambda x:hashUUID.get(x,"")[5:],diskDev)
|
|
|
|
|
|
|
|
|
|
def get_os_install_disk_options(self):
|
|
|
|
|
"""List mount options for partition devices of installed os"""
|
|
|
|
@ -510,27 +410,32 @@ class fillVars(object, glob_attr):
|
|
|
|
|
"""List mounted points for installed system"""
|
|
|
|
|
rootdev = self.Get('os_install_root_dev')
|
|
|
|
|
disk_hash = self.Get('os_disk_hash')
|
|
|
|
|
fstabHasSwap = isFstabMount('swap')
|
|
|
|
|
fstab = FStab('/etc/fstab')
|
|
|
|
|
fstabHasSwap = bool(fstab.isExists(what=FStab.TYPE,eq="swap"))
|
|
|
|
|
def getMountPoint(disk):
|
|
|
|
|
"""Get mount point for disk. If fstab not contains swap then
|
|
|
|
|
for swap use all swap formated partition"""
|
|
|
|
|
if disk == rootdev:
|
|
|
|
|
return "/"
|
|
|
|
|
elif not fstabHasSwap and "format" in disk_hash[disk] and \
|
|
|
|
|
"swap" in disk_hash[disk]['format']:
|
|
|
|
|
return "swap"
|
|
|
|
|
else:
|
|
|
|
|
mount_point = isFstabMount(disk)
|
|
|
|
|
mount_point = fstab.getBy(eq=disk)
|
|
|
|
|
if mount_point in self.nonTransferedDirs:
|
|
|
|
|
return ""
|
|
|
|
|
else:
|
|
|
|
|
return mount_point
|
|
|
|
|
return map(lambda x: getMountPoint(x),
|
|
|
|
|
sorted(self.Get('os_disk_hash').keys(),
|
|
|
|
|
key=self.separateDevice))
|
|
|
|
|
sorted(
|
|
|
|
|
self.Get('os_disk_hash').keys(),key=self.separateDevice))
|
|
|
|
|
|
|
|
|
|
def get_os_disk_mount(self):
|
|
|
|
|
"""List mounted points for current operation system"""
|
|
|
|
|
disk_hash = self.Get('os_disk_hash')
|
|
|
|
|
return map(lambda x: isFstabMount(x) or "",
|
|
|
|
|
fstab = FStab('/etc/fstab')
|
|
|
|
|
rootdev = self.Get('os_root_dev')
|
|
|
|
|
return map(lambda x: '/' if x == rootdev else fstab.getBy(eq=x) or "",
|
|
|
|
|
sorted(self.Get('os_disk_hash').keys(),
|
|
|
|
|
key=self.separateDevice))
|
|
|
|
|
|
|
|
|
@ -577,6 +482,10 @@ class fillVars(object, glob_attr):
|
|
|
|
|
"""Type of partition devices (primary, extended or logical)"""
|
|
|
|
|
return self.getAttributeFromHash('os_disk_hash','part')
|
|
|
|
|
|
|
|
|
|
def get_os_disk_table(self):
|
|
|
|
|
"""Partition table for this partition"""
|
|
|
|
|
return self.getAttributeFromHash('os_disk_hash','table')
|
|
|
|
|
|
|
|
|
|
def get_os_install_disk_perform_format(self):
|
|
|
|
|
"""Needformat partitions"""
|
|
|
|
|
return self.getAttributeFromHash('os_disk_hash','needformat')
|
|
|
|
@ -585,6 +494,46 @@ class fillVars(object, glob_attr):
|
|
|
|
|
"""Partition size"""
|
|
|
|
|
return self.getAttributeFromHash('os_disk_hash','size')
|
|
|
|
|
|
|
|
|
|
def get_os_disk_type(self):
|
|
|
|
|
"""Partition type"""
|
|
|
|
|
return self.getAttributeFromHash('os_disk_hash','type')
|
|
|
|
|
|
|
|
|
|
def get_os_disk_content(self):
|
|
|
|
|
"""Partition content"""
|
|
|
|
|
distrRep = DistributiveRepository()
|
|
|
|
|
osProberHash = getOsProberHash(getContentFunc=distrRep._getfromcontent)
|
|
|
|
|
devicesHash = self.Get('os_device_hash')
|
|
|
|
|
def detectContent(devName,devType,devParent,mountPoint):
|
|
|
|
|
if mountPoint == '/':
|
|
|
|
|
return "{short}-{march}{build}".format(
|
|
|
|
|
short=self.Get('os_linux_shortname'),
|
|
|
|
|
march=self.Get('os_arch_machine'),
|
|
|
|
|
build="-%s"%(self.Get('os_linux_build') if
|
|
|
|
|
self.Get('os_linux_build') else
|
|
|
|
|
self.Get('os_linux_ver')))
|
|
|
|
|
content = osProberHash.get(devName,'')
|
|
|
|
|
if not content and ((devParent in devicesHash and \
|
|
|
|
|
devicesHash[devParent]['type'] == "flash") or
|
|
|
|
|
"cdrom" in devType or devType.endswith('raid') or
|
|
|
|
|
devType.endswith('lvm')):
|
|
|
|
|
dataInfo = distrRep._getfromcontent(devName)
|
|
|
|
|
if "build" in dataInfo and dataInfo['build']:
|
|
|
|
|
if "cdrom" in devType:
|
|
|
|
|
dataInfo['livetype'] = " livecd"
|
|
|
|
|
elif devType.endswith('raid') or devType.endswith('lvm'):
|
|
|
|
|
dataInfo['livetype'] = ""
|
|
|
|
|
else:
|
|
|
|
|
dataInfo['livetype'] = " liveusb"
|
|
|
|
|
content = \
|
|
|
|
|
"{name}-{march}-{build}{livetype}".format(
|
|
|
|
|
**dataInfo)
|
|
|
|
|
return content
|
|
|
|
|
return map(lambda x:detectContent(x[0],x[1],x[2],x[3]),
|
|
|
|
|
zip(self.Get('os_disk_dev'),
|
|
|
|
|
self.Get('os_disk_type'),
|
|
|
|
|
self.getAttributeFromHash('os_disk_hash','parent'),
|
|
|
|
|
self.Get('os_disk_mount')))
|
|
|
|
|
|
|
|
|
|
def get_os_disk_name(self):
|
|
|
|
|
"""Label of partitions"""
|
|
|
|
|
return self.getAttributeFromHash('os_disk_hash','name')
|
|
|
|
@ -602,10 +551,14 @@ class fillVars(object, glob_attr):
|
|
|
|
|
"""Map number for grub"""
|
|
|
|
|
return self.getAttributeFromHash('os_device_hash','map')
|
|
|
|
|
|
|
|
|
|
def get_os_device_table(self):
|
|
|
|
|
"""Table on device"""
|
|
|
|
|
return self.getAttributeFromHash('os_device_hash','table')
|
|
|
|
|
|
|
|
|
|
def get_os_install_grub_devicemap_conf(self):
|
|
|
|
|
"""Content of device.map file for grub"""
|
|
|
|
|
rootType = self.Get('os_install_root_type')
|
|
|
|
|
return "\n".join(map(lambda x: "(hd%s) /dev/%s" % (x[0],x[1]),
|
|
|
|
|
return "\n".join(map(lambda x: "(hd%s) %s" % (x[0],x[1]),
|
|
|
|
|
filter(lambda x:x[2] == rootType,
|
|
|
|
|
zip(self.Get('os_device_map'),
|
|
|
|
|
self.Get('os_device_dev'),
|
|
|
|
@ -735,13 +688,31 @@ class fillVars(object, glob_attr):
|
|
|
|
|
return res.groups()[0]
|
|
|
|
|
return "cfq"
|
|
|
|
|
|
|
|
|
|
def get_os_install_lvm_set(self):
|
|
|
|
|
"""Using lvm"""
|
|
|
|
|
typeRoot = \
|
|
|
|
|
self.selectVar("os_disk_type",where="os_install_disk_mount",
|
|
|
|
|
eq="/")
|
|
|
|
|
return "on" if "lvm" in typeRoot else "off"
|
|
|
|
|
|
|
|
|
|
def get_os_install_mdadm_set(self):
|
|
|
|
|
"""Using mdadm"""
|
|
|
|
|
typeRoot = \
|
|
|
|
|
self.selectVar("os_disk_type",where="os_install_disk_mount",
|
|
|
|
|
eq="/")
|
|
|
|
|
return "on" if "raid" in typeRoot else "off"
|
|
|
|
|
|
|
|
|
|
def get_os_install_kernel_attr(self):
|
|
|
|
|
"""Kernel attributes"""
|
|
|
|
|
# on usb-hdd install must be "delay=5"
|
|
|
|
|
attr = ""
|
|
|
|
|
if self.Get('os_install_root_type') == 'usb-hdd':
|
|
|
|
|
return " scandelay=5"
|
|
|
|
|
else:
|
|
|
|
|
return ""
|
|
|
|
|
attr = " scandelay=5"
|
|
|
|
|
if self.Get('os_install_mdadm_set') == 'on':
|
|
|
|
|
attr += " domdadm"
|
|
|
|
|
if self.Get('os_install_lvm_set') == 'on':
|
|
|
|
|
attr += " dolvm"
|
|
|
|
|
return attr
|
|
|
|
|
|
|
|
|
|
def get_os_install_kernel_resume(self):
|
|
|
|
|
"""install kernel resume parameter"""
|
|
|
|
@ -765,8 +736,13 @@ class fillVars(object, glob_attr):
|
|
|
|
|
livedistr = ['/mnt/cdrom']
|
|
|
|
|
else:
|
|
|
|
|
livedistr = []
|
|
|
|
|
return ['/var/calculate/remote/linux', '/var/calculate/linux',
|
|
|
|
|
'/usr/calculate/share/linux'] + livedistr
|
|
|
|
|
livedistr += \
|
|
|
|
|
map(lambda x:x[0],
|
|
|
|
|
filter(lambda x:" live" in x[1],
|
|
|
|
|
zip(self.Get('os_disk_dev'),
|
|
|
|
|
self.Get('os_disk_content'))))
|
|
|
|
|
return ['/var/calculate/remote/linux',
|
|
|
|
|
'/var/calculate/linux'] + livedistr
|
|
|
|
|
|
|
|
|
|
def getImage(self,scratch,rootType,imagePath,archMachine,
|
|
|
|
|
shortName,linuxVer=None):
|
|
|
|
@ -775,7 +751,9 @@ class fillVars(object, glob_attr):
|
|
|
|
|
discardType = ["dir"]
|
|
|
|
|
else:
|
|
|
|
|
discardType = []
|
|
|
|
|
distRep = DistributiveRepository(self.Get('cl_image_path'))
|
|
|
|
|
if type(imagePath) == str:
|
|
|
|
|
imagePath = [imagePath]
|
|
|
|
|
distRep = DistributiveRepository(imagePath)
|
|
|
|
|
return distRep.getBestDistributive(march=archMachine,
|
|
|
|
|
shortname=shortName.lower(),
|
|
|
|
|
discardType=discardType,
|
|
|
|
@ -1153,10 +1131,12 @@ class fillVars(object, glob_attr):
|
|
|
|
|
def get_os_install_root_type(self):
|
|
|
|
|
"""Type of device for install"""
|
|
|
|
|
rootdev = self.Get('os_install_root_dev')
|
|
|
|
|
devicetype = getPartitionDevice(
|
|
|
|
|
getUdevDeviceInfo(name=rootdev).get('DEVPATH',''))
|
|
|
|
|
devicetype = map(lambda x: x[1],
|
|
|
|
|
filter(lambda x:x[0] in rootdev,
|
|
|
|
|
zip(self.Get('os_device_dev'),
|
|
|
|
|
self.Get('os_device_type'))))
|
|
|
|
|
filter(lambda x:x[0] == devicetype,
|
|
|
|
|
zip(self.Get('os_device_dev'),
|
|
|
|
|
self.Get('os_device_type'))))
|
|
|
|
|
if devicetype:
|
|
|
|
|
return devicetype[0]
|
|
|
|
|
else:
|
|
|
|
@ -1391,8 +1371,7 @@ class fillVars(object, glob_attr):
|
|
|
|
|
return self.Get('cl_autoupdate_set')
|
|
|
|
|
|
|
|
|
|
def get_cl_install_kernel_uid(self):
|
|
|
|
|
mapDevUuid = getUUIDDict(revers=True)
|
|
|
|
|
return mapDevUuid.get(self.Get('os_install_root_dev'),"")[5:13]
|
|
|
|
|
return self.getKernelUid(self.Get('os_install_root_dev'))
|
|
|
|
|
|
|
|
|
|
def get_os_nvidia_mask(self):
|
|
|
|
|
nvidiaeclass = pathJoin(self.Get('cl_chroot_path'),
|
|
|
|
@ -1448,10 +1427,6 @@ class fillVars(object, glob_attr):
|
|
|
|
|
return build
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
def get_os_device_partition(self):
|
|
|
|
|
"""Get partition table list"""
|
|
|
|
|
return self.getAttributeFromHash('os_device_hash','table')
|
|
|
|
|
|
|
|
|
|
def get_os_install_fb_resolution(self):
|
|
|
|
|
"""Get current framebuffer resolution"""
|
|
|
|
|
textLines = self._runos("/sbin/fbres 2>&1")
|
|
|
|
|