* Move DMTF.cim_pool_status_of() to
smis_pool._pool_status_of_cim_pool().
# This method is for smis_pool internal use only now.
* Move Smis._pool_element_type() to
smis_pool._pool_element_type()
# This method is for smis_pool internal use only now.
* Removed Smis._sys_id_of_cim_pool() as no method require it.
* Add MegaRAID workaround for smis_pool._pool_element_type()
to improve performance by returning (Pool.ELEMENT_TYPE_VOLUME, 0)
directly. Tested on a remote MegaRAID card with two pools:
Old: 10.10s # With all pending patches but this one.
New: 4.61s
* Move Smis._new_pool() to smis_pool.cim_pool_to_lsm_pool()
* Including three changes in patch as _pool_status_of_cim_pool() and
_pool_element_type() is now internal method for
smis_pool.cim_pool_to_lsm_pool() now.
Signed-off-by: Gris Ge <***@redhat.com>
---
plugin/smispy/dmtf.py | 17 ------
plugin/smispy/smis.py | 105 +--------------------------------------
plugin/smispy/smis_pool.py | 117 +++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 118 insertions(+), 121 deletions(-)
diff --git a/plugin/smispy/dmtf.py b/plugin/smispy/dmtf.py
index d020a9a..c5ea3fe 100644
--- a/plugin/smispy/dmtf.py
+++ b/plugin/smispy/dmtf.py
@@ -96,23 +96,6 @@ class DMTF(object):
return status, " ".join(status_info_list)
- _LSM_POOL_OP_STATUS_CONV = {
- OP_STATUS_OK: Pool.STATUS_OK,
- OP_STATUS_ERROR: Pool.STATUS_ERROR,
- OP_STATUS_DEGRADED: Pool.STATUS_DEGRADED,
- OP_STATUS_NON_RECOVERABLE_ERROR: Pool.STATUS_ERROR,
- OP_STATUS_SUPPORTING_ENTITY_IN_ERROR: Pool.STATUS_ERROR,
- }
-
- @staticmethod
- def cim_pool_status_of(dmtf_op_status_list):
- """
- Convert CIM_StoragePool['OperationalStatus'] to LSM
- """
- return DMTF.dmtf_op_status_list_conv(
- DMTF._LSM_POOL_OP_STATUS_CONV, dmtf_op_status_list,
- Pool.STATUS_UNKNOWN, Pool.STATUS_OTHER)
-
EMC_DISK_STATUS_REMOVED = 32768
_LSM_DISK_OP_STATUS_CONV = {
diff --git a/plugin/smispy/smis.py b/plugin/smispy/smis.py
index 9ba51d2..46d1dbb 100644
--- a/plugin/smispy/smis.py
+++ b/plugin/smispy/smis.py
@@ -813,54 +813,12 @@ class Smis(IStorageAreaNetwork):
cim_pools = smis_pool.cim_pools_of_cim_sys_path(
self._c, cim_sys.path, cim_pool_pros)
for cim_pool in cim_pools:
- rc.append(self._new_pool(cim_pool, system_id))
+ rc.append(
+ smis_pool.cim_pool_to_lsm_pool(
+ self._c, cim_pool, system_id))
return search_property(rc, search_key, search_value)
- def _sys_id_of_cim_pool(self, cim_pool):
- """
- Find out the system ID for certain CIM_StoragePool.
- Will return '' if failed.
- """
- sys_pros = smis_sys.cim_sys_id_pros()
- cim_syss = self._c.Associators(cim_pool.path,
- ResultClass='CIM_ComputerSystem',
- PropertyList=sys_pros)
- if len(cim_syss) == 1:
- return smis_sys.sys_id_of_cim_sys(cim_syss[0])
- return ''
-
- @handle_cim_errors
- def _new_pool(self, cim_pool, system_id=''):
- """
- Return a Pool object base on information of cim_pool.
- Assuming cim_pool already holding correct properties.
- """
- if not system_id:
- system_id = self._sys_id_of_cim_pool(cim_pool)
-
- status_info = ''
- pool_id = smis_pool.pool_id_of_cim_pool(cim_pool)
- name = ''
- total_space = Pool.TOTAL_SPACE_NOT_FOUND
- free_space = Pool.FREE_SPACE_NOT_FOUND
- status = Pool.STATUS_OK
- if 'ElementName' in cim_pool:
- name = cim_pool['ElementName']
- if 'TotalManagedSpace' in cim_pool:
- total_space = cim_pool['TotalManagedSpace']
- if 'RemainingManagedSpace' in cim_pool:
- free_space = cim_pool['RemainingManagedSpace']
- if 'OperationalStatus' in cim_pool:
- (status, status_info) = DMTF.cim_pool_status_of(
- cim_pool['OperationalStatus'])
-
- element_type, unsupported = self._pool_element_type(cim_pool)
-
- return Pool(pool_id, name, element_type, unsupported,
- total_space, free_space,
- status, status_info, system_id)
-
@handle_cim_errors
def systems(self, flags=0):
"""
@@ -2359,63 +2317,6 @@ class Smis(IStorageAreaNetwork):
"requested CIM_StorageExtent %s" %
cim_pri_ext_path)
- def _pool_element_type(self, cim_pool):
-
- element_type = 0
- unsupported = 0
-
- # check whether current pool support create volume or not.
- cim_sccs = self._c.Associators(
- cim_pool.path,
- AssocClass='CIM_ElementCapabilities',
- ResultClass='CIM_StorageConfigurationCapabilities',
- PropertyList=['SupportedStorageElementFeatures',
- 'SupportedStorageElementTypes'])
- # Associate StorageConfigurationCapabilities to StoragePool
- # is experimental in SNIA 1.6rev4, Block Book PDF Page 68.
- # Section 5.1.6 StoragePool, StorageVolume and LogicalDisk
- # Manipulation, Figure 9 - Capabilities Specific to a StoragePool
- if len(cim_sccs) == 1:
- cim_scc = cim_sccs[0]
- if 'SupportedStorageElementFeatures' in cim_scc:
- supported_features = cim_scc['SupportedStorageElementFeatures']
-
- if DMTF_SUPPORT_VOL_CREATE in supported_features:
- element_type |= Pool.ELEMENT_TYPE_VOLUME
- if DMTF_SUPPORT_ELEMENT_EXPAND not in supported_features:
- unsupported |= Pool.UNSUPPORTED_VOLUME_GROW
- if DMTF_SUPPORT_ELEMENT_REDUCE not in supported_features:
- unsupported |= Pool.UNSUPPORTED_VOLUME_SHRINK
-
- else:
- # IBM DS 8000 does not support StorageConfigurationCapabilities
- # per pool yet. They has been informed. Before fix, use a quick
- # workaround.
- # TODO: Currently, we don't have a way to detect
- # Pool.ELEMENT_TYPE_POOL
- # but based on knowing definition of each vendor.
- if cim_pool.classname == 'IBMTSDS_VirtualPool' or \
- cim_pool.classname == 'IBMTSDS_ExtentPool':
- element_type = Pool.ELEMENT_TYPE_VOLUME
- elif cim_pool.classname == 'IBMTSDS_RankPool':
- element_type = Pool.ELEMENT_TYPE_POOL
- elif cim_pool.classname == 'LSIESG_StoragePool':
- element_type = Pool.ELEMENT_TYPE_VOLUME
-
- if 'Usage' in cim_pool:
- usage = cim_pool['Usage']
-
- if usage == DMTF_POOL_USAGE_UNRESTRICTED:
- element_type |= Pool.ELEMENT_TYPE_VOLUME
- if usage == DMTF_POOL_USAGE_RESERVED_FOR_SYSTEM or \
- usage > DMTF_POOL_USAGE_DELTA:
- element_type |= Pool.ELEMENT_TYPE_SYS_RESERVED
- if usage == DMTF_POOL_USAGE_DELTA:
- # We blitz all the other elements types for this designation
- element_type = Pool.ELEMENT_TYPE_DELTA
-
- return element_type, unsupported
-
@staticmethod
def _is_frontend_fc_tgt(cim_fc_tgt):
"""
diff --git a/plugin/smispy/smis_pool.py b/plugin/smispy/smis_pool.py
index 2fec3bc..a64c628 100644
--- a/plugin/smispy/smis_pool.py
+++ b/plugin/smispy/smis_pool.py
@@ -16,8 +16,8 @@
# Author: Gris Ge <***@redhat.com>
from utils import merge_list
-from dmtf import DMTF_POOL_USAGE_SPARE
-from lsm import LsmError, ErrorNumber
+from dmtf import *
+from lsm import LsmError, ErrorNumber, Pool
def cim_pools_of_cim_sys_path(smis_common, cim_sys_path, property_list=None):
@@ -109,3 +109,116 @@ def cim_pool_pros():
'RemainingManagedSpace', 'Usage',
'OperationalStatus'])
return pool_pros
+
+
+def _pool_element_type(smis_common, cim_pool):
+ """
+ Return a set (Pool.element_type, Pool.unsupported)
+ Using CIM_StorageConfigurationCapabilities
+ 'SupportedStorageElementFeatures' and 'SupportedStorageElementTypes'
+ property.
+ For MegaRAID, just return (Pool.ELEMENT_TYPE_VOLUME, 0)
+ """
+ if smis_common.is_megaraid():
+ return Pool.ELEMENT_TYPE_VOLUME, 0
+
+ element_type = 0
+ unsupported = 0
+
+ # check whether current pool support create volume or not.
+ cim_sccs = smis_common.Associators(
+ cim_pool.path,
+ AssocClass='CIM_ElementCapabilities',
+ ResultClass='CIM_StorageConfigurationCapabilities',
+ PropertyList=['SupportedStorageElementFeatures',
+ 'SupportedStorageElementTypes'])
+ # Associate StorageConfigurationCapabilities to StoragePool
+ # is experimental in SNIA 1.6rev4, Block Book PDF Page 68.
+ # Section 5.1.6 StoragePool, StorageVolume and LogicalDisk
+ # Manipulation, Figure 9 - Capabilities Specific to a StoragePool
+ if len(cim_sccs) == 1:
+ cim_scc = cim_sccs[0]
+ if 'SupportedStorageElementFeatures' in cim_scc:
+ supported_features = cim_scc['SupportedStorageElementFeatures']
+
+ if DMTF_SUPPORT_VOL_CREATE in supported_features:
+ element_type |= Pool.ELEMENT_TYPE_VOLUME
+ if DMTF_SUPPORT_ELEMENT_EXPAND not in supported_features:
+ unsupported |= Pool.UNSUPPORTED_VOLUME_GROW
+ if DMTF_SUPPORT_ELEMENT_REDUCE not in supported_features:
+ unsupported |= Pool.UNSUPPORTED_VOLUME_SHRINK
+
+ else:
+ # IBM DS 8000 does not support StorageConfigurationCapabilities
+ # per pool yet. They has been informed. Before fix, use a quick
+ # workaround.
+ # TODO: Currently, we don't have a way to detect
+ # Pool.ELEMENT_TYPE_POOL
+ # but based on knowing definition of each vendor.
+ if cim_pool.classname == 'IBMTSDS_VirtualPool' or \
+ cim_pool.classname == 'IBMTSDS_ExtentPool':
+ element_type = Pool.ELEMENT_TYPE_VOLUME
+ elif cim_pool.classname == 'IBMTSDS_RankPool':
+ element_type = Pool.ELEMENT_TYPE_POOL
+ elif cim_pool.classname == 'LSIESG_StoragePool':
+ element_type = Pool.ELEMENT_TYPE_VOLUME
+
+ if 'Usage' in cim_pool:
+ usage = cim_pool['Usage']
+
+ if usage == DMTF_POOL_USAGE_UNRESTRICTED:
+ element_type |= Pool.ELEMENT_TYPE_VOLUME
+ if usage == DMTF_POOL_USAGE_RESERVED_FOR_SYSTEM or \
+ usage > DMTF_POOL_USAGE_DELTA:
+ element_type |= Pool.ELEMENT_TYPE_SYS_RESERVED
+ if usage == DMTF_POOL_USAGE_DELTA:
+ # We blitz all the other elements types for this designation
+ element_type = Pool.ELEMENT_TYPE_DELTA
+
+ return element_type, unsupported
+
+
+_LSM_POOL_OP_STATUS_CONV = {
+ DMTF.OP_STATUS_OK: Pool.STATUS_OK,
+ DMTF.OP_STATUS_ERROR: Pool.STATUS_ERROR,
+ DMTF.OP_STATUS_DEGRADED: Pool.STATUS_DEGRADED,
+ DMTF.OP_STATUS_NON_RECOVERABLE_ERROR: Pool.STATUS_ERROR,
+ DMTF.OP_STATUS_SUPPORTING_ENTITY_IN_ERROR: Pool.STATUS_ERROR,
+}
+
+
+def _pool_status_of_cim_pool(dmtf_op_status_list):
+ """
+ Convert CIM_StoragePool['OperationalStatus'] to LSM
+ """
+ return DMTF.dmtf_op_status_list_conv(
+ _LSM_POOL_OP_STATUS_CONV, dmtf_op_status_list,
+ Pool.STATUS_UNKNOWN, Pool.STATUS_OTHER)
+
+
+def cim_pool_to_lsm_pool(smis_common, cim_pool, system_id):
+ """
+ Return a Pool object base on information of cim_pool.
+ Assuming cim_pool already holding correct properties.
+ """
+ status_info = ''
+ pool_id = pool_id_of_cim_pool(cim_pool)
+ name = ''
+ total_space = Pool.TOTAL_SPACE_NOT_FOUND
+ free_space = Pool.FREE_SPACE_NOT_FOUND
+ status = Pool.STATUS_OK
+ if 'ElementName' in cim_pool:
+ name = cim_pool['ElementName']
+ if 'TotalManagedSpace' in cim_pool:
+ total_space = cim_pool['TotalManagedSpace']
+ if 'RemainingManagedSpace' in cim_pool:
+ free_space = cim_pool['RemainingManagedSpace']
+ if 'OperationalStatus' in cim_pool:
+ (status, status_info) = _pool_status_of_cim_pool(
+ cim_pool['OperationalStatus'])
+
+ element_type, unsupported = _pool_element_type(smis_common, cim_pool)
+
+ return Pool(pool_id, name, element_type, unsupported,
+ total_space, free_space,
+ status, status_info, system_id)
--
1.7.1