Discussion:
[Libstoragemgmt-devel] [PATCH 0/3] SMI-S Plugin: Remove DMTF class.
Gris Ge
2014-09-30 12:15:42 UTC
Permalink
This patchset is based on master plus these patchset:
* [V2 0/3] Move capablities to separate file
* [PATCH V3 00/10] SMI-S plugin: Reorganize code layout.
* [PATCH 0/7] Move lsm.System related methods to smis_sys.py.
* [PATCH V2 0/8] SMI-S Plugin: Split lsm.Pool related methods from smis.py
to smis_pool.py
* [PATCH 00/10] SMI-S Plugin: Split lsm.Disk methods to smis_disk.py

This patchset removed DMTF class by moving DMTF constants and methods to
dmtf.py file level.

Gris Ge (3):
SMI-S Plugin: Clean up DMTF.OP_STATUS_XXX of dmtf.py
SMI-S Plugin: Remove unused constants: dmtf.DMTF_STATUS_XXX
SMI-S Plugin: Remove DMTF class.

plugin/smispy/dmtf.py | 275 +++++++++++++++++++-----------------------
plugin/smispy/smis.py | 40 +++---
plugin/smispy/smis_cap.py | 22 ++--
plugin/smispy/smis_common.py | 12 +-
plugin/smispy/smis_disk.py | 22 ++--
plugin/smispy/smis_pool.py | 12 +-
plugin/smispy/smis_sys.py | 18 ++--
7 files changed, 187 insertions(+), 214 deletions(-)
Gris Ge
2014-09-30 12:15:43 UTC
Permalink
* Move dmtf.DMTF.OP_STATUS_XXX to dmtf.DMTF_OP_STATUS_XXX.
* Move dmtf.DMTF.dmtf_op_status_list_conv() to
dmtf.dmtf_op_status_list_conv()
* Move dmtf.DMTF.dmtf_op_status_to_str() to
dmtf._dmtf_op_status_to_str()

Signed-off-by: Gris Ge <***@redhat.com>
---
plugin/smispy/dmtf.py | 142 ++++++++++++++++++++++----------------------
plugin/smispy/smis_disk.py | 22 +++----
plugin/smispy/smis_pool.py | 12 ++--
plugin/smispy/smis_sys.py | 18 +++---
4 files changed, 95 insertions(+), 99 deletions(-)

diff --git a/plugin/smispy/dmtf.py b/plugin/smispy/dmtf.py
index 8ebf06a..f2d3037 100644
--- a/plugin/smispy/dmtf.py
+++ b/plugin/smispy/dmtf.py
@@ -23,78 +23,6 @@ from pywbem import Uint16


class DMTF(object):
- # CIM_ManagedSystemElement['OperationalStatus']
- OP_STATUS_UNKNOWN = 0
- OP_STATUS_OTHER = 1
- OP_STATUS_OK = 2
- OP_STATUS_DEGRADED = 3
- OP_STATUS_STRESSED = 4
- OP_STATUS_PREDICTIVE_FAILURE = 5
- OP_STATUS_ERROR = 6
- OP_STATUS_NON_RECOVERABLE_ERROR = 7
- OP_STATUS_STARTING = 8
- OP_STATUS_STOPPING = 9
- OP_STATUS_STOPPED = 10
- OP_STATUS_IN_SERVICE = 11
- OP_STATUS_NO_CONTACT = 12
- OP_STATUS_LOST_COMMUNICATION = 13
- OP_STATUS_ABORTED = 14
- OP_STATUS_DORMANT = 15
- OP_STATUS_SUPPORTING_ENTITY_IN_ERROR = 16
- OP_STATUS_COMPLETED = 17
- OP_STATUS_POWER_MODE = 18
-
- _OP_STATUS_STR_CONV = {
- OP_STATUS_UNKNOWN: "UNKNOWN",
- OP_STATUS_OTHER: "OTHER",
- OP_STATUS_OK: "OK",
- OP_STATUS_DEGRADED: "DEGRADED",
- OP_STATUS_STRESSED: "STRESSED",
- OP_STATUS_PREDICTIVE_FAILURE: "PREDICTIVE_FAILURE",
- OP_STATUS_ERROR: "ERROR",
- OP_STATUS_NON_RECOVERABLE_ERROR: "NON_RECOVERABLE_ERROR",
- OP_STATUS_STARTING: "STARTING",
- OP_STATUS_STOPPING: "STOPPING",
- OP_STATUS_STOPPED: "STOPPED",
- OP_STATUS_IN_SERVICE: "IN_SERVICE",
- OP_STATUS_NO_CONTACT: "NO_CONTACT",
- OP_STATUS_LOST_COMMUNICATION: "LOST_COMMUNICATION",
- OP_STATUS_ABORTED: "ABORTED",
- OP_STATUS_DORMANT: "DORMANT",
- OP_STATUS_SUPPORTING_ENTITY_IN_ERROR: "SUPPORTING_ENTITY_IN_ERROR",
- OP_STATUS_COMPLETED: "COMPLETED",
- OP_STATUS_POWER_MODE: "POWER_MODE",
- }
-
- @staticmethod
- def dmtf_op_status_to_str(dmtf_op_status):
- """
- Just convert integer to string. NOT ALLOWING provide a list.
- Return emtpy string is not found.
- """
- try:
- return DMTF._OP_STATUS_STR_CONV[dmtf_op_status]
- except KeyError:
- return ''
-
- @staticmethod
- def dmtf_op_status_list_conv(conv_dict, dmtf_op_status_list,
- unknown_value, other_value):
- status = 0
- status_info_list = []
- for dmtf_op_status in dmtf_op_status_list:
- if dmtf_op_status in conv_dict.keys():
- status |= conv_dict[dmtf_op_status]
- else:
- if dmtf_op_status in DMTF._OP_STATUS_STR_CONV.keys():
- status |= other_value
- status_info_list.append(
- DMTF.dmtf_op_status_to_str(dmtf_op_status))
- continue
- if status == 0:
- status = unknown_value
- return status, " ".join(status_info_list)
-

# CIM_StorageHardwareID['IDType']
ID_TYPE_OTHER = Uint16(1)
@@ -206,3 +134,73 @@ DMTF_STATUS_DORMANT = 15
DMTF_STATUS_SUPPORTING_ENTITY_IN_ERROR = 16
DMTF_STATUS_COMPLETED = 17
DMTF_STATUS_POWER_MODE = 18
+
+# CIM_ManagedSystemElement['OperationalStatus']
+DMTF_OP_STATUS_UNKNOWN = 0
+DMTF_OP_STATUS_OTHER = 1
+DMTF_OP_STATUS_OK = 2
+DMTF_OP_STATUS_DEGRADED = 3
+DMTF_OP_STATUS_STRESSED = 4
+DMTF_OP_STATUS_PREDICTIVE_FAILURE = 5
+DMTF_OP_STATUS_ERROR = 6
+DMTF_OP_STATUS_NON_RECOVERABLE_ERROR = 7
+DMTF_OP_STATUS_STARTING = 8
+DMTF_OP_STATUS_STOPPING = 9
+DMTF_OP_STATUS_STOPPED = 10
+DMTF_OP_STATUS_IN_SERVICE = 11
+DMTF_OP_STATUS_NO_CONTACT = 12
+DMTF_OP_STATUS_LOST_COMMUNICATION = 13
+DMTF_OP_STATUS_ABORTED = 14
+DMTF_OP_STATUS_DORMANT = 15
+DMTF_OP_STATUS_SUPPORTING_ENTITY_IN_ERROR = 16
+DMTF_OP_STATUS_COMPLETED = 17
+DMTF_OP_STATUS_POWER_MODE = 18
+
+_DMTF_OP_STATUS_STR_CONV = {
+ DMTF_OP_STATUS_UNKNOWN: "UNKNOWN",
+ DMTF_OP_STATUS_OTHER: "OTHER",
+ DMTF_OP_STATUS_OK: "OK",
+ DMTF_OP_STATUS_DEGRADED: "DEGRADED",
+ DMTF_OP_STATUS_STRESSED: "STRESSED",
+ DMTF_OP_STATUS_PREDICTIVE_FAILURE: "PREDICTIVE_FAILURE",
+ DMTF_OP_STATUS_ERROR: "ERROR",
+ DMTF_OP_STATUS_NON_RECOVERABLE_ERROR: "NON_RECOVERABLE_ERROR",
+ DMTF_OP_STATUS_STARTING: "STARTING",
+ DMTF_OP_STATUS_STOPPING: "STOPPING",
+ DMTF_OP_STATUS_STOPPED: "STOPPED",
+ DMTF_OP_STATUS_IN_SERVICE: "IN_SERVICE",
+ DMTF_OP_STATUS_NO_CONTACT: "NO_CONTACT",
+ DMTF_OP_STATUS_LOST_COMMUNICATION: "LOST_COMMUNICATION",
+ DMTF_OP_STATUS_ABORTED: "ABORTED",
+ DMTF_OP_STATUS_DORMANT: "DORMANT",
+ DMTF_OP_STATUS_SUPPORTING_ENTITY_IN_ERROR: "SUPPORTING_ENTITY_IN_ERROR",
+ DMTF_OP_STATUS_COMPLETED: "COMPLETED",
+ DMTF_OP_STATUS_POWER_MODE: "POWER_MODE",
+}
+
+def _dmtf_op_status_to_str(dmtf_op_status):
+ """
+ Just convert integer to string. NOT ALLOWING provide a list.
+ Return emtpy string is not found.
+ """
+ try:
+ return _DMTF_OP_STATUS_STR_CONV[dmtf_op_status]
+ except KeyError:
+ return ''
+
+def dmtf_op_status_list_conv(conv_dict, dmtf_op_status_list,
+ unknown_value, other_value):
+ status = 0
+ status_info_list = []
+ for dmtf_op_status in dmtf_op_status_list:
+ if dmtf_op_status in conv_dict.keys():
+ status |= conv_dict[dmtf_op_status]
+ else:
+ if dmtf_op_status in _DMTF_OP_STATUS_STR_CONV.keys():
+ status |= other_value
+ status_info_list.append(
+ _dmtf_op_status_to_str(dmtf_op_status))
+ continue
+ if status == 0:
+ status = unknown_value
+ return status, " ".join(status_info_list)
diff --git a/plugin/smispy/smis_disk.py b/plugin/smispy/smis_disk.py
index 01de3db..6ca7afd 100644
--- a/plugin/smispy/smis_disk.py
+++ b/plugin/smispy/smis_disk.py
@@ -16,21 +16,19 @@
# Author: Gris Ge <***@redhat.com>

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 dmtf import *
from utils import merge_list


_LSM_DISK_OP_STATUS_CONV = {
- DMTF.OP_STATUS_UNKNOWN: Disk.STATUS_UNKNOWN,
- DMTF.OP_STATUS_OK: Disk.STATUS_OK,
- DMTF.OP_STATUS_PREDICTIVE_FAILURE: Disk.STATUS_PREDICTIVE_FAILURE,
- DMTF.OP_STATUS_ERROR: Disk.STATUS_ERROR,
- DMTF.OP_STATUS_NON_RECOVERABLE_ERROR: Disk.STATUS_ERROR,
- DMTF.OP_STATUS_STARTING: Disk.STATUS_STARTING,
- DMTF.OP_STATUS_STOPPING: Disk.STATUS_STOPPING,
- DMTF.OP_STATUS_STOPPED: Disk.STATUS_STOPPED,
+ DMTF_OP_STATUS_UNKNOWN: Disk.STATUS_UNKNOWN,
+ DMTF_OP_STATUS_OK: Disk.STATUS_OK,
+ DMTF_OP_STATUS_PREDICTIVE_FAILURE: Disk.STATUS_PREDICTIVE_FAILURE,
+ DMTF_OP_STATUS_ERROR: Disk.STATUS_ERROR,
+ DMTF_OP_STATUS_NON_RECOVERABLE_ERROR: Disk.STATUS_ERROR,
+ DMTF_OP_STATUS_STARTING: Disk.STATUS_STARTING,
+ DMTF_OP_STATUS_STOPPING: Disk.STATUS_STOPPING,
+ DMTF_OP_STATUS_STOPPED: Disk.STATUS_STOPPED,
}


@@ -42,7 +40,7 @@ def _disk_status_of_cim_disk(cim_disk):
if 'OperationalStatus' not in cim_disk:
return Disk.STATUS_UNKNOWN

- return DMTF.dmtf_op_status_list_conv(
+ return dmtf_op_status_list_conv(
_LSM_DISK_OP_STATUS_CONV, cim_disk['OperationalStatus'],
Disk.STATUS_UNKNOWN, Disk.STATUS_OTHER)[0]

diff --git a/plugin/smispy/smis_pool.py b/plugin/smispy/smis_pool.py
index e97b631..99639f6 100644
--- a/plugin/smispy/smis_pool.py
+++ b/plugin/smispy/smis_pool.py
@@ -181,11 +181,11 @@ def _pool_element_type(smis_common, cim_pool):


_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,
+ 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,
}


@@ -193,7 +193,7 @@ def _pool_status_of_cim_pool(dmtf_op_status_list):
"""
Convert CIM_StoragePool['OperationalStatus'] to LSM
"""
- return DMTF.dmtf_op_status_list_conv(
+ return dmtf_op_status_list_conv(
_LSM_POOL_OP_STATUS_CONV, dmtf_op_status_list,
Pool.STATUS_UNKNOWN, Pool.STATUS_OTHER)

diff --git a/plugin/smispy/smis_sys.py b/plugin/smispy/smis_sys.py
index 683ae2b..b750c75 100644
--- a/plugin/smispy/smis_sys.py
+++ b/plugin/smispy/smis_sys.py
@@ -16,7 +16,7 @@
# Author: Gris Ge <***@redhat.com>

from utils import merge_list
-from dmtf import DMTF
+from dmtf import *
from lsm import System, LsmError, ErrorNumber


@@ -91,13 +91,13 @@ def cim_sys_pros():


_LSM_SYS_OP_STATUS_CONV = {
- DMTF.OP_STATUS_UNKNOWN: System.STATUS_UNKNOWN,
- DMTF.OP_STATUS_OK: System.STATUS_OK,
- DMTF.OP_STATUS_ERROR: System.STATUS_ERROR,
- DMTF.OP_STATUS_DEGRADED: System.STATUS_DEGRADED,
- DMTF.OP_STATUS_NON_RECOVERABLE_ERROR: System.STATUS_ERROR,
- DMTF.OP_STATUS_PREDICTIVE_FAILURE: System.STATUS_PREDICTIVE_FAILURE,
- DMTF.OP_STATUS_SUPPORTING_ENTITY_IN_ERROR: System.STATUS_ERROR,
+ DMTF_OP_STATUS_UNKNOWN: System.STATUS_UNKNOWN,
+ DMTF_OP_STATUS_OK: System.STATUS_OK,
+ DMTF_OP_STATUS_ERROR: System.STATUS_ERROR,
+ DMTF_OP_STATUS_DEGRADED: System.STATUS_DEGRADED,
+ DMTF_OP_STATUS_NON_RECOVERABLE_ERROR: System.STATUS_ERROR,
+ DMTF_OP_STATUS_PREDICTIVE_FAILURE: System.STATUS_PREDICTIVE_FAILURE,
+ DMTF_OP_STATUS_SUPPORTING_ENTITY_IN_ERROR: System.STATUS_ERROR,
}


@@ -111,7 +111,7 @@ def _sys_status_of_cim_sys(cim_sys):
"sys_status_of_cim_sys(): Got a CIM_ComputerSystem with no "
"OperationalStatus: %s, %s" % (cim_sys.items(), cim_sys.path))

- return DMTF.dmtf_op_status_list_conv(
+ return dmtf_op_status_list_conv(
_LSM_SYS_OP_STATUS_CONV, cim_sys['OperationalStatus'],
System.STATUS_UNKNOWN, System.STATUS_OTHER)
--
1.7.1
Gris Ge
2014-09-30 12:15:44 UTC
Permalink
* Removed all dmtf.DMTF_STATUS_XXX constants as no method is
using it.
* Please use dmtf.DMTF_OP_STATUS_XXX instead if needed.

Signed-off-by: Gris Ge <***@redhat.com>
---
plugin/smispy/dmtf.py | 20 --------------------
1 files changed, 0 insertions(+), 20 deletions(-)

diff --git a/plugin/smispy/dmtf.py b/plugin/smispy/dmtf.py
index f2d3037..a32055f 100644
--- a/plugin/smispy/dmtf.py
+++ b/plugin/smispy/dmtf.py
@@ -115,26 +115,6 @@ DMTF_DISK_TYPE_HDD = 2
DMTF_DISK_TYPE_SSD = 3
DMTF_DISK_TYPE_HYBRID = 4

-DMTF_STATUS_UNKNOWN = 0
-DMTF_STATUS_OTHER = 1
-DMTF_STATUS_OK = 2
-DMTF_STATUS_DEGRADED = 3
-DMTF_STATUS_STRESSED = 4
-DMTF_STATUS_PREDICTIVE_FAILURE = 5
-DMTF_STATUS_ERROR = 6
-DMTF_STATUS_NON_RECOVERABLE_ERROR = 7
-DMTF_STATUS_STARTING = 8
-DMTF_STATUS_STOPPING = 9
-DMTF_STATUS_STOPPED = 10
-DMTF_STATUS_IN_SERVICE = 11
-DMTF_STATUS_NO_CONTACT = 12
-DMTF_STATUS_LOST_COMMUNICATION = 13
-DMTF_STATUS_ABORTED = 14
-DMTF_STATUS_DORMANT = 15
-DMTF_STATUS_SUPPORTING_ENTITY_IN_ERROR = 16
-DMTF_STATUS_COMPLETED = 17
-DMTF_STATUS_POWER_MODE = 18
-
# CIM_ManagedSystemElement['OperationalStatus']
DMTF_OP_STATUS_UNKNOWN = 0
DMTF_OP_STATUS_OTHER = 1
--
1.7.1
Gris Ge
2014-09-30 12:15:45 UTC
Permalink
* Remove DMTF class as no __init__() or methods any more.
* All DMTF constants moved to dmtf.py file level with DMTF_ prefix.

Signed-off-by: Gris Ge <***@redhat.com>
---
plugin/smispy/dmtf.py | 101 ++++++++++++++++++++---------------------
plugin/smispy/smis.py | 40 ++++++++--------
plugin/smispy/smis_cap.py | 22 +++++-----
plugin/smispy/smis_common.py | 12 +++---
4 files changed, 86 insertions(+), 89 deletions(-)

diff --git a/plugin/smispy/dmtf.py b/plugin/smispy/dmtf.py
index a32055f..94459d6 100644
--- a/plugin/smispy/dmtf.py
+++ b/plugin/smispy/dmtf.py
@@ -18,68 +18,65 @@

# This class handle DMTF CIM constants and convert to LSM type.

-from lsm import (System, Pool, Disk)
from pywbem import Uint16


-class DMTF(object):
-
- # CIM_StorageHardwareID['IDType']
- ID_TYPE_OTHER = Uint16(1)
- ID_TYPE_WWPN = Uint16(2)
- ID_TYPE_ISCSI = Uint16(5)
-
- TGT_PORT_USAGE_FRONTEND_ONLY = Uint16(2)
- TGT_PORT_USAGE_UNRESTRICTED = Uint16(4)
- # CIM_FCPort['PortDiscriminator']
- FC_PORT_PORT_DISCRIMINATOR_FCOE = Uint16(10)
- # CIM_NetworkPort['LinkTechnology']
- NET_PORT_LINK_TECH_ETHERNET = Uint16(2)
- # CIM_iSCSIProtocolEndpoint['Role']
- ISCSI_TGT_ROLE_TARGET = Uint16(3)
- # CIM_SCSIProtocolController['NameFormat']
- SPC_NAME_FORMAT_ISCSI = Uint16(3)
- # CIM_IPProtocolEndpoint['IPv6AddressType']
- IPV6_ADDR_TYPE_GUA = Uint16(6)
- # GUA: Global Unicast Address.
- # 2000::/3
- IPV6_ADDR_TYPE_6TO4 = Uint16(7)
- # IPv6 to IPv4 transition
- # ::ffff:0:0/96
- # ::ffff:0:0:0/96
- # 64:ff9b::/96 # well-known prefix
- # 2002::/16 # 6to4
- IPV6_ADDR_TYPE_ULA = Uint16(8)
- # ULA: Unique Local Address, aka Site Local Unicast.
- # fc00::/7
-
- # CIM_GroupMaskingMappingService.CreateGroup('Type')
- MASK_GROUP_TYPE_INIT = Uint16(2)
- MASK_GROUP_TYPE_TGT = Uint16(3)
- MASK_GROUP_TYPE_DEV = Uint16(4)
-
- # CIM_GroupMaskingMappingCapabilities['SupportedDeviceGroupFeatures']
- # Allowing empty DeviceMaskingGroup associated to SPC
- GMM_CAP_DEV_MG_ALLOW_EMPTY_W_SPC = Uint16(5)
-
- # CIM_GroupMaskingMappingCapabilities['SupportedAsynchronousActions']
- # and 'SupportedSynchronousActions'. They are using the same value map.
- GMM_CAP_DELETE_SPC = Uint16(24)
- GMM_CAP_DELETE_GROUP = Uint16(20)
-
- # CIM_StorageConfigurationCapabilities['SupportedStorageElementTypes']
- SCS_CAP_SUP_ST_VOLUME = Uint16(2)
- SCS_CAP_SUP_THIN_ST_VOLUME = Uint16(5)
-
- # CIM_StorageConfigurationCapabilities['SupportedAsynchronousActions']
- # and also for 'SupportedSynchronousActions'
- SCS_CAP_VOLUME_CREATE = Uint16(5)
- SCS_CAP_VOLUME_DELETE = Uint16(6)
- SCS_CAP_VOLUME_MODIFY = Uint16(7)
-
- # DSP 1033 Profile Registration
- INTEROP_NAMESPACES = ['interop', 'root/interop', 'root/PG_Interop']
- DEFAULT_NAMESPACE = 'interop'
+# CIM_StorageHardwareID['IDType']
+DMTF_ID_TYPE_OTHER = Uint16(1)
+DMTF_ID_TYPE_WWPN = Uint16(2)
+DMTF_ID_TYPE_ISCSI = Uint16(5)
+
+DMTF_TGT_PORT_USAGE_FRONTEND_ONLY = Uint16(2)
+DMTF_TGT_PORT_USAGE_UNRESTRICTED = Uint16(4)
+# CIM_FCPort['PortDiscriminator']
+DMTF_FC_PORT_PORT_DISCRIMINATOR_FCOE = Uint16(10)
+# CIM_NetworkPort['LinkTechnology']
+DMTF_NET_PORT_LINK_TECH_ETHERNET = Uint16(2)
+# CIM_iSCSIProtocolEndpoint['Role']
+DMTF_ISCSI_TGT_ROLE_TARGET = Uint16(3)
+# CIM_SCSIProtocolController['NameFormat']
+DMTF_SPC_NAME_FORMAT_ISCSI = Uint16(3)
+# CIM_IPProtocolEndpoint['IPv6AddressType']
+DMTF_IPV6_ADDR_TYPE_GUA = Uint16(6)
+# GUA: Global Unicast Address.
+# 2000::/3
+DMTF_IPV6_ADDR_TYPE_6TO4 = Uint16(7)
+# IPv6 to IPv4 transition
+# ::ffff:0:0/96
+# ::ffff:0:0:0/96
+# 64:ff9b::/96 # well-known prefix
+# 2002::/16 # 6to4
+DMTF_IPV6_ADDR_TYPE_ULA = Uint16(8)
+# ULA: Unique Local Address, aka Site Local Unicast.
+# fc00::/7
+
+# CIM_GroupMaskingMappingService.CreateGroup('Type')
+DMTF_MASK_GROUP_TYPE_INIT = Uint16(2)
+DMTF_MASK_GROUP_TYPE_TGT = Uint16(3)
+DMTF_MASK_GROUP_TYPE_DEV = Uint16(4)
+
+# CIM_GroupMaskingMappingCapabilities['SupportedDeviceGroupFeatures']
+# Allowing empty DeviceMaskingGroup associated to SPC
+DMTF_GMM_CAP_DEV_MG_ALLOW_EMPTY_W_SPC = Uint16(5)
+
+# CIM_GroupMaskingMappingCapabilities['SupportedAsynchronousActions']
+# and 'SupportedSynchronousActions'. They are using the same value map.
+DMTF_GMM_CAP_DELETE_SPC = Uint16(24)
+DMTF_GMM_CAP_DELETE_GROUP = Uint16(20)
+
+# CIM_StorageConfigurationCapabilities['SupportedStorageElementTypes']
+DMTF_SCS_CAP_SUP_ST_VOLUME = Uint16(2)
+DMTF_SCS_CAP_SUP_THIN_ST_VOLUME = Uint16(5)
+
+# CIM_StorageConfigurationCapabilities['SupportedAsynchronousActions']
+# and also for 'SupportedSynchronousActions'
+DMTF_SCS_CAP_VOLUME_CREATE = Uint16(5)
+DMTF_SCS_CAP_VOLUME_DELETE = Uint16(6)
+DMTF_SCS_CAP_VOLUME_MODIFY = Uint16(7)
+
+# DSP 1033 Profile Registration
+DMTF_INTEROP_NAMESPACES = ['interop', 'root/interop', 'root/PG_Interop']
+DMTF_DEFAULT_NAMESPACE = 'interop'


# DMTF CIM 2.37.0 experimental CIM_StoragePool['Usage']
diff --git a/plugin/smispy/smis.py b/plugin/smispy/smis.py
index 351de57..8e59797 100644
--- a/plugin/smispy/smis.py
+++ b/plugin/smispy/smis.py
@@ -99,9 +99,9 @@ def _lsm_init_id_to_snia(lsm_init_id):

def _dmtf_init_type_to_lsm(cim_init):
if 'IDType' in cim_init:
- if cim_init['IDType'] == DMTF.ID_TYPE_WWPN:
+ if cim_init['IDType'] == DMTF_ID_TYPE_WWPN:
return AccessGroup.INIT_TYPE_WWPN
- elif cim_init['IDType'] == DMTF.ID_TYPE_ISCSI:
+ elif cim_init['IDType'] == DMTF_ID_TYPE_ISCSI:
return AccessGroup.INIT_TYPE_ISCSI_IQN
return AccessGroup.INIT_TYPE_UNKNOWN

@@ -115,19 +115,19 @@ def _lsm_tgt_port_type_of_cim_fc_tgt(cim_fc_tgt):
# for FCoE target port.
if 'PortDiscriminator' in cim_fc_tgt and \
cim_fc_tgt['PortDiscriminator'] and \
- DMTF.FC_PORT_PORT_DISCRIMINATOR_FCOE in cim_fc_tgt['PortDiscriminator']:
+ DMTF_FC_PORT_PORT_DISCRIMINATOR_FCOE in cim_fc_tgt['PortDiscriminator']:
return TargetPort.TYPE_FCOE
if 'LinkTechnology' in cim_fc_tgt and \
- cim_fc_tgt['LinkTechnology'] == DMTF.NET_PORT_LINK_TECH_ETHERNET:
+ cim_fc_tgt['LinkTechnology'] == DMTF_NET_PORT_LINK_TECH_ETHERNET:
return TargetPort.TYPE_FCOE
return TargetPort.TYPE_FC


def _lsm_init_type_to_dmtf(init_type):
if init_type == AccessGroup.INIT_TYPE_WWPN:
- return DMTF.ID_TYPE_WWPN
+ return DMTF_ID_TYPE_WWPN
if init_type == AccessGroup.INIT_TYPE_ISCSI_IQN:
- return DMTF.ID_TYPE_ISCSI
+ return DMTF_ID_TYPE_ISCSI
raise LsmError(ErrorNumber.NO_SUPPORT,
"Does not support provided init_type: %d" % init_type)

@@ -584,7 +584,7 @@ class Smis(IStorageAreaNetwork):
if not (nf and nn and name):
return None
# SNIA might have miss documented VPD83Type3(1), it should be
- # VOL_NAME_FORMAT_OTHER(1) based on DMTF.
+ # VOL_NAME_FORMAT_OTHER(1) based on DMTF_
# Will remove the Smis.VOL_NAME_FORMAT_OTHER condition if confirmed as
# SNIA document fault.
if (nf == VOL_NAME_FORMAT_NNA and
@@ -1204,7 +1204,7 @@ class Smis(IStorageAreaNetwork):
in_params = {
'GroupName': name,
'Members': [cim_vol_path],
- 'Type': DMTF.MASK_GROUP_TYPE_DEV}
+ 'Type': DMTF_MASK_GROUP_TYPE_DEV}

cim_dev_mg_path = None
try:
@@ -1238,7 +1238,7 @@ class Smis(IStorageAreaNetwork):

in_params = {
'GroupName': name,
- 'Type': DMTF.MASK_GROUP_TYPE_TGT}
+ 'Type': DMTF_MASK_GROUP_TYPE_TGT}

if init_type == AccessGroup.INIT_TYPE_WWPN:
cim_fc_tgts = self._cim_fc_tgt_of(cim_sys_path)
@@ -1443,14 +1443,14 @@ class Smis(IStorageAreaNetwork):

flag_empty_dev_in_spc = False

- if DMTF.GMM_CAP_DEV_MG_ALLOW_EMPTY_W_SPC in \
+ if DMTF_GMM_CAP_DEV_MG_ALLOW_EMPTY_W_SPC in \
cim_gmm_cap['SupportedDeviceGroupFeatures']:
flag_empty_dev_in_spc = True

if flag_empty_dev_in_spc is False:
- if ((DMTF.GMM_CAP_DELETE_SPC not in
+ if ((DMTF_GMM_CAP_DELETE_SPC not in
cim_gmm_cap['SupportedSynchronousActions']) and
- (DMTF.GMM_CAP_DELETE_SPC not in
+ (DMTF_GMM_CAP_DELETE_SPC not in
cim_gmm_cap['SupportedAsynchronousActions'])):
raise LsmError(
ErrorNumber.NO_SUPPORT,
@@ -2154,8 +2154,8 @@ class Smis(IStorageAreaNetwork):
Check CIM_FCPort['UsageRestriction'] for frontend port.
"""
dmtf_usage = cim_fc_tgt['UsageRestriction']
- if dmtf_usage == DMTF.TGT_PORT_USAGE_FRONTEND_ONLY or \
- dmtf_usage == DMTF.TGT_PORT_USAGE_UNRESTRICTED:
+ if dmtf_usage == DMTF_TGT_PORT_USAGE_FRONTEND_ONLY or \
+ dmtf_usage == DMTF_TGT_PORT_USAGE_UNRESTRICTED:
return True
return False

@@ -2223,7 +2223,7 @@ class Smis(IStorageAreaNetwork):
# EMC has vendor specific class which contain identical
# properties of SPC for iSCSI node.
continue
- if cim_spc['NameFormat'] == DMTF.SPC_NAME_FORMAT_ISCSI:
+ if cim_spc['NameFormat'] == DMTF_SPC_NAME_FORMAT_ISCSI:
cim_iscsi_nodes.extend([cim_spc])

if len(cim_iscsi_nodes) == 0:
@@ -2259,7 +2259,7 @@ class Smis(IStorageAreaNetwork):
ResultClass='CIM_iSCSIProtocolEndpoint',
PropertyList=property_list)
for cim_iscsi_pg in cur_cim_iscsi_pgs:
- if cim_iscsi_pg['Role'] == DMTF.ISCSI_TGT_ROLE_TARGET:
+ if cim_iscsi_pg['Role'] == DMTF_ISCSI_TGT_ROLE_TARGET:
rc.extend([cim_iscsi_pg])
return rc

@@ -2325,9 +2325,9 @@ class Smis(IStorageAreaNetwork):
# Local Address.
if 'IPv6AddressType' in cim_ip and cim_ip['IPv6AddressType']:
ipv6_addr_type = cim_ip['IPv6AddressType']
- if ipv6_addr_type != DMTF.IPV6_ADDR_TYPE_GUA and \
- ipv6_addr_type != DMTF.IPV6_ADDR_TYPE_6TO4 and \
- ipv6_addr_type != DMTF.IPV6_ADDR_TYPE_ULA:
+ if ipv6_addr_type != DMTF_IPV6_ADDR_TYPE_GUA and \
+ ipv6_addr_type != DMTF_IPV6_ADDR_TYPE_6TO4 and \
+ ipv6_addr_type != DMTF_IPV6_ADDR_TYPE_ULA:
ipv6_addr = ''

# NetApp is using this kind of IPv6 address
@@ -2694,7 +2694,7 @@ class Smis(IStorageAreaNetwork):

in_params = {'GroupName': name,
'Members': [cim_init_path],
- 'Type': DMTF.MASK_GROUP_TYPE_INIT}
+ 'Type': DMTF_MASK_GROUP_TYPE_INIT}

cim_init_mg_pros = self._cim_init_mg_pros()

diff --git a/plugin/smispy/smis_cap.py b/plugin/smispy/smis_cap.py
index ae11460..0e83e0f 100644
--- a/plugin/smispy/smis_cap.py
+++ b/plugin/smispy/smis_cap.py
@@ -133,19 +133,19 @@ def _bsp_cap_set(smis_common, cim_sys_path, cap):
if cim_scs_cap['SupportedAsynchronousActions']:
sup_actions.extend(cim_scs_cap['SupportedAsynchronousActions'])

- if DMTF.SCS_CAP_SUP_ST_VOLUME in element_types or \
- DMTF.SCS_CAP_SUP_THIN_ST_VOLUME in element_types:
+ if DMTF_SCS_CAP_SUP_ST_VOLUME in element_types or \
+ DMTF_SCS_CAP_SUP_THIN_ST_VOLUME in element_types:
cap.set(Capabilities.VOLUMES)
- if DMTF.SCS_CAP_SUP_THIN_ST_VOLUME in element_types:
+ if DMTF_SCS_CAP_SUP_THIN_ST_VOLUME in element_types:
cap.set(Capabilities.VOLUME_THIN)

- if DMTF.SCS_CAP_VOLUME_CREATE in sup_actions:
+ if DMTF_SCS_CAP_VOLUME_CREATE in sup_actions:
cap.set(Capabilities.VOLUME_CREATE)

- if DMTF.SCS_CAP_VOLUME_DELETE in sup_actions:
+ if DMTF_SCS_CAP_VOLUME_DELETE in sup_actions:
cap.set(Capabilities.VOLUME_DELETE)

- if DMTF.SCS_CAP_VOLUME_MODIFY in sup_actions:
+ if DMTF_SCS_CAP_VOLUME_MODIFY in sup_actions:
cap.set(Capabilities.VOLUME_RESIZE)

return
@@ -203,22 +203,22 @@ def _group_mask_map_cap_set(smis_common, cim_sys_path, cap):

# if empty dev group in spc is allowed, RemoveMembers() is enough
# to do volume_unmask(). RemoveMembers() is mandatory.
- if DMTF.GMM_CAP_DEV_MG_ALLOW_EMPTY_W_SPC in \
+ if DMTF_GMM_CAP_DEV_MG_ALLOW_EMPTY_W_SPC in \
cim_gmm_cap['SupportedDeviceGroupFeatures']:
cap.set(Capabilities.VOLUME_UNMASK)

# DeleteMaskingView() is optional, this is required by volume_unmask()
# when empty dev group in spc not allowed.
- elif ((DMTF.GMM_CAP_DELETE_SPC in
+ elif ((DMTF_GMM_CAP_DELETE_SPC in
cim_gmm_cap['SupportedSynchronousActions']) or
- (DMTF.GMM_CAP_DELETE_SPC in
+ (DMTF_GMM_CAP_DELETE_SPC in
cim_gmm_cap['SupportedAsynchronousActions'])):
cap.set(Capabilities.VOLUME_UNMASK)

# DeleteGroup is optional, this is required by access_group_delete()
- if ((DMTF.GMM_CAP_DELETE_GROUP in
+ if ((DMTF_GMM_CAP_DELETE_GROUP in
cim_gmm_cap['SupportedSynchronousActions']) or
- (DMTF.GMM_CAP_DELETE_GROUP in
+ (DMTF_GMM_CAP_DELETE_GROUP in
cim_gmm_cap['SupportedAsynchronousActions'])):
cap.set(Capabilities.ACCESS_GROUP_DELETE)
return None
diff --git a/plugin/smispy/smis_common.py b/plugin/smispy/smis_common.py
index d66286c..a404f16 100644
--- a/plugin/smispy/smis_common.py
+++ b/plugin/smispy/smis_common.py
@@ -25,7 +25,7 @@
from pywbem import Uint16, CIMError
import pywbem

-from dmtf import DMTF
+from dmtf import *
from lsm import LsmError, ErrorNumber
from utils import (merge_list)

@@ -45,7 +45,7 @@ def _profile_register_load(wbem_conn):
"""
profile_dict = {}
root_blk_cim_rp = None
- namespace_check_list = DMTF.INTEROP_NAMESPACES
+ namespace_check_list = DMTF_INTEROP_NAMESPACES

cim_rps = []
for namespace in namespace_check_list:
@@ -160,7 +160,7 @@ class SmisCommon(object):
_PRODUCT_NETAPP_E = 'NetApp-E'

def __init__(self, url, username, password,
- namespace=DMTF.DEFAULT_NAMESPACE,
+ namespace=DMTF_DEFAULT_NAMESPACE,
no_ssl_verify=False, debug=False, system_list=None):
self._wbem_conn = None
self._profile_dict = {}
@@ -169,7 +169,7 @@ class SmisCommon(object):
self.system_list = system_list

if namespace is None:
- namespace = DMTF.DEFAULT_NAMESPACE
+ namespace = DMTF_DEFAULT_NAMESPACE

self._wbem_conn = pywbem.WBEMConnection(
url, (username, password), namespace)
@@ -307,7 +307,7 @@ class SmisCommon(object):
"_vendor_namespace(): self.root_blk_cim_rp not set yet")

def EnumerateInstances(self, ClassName, namespace=None, **params):
- if self._wbem_conn.default_namespace in DMTF.INTEROP_NAMESPACES:
+ if self._wbem_conn.default_namespace in DMTF_INTEROP_NAMESPACES:
# We have to enumerate in vendor namespace
self._wbem_conn.default_namespace = self._vendor_namespace()
params['LocalOnly']=False
@@ -315,7 +315,7 @@ class SmisCommon(object):
ClassName, namespace, **params)

def EnumerateInstanceNames(self, ClassName, namespace=None, **params):
- if self._wbem_conn.default_namespace in DMTF.INTEROP_NAMESPACES:
+ if self._wbem_conn.default_namespace in DMTF_INTEROP_NAMESPACES:
# We have to enumerate in vendor namespace
self._wbem_conn.default_namespace = self._vendor_namespace()
params['LocalOnly']=False
--
1.7.1
Tony Asleson
2014-09-30 22:02:07 UTC
Permalink
Post by Gris Ge
This patchset removed DMTF class by moving DMTF constants and methods to
dmtf.py file level.
The code looks fine and regression tests look as good as they were
before the refactoring (tested using all outstanding patches).

However, I'm wondering about the dmtf constants and functions. This
patch changed it so users of dmtf do:

from dmtf import *

and then use the constants and functions like:

# Constant
DMTF_SCS_CAP_SUP_ST_VOLUME

# Function
dmtf_op_status_list_conv(...)


This is totally fine syntax, but I'm wondering if we should do it this
way or adopt something like:


import dmtf

# Constant
dmtf.DMTF_SCS_CAP_SUP_ST_VOLUME

# Function
dmtf.dmtf_op_status_list_conv(...)

This does look like a little redundant with the namespace as we have the
dmtf namespace and everything in it prefixed with dmtf, so it would
probably be better to do something where we rename the contents of dmtf
and use it like:

import dmtf

# Constant
dmtf.SCS_CAP_SUP_ST_VOLUME

# Function
dmtf.op_status_list_conv(...)


So which approach is more pythonic or more acceptable? Andy any
suggestions on this?

Thanks,
Tony
Andy Grover
2014-09-30 22:39:05 UTC
Permalink
Post by Tony Asleson
Post by Gris Ge
This patchset removed DMTF class by moving DMTF constants and methods to
dmtf.py file level.
The code looks fine and regression tests look as good as they were
before the refactoring (tested using all outstanding patches).
However, I'm wondering about the dmtf constants and functions. This
from dmtf import *
# Constant
DMTF_SCS_CAP_SUP_ST_VOLUME
import dmtf
So which approach is more pythonic or more acceptable? Andy any
suggestions on this?
'import dmtf" is generally preferred. It makes it clearer where
everything comes from. For a longer named module, you can do:

import verylongmodulename as vlmn

vlmn.whatever()

Regards -- Andy
Gris Ge
2014-10-01 01:56:46 UTC
Permalink
Post by Andy Grover
'import dmtf" is generally preferred. It makes it clearer where
import verylongmodulename as vlmn
vlmn.whatever()
Regards -- Andy
Thanks for the suggestion.
I will generate V2.
For smis_constants.py, its constants could be merged into dmtf.py[1] or
smis_common.py[2]. I will reflect this in V2 patch also.

[1] Hold DMTF CIM constants and methods.
[2] Hold SNIA constants(just some profile name and version),
plugin internal constants(like JOB_RETRIEVE_VOLUME)
and other constants(like port number IAAN_WBEM_HTTP_PORT).

Best regards.
--
Gris Ge
Gris Ge
2014-10-03 06:29:25 UTC
Permalink
This patchset is based on master plus these patchset:
* [V2 0/3] Move capablities to separate file
* [PATCH V3 00/10] SMI-S plugin: Reorganize code layout.
* [PATCH 0/7] Move lsm.System related methods to smis_sys.py.
* [PATCH V2 0/8] SMI-S Plugin: Split lsm.Pool related methods from smis.py
to smis_pool.py
* [PATCH 00/10] SMI-S Plugin: Split lsm.Disk methods to smis_disk.py

This patchset removed DMTF class by moving DMTF constants and methods to
dmtf.py file level.

Changed in V2:
* Remove 'DMTF_' prefix of dmtf.py constants.
* Renamed dmtf.dmtf_op_status_list_conv() to dmtf.op_status_list_conv().
* Changed 'from dmtf import *' to 'import dmtf' in smis_xxx.py files.

Gris Ge (3):
SMI-S Plugin: Clean up DMTF.OP_STATUS_XXX of dmtf.py
SMI-S Plugin: Remove unused constants: dmtf.DMTF_STATUS_XXX
SMI-S Plugin: Remove DMTF class.

plugin/smispy/dmtf.py | 312 ++++++++++++++++++++-----------------------
plugin/smispy/smis.py | 42 +++---
plugin/smispy/smis_cap.py | 24 ++--
plugin/smispy/smis_common.py | 12 +-
plugin/smispy/smis_disk.py | 32 +++--
plugin/smispy/smis_pool.py | 32 ++---
plugin/smispy/smis_sys.py | 18 +--
7 files changed, 222 insertions(+), 250 deletions(-)
--
1.8.3.1
Gris Ge
2014-10-03 06:29:26 UTC
Permalink
* Move dmtf.DMTF.OP_STATUS_XXX to dmtf.DMTF_OP_STATUS_XXX.
* Move dmtf.DMTF.dmtf_op_status_list_conv() to
dmtf.dmtf_op_status_list_conv()
* Move dmtf.DMTF.dmtf_op_status_to_str() to
dmtf._dmtf_op_status_to_str()

Signed-off-by: Gris Ge <***@redhat.com>
---
plugin/smispy/dmtf.py | 142 ++++++++++++++++++++++-----------------------
plugin/smispy/smis_disk.py | 22 ++++---
plugin/smispy/smis_pool.py | 12 ++--
plugin/smispy/smis_sys.py | 18 +++---
4 files changed, 95 insertions(+), 99 deletions(-)

diff --git a/plugin/smispy/dmtf.py b/plugin/smispy/dmtf.py
index 8ebf06a..f2d3037 100644
--- a/plugin/smispy/dmtf.py
+++ b/plugin/smispy/dmtf.py
@@ -23,78 +23,6 @@ from pywbem import Uint16


class DMTF(object):
- # CIM_ManagedSystemElement['OperationalStatus']
- OP_STATUS_UNKNOWN = 0
- OP_STATUS_OTHER = 1
- OP_STATUS_OK = 2
- OP_STATUS_DEGRADED = 3
- OP_STATUS_STRESSED = 4
- OP_STATUS_PREDICTIVE_FAILURE = 5
- OP_STATUS_ERROR = 6
- OP_STATUS_NON_RECOVERABLE_ERROR = 7
- OP_STATUS_STARTING = 8
- OP_STATUS_STOPPING = 9
- OP_STATUS_STOPPED = 10
- OP_STATUS_IN_SERVICE = 11
- OP_STATUS_NO_CONTACT = 12
- OP_STATUS_LOST_COMMUNICATION = 13
- OP_STATUS_ABORTED = 14
- OP_STATUS_DORMANT = 15
- OP_STATUS_SUPPORTING_ENTITY_IN_ERROR = 16
- OP_STATUS_COMPLETED = 17
- OP_STATUS_POWER_MODE = 18
-
- _OP_STATUS_STR_CONV = {
- OP_STATUS_UNKNOWN: "UNKNOWN",
- OP_STATUS_OTHER: "OTHER",
- OP_STATUS_OK: "OK",
- OP_STATUS_DEGRADED: "DEGRADED",
- OP_STATUS_STRESSED: "STRESSED",
- OP_STATUS_PREDICTIVE_FAILURE: "PREDICTIVE_FAILURE",
- OP_STATUS_ERROR: "ERROR",
- OP_STATUS_NON_RECOVERABLE_ERROR: "NON_RECOVERABLE_ERROR",
- OP_STATUS_STARTING: "STARTING",
- OP_STATUS_STOPPING: "STOPPING",
- OP_STATUS_STOPPED: "STOPPED",
- OP_STATUS_IN_SERVICE: "IN_SERVICE",
- OP_STATUS_NO_CONTACT: "NO_CONTACT",
- OP_STATUS_LOST_COMMUNICATION: "LOST_COMMUNICATION",
- OP_STATUS_ABORTED: "ABORTED",
- OP_STATUS_DORMANT: "DORMANT",
- OP_STATUS_SUPPORTING_ENTITY_IN_ERROR: "SUPPORTING_ENTITY_IN_ERROR",
- OP_STATUS_COMPLETED: "COMPLETED",
- OP_STATUS_POWER_MODE: "POWER_MODE",
- }
-
- @staticmethod
- def dmtf_op_status_to_str(dmtf_op_status):
- """
- Just convert integer to string. NOT ALLOWING provide a list.
- Return emtpy string is not found.
- """
- try:
- return DMTF._OP_STATUS_STR_CONV[dmtf_op_status]
- except KeyError:
- return ''
-
- @staticmethod
- def dmtf_op_status_list_conv(conv_dict, dmtf_op_status_list,
- unknown_value, other_value):
- status = 0
- status_info_list = []
- for dmtf_op_status in dmtf_op_status_list:
- if dmtf_op_status in conv_dict.keys():
- status |= conv_dict[dmtf_op_status]
- else:
- if dmtf_op_status in DMTF._OP_STATUS_STR_CONV.keys():
- status |= other_value
- status_info_list.append(
- DMTF.dmtf_op_status_to_str(dmtf_op_status))
- continue
- if status == 0:
- status = unknown_value
- return status, " ".join(status_info_list)
-

# CIM_StorageHardwareID['IDType']
ID_TYPE_OTHER = Uint16(1)
@@ -206,3 +134,73 @@ DMTF_STATUS_DORMANT = 15
DMTF_STATUS_SUPPORTING_ENTITY_IN_ERROR = 16
DMTF_STATUS_COMPLETED = 17
DMTF_STATUS_POWER_MODE = 18
+
+# CIM_ManagedSystemElement['OperationalStatus']
+DMTF_OP_STATUS_UNKNOWN = 0
+DMTF_OP_STATUS_OTHER = 1
+DMTF_OP_STATUS_OK = 2
+DMTF_OP_STATUS_DEGRADED = 3
+DMTF_OP_STATUS_STRESSED = 4
+DMTF_OP_STATUS_PREDICTIVE_FAILURE = 5
+DMTF_OP_STATUS_ERROR = 6
+DMTF_OP_STATUS_NON_RECOVERABLE_ERROR = 7
+DMTF_OP_STATUS_STARTING = 8
+DMTF_OP_STATUS_STOPPING = 9
+DMTF_OP_STATUS_STOPPED = 10
+DMTF_OP_STATUS_IN_SERVICE = 11
+DMTF_OP_STATUS_NO_CONTACT = 12
+DMTF_OP_STATUS_LOST_COMMUNICATION = 13
+DMTF_OP_STATUS_ABORTED = 14
+DMTF_OP_STATUS_DORMANT = 15
+DMTF_OP_STATUS_SUPPORTING_ENTITY_IN_ERROR = 16
+DMTF_OP_STATUS_COMPLETED = 17
+DMTF_OP_STATUS_POWER_MODE = 18
+
+_DMTF_OP_STATUS_STR_CONV = {
+ DMTF_OP_STATUS_UNKNOWN: "UNKNOWN",
+ DMTF_OP_STATUS_OTHER: "OTHER",
+ DMTF_OP_STATUS_OK: "OK",
+ DMTF_OP_STATUS_DEGRADED: "DEGRADED",
+ DMTF_OP_STATUS_STRESSED: "STRESSED",
+ DMTF_OP_STATUS_PREDICTIVE_FAILURE: "PREDICTIVE_FAILURE",
+ DMTF_OP_STATUS_ERROR: "ERROR",
+ DMTF_OP_STATUS_NON_RECOVERABLE_ERROR: "NON_RECOVERABLE_ERROR",
+ DMTF_OP_STATUS_STARTING: "STARTING",
+ DMTF_OP_STATUS_STOPPING: "STOPPING",
+ DMTF_OP_STATUS_STOPPED: "STOPPED",
+ DMTF_OP_STATUS_IN_SERVICE: "IN_SERVICE",
+ DMTF_OP_STATUS_NO_CONTACT: "NO_CONTACT",
+ DMTF_OP_STATUS_LOST_COMMUNICATION: "LOST_COMMUNICATION",
+ DMTF_OP_STATUS_ABORTED: "ABORTED",
+ DMTF_OP_STATUS_DORMANT: "DORMANT",
+ DMTF_OP_STATUS_SUPPORTING_ENTITY_IN_ERROR: "SUPPORTING_ENTITY_IN_ERROR",
+ DMTF_OP_STATUS_COMPLETED: "COMPLETED",
+ DMTF_OP_STATUS_POWER_MODE: "POWER_MODE",
+}
+
+def _dmtf_op_status_to_str(dmtf_op_status):
+ """
+ Just convert integer to string. NOT ALLOWING provide a list.
+ Return emtpy string is not found.
+ """
+ try:
+ return _DMTF_OP_STATUS_STR_CONV[dmtf_op_status]
+ except KeyError:
+ return ''
+
+def dmtf_op_status_list_conv(conv_dict, dmtf_op_status_list,
+ unknown_value, other_value):
+ status = 0
+ status_info_list = []
+ for dmtf_op_status in dmtf_op_status_list:
+ if dmtf_op_status in conv_dict.keys():
+ status |= conv_dict[dmtf_op_status]
+ else:
+ if dmtf_op_status in _DMTF_OP_STATUS_STR_CONV.keys():
+ status |= other_value
+ status_info_list.append(
+ _dmtf_op_status_to_str(dmtf_op_status))
+ continue
+ if status == 0:
+ status = unknown_value
+ return status, " ".join(status_info_list)
diff --git a/plugin/smispy/smis_disk.py b/plugin/smispy/smis_disk.py
index 01de3db..6ca7afd 100644
--- a/plugin/smispy/smis_disk.py
+++ b/plugin/smispy/smis_disk.py
@@ -16,21 +16,19 @@
# Author: Gris Ge <***@redhat.com>

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 dmtf import *
from utils import merge_list


_LSM_DISK_OP_STATUS_CONV = {
- DMTF.OP_STATUS_UNKNOWN: Disk.STATUS_UNKNOWN,
- DMTF.OP_STATUS_OK: Disk.STATUS_OK,
- DMTF.OP_STATUS_PREDICTIVE_FAILURE: Disk.STATUS_PREDICTIVE_FAILURE,
- DMTF.OP_STATUS_ERROR: Disk.STATUS_ERROR,
- DMTF.OP_STATUS_NON_RECOVERABLE_ERROR: Disk.STATUS_ERROR,
- DMTF.OP_STATUS_STARTING: Disk.STATUS_STARTING,
- DMTF.OP_STATUS_STOPPING: Disk.STATUS_STOPPING,
- DMTF.OP_STATUS_STOPPED: Disk.STATUS_STOPPED,
+ DMTF_OP_STATUS_UNKNOWN: Disk.STATUS_UNKNOWN,
+ DMTF_OP_STATUS_OK: Disk.STATUS_OK,
+ DMTF_OP_STATUS_PREDICTIVE_FAILURE: Disk.STATUS_PREDICTIVE_FAILURE,
+ DMTF_OP_STATUS_ERROR: Disk.STATUS_ERROR,
+ DMTF_OP_STATUS_NON_RECOVERABLE_ERROR: Disk.STATUS_ERROR,
+ DMTF_OP_STATUS_STARTING: Disk.STATUS_STARTING,
+ DMTF_OP_STATUS_STOPPING: Disk.STATUS_STOPPING,
+ DMTF_OP_STATUS_STOPPED: Disk.STATUS_STOPPED,
}


@@ -42,7 +40,7 @@ def _disk_status_of_cim_disk(cim_disk):
if 'OperationalStatus' not in cim_disk:
return Disk.STATUS_UNKNOWN

- return DMTF.dmtf_op_status_list_conv(
+ return dmtf_op_status_list_conv(
_LSM_DISK_OP_STATUS_CONV, cim_disk['OperationalStatus'],
Disk.STATUS_UNKNOWN, Disk.STATUS_OTHER)[0]

diff --git a/plugin/smispy/smis_pool.py b/plugin/smispy/smis_pool.py
index e97b631..99639f6 100644
--- a/plugin/smispy/smis_pool.py
+++ b/plugin/smispy/smis_pool.py
@@ -181,11 +181,11 @@ def _pool_element_type(smis_common, cim_pool):


_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,
+ 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,
}


@@ -193,7 +193,7 @@ def _pool_status_of_cim_pool(dmtf_op_status_list):
"""
Convert CIM_StoragePool['OperationalStatus'] to LSM
"""
- return DMTF.dmtf_op_status_list_conv(
+ return dmtf_op_status_list_conv(
_LSM_POOL_OP_STATUS_CONV, dmtf_op_status_list,
Pool.STATUS_UNKNOWN, Pool.STATUS_OTHER)

diff --git a/plugin/smispy/smis_sys.py b/plugin/smispy/smis_sys.py
index 683ae2b..b750c75 100644
--- a/plugin/smispy/smis_sys.py
+++ b/plugin/smispy/smis_sys.py
@@ -16,7 +16,7 @@
# Author: Gris Ge <***@redhat.com>

from utils import merge_list
-from dmtf import DMTF
+from dmtf import *
from lsm import System, LsmError, ErrorNumber


@@ -91,13 +91,13 @@ def cim_sys_pros():


_LSM_SYS_OP_STATUS_CONV = {
- DMTF.OP_STATUS_UNKNOWN: System.STATUS_UNKNOWN,
- DMTF.OP_STATUS_OK: System.STATUS_OK,
- DMTF.OP_STATUS_ERROR: System.STATUS_ERROR,
- DMTF.OP_STATUS_DEGRADED: System.STATUS_DEGRADED,
- DMTF.OP_STATUS_NON_RECOVERABLE_ERROR: System.STATUS_ERROR,
- DMTF.OP_STATUS_PREDICTIVE_FAILURE: System.STATUS_PREDICTIVE_FAILURE,
- DMTF.OP_STATUS_SUPPORTING_ENTITY_IN_ERROR: System.STATUS_ERROR,
+ DMTF_OP_STATUS_UNKNOWN: System.STATUS_UNKNOWN,
+ DMTF_OP_STATUS_OK: System.STATUS_OK,
+ DMTF_OP_STATUS_ERROR: System.STATUS_ERROR,
+ DMTF_OP_STATUS_DEGRADED: System.STATUS_DEGRADED,
+ DMTF_OP_STATUS_NON_RECOVERABLE_ERROR: System.STATUS_ERROR,
+ DMTF_OP_STATUS_PREDICTIVE_FAILURE: System.STATUS_PREDICTIVE_FAILURE,
+ DMTF_OP_STATUS_SUPPORTING_ENTITY_IN_ERROR: System.STATUS_ERROR,
}


@@ -111,7 +111,7 @@ def _sys_status_of_cim_sys(cim_sys):
"sys_status_of_cim_sys(): Got a CIM_ComputerSystem with no "
"OperationalStatus: %s, %s" % (cim_sys.items(), cim_sys.path))

- return DMTF.dmtf_op_status_list_conv(
+ return dmtf_op_status_list_conv(
_LSM_SYS_OP_STATUS_CONV, cim_sys['OperationalStatus'],
System.STATUS_UNKNOWN, System.STATUS_OTHER)
--
1.8.3.1
Gris Ge
2014-10-03 06:29:27 UTC
Permalink
* Removed all dmtf.DMTF_STATUS_XXX constants as no method is
using it.
* Please use dmtf.DMTF_OP_STATUS_XXX instead if needed.

Signed-off-by: Gris Ge <***@redhat.com>
---
plugin/smispy/dmtf.py | 20 --------------------
1 file changed, 20 deletions(-)

diff --git a/plugin/smispy/dmtf.py b/plugin/smispy/dmtf.py
index f2d3037..a32055f 100644
--- a/plugin/smispy/dmtf.py
+++ b/plugin/smispy/dmtf.py
@@ -115,26 +115,6 @@ DMTF_DISK_TYPE_HDD = 2
DMTF_DISK_TYPE_SSD = 3
DMTF_DISK_TYPE_HYBRID = 4

-DMTF_STATUS_UNKNOWN = 0
-DMTF_STATUS_OTHER = 1
-DMTF_STATUS_OK = 2
-DMTF_STATUS_DEGRADED = 3
-DMTF_STATUS_STRESSED = 4
-DMTF_STATUS_PREDICTIVE_FAILURE = 5
-DMTF_STATUS_ERROR = 6
-DMTF_STATUS_NON_RECOVERABLE_ERROR = 7
-DMTF_STATUS_STARTING = 8
-DMTF_STATUS_STOPPING = 9
-DMTF_STATUS_STOPPED = 10
-DMTF_STATUS_IN_SERVICE = 11
-DMTF_STATUS_NO_CONTACT = 12
-DMTF_STATUS_LOST_COMMUNICATION = 13
-DMTF_STATUS_ABORTED = 14
-DMTF_STATUS_DORMANT = 15
-DMTF_STATUS_SUPPORTING_ENTITY_IN_ERROR = 16
-DMTF_STATUS_COMPLETED = 17
-DMTF_STATUS_POWER_MODE = 18
-
# CIM_ManagedSystemElement['OperationalStatus']
DMTF_OP_STATUS_UNKNOWN = 0
DMTF_OP_STATUS_OTHER = 1
--
1.8.3.1
Gris Ge
2014-10-03 06:29:28 UTC
Permalink
* Remove DMTF class as no __init__() or methods any more.
* All DMTF constants moved to dmtf.py file level.

Changes in V2:

* Remove 'DMTF_' prefix of constants in dmtf.py.
* Changed 'from dmtf import *' to 'import dmtf' in smis_xxx.py files.
* Renamed dmtf.dmtf_op_status_list_conv() to dmtf.op_status_list_conv()

Signed-off-by: Gris Ge <***@redhat.com>
---
plugin/smispy/dmtf.py | 244 +++++++++++++++++++++----------------------
plugin/smispy/smis.py | 42 ++++----
plugin/smispy/smis_cap.py | 24 ++---
plugin/smispy/smis_common.py | 12 +--
plugin/smispy/smis_disk.py | 30 +++---
plugin/smispy/smis_pool.py | 32 +++---
plugin/smispy/smis_sys.py | 18 ++--
7 files changed, 199 insertions(+), 203 deletions(-)

diff --git a/plugin/smispy/dmtf.py b/plugin/smispy/dmtf.py
index a32055f..18a8a8f 100644
--- a/plugin/smispy/dmtf.py
+++ b/plugin/smispy/dmtf.py
@@ -18,168 +18,164 @@

# This class handle DMTF CIM constants and convert to LSM type.

-from lsm import (System, Pool, Disk)
from pywbem import Uint16


-class DMTF(object):
-
- # CIM_StorageHardwareID['IDType']
- ID_TYPE_OTHER = Uint16(1)
- ID_TYPE_WWPN = Uint16(2)
- ID_TYPE_ISCSI = Uint16(5)
-
- TGT_PORT_USAGE_FRONTEND_ONLY = Uint16(2)
- TGT_PORT_USAGE_UNRESTRICTED = Uint16(4)
- # CIM_FCPort['PortDiscriminator']
- FC_PORT_PORT_DISCRIMINATOR_FCOE = Uint16(10)
- # CIM_NetworkPort['LinkTechnology']
- NET_PORT_LINK_TECH_ETHERNET = Uint16(2)
- # CIM_iSCSIProtocolEndpoint['Role']
- ISCSI_TGT_ROLE_TARGET = Uint16(3)
- # CIM_SCSIProtocolController['NameFormat']
- SPC_NAME_FORMAT_ISCSI = Uint16(3)
- # CIM_IPProtocolEndpoint['IPv6AddressType']
- IPV6_ADDR_TYPE_GUA = Uint16(6)
- # GUA: Global Unicast Address.
- # 2000::/3
- IPV6_ADDR_TYPE_6TO4 = Uint16(7)
- # IPv6 to IPv4 transition
- # ::ffff:0:0/96
- # ::ffff:0:0:0/96
- # 64:ff9b::/96 # well-known prefix
- # 2002::/16 # 6to4
- IPV6_ADDR_TYPE_ULA = Uint16(8)
- # ULA: Unique Local Address, aka Site Local Unicast.
- # fc00::/7
-
- # CIM_GroupMaskingMappingService.CreateGroup('Type')
- MASK_GROUP_TYPE_INIT = Uint16(2)
- MASK_GROUP_TYPE_TGT = Uint16(3)
- MASK_GROUP_TYPE_DEV = Uint16(4)
-
- # CIM_GroupMaskingMappingCapabilities['SupportedDeviceGroupFeatures']
- # Allowing empty DeviceMaskingGroup associated to SPC
- GMM_CAP_DEV_MG_ALLOW_EMPTY_W_SPC = Uint16(5)
-
- # CIM_GroupMaskingMappingCapabilities['SupportedAsynchronousActions']
- # and 'SupportedSynchronousActions'. They are using the same value map.
- GMM_CAP_DELETE_SPC = Uint16(24)
- GMM_CAP_DELETE_GROUP = Uint16(20)
-
- # CIM_StorageConfigurationCapabilities['SupportedStorageElementTypes']
- SCS_CAP_SUP_ST_VOLUME = Uint16(2)
- SCS_CAP_SUP_THIN_ST_VOLUME = Uint16(5)
-
- # CIM_StorageConfigurationCapabilities['SupportedAsynchronousActions']
- # and also for 'SupportedSynchronousActions'
- SCS_CAP_VOLUME_CREATE = Uint16(5)
- SCS_CAP_VOLUME_DELETE = Uint16(6)
- SCS_CAP_VOLUME_MODIFY = Uint16(7)
-
- # DSP 1033 Profile Registration
- INTEROP_NAMESPACES = ['interop', 'root/interop', 'root/PG_Interop']
- DEFAULT_NAMESPACE = 'interop'
+# CIM_StorageHardwareID['IDType']
+ID_TYPE_OTHER = Uint16(1)
+ID_TYPE_WWPN = Uint16(2)
+ID_TYPE_ISCSI = Uint16(5)
+
+TGT_PORT_USAGE_FRONTEND_ONLY = Uint16(2)
+TGT_PORT_USAGE_UNRESTRICTED = Uint16(4)
+# CIM_FCPort['PortDiscriminator']
+FC_PORT_PORT_DISCRIMINATOR_FCOE = Uint16(10)
+# CIM_NetworkPort['LinkTechnology']
+NET_PORT_LINK_TECH_ETHERNET = Uint16(2)
+# CIM_iSCSIProtocolEndpoint['Role']
+ISCSI_TGT_ROLE_TARGET = Uint16(3)
+# CIM_SCSIProtocolController['NameFormat']
+SPC_NAME_FORMAT_ISCSI = Uint16(3)
+# CIM_IPProtocolEndpoint['IPv6AddressType']
+IPV6_ADDR_TYPE_GUA = Uint16(6)
+# GUA: Global Unicast Address.
+# 2000::/3
+IPV6_ADDR_TYPE_6TO4 = Uint16(7)
+# IPv6 to IPv4 transition
+# ::ffff:0:0/96
+# ::ffff:0:0:0/96
+# 64:ff9b::/96 # well-known prefix
+# 2002::/16 # 6to4
+IPV6_ADDR_TYPE_ULA = Uint16(8)
+# ULA: Unique Local Address, aka Site Local Unicast.
+# fc00::/7
+
+# CIM_GroupMaskingMappingService.CreateGroup('Type')
+MASK_GROUP_TYPE_INIT = Uint16(2)
+MASK_GROUP_TYPE_TGT = Uint16(3)
+MASK_GROUP_TYPE_DEV = Uint16(4)
+
+# CIM_GroupMaskingMappingCapabilities['SupportedDeviceGroupFeatures']
+# Allowing empty DeviceMaskingGroup associated to SPC
+GMM_CAP_DEV_MG_ALLOW_EMPTY_W_SPC = Uint16(5)
+
+# CIM_GroupMaskingMappingCapabilities['SupportedAsynchronousActions']
+# and 'SupportedSynchronousActions'. They are using the same value map.
+GMM_CAP_DELETE_SPC = Uint16(24)
+GMM_CAP_DELETE_GROUP = Uint16(20)
+
+# CIM_StorageConfigurationCapabilities['SupportedStorageElementTypes']
+SCS_CAP_SUP_ST_VOLUME = Uint16(2)
+SCS_CAP_SUP_THIN_ST_VOLUME = Uint16(5)
+
+# CIM_StorageConfigurationCapabilities['SupportedAsynchronousActions']
+# and also for 'SupportedSynchronousActions'
+SCS_CAP_VOLUME_CREATE = Uint16(5)
+SCS_CAP_VOLUME_DELETE = Uint16(6)
+SCS_CAP_VOLUME_MODIFY = Uint16(7)
+
+# DSP 1033 Profile Registration
+INTEROP_NAMESPACES = ['interop', 'root/interop', 'root/PG_Interop']
+DEFAULT_NAMESPACE = 'interop'


# DMTF CIM 2.37.0 experimental CIM_StoragePool['Usage']
-DMTF_POOL_USAGE_UNRESTRICTED = 2
-DMTF_POOL_USAGE_RESERVED_FOR_SYSTEM = 3
-DMTF_POOL_USAGE_DELTA = 4
-DMTF_POOL_USAGE_SPARE = 8
+POOL_USAGE_UNRESTRICTED = 2
+POOL_USAGE_RESERVED_FOR_SYSTEM = 3
+POOL_USAGE_DELTA = 4
+POOL_USAGE_SPARE = 8

# DMTF CIM 2.29.1 CIM_StorageConfigurationCapabilities
# ['SupportedStorageElementFeatures']
-DMTF_SUPPORT_VOL_CREATE = 3
-DMTF_SUPPORT_ELEMENT_EXPAND = 12
-DMTF_SUPPORT_ELEMENT_REDUCE = 13
+SUPPORT_VOL_CREATE = 3
+SUPPORT_ELEMENT_EXPAND = 12
+SUPPORT_ELEMENT_REDUCE = 13

# DMTF CIM 2.37.0 experimental CIM_StorageConfigurationCapabilities
# ['SupportedStorageElementTypes']
-DMTF_ELEMENT_THICK_VOLUME = 2
-DMTF_ELEMENT_THIN_VOLUME = 5
+ELEMENT_THICK_VOLUME = 2
+ELEMENT_THIN_VOLUME = 5

# DMTF CIM 2.29.1 CIM_StorageConfigurationCapabilities
# ['SupportedStoragePoolFeatures']
-DMTF_ST_POOL_FEATURE_INEXTS = 2
-DMTF_ST_POOL_FEATURE_SINGLE_INPOOL = 3
-DMTF_ST_POOL_FEATURE_MULTI_INPOOL = 4
+ST_POOL_FEATURE_INEXTS = 2
+ST_POOL_FEATURE_SINGLE_INPOOL = 3
+ST_POOL_FEATURE_MULTI_INPOOL = 4

# DMTF CIM 2.38.0+ CIM_StorageSetting['ThinProvisionedPoolType']
-DMTF_THINP_POOL_TYPE_ALLOCATED = Uint16(7)
+THINP_POOL_TYPE_ALLOCATED = Uint16(7)

# DMTF Disk Type
-DMTF_DISK_TYPE_UNKNOWN = 0
-DMTF_DISK_TYPE_OTHER = 1
-DMTF_DISK_TYPE_HDD = 2
-DMTF_DISK_TYPE_SSD = 3
-DMTF_DISK_TYPE_HYBRID = 4
+DISK_TYPE_UNKNOWN = 0
+DISK_TYPE_OTHER = 1
+DISK_TYPE_HDD = 2
+DISK_TYPE_SSD = 3
+DISK_TYPE_HYBRID = 4

# CIM_ManagedSystemElement['OperationalStatus']
-DMTF_OP_STATUS_UNKNOWN = 0
-DMTF_OP_STATUS_OTHER = 1
-DMTF_OP_STATUS_OK = 2
-DMTF_OP_STATUS_DEGRADED = 3
-DMTF_OP_STATUS_STRESSED = 4
-DMTF_OP_STATUS_PREDICTIVE_FAILURE = 5
-DMTF_OP_STATUS_ERROR = 6
-DMTF_OP_STATUS_NON_RECOVERABLE_ERROR = 7
-DMTF_OP_STATUS_STARTING = 8
-DMTF_OP_STATUS_STOPPING = 9
-DMTF_OP_STATUS_STOPPED = 10
-DMTF_OP_STATUS_IN_SERVICE = 11
-DMTF_OP_STATUS_NO_CONTACT = 12
-DMTF_OP_STATUS_LOST_COMMUNICATION = 13
-DMTF_OP_STATUS_ABORTED = 14
-DMTF_OP_STATUS_DORMANT = 15
-DMTF_OP_STATUS_SUPPORTING_ENTITY_IN_ERROR = 16
-DMTF_OP_STATUS_COMPLETED = 17
-DMTF_OP_STATUS_POWER_MODE = 18
-
-_DMTF_OP_STATUS_STR_CONV = {
- DMTF_OP_STATUS_UNKNOWN: "UNKNOWN",
- DMTF_OP_STATUS_OTHER: "OTHER",
- DMTF_OP_STATUS_OK: "OK",
- DMTF_OP_STATUS_DEGRADED: "DEGRADED",
- DMTF_OP_STATUS_STRESSED: "STRESSED",
- DMTF_OP_STATUS_PREDICTIVE_FAILURE: "PREDICTIVE_FAILURE",
- DMTF_OP_STATUS_ERROR: "ERROR",
- DMTF_OP_STATUS_NON_RECOVERABLE_ERROR: "NON_RECOVERABLE_ERROR",
- DMTF_OP_STATUS_STARTING: "STARTING",
- DMTF_OP_STATUS_STOPPING: "STOPPING",
- DMTF_OP_STATUS_STOPPED: "STOPPED",
- DMTF_OP_STATUS_IN_SERVICE: "IN_SERVICE",
- DMTF_OP_STATUS_NO_CONTACT: "NO_CONTACT",
- DMTF_OP_STATUS_LOST_COMMUNICATION: "LOST_COMMUNICATION",
- DMTF_OP_STATUS_ABORTED: "ABORTED",
- DMTF_OP_STATUS_DORMANT: "DORMANT",
- DMTF_OP_STATUS_SUPPORTING_ENTITY_IN_ERROR: "SUPPORTING_ENTITY_IN_ERROR",
- DMTF_OP_STATUS_COMPLETED: "COMPLETED",
- DMTF_OP_STATUS_POWER_MODE: "POWER_MODE",
+OP_STATUS_UNKNOWN = 0
+OP_STATUS_OTHER = 1
+OP_STATUS_OK = 2
+OP_STATUS_DEGRADED = 3
+OP_STATUS_STRESSED = 4
+OP_STATUS_PREDICTIVE_FAILURE = 5
+OP_STATUS_ERROR = 6
+OP_STATUS_NON_RECOVERABLE_ERROR = 7
+OP_STATUS_STARTING = 8
+OP_STATUS_STOPPING = 9
+OP_STATUS_STOPPED = 10
+OP_STATUS_IN_SERVICE = 11
+OP_STATUS_NO_CONTACT = 12
+OP_STATUS_LOST_COMMUNICATION = 13
+OP_STATUS_ABORTED = 14
+OP_STATUS_DORMANT = 15
+OP_STATUS_SUPPORTING_ENTITY_IN_ERROR = 16
+OP_STATUS_COMPLETED = 17
+OP_STATUS_POWER_MODE = 18
+
+_OP_STATUS_STR_CONV = {
+ OP_STATUS_UNKNOWN: "UNKNOWN",
+ OP_STATUS_OTHER: "OTHER",
+ OP_STATUS_OK: "OK",
+ OP_STATUS_DEGRADED: "DEGRADED",
+ OP_STATUS_STRESSED: "STRESSED",
+ OP_STATUS_PREDICTIVE_FAILURE: "PREDICTIVE_FAILURE",
+ OP_STATUS_ERROR: "ERROR",
+ OP_STATUS_NON_RECOVERABLE_ERROR: "NON_RECOVERABLE_ERROR",
+ OP_STATUS_STARTING: "STARTING",
+ OP_STATUS_STOPPING: "STOPPING",
+ OP_STATUS_STOPPED: "STOPPED",
+ OP_STATUS_IN_SERVICE: "IN_SERVICE",
+ OP_STATUS_NO_CONTACT: "NO_CONTACT",
+ OP_STATUS_LOST_COMMUNICATION: "LOST_COMMUNICATION",
+ OP_STATUS_ABORTED: "ABORTED",
+ OP_STATUS_DORMANT: "DORMANT",
+ OP_STATUS_SUPPORTING_ENTITY_IN_ERROR: "SUPPORTING_ENTITY_IN_ERROR",
+ OP_STATUS_COMPLETED: "COMPLETED",
+ OP_STATUS_POWER_MODE: "POWER_MODE",
}

-def _dmtf_op_status_to_str(dmtf_op_status):
+def _op_status_to_str(dmtf_op_status):
"""
Just convert integer to string. NOT ALLOWING provide a list.
Return emtpy string is not found.
"""
try:
- return _DMTF_OP_STATUS_STR_CONV[dmtf_op_status]
+ return _OP_STATUS_STR_CONV[dmtf_op_status]
except KeyError:
return ''

-def dmtf_op_status_list_conv(conv_dict, dmtf_op_status_list,
- unknown_value, other_value):
+def op_status_list_conv(conv_dict, dmtf_op_status_list,
+ unknown_value, other_value):
status = 0
status_info_list = []
for dmtf_op_status in dmtf_op_status_list:
if dmtf_op_status in conv_dict.keys():
status |= conv_dict[dmtf_op_status]
else:
- if dmtf_op_status in _DMTF_OP_STATUS_STR_CONV.keys():
+ if dmtf_op_status in _OP_STATUS_STR_CONV.keys():
status |= other_value
- status_info_list.append(
- _dmtf_op_status_to_str(dmtf_op_status))
+ status_info_list.append(_op_status_to_str(dmtf_op_status))
continue
if status == 0:
status = unknown_value
diff --git a/plugin/smispy/smis.py b/plugin/smispy/smis.py
index 351de57..2cee221 100644
--- a/plugin/smispy/smis.py
+++ b/plugin/smispy/smis.py
@@ -33,13 +33,13 @@ import smis_cap
import smis_sys
import smis_pool
import smis_disk
+import dmtf

from lsm import (IStorageAreaNetwork, uri_parse, LsmError, ErrorNumber,
JobStatus, md5, Volume, AccessGroup,
VERSION, TargetPort,
search_property)

-from dmtf import *
from utils import (merge_list, handle_cim_errors, hex_string_format)

from smis_common import SmisCommon
@@ -99,9 +99,9 @@ def _lsm_init_id_to_snia(lsm_init_id):

def _dmtf_init_type_to_lsm(cim_init):
if 'IDType' in cim_init:
- if cim_init['IDType'] == DMTF.ID_TYPE_WWPN:
+ if cim_init['IDType'] == dmtf.ID_TYPE_WWPN:
return AccessGroup.INIT_TYPE_WWPN
- elif cim_init['IDType'] == DMTF.ID_TYPE_ISCSI:
+ elif cim_init['IDType'] == dmtf.ID_TYPE_ISCSI:
return AccessGroup.INIT_TYPE_ISCSI_IQN
return AccessGroup.INIT_TYPE_UNKNOWN

@@ -115,19 +115,19 @@ def _lsm_tgt_port_type_of_cim_fc_tgt(cim_fc_tgt):
# for FCoE target port.
if 'PortDiscriminator' in cim_fc_tgt and \
cim_fc_tgt['PortDiscriminator'] and \
- DMTF.FC_PORT_PORT_DISCRIMINATOR_FCOE in cim_fc_tgt['PortDiscriminator']:
+ dmtf.FC_PORT_PORT_DISCRIMINATOR_FCOE in cim_fc_tgt['PortDiscriminator']:
return TargetPort.TYPE_FCOE
if 'LinkTechnology' in cim_fc_tgt and \
- cim_fc_tgt['LinkTechnology'] == DMTF.NET_PORT_LINK_TECH_ETHERNET:
+ cim_fc_tgt['LinkTechnology'] == dmtf.NET_PORT_LINK_TECH_ETHERNET:
return TargetPort.TYPE_FCOE
return TargetPort.TYPE_FC


def _lsm_init_type_to_dmtf(init_type):
if init_type == AccessGroup.INIT_TYPE_WWPN:
- return DMTF.ID_TYPE_WWPN
+ return dmtf.ID_TYPE_WWPN
if init_type == AccessGroup.INIT_TYPE_ISCSI_IQN:
- return DMTF.ID_TYPE_ISCSI
+ return dmtf.ID_TYPE_ISCSI
raise LsmError(ErrorNumber.NO_SUPPORT,
"Does not support provided init_type: %d" % init_type)

@@ -584,7 +584,7 @@ class Smis(IStorageAreaNetwork):
if not (nf and nn and name):
return None
# SNIA might have miss documented VPD83Type3(1), it should be
- # VOL_NAME_FORMAT_OTHER(1) based on DMTF.
+ # VOL_NAME_FORMAT_OTHER(1) based on dmtf.
# Will remove the Smis.VOL_NAME_FORMAT_OTHER condition if confirmed as
# SNIA document fault.
if (nf == VOL_NAME_FORMAT_NNA and
@@ -1204,7 +1204,7 @@ class Smis(IStorageAreaNetwork):
in_params = {
'GroupName': name,
'Members': [cim_vol_path],
- 'Type': DMTF.MASK_GROUP_TYPE_DEV}
+ 'Type': dmtf.MASK_GROUP_TYPE_DEV}

cim_dev_mg_path = None
try:
@@ -1238,7 +1238,7 @@ class Smis(IStorageAreaNetwork):

in_params = {
'GroupName': name,
- 'Type': DMTF.MASK_GROUP_TYPE_TGT}
+ 'Type': dmtf.MASK_GROUP_TYPE_TGT}

if init_type == AccessGroup.INIT_TYPE_WWPN:
cim_fc_tgts = self._cim_fc_tgt_of(cim_sys_path)
@@ -1443,14 +1443,14 @@ class Smis(IStorageAreaNetwork):

flag_empty_dev_in_spc = False

- if DMTF.GMM_CAP_DEV_MG_ALLOW_EMPTY_W_SPC in \
+ if dmtf.GMM_CAP_DEV_MG_ALLOW_EMPTY_W_SPC in \
cim_gmm_cap['SupportedDeviceGroupFeatures']:
flag_empty_dev_in_spc = True

if flag_empty_dev_in_spc is False:
- if ((DMTF.GMM_CAP_DELETE_SPC not in
+ if ((dmtf.GMM_CAP_DELETE_SPC not in
cim_gmm_cap['SupportedSynchronousActions']) and
- (DMTF.GMM_CAP_DELETE_SPC not in
+ (dmtf.GMM_CAP_DELETE_SPC not in
cim_gmm_cap['SupportedAsynchronousActions'])):
raise LsmError(
ErrorNumber.NO_SUPPORT,
@@ -2154,8 +2154,8 @@ class Smis(IStorageAreaNetwork):
Check CIM_FCPort['UsageRestriction'] for frontend port.
"""
dmtf_usage = cim_fc_tgt['UsageRestriction']
- if dmtf_usage == DMTF.TGT_PORT_USAGE_FRONTEND_ONLY or \
- dmtf_usage == DMTF.TGT_PORT_USAGE_UNRESTRICTED:
+ if dmtf_usage == dmtf.TGT_PORT_USAGE_FRONTEND_ONLY or \
+ dmtf_usage == dmtf.TGT_PORT_USAGE_UNRESTRICTED:
return True
return False

@@ -2223,7 +2223,7 @@ class Smis(IStorageAreaNetwork):
# EMC has vendor specific class which contain identical
# properties of SPC for iSCSI node.
continue
- if cim_spc['NameFormat'] == DMTF.SPC_NAME_FORMAT_ISCSI:
+ if cim_spc['NameFormat'] == dmtf.SPC_NAME_FORMAT_ISCSI:
cim_iscsi_nodes.extend([cim_spc])

if len(cim_iscsi_nodes) == 0:
@@ -2259,7 +2259,7 @@ class Smis(IStorageAreaNetwork):
ResultClass='CIM_iSCSIProtocolEndpoint',
PropertyList=property_list)
for cim_iscsi_pg in cur_cim_iscsi_pgs:
- if cim_iscsi_pg['Role'] == DMTF.ISCSI_TGT_ROLE_TARGET:
+ if cim_iscsi_pg['Role'] == dmtf.ISCSI_TGT_ROLE_TARGET:
rc.extend([cim_iscsi_pg])
return rc

@@ -2325,9 +2325,9 @@ class Smis(IStorageAreaNetwork):
# Local Address.
if 'IPv6AddressType' in cim_ip and cim_ip['IPv6AddressType']:
ipv6_addr_type = cim_ip['IPv6AddressType']
- if ipv6_addr_type != DMTF.IPV6_ADDR_TYPE_GUA and \
- ipv6_addr_type != DMTF.IPV6_ADDR_TYPE_6TO4 and \
- ipv6_addr_type != DMTF.IPV6_ADDR_TYPE_ULA:
+ if ipv6_addr_type != dmtf.IPV6_ADDR_TYPE_GUA and \
+ ipv6_addr_type != dmtf.IPV6_ADDR_TYPE_6TO4 and \
+ ipv6_addr_type != dmtf.IPV6_ADDR_TYPE_ULA:
ipv6_addr = ''

# NetApp is using this kind of IPv6 address
@@ -2694,7 +2694,7 @@ class Smis(IStorageAreaNetwork):

in_params = {'GroupName': name,
'Members': [cim_init_path],
- 'Type': DMTF.MASK_GROUP_TYPE_INIT}
+ 'Type': dmtf.MASK_GROUP_TYPE_INIT}

cim_init_mg_pros = self._cim_init_mg_pros()

diff --git a/plugin/smispy/smis_cap.py b/plugin/smispy/smis_cap.py
index ae11460..0c9751d 100644
--- a/plugin/smispy/smis_cap.py
+++ b/plugin/smispy/smis_cap.py
@@ -16,7 +16,7 @@

from lsm import Capabilities, LsmError, ErrorNumber
from smis_constants import *
-from dmtf import *
+import dmtf
from smis_common import SmisCommon

MASK_TYPE_NO_SUPPORT = 0
@@ -133,19 +133,19 @@ def _bsp_cap_set(smis_common, cim_sys_path, cap):
if cim_scs_cap['SupportedAsynchronousActions']:
sup_actions.extend(cim_scs_cap['SupportedAsynchronousActions'])

- if DMTF.SCS_CAP_SUP_ST_VOLUME in element_types or \
- DMTF.SCS_CAP_SUP_THIN_ST_VOLUME in element_types:
+ if dmtf.SCS_CAP_SUP_ST_VOLUME in element_types or \
+ dmtf.SCS_CAP_SUP_THIN_ST_VOLUME in element_types:
cap.set(Capabilities.VOLUMES)
- if DMTF.SCS_CAP_SUP_THIN_ST_VOLUME in element_types:
+ if dmtf.SCS_CAP_SUP_THIN_ST_VOLUME in element_types:
cap.set(Capabilities.VOLUME_THIN)

- if DMTF.SCS_CAP_VOLUME_CREATE in sup_actions:
+ if dmtf.SCS_CAP_VOLUME_CREATE in sup_actions:
cap.set(Capabilities.VOLUME_CREATE)

- if DMTF.SCS_CAP_VOLUME_DELETE in sup_actions:
+ if dmtf.SCS_CAP_VOLUME_DELETE in sup_actions:
cap.set(Capabilities.VOLUME_DELETE)

- if DMTF.SCS_CAP_VOLUME_MODIFY in sup_actions:
+ if dmtf.SCS_CAP_VOLUME_MODIFY in sup_actions:
cap.set(Capabilities.VOLUME_RESIZE)

return
@@ -203,22 +203,22 @@ def _group_mask_map_cap_set(smis_common, cim_sys_path, cap):

# if empty dev group in spc is allowed, RemoveMembers() is enough
# to do volume_unmask(). RemoveMembers() is mandatory.
- if DMTF.GMM_CAP_DEV_MG_ALLOW_EMPTY_W_SPC in \
+ if dmtf.GMM_CAP_DEV_MG_ALLOW_EMPTY_W_SPC in \
cim_gmm_cap['SupportedDeviceGroupFeatures']:
cap.set(Capabilities.VOLUME_UNMASK)

# DeleteMaskingView() is optional, this is required by volume_unmask()
# when empty dev group in spc not allowed.
- elif ((DMTF.GMM_CAP_DELETE_SPC in
+ elif ((dmtf.GMM_CAP_DELETE_SPC in
cim_gmm_cap['SupportedSynchronousActions']) or
- (DMTF.GMM_CAP_DELETE_SPC in
+ (dmtf.GMM_CAP_DELETE_SPC in
cim_gmm_cap['SupportedAsynchronousActions'])):
cap.set(Capabilities.VOLUME_UNMASK)

# DeleteGroup is optional, this is required by access_group_delete()
- if ((DMTF.GMM_CAP_DELETE_GROUP in
+ if ((dmtf.GMM_CAP_DELETE_GROUP in
cim_gmm_cap['SupportedSynchronousActions']) or
- (DMTF.GMM_CAP_DELETE_GROUP in
+ (dmtf.GMM_CAP_DELETE_GROUP in
cim_gmm_cap['SupportedAsynchronousActions'])):
cap.set(Capabilities.ACCESS_GROUP_DELETE)
return None
diff --git a/plugin/smispy/smis_common.py b/plugin/smispy/smis_common.py
index d66286c..e497b29 100644
--- a/plugin/smispy/smis_common.py
+++ b/plugin/smispy/smis_common.py
@@ -25,7 +25,7 @@
from pywbem import Uint16, CIMError
import pywbem

-from dmtf import DMTF
+import dmtf
from lsm import LsmError, ErrorNumber
from utils import (merge_list)

@@ -45,7 +45,7 @@ def _profile_register_load(wbem_conn):
"""
profile_dict = {}
root_blk_cim_rp = None
- namespace_check_list = DMTF.INTEROP_NAMESPACES
+ namespace_check_list = dmtf.INTEROP_NAMESPACES

cim_rps = []
for namespace in namespace_check_list:
@@ -160,7 +160,7 @@ class SmisCommon(object):
_PRODUCT_NETAPP_E = 'NetApp-E'

def __init__(self, url, username, password,
- namespace=DMTF.DEFAULT_NAMESPACE,
+ namespace=dmtf.DEFAULT_NAMESPACE,
no_ssl_verify=False, debug=False, system_list=None):
self._wbem_conn = None
self._profile_dict = {}
@@ -169,7 +169,7 @@ class SmisCommon(object):
self.system_list = system_list

if namespace is None:
- namespace = DMTF.DEFAULT_NAMESPACE
+ namespace = dmtf.DEFAULT_NAMESPACE

self._wbem_conn = pywbem.WBEMConnection(
url, (username, password), namespace)
@@ -307,7 +307,7 @@ class SmisCommon(object):
"_vendor_namespace(): self.root_blk_cim_rp not set yet")

def EnumerateInstances(self, ClassName, namespace=None, **params):
- if self._wbem_conn.default_namespace in DMTF.INTEROP_NAMESPACES:
+ if self._wbem_conn.default_namespace in dmtf.INTEROP_NAMESPACES:
# We have to enumerate in vendor namespace
self._wbem_conn.default_namespace = self._vendor_namespace()
params['LocalOnly']=False
@@ -315,7 +315,7 @@ class SmisCommon(object):
ClassName, namespace, **params)

def EnumerateInstanceNames(self, ClassName, namespace=None, **params):
- if self._wbem_conn.default_namespace in DMTF.INTEROP_NAMESPACES:
+ if self._wbem_conn.default_namespace in dmtf.INTEROP_NAMESPACES:
# We have to enumerate in vendor namespace
self._wbem_conn.default_namespace = self._vendor_namespace()
params['LocalOnly']=False
diff --git a/plugin/smispy/smis_disk.py b/plugin/smispy/smis_disk.py
index 6ca7afd..11e5669 100644
--- a/plugin/smispy/smis_disk.py
+++ b/plugin/smispy/smis_disk.py
@@ -16,19 +16,19 @@
# Author: Gris Ge <***@redhat.com>

from lsm import Disk, md5, LsmError, ErrorNumber
-from dmtf import *
+import dmtf
from utils import merge_list


_LSM_DISK_OP_STATUS_CONV = {
- DMTF_OP_STATUS_UNKNOWN: Disk.STATUS_UNKNOWN,
- DMTF_OP_STATUS_OK: Disk.STATUS_OK,
- DMTF_OP_STATUS_PREDICTIVE_FAILURE: Disk.STATUS_PREDICTIVE_FAILURE,
- DMTF_OP_STATUS_ERROR: Disk.STATUS_ERROR,
- DMTF_OP_STATUS_NON_RECOVERABLE_ERROR: Disk.STATUS_ERROR,
- DMTF_OP_STATUS_STARTING: Disk.STATUS_STARTING,
- DMTF_OP_STATUS_STOPPING: Disk.STATUS_STOPPING,
- DMTF_OP_STATUS_STOPPED: Disk.STATUS_STOPPED,
+ dmtf.OP_STATUS_UNKNOWN: Disk.STATUS_UNKNOWN,
+ dmtf.OP_STATUS_OK: Disk.STATUS_OK,
+ dmtf.OP_STATUS_PREDICTIVE_FAILURE: Disk.STATUS_PREDICTIVE_FAILURE,
+ dmtf.OP_STATUS_ERROR: Disk.STATUS_ERROR,
+ dmtf.OP_STATUS_NON_RECOVERABLE_ERROR: Disk.STATUS_ERROR,
+ dmtf.OP_STATUS_STARTING: Disk.STATUS_STARTING,
+ dmtf.OP_STATUS_STOPPING: Disk.STATUS_STOPPING,
+ dmtf.OP_STATUS_STOPPED: Disk.STATUS_STOPPED,
}


@@ -40,17 +40,17 @@ def _disk_status_of_cim_disk(cim_disk):
if 'OperationalStatus' not in cim_disk:
return Disk.STATUS_UNKNOWN

- return dmtf_op_status_list_conv(
+ return dmtf.op_status_list_conv(
_LSM_DISK_OP_STATUS_CONV, cim_disk['OperationalStatus'],
Disk.STATUS_UNKNOWN, Disk.STATUS_OTHER)[0]


_DMTF_DISK_TYPE_2_LSM = {
- DMTF_DISK_TYPE_UNKNOWN: Disk.TYPE_UNKNOWN,
- DMTF_DISK_TYPE_OTHER: Disk.TYPE_OTHER,
- DMTF_DISK_TYPE_HDD: Disk.TYPE_HDD,
- DMTF_DISK_TYPE_SSD: Disk.TYPE_SSD,
- DMTF_DISK_TYPE_HYBRID: Disk.TYPE_HYBRID,
+ dmtf.DISK_TYPE_UNKNOWN: Disk.TYPE_UNKNOWN,
+ dmtf.DISK_TYPE_OTHER: Disk.TYPE_OTHER,
+ dmtf.DISK_TYPE_HDD: Disk.TYPE_HDD,
+ dmtf.DISK_TYPE_SSD: Disk.TYPE_SSD,
+ dmtf.DISK_TYPE_HYBRID: Disk.TYPE_HYBRID,
}


diff --git a/plugin/smispy/smis_pool.py b/plugin/smispy/smis_pool.py
index 99639f6..fba8931 100644
--- a/plugin/smispy/smis_pool.py
+++ b/plugin/smispy/smis_pool.py
@@ -16,7 +16,7 @@
# Author: Gris Ge <***@redhat.com>

from utils import merge_list
-from dmtf import *
+import dmtf
from lsm import LsmError, ErrorNumber, Pool
import json
from pywbem import CIMInstanceName
@@ -35,7 +35,7 @@ def cim_pools_of_cim_sys_path(smis_common, cim_sys_path, property_list=None):
checked by plugin_register(), we don't do any profile check here.
Primordial pool will be eliminated from return list.
These pools will be eliminated also:
- * Spare pool with CIM_StoragePool['Usage'] == DMTF_POOL_USAGE_SPARE
+ * Spare pool with CIM_StoragePool['Usage'] == dmtf.POOL_USAGE_SPARE
* IBM ArrayPool(IBMTSDS_ArrayPool)
* IBM ArraySitePool(IBMTSDS_ArraySitePool)
"""
@@ -56,7 +56,7 @@ def cim_pools_of_cim_sys_path(smis_common, cim_sys_path, property_list=None):
for cim_pool in cim_pools:
if 'Primordial' in cim_pool and cim_pool['Primordial']:
continue
- if 'Usage' in cim_pool and cim_pool['Usage'] == DMTF_POOL_USAGE_SPARE:
+ if 'Usage' in cim_pool and cim_pool['Usage'] == dmtf.POOL_USAGE_SPARE:
continue
# Skip IBM ArrayPool and ArraySitePool
# ArrayPool is holding RAID info.
@@ -143,11 +143,11 @@ def _pool_element_type(smis_common, cim_pool):
if 'SupportedStorageElementFeatures' in cim_scc:
supported_features = cim_scc['SupportedStorageElementFeatures']

- if DMTF_SUPPORT_VOL_CREATE in supported_features:
+ if dmtf.SUPPORT_VOL_CREATE in supported_features:
element_type |= Pool.ELEMENT_TYPE_VOLUME
- if DMTF_SUPPORT_ELEMENT_EXPAND not in supported_features:
+ if dmtf.SUPPORT_ELEMENT_EXPAND not in supported_features:
unsupported |= Pool.UNSUPPORTED_VOLUME_GROW
- if DMTF_SUPPORT_ELEMENT_REDUCE not in supported_features:
+ if dmtf.SUPPORT_ELEMENT_REDUCE not in supported_features:
unsupported |= Pool.UNSUPPORTED_VOLUME_SHRINK

else:
@@ -168,12 +168,12 @@ def _pool_element_type(smis_common, cim_pool):
if 'Usage' in cim_pool:
usage = cim_pool['Usage']

- if usage == DMTF_POOL_USAGE_UNRESTRICTED:
+ 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:
+ 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:
+ if usage == dmtf.POOL_USAGE_DELTA:
# We blitz all the other elements types for this designation
element_type = Pool.ELEMENT_TYPE_DELTA

@@ -181,11 +181,11 @@ def _pool_element_type(smis_common, cim_pool):


_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,
+ 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,
}


@@ -193,7 +193,7 @@ def _pool_status_of_cim_pool(dmtf_op_status_list):
"""
Convert CIM_StoragePool['OperationalStatus'] to LSM
"""
- return dmtf_op_status_list_conv(
+ return dmtf.op_status_list_conv(
_LSM_POOL_OP_STATUS_CONV, dmtf_op_status_list,
Pool.STATUS_UNKNOWN, Pool.STATUS_OTHER)

diff --git a/plugin/smispy/smis_sys.py b/plugin/smispy/smis_sys.py
index b750c75..64a9723 100644
--- a/plugin/smispy/smis_sys.py
+++ b/plugin/smispy/smis_sys.py
@@ -16,7 +16,7 @@
# Author: Gris Ge <***@redhat.com>

from utils import merge_list
-from dmtf import *
+import dmtf
from lsm import System, LsmError, ErrorNumber


@@ -91,13 +91,13 @@ def cim_sys_pros():


_LSM_SYS_OP_STATUS_CONV = {
- DMTF_OP_STATUS_UNKNOWN: System.STATUS_UNKNOWN,
- DMTF_OP_STATUS_OK: System.STATUS_OK,
- DMTF_OP_STATUS_ERROR: System.STATUS_ERROR,
- DMTF_OP_STATUS_DEGRADED: System.STATUS_DEGRADED,
- DMTF_OP_STATUS_NON_RECOVERABLE_ERROR: System.STATUS_ERROR,
- DMTF_OP_STATUS_PREDICTIVE_FAILURE: System.STATUS_PREDICTIVE_FAILURE,
- DMTF_OP_STATUS_SUPPORTING_ENTITY_IN_ERROR: System.STATUS_ERROR,
+ dmtf.OP_STATUS_UNKNOWN: System.STATUS_UNKNOWN,
+ dmtf.OP_STATUS_OK: System.STATUS_OK,
+ dmtf.OP_STATUS_ERROR: System.STATUS_ERROR,
+ dmtf.OP_STATUS_DEGRADED: System.STATUS_DEGRADED,
+ dmtf.OP_STATUS_NON_RECOVERABLE_ERROR: System.STATUS_ERROR,
+ dmtf.OP_STATUS_PREDICTIVE_FAILURE: System.STATUS_PREDICTIVE_FAILURE,
+ dmtf.OP_STATUS_SUPPORTING_ENTITY_IN_ERROR: System.STATUS_ERROR,
}


@@ -111,7 +111,7 @@ def _sys_status_of_cim_sys(cim_sys):
"sys_status_of_cim_sys(): Got a CIM_ComputerSystem with no "
"OperationalStatus: %s, %s" % (cim_sys.items(), cim_sys.path))

- return dmtf_op_status_list_conv(
+ return dmtf.op_status_list_conv(
_LSM_SYS_OP_STATUS_CONV, cim_sys['OperationalStatus'],
System.STATUS_UNKNOWN, System.STATUS_OTHER)
--
1.8.3.1
Tony Asleson
2014-10-06 21:00:46 UTC
Permalink
Patch set looks good.

Thanks,
Tony
Post by Gris Ge
* [V2 0/3] Move capablities to separate file
* [PATCH V3 00/10] SMI-S plugin: Reorganize code layout.
* [PATCH 0/7] Move lsm.System related methods to smis_sys.py.
* [PATCH V2 0/8] SMI-S Plugin: Split lsm.Pool related methods from smis.py
to smis_pool.py
* [PATCH 00/10] SMI-S Plugin: Split lsm.Disk methods to smis_disk.py
This patchset removed DMTF class by moving DMTF constants and methods to
dmtf.py file level.
* Remove 'DMTF_' prefix of dmtf.py constants.
* Renamed dmtf.dmtf_op_status_list_conv() to dmtf.op_status_list_conv().
* Changed 'from dmtf import *' to 'import dmtf' in smis_xxx.py files.
SMI-S Plugin: Clean up DMTF.OP_STATUS_XXX of dmtf.py
SMI-S Plugin: Remove unused constants: dmtf.DMTF_STATUS_XXX
SMI-S Plugin: Remove DMTF class.
plugin/smispy/dmtf.py | 312 ++++++++++++++++++++-----------------------
plugin/smispy/smis.py | 42 +++---
plugin/smispy/smis_cap.py | 24 ++--
plugin/smispy/smis_common.py | 12 +-
plugin/smispy/smis_disk.py | 32 +++--
plugin/smispy/smis_pool.py | 32 ++---
plugin/smispy/smis_sys.py | 18 +--
7 files changed, 222 insertions(+), 250 deletions(-)
Loading...