* Replace Smis._new_disk() with smis_disk.cim_disk_to_lsm_disk()
* Moved Smis._pri_cim_ext_of_cim_disk() into smis_disk.
* Merged Smis._new_disk_cim_ext_pros() into smis_disk.cim_disk_to_lsm_disk()
as no need to has a method for storing a non-shared list.
* Combining these changes in one patch as they are internal actions for
smis_disk.cim_disk_to_lsm_disk().
Signed-off-by: Gris Ge <***@redhat.com>
---
plugin/smispy/smis.py | 114 +-------------------------------------------
plugin/smispy/smis_disk.py | 107 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 107 insertions(+), 114 deletions(-)
diff --git a/plugin/smispy/smis.py b/plugin/smispy/smis.py
index af20310..351de57 100644
--- a/plugin/smispy/smis.py
+++ b/plugin/smispy/smis.py
@@ -2125,7 +2125,6 @@ class Smis(IStorageAreaNetwork):
return all object of data.Disk.
We are using "Disk Drive Lite Subprofile" v1.4 of SNIA SMI-S for these
classes to create LSM Disk:
- CIM_PhysicalPackage
CIM_DiskDrive
CIM_StorageExtent (Primordial)
Due to 'Multiple Computer System' profile, disks might associated to
@@ -2145,122 +2144,11 @@ class Smis(IStorageAreaNetwork):
smis_disk.sys_id_of_cim_disk(cim_disk) not in \
self._c.system_list:
continue
- cim_ext_pros = Smis._new_disk_cim_ext_pros(flags)
- cim_ext = self._pri_cim_ext_of_cim_disk(cim_disk.path,
- cim_ext_pros)
- rc.extend([self._new_disk(cim_disk, cim_ext)])
+ rc.extend([smis_disk.cim_disk_to_lsm_disk(self._c, cim_disk)])
return search_property(rc, search_key, search_value)
@staticmethod
- def _new_disk_cim_ext_pros(flag=0):
- """
- Return all CIM_StorageExtent Properties needed to create a Disk
- object.
- """
- return ['BlockSize', 'NumberOfBlocks']
-
- def _new_disk(self, cim_disk, cim_ext):
- """
- Takes a CIM_DiskDrive and CIM_StorageExtent, returns a lsm Disk
- Assuming cim_disk and cim_ext already contained the correct
- properties.
- """
- status = smis_disk.disk_status_of_cim_disk(cim_disk)
- name = ''
- block_size = Disk.BLOCK_SIZE_NOT_FOUND
- num_of_block = Disk.BLOCK_COUNT_NOT_FOUND
- disk_type = Disk.TYPE_UNKNOWN
- sys_id = smis_disk.sys_id_of_cim_sys(cim_disk)
-
- # These are mandatory
- # we do not check whether they follow the SNIA standard.
- if 'Name' in cim_disk:
- name = cim_disk["Name"]
- if 'BlockSize' in cim_ext:
- block_size = cim_ext['BlockSize']
- if 'NumberOfBlocks' in cim_ext:
- num_of_block = cim_ext['NumberOfBlocks']
-
- # SNIA SMI-S 1.4 or even 1.6 does not define anyway to find out disk
- # type.
- # Currently, EMC is following DMTF define to do so.
- if 'InterconnectType' in cim_disk: # DMTF 2.31 CIM_DiskDrive
- disk_type = cim_disk['InterconnectType']
- if 'Caption' in cim_disk:
- # EMC VNX introduced NL_SAS disk.
- if cim_disk['Caption'] == 'NL_SAS':
- disk_type = Disk.TYPE_NL_SAS
-
- if disk_type == Disk.TYPE_UNKNOWN and 'DiskType' in cim_disk:
- disk_type = smis_disk.dmtf_disk_type_2_lsm_disk_type(
- cim_disk['DiskType'])
-
- # LSI way for checking disk type
- if not disk_type and cim_disk.classname == 'LSIESG_DiskDrive':
- cim_pes = self._c.Associators(
- cim_disk.path,
- AssocClass='CIM_SAPAvailableForElement',
- ResultClass='CIM_ProtocolEndpoint',
- PropertyList=['CreationClassName'])
- if cim_pes and cim_pes[0]:
- if 'CreationClassName' in cim_pes[0]:
- ccn = cim_pes[0]['CreationClassName']
- if ccn == 'LSIESG_TargetSATAProtocolEndpoint':
- disk_type = Disk.TYPE_SATA
- if ccn == 'LSIESG_TargetSASProtocolEndpoint':
- disk_type = Disk.TYPE_SAS
-
- disk_id = smis_disk.disk_id_of_cim_disk(cim_disk)
-
- new_disk = Disk(disk_id, name, disk_type, block_size,
- num_of_block, status, sys_id)
-
- return new_disk
-
- def _pri_cim_ext_of_cim_disk(self, cim_disk_path, property_list=None):
- """
- Usage:
- Find out the Primordial CIM_StorageExtent of CIM_DiskDrive
- In SNIA SMI-S 1.4 rev.6 Block book, section 11.1.1 'Base Model'
- quote:
- A disk drive is modeled as a single MediaAccessDevice (DiskDrive)
- That shall be linked to a single StorageExtent (representing the
- storage in the drive) by a MediaPresent association. The
- StorageExtent class represents the storage of the drive and
- contains its size.
- Parameter:
- cim_disk_path # CIM_InstanceName of CIM_DiskDrive
- property_list # a List of properties needed on returned
- # CIM_StorageExtent
- Returns:
- cim_pri_ext # The CIM_Instance of Primordial CIM_StorageExtent
- Exceptions:
- LsmError
- ErrorNumber.LSM_PLUGIN_BUG # Failed to find out pri cim_ext
- """
- if property_list is None:
- property_list = ['Primordial']
- else:
- property_list = merge_list(property_list, ['Primordial'])
-
- cim_exts = self._c.Associators(
- cim_disk_path,
- AssocClass='CIM_MediaPresent',
- ResultClass='CIM_StorageExtent',
- PropertyList=property_list)
- cim_exts = [p for p in cim_exts if p["Primordial"]]
- if cim_exts and cim_exts[0]:
- # As SNIA commanded, only _ONE_ Primordial CIM_StorageExtent for
- # each CIM_DiskDrive
- return cim_exts[0]
- else:
- raise LsmError(ErrorNumber.PLUGIN_BUG,
- "Failed to find out Primordial " +
- "CIM_StorageExtent for CIM_DiskDrive %s " %
- cim_disk_path)
-
- @staticmethod
def _is_frontend_fc_tgt(cim_fc_tgt):
"""
Check CIM_FCPort['UsageRestriction'] for frontend port.
diff --git a/plugin/smispy/smis_disk.py b/plugin/smispy/smis_disk.py
index 7364f7f..4245a5b 100644
--- a/plugin/smispy/smis_disk.py
+++ b/plugin/smispy/smis_disk.py
@@ -19,6 +19,7 @@ from lsm import Disk, md5, LsmError, ErrorNumber
from dmtf import (
DMTF, DMTF_DISK_TYPE_UNKNOWN, DMTF_DISK_TYPE_OTHER,
DMTF_DISK_TYPE_HDD, DMTF_DISK_TYPE_SSD, DMTF_DISK_TYPE_HYBRID)
+from utils import merge_list
_LSM_DISK_OP_STATUS_CONV = {
@@ -79,7 +80,7 @@ def cim_disk_pros():
Return all CIM_DiskDrive Properties needed to create a Disk object.
"""
return ['OperationalStatus', 'Name', 'SystemName',
- 'Caption', 'InterconnectType', 'DiskType']
+ 'Caption', 'InterconnectType', 'DiskType', 'DeviceID']
def sys_id_of_cim_disk(cim_disk):
@@ -90,3 +91,107 @@ def sys_id_of_cim_disk(cim_disk):
"SystemName property: %s, %s" %
(cim_disk.path, cim_disk.items()))
return cim_disk['SystemName']
+
+
+def _pri_cim_ext_of_cim_disk(smis_common, cim_disk_path, property_list=None):
+ """
+ Usage:
+ Find out the Primordial CIM_StorageExtent of CIM_DiskDrive
+ In SNIA SMI-S 1.4 rev.6 Block book, section 11.1.1 'Base Model'
+ quote:
+ A disk drive is modeled as a single MediaAccessDevice (DiskDrive)
+ That shall be linked to a single StorageExtent (representing the
+ storage in the drive) by a MediaPresent association. The
+ StorageExtent class represents the storage of the drive and
+ contains its size.
+ Parameter:
+ cim_disk_path # CIM_InstanceName of CIM_DiskDrive
+ property_list # a List of properties needed on returned
+ # CIM_StorageExtent
+ Returns:
+ cim_pri_ext # The CIM_Instance of Primordial CIM_StorageExtent
+ Exceptions:
+ LsmError
+ ErrorNumber.LSM_PLUGIN_BUG # Failed to find out pri cim_ext
+ """
+ if property_list is None:
+ property_list = ['Primordial']
+ else:
+ property_list = merge_list(property_list, ['Primordial'])
+
+ cim_exts = smis_common.Associators(
+ cim_disk_path,
+ AssocClass='CIM_MediaPresent',
+ ResultClass='CIM_StorageExtent',
+ PropertyList=property_list)
+ cim_exts = [p for p in cim_exts if p["Primordial"]]
+ if len(cim_exts) == 1:
+ # As SNIA commanded, only _ONE_ Primordial CIM_StorageExtent for
+ # each CIM_DiskDrive
+ return cim_exts[0]
+ else:
+ raise LsmError(ErrorNumber.PLUGIN_BUG,
+ "_pri_cim_ext_of_cim_disk(): "
+ "Got unexpected count of Primordial " +
+ "CIM_StorageExtent for CIM_DiskDrive: %s, %s " %
+ (cim_disk_path, cim_exts))
+
+
+def cim_disk_to_lsm_disk(smis_common, cim_disk):
+ """
+ Convert CIM_DiskDrive to lsm.Disk.
+ """
+ # CIM_DiskDrive does not have disk size information.
+ # We have to find out the Primodial CIM_StorageExtent for that.
+ cim_ext = _pri_cim_ext_of_cim_disk(
+ smis_common, cim_disk.path,
+ property_list=['BlockSize', 'NumberOfBlocks'])
+
+ status = disk_status_of_cim_disk(cim_disk)
+ name = ''
+ block_size = Disk.BLOCK_SIZE_NOT_FOUND
+ num_of_block = Disk.BLOCK_COUNT_NOT_FOUND
+ disk_type = Disk.TYPE_UNKNOWN
+ sys_id = sys_id_of_cim_disk(cim_disk)
+
+ # These are mandatory
+ # we do not check whether they follow the SNIA standard.
+ if 'Name' in cim_disk:
+ name = cim_disk["Name"]
+ if 'BlockSize' in cim_ext:
+ block_size = cim_ext['BlockSize']
+ if 'NumberOfBlocks' in cim_ext:
+ num_of_block = cim_ext['NumberOfBlocks']
+
+ # SNIA SMI-S 1.4 or even 1.6 does not define anyway to find out disk
+ # type.
+ # Currently, EMC is following DMTF define to do so.
+ if 'InterconnectType' in cim_disk: # DMTF 2.31 CIM_DiskDrive
+ disk_type = cim_disk['InterconnectType']
+ if 'Caption' in cim_disk:
+ # EMC VNX introduced NL_SAS disk.
+ if cim_disk['Caption'] == 'NL_SAS':
+ disk_type = Disk.TYPE_NL_SAS
+
+ if disk_type == Disk.TYPE_UNKNOWN and 'DiskType' in cim_disk:
+ disk_type = dmtf_disk_type_2_lsm_disk_type(cim_disk['DiskType'])
+
+ # LSI way for checking disk type
+ if not disk_type and cim_disk.classname == 'LSIESG_DiskDrive':
+ cim_pes = smis_common.Associators(
+ cim_disk.path,
+ AssocClass='CIM_SAPAvailableForElement',
+ ResultClass='CIM_ProtocolEndpoint',
+ PropertyList=['CreationClassName'])
+ if cim_pes and cim_pes[0]:
+ if 'CreationClassName' in cim_pes[0]:
+ ccn = cim_pes[0]['CreationClassName']
+ if ccn == 'LSIESG_TargetSATAProtocolEndpoint':
+ disk_type = Disk.TYPE_SATA
+ if ccn == 'LSIESG_TargetSASProtocolEndpoint':
+ disk_type = Disk.TYPE_SAS
+
+ disk_id = disk_id_of_cim_disk(cim_disk)
+
+ return Disk(disk_id, name, disk_type, block_size, num_of_block, status,
+ sys_id)
--
1.7.1