Refactoring disk_content

lvmraid
Mike Hiretsky 13 years ago
parent b4c4e69ec3
commit 881f9d22fb

@ -298,8 +298,6 @@ class fillVars(object, glob_attr):
disk_hash = {}
fstab = FStab('/etc/fstab')
distrRep = DistributiveRepository()
osProberHash = getOsProberHash(getContentFunc=distrRep._getfromcontent)
raidUsedDisks = []
lvmUsedDisks = []
for disk in new_disks:
@ -321,19 +319,6 @@ class fillVars(object, glob_attr):
dev_hash['part'] = getPartitionType(props)
dev_hash['options'] = fstab.getBy(what=fstab.OPTS,eq=devName) or ""
dev_hash['size'] = getPartitionSize(disk)
dev_hash['content'] = osProberHash.get(devName,'')
if not dev_hash['content'] and ((devParent in devicesHash and \
devicesHash[devParent]['type'] == "flash") or
"cdrom" in dev_hash['type']):
dataInfo = distrRep._getfromcontent(devName)
if "build" in dataInfo and dataInfo['build']:
if "cdrom" in dev_hash['type']:
dataInfo['livetype'] = "cd"
else:
dataInfo['livetype'] = "usb"
dev_hash['content'] = \
"{name}-{march}-{build} live{livetype}".format(
**dataInfo)
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)
@ -511,15 +496,36 @@ class fillVars(object, glob_attr):
def get_os_disk_content(self):
"""Partition content"""
return map(lambda x: x[1] if x[0] != '/' else
"{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'))),
zip(self.Get('os_disk_mount'),
self.getAttributeFromHash('os_disk_hash','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):
dataInfo = distrRep._getfromcontent(devName)
if "build" in dataInfo and dataInfo['build']:
if "cdrom" in devType:
dataInfo['livetype'] = "cd"
else:
dataInfo['livetype'] = "usb"
content = \
"{name}-{march}-{build} live{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"""

Loading…
Cancel
Save