Os detect update.

lvmraid
Mike Hiretsky 13 years ago
parent 71ae46b885
commit b129e397bc

@ -130,7 +130,7 @@ class DistributiveRepository:
else: else:
return {} return {}
def _getfromcontent(self,filename): def _getfromcontent(self,filename,addFunc=None):
"""Get info from content""" """Get info from content"""
varsShare = self.varsShare varsShare = self.varsShare
distr = None distr = None
@ -173,6 +173,8 @@ class DistributiveRepository:
d['build'] = os_linux_build[-1] d['build'] = os_linux_build[-1]
else: else:
d['build'] = "" d['build'] = ""
if addFunc:
d = addFunc(filename,d)
if distr: if distr:
distr.close() distr.close()
return d return d

@ -27,7 +27,7 @@ from cl_utils import isMount,typeFile,getTupleVersion,pathJoin,isFstabMount,\
getUdevDeviceInfo, getPartitionDevice, getPartitionSize, \ getUdevDeviceInfo, getPartitionDevice, getPartitionSize, \
isPkgInstalled, process, checkUtils, readLinesFile, \ isPkgInstalled, process, checkUtils, readLinesFile, \
FStab, lspci, getInstalledVideo,getDeviceType, \ FStab, lspci, getInstalledVideo,getDeviceType, \
getPartitionType getPartitionType, getOsProberHash
from cl_distr import DistributiveRepository,PartitionDistributive from cl_distr import DistributiveRepository,PartitionDistributive
from cl_fill import clLocale from cl_fill import clLocale
from operator import itemgetter from operator import itemgetter
@ -291,6 +291,8 @@ class fillVars(object, glob_attr):
disk_hash = {} disk_hash = {}
fstab = FStab('/etc/fstab') fstab = FStab('/etc/fstab')
distrRep = DistributiveRepository()
osProberHash = getOsProberHash(getContentFunc=distrRep._getfromcontent)
for disk in new_disks: for disk in new_disks:
props = getUdevDeviceInfo(disk) props = getUdevDeviceInfo(disk)
if not "DEVNAME" in props: if not "DEVNAME" in props:
@ -310,6 +312,7 @@ class fillVars(object, glob_attr):
dev_hash['part'] = getPartitionType(props) dev_hash['part'] = getPartitionType(props)
dev_hash['options'] = fstab.getBy(what=fstab.OPTS,eq=devName) or "" dev_hash['options'] = fstab.getBy(what=fstab.OPTS,eq=devName) or ""
dev_hash['size'] = getPartitionSize(disk) dev_hash['size'] = getPartitionSize(disk)
dev_hash['content'] = osProberHash.get(devName,'')
if devParent in devicesHash and 'ID_PART_ENTRY_NUMBER' in props: if devParent in devicesHash and 'ID_PART_ENTRY_NUMBER' in props:
dev_hash['grub'] = "%s,%d"%(devicesHash[devParent]['map'], dev_hash['grub'] = "%s,%d"%(devicesHash[devParent]['map'],
int(props['ID_PART_ENTRY_NUMBER'])-1) int(props['ID_PART_ENTRY_NUMBER'])-1)
@ -470,6 +473,10 @@ class fillVars(object, glob_attr):
"""Partition type""" """Partition type"""
return self.getAttributeFromHash('os_disk_hash','type') return self.getAttributeFromHash('os_disk_hash','type')
def get_os_disk_content(self):
"""Partition content"""
return self.getAttributeFromHash('os_disk_hash','content')
def get_os_disk_name(self): def get_os_disk_name(self):
"""Label of partitions""" """Label of partitions"""
return self.getAttributeFromHash('os_disk_hash','name') return self.getAttributeFromHash('os_disk_hash','name')

@ -1769,24 +1769,30 @@ class cl_install(color_print, SignalInterrupt):
"""Generate table for all partitions""" """Generate table for all partitions"""
def convertTypeToScheme(diskType): def convertTypeToScheme(diskType):
res = "" res = ""
typeDict = {'loop':_("Loop"), if "raid-lvm" in diskType:
'raid':_("RAID"), return _("LVM on RAID")
'lvm':_("LVM"), elif "disk-partition" == diskType:
'partition':_("Partition"), return _("Partition on disk")
'disk':_("Disk")} elif "raid-partition" == diskType:
for i in diskType.split('-'): return _("Partition on RAID")
res = "%s on %s"%(typeDict.get(i,_('None')),res) if res else \ elif "disk" in diskType:
typeDict.get(i,_('None')) return _("Disk without partitions")
return res elif "lvm" in diskType:
return _("LVM")
elif "raid" in diskType:
return _("RAID")
else:
return _("Partition")
title = _("Available partitions") title = _("Available partitions")
headerList = [_("Size"),_("Device"),_("Label"),_("Directory"), headerList = [_("Size"),_("Device"),_("Label"),_("Mount point"),
_("File system"), _("Scheme")] _("File system"), _("Type"),_("OS")]
return title, headerList, zip(self.clVars.Get('os_disk_size'), return title, headerList, zip(self.clVars.Get('os_disk_size'),
self.clVars.Get('os_disk_dev'), self.clVars.Get('os_disk_dev'),
self.clVars.Get('os_disk_name'), self.clVars.Get('os_disk_name'),
self.clVars.Get('os_disk_mount'), self.clVars.Get('os_disk_mount'),
self.clVars.Get('os_disk_format'), self.clVars.Get('os_disk_format'),
map(convertTypeToScheme,self.clVars.Get('os_disk_type'))) map(convertTypeToScheme,self.clVars.Get('os_disk_type')),
self.clVars.Get('os_disk_content'))
def generateTableMountData(self): def generateTableMountData(self):
"""Get data from print table""" """Get data from print table"""

@ -148,7 +148,8 @@ CMD_OPTIONS = [{'shortOption':"d",
'help':_("use passwords for the users accounts \ 'help':_("use passwords for the users accounts \
(from standard input)") (from standard input)")
}, },
{'longOption':"show-partitions", {'shortOption':'p',
'longOption':"show-partitions",
'help':_("display all partitions")} 'help':_("display all partitions")}
] ]

@ -61,6 +61,9 @@ class Data:
# list mounted points for current operation system # list mounted points for current operation system
os_disk_mount = {} os_disk_mount = {}
# partition content
os_disk_content = {}
# list filesystem for partition devices # list filesystem for partition devices
os_disk_format = {} os_disk_format = {}

@ -59,7 +59,7 @@ if __name__ == "__main__":
if options.v or options.filter or options.xml: if options.v or options.filter or options.xml:
install.printVars(options) install.printVars(options)
sys.exit(0) sys.exit(0)
if options.show_partitions: if options.p:
install.showPartitions() install.showPartitions()
sys.exit(0) sys.exit(0)
# check root # check root

Loading…
Cancel
Save