diff options
Diffstat (limited to 'commands/storage/lmi')
-rw-r--r-- | commands/storage/lmi/scripts/storage/common.py | 34 | ||||
-rw-r--r-- | commands/storage/lmi/scripts/storage/device_cmd.py | 33 | ||||
-rw-r--r-- | commands/storage/lmi/scripts/storage/fs.py | 2 | ||||
-rw-r--r-- | commands/storage/lmi/scripts/storage/lvm.py | 1 |
4 files changed, 67 insertions, 3 deletions
diff --git a/commands/storage/lmi/scripts/storage/common.py b/commands/storage/lmi/scripts/storage/common.py index aea65f2..367f6ef 100644 --- a/commands/storage/lmi/scripts/storage/common.py +++ b/commands/storage/lmi/scripts/storage/common.py @@ -274,9 +274,11 @@ def get_devices(ns, devices=None): :rtype: list of LMIInstance/CIM_StorageExtent. """ if devices: + LOG().debug("get_devices: Loading list of selected devices.") for dev in devices: yield str2device(ns, dev) else: + LOG().debug("get_devices: Loading list of all devices.") for dev in ns.CIM_StorageExtent.instances(): yield dev @@ -330,7 +332,21 @@ def get_parents(ns, obj, deep=False): # Try usual BasedOn next parents = obj.associators(AssocClass="CIM_BasedOn", Role="Dependent") for parent in parents: - yield parent + # Be careful with logical partitions - they are BasedOn extended + # partition, but we want to return appropriate disk instead. + logical = ns.LMI_DiskPartition.PartitionTypeValues.Logical + extended = ns.LMI_DiskPartition.PartitionTypeValues.Extended + if (lmi_isinstance(parent, ns.CIM_DiskPartition) + and lmi_isinstance(obj, ns.CIM_DiskPartition) + and obj.PartitionType == logical + and parent.PartitionType == extended): + LOG().debug("Looking for disk instead of extended partition %s" + % (parent.DeviceID)) + for p in get_parents(ns, parent, False): + yield p + else: + # It is not logical partition + yield parent elif lmi_isinstance(obj, ns.CIM_StoragePool): # find physical volumes of the VG @@ -395,10 +411,26 @@ def get_children(ns, obj, deep=False): yield child return + # Extended partition don't have children + extended = ns.LMI_DiskPartition.PartitionTypeValues.Extended + if (lmi_isinstance(obj, ns.CIM_DiskPartition) + and obj.PartitionType == extended): + return + # try usual BasedOn next children = obj.associators(AssocClass="CIM_BasedOn", Role="Antecedent") for child in children: yield child + # Be careful with logical partitions - they are BasedOn extended + # partition, but we want to have them as children of appropriate + # disk instead. + if (lmi_isinstance(child, ns.CIM_DiskPartition) + and child.PartitionType == extended): + LOG().debug("Looking for logical partitions on %s" + % (child.DeviceID)) + for c in child.associators(AssocClass="CIM_BasedOn", + Role="Antecedent"): + yield c elif lmi_isinstance(obj, ns.CIM_StoragePool): # find LVs allocated from the VG diff --git a/commands/storage/lmi/scripts/storage/device_cmd.py b/commands/storage/lmi/scripts/storage/device_cmd.py index 0e4dede..d250d56 100644 --- a/commands/storage/lmi/scripts/storage/device_cmd.py +++ b/commands/storage/lmi/scripts/storage/device_cmd.py @@ -79,7 +79,8 @@ from lmi.scripts.storage.common import (size2str, get_devices, get_children, get_parents, str2device) from lmi.scripts.storage.lvm import get_vgs from lmi.shell.LMIUtil import lmi_isinstance -from lmi.scripts.common import formatter +from lmi.scripts.common import formatter, get_logger +LOG = get_logger(__name__) def get_device_info(ns, device, human_friendly): """ @@ -90,11 +91,12 @@ def get_device_info(ns, device, human_friendly): else: size = 'N/A' + fslabel = fs.get_device_format_label(ns, device) return (device.DeviceID, device.Name, device.ElementName, size, - fs.get_device_format_label(ns, device)) + fslabel) def get_pool_info(_ns, pool, human_friendly): """ @@ -257,17 +259,44 @@ class Tree(command.LmiLister): # Load all dependencies, calling get_children iteratively is slow # Add CIM_BasedOn dependencies (and omit LMI_LVBasedOn, we need # LMI_LVAllocatedFromStoragePool instead) + LOG().debug("Loading list of CIM_BasedOn associations.") deps = [(self.get_obj_id(ns, i.Antecedent), self.get_obj_id(ns, i.Dependent)) for i in ns.CIM_BasedOn.instances() if not lmi_isinstance(i, ns.LMI_LVBasedOn)] + # Be careful with logical partitions - they are BasedOn on appropriate + # extended partition, but we want to draw them as children of + # appropriate disk. + LOG().debug("Reworking BasedOn associations for logical partitions.") + logical = ns.LMI_DiskPartition.PartitionTypeValues.Logical + extended = ns.LMI_DiskPartition.PartitionTypeValues.Extended + for i in xrange(len(deps)): + dev = devices[deps[i][0]] + child = devices[deps[i][1]] + LOG().debug("Inspecting %s - %s" % deps[i]) + if ("PartitionType" in dev.properties() + and "PartitionType" in child.properties() + and dev.PartitionType == extended + and child.PartitionType == logical): + # We found ext. partition - logical partition dependency + # Find the disk + disk_id = None + for (d, c) in deps: + if c == deps[i][0]: + disk_id = d + # Replace the extended->logical dependency with disk->logical + deps[i] = (disk_id, deps[i][1]) + LOG().debug("--- Replaced with %s - %s" % deps[i]) + # Add VG-LV dependencies from LMI_LVAllocatedFromStoragePool association + LOG().debug("Loading LVAllocatedFromStoragePool associations.") deps += [(self.get_obj_id(ns, i.Antecedent), self.get_obj_id(ns, i.Dependent)) for i in ns.LMI_LVAllocatedFromStoragePool.instances()] # Add PV-VG dependencies from LMI_VGAssociatedComponentExtent + LOG().debug("Loading VGAssociatedComponentExtent associations.") deps += [ (self.get_obj_id(ns, i.PartComponent), self.get_obj_id(ns, i.GroupComponent)) diff --git a/commands/storage/lmi/scripts/storage/fs.py b/commands/storage/lmi/scripts/storage/fs.py index f20cc86..9176504 100644 --- a/commands/storage/lmi/scripts/storage/fs.py +++ b/commands/storage/lmi/scripts/storage/fs.py @@ -247,6 +247,8 @@ def get_device_format_label(ns, device): :rtype: string """ + LOG().debug("get_device_format_label: Loading filesystem information for %s" + % (device.DeviceID)) fmt = get_format_on_device(ns, device) if fmt: return get_format_label(ns, fmt) diff --git a/commands/storage/lmi/scripts/storage/lvm.py b/commands/storage/lmi/scripts/storage/lvm.py index da4ee4d..0d788ad 100644 --- a/commands/storage/lmi/scripts/storage/lvm.py +++ b/commands/storage/lmi/scripts/storage/lvm.py @@ -110,6 +110,7 @@ def get_vgs(ns): :rtype: list of LMIInstance/LMI_VGStoragePool """ + LOG().debug("get_vgs: Loading list of all volume groups.") for vg in ns.LMI_VGStoragePool.instances(): yield vg |