Discussion:
[Libstoragemgmt-devel] [PATCH] RFC: Removal of unused constants
Tony Asleson
2014-09-03 19:28:44 UTC
Permalink
On IRC Gris provided the following list of unused plug-in constants
with a script he put together.

The constants are shared between python and C code, thus for a constant
to be un-used it cannot be referenced in the C or python code. However,
just because a constant isn't used in a plug-in doesn't mean it not
needed in other parts of the library.

FAIL: ErrorNumber.UNSUPPORTED_SEARCH_KEY is un-used
Used in both, just not in the plug-ins

FAIL: ErrorNumber.TRANSPORT_SERIALIZATION is un-used
Used in C when converting types for JSON

FAIL: ErrorNumber.TRANSPORT_INVALID_ARG is un-used
Used in C when parsing expected parameters from JSON

FAIL: ErrorNumber.PLUGIN_SOCKET_PERMISSION is un-used
FAIL: ErrorNumber.PLUGIN_NOT_EXIST is un-used
FAIL: ErrorNumber.PLUGIN_IPC_FAIL is un-used
Used in both, just not in the plug-ins

FAIL: ErrorNumber.OK is un-used
Used in C code

FAIL: ErrorNumber.NO_SUPPORT_OFFLINE_CHANGE is un-used
Probably should keep both so that we have both available
(NO_SUPPORT_ONLINE_CHANGE, NO_SUPPORT_OFFLINE_CHANGE)

FAIL: ErrorNumber.NO_MEMORY is un-used
This error only pertains to C code and it is possible for a C plug-in to
return this error and thus we need the corresponding value in python as well.

FAIL: ErrorNumber.LIB_BUG is un-used
Used C code of the library and simc plug-in

FAIL: ErrorNumber.JOB_STARTED is un-used
Used in cmdline.py and in C code

FAIL: ErrorNumber.DAEMON_NOT_RUNNING is un-used
Used in _client.py

FAIL: Client.FLAG_RSVD is un-used
Used in C code, should be used in python code too

FAIL: Capabilities.SUPPORTED is un-used
Used in both C and Python

This patch does the following:

FAIL: TargetPort.TYPE_UNKNOWN is un-used
FAIL: TargetPort.TYPE_OTHER is un-used
Kept TYPE_OTHER, removed UNKNOWN.

FAIL: Pool.ELEMENT_TYPE_UNKNOWN is un-used
FAIL: Pool.STATUS_STARTING is un-used
FAIL: Pool.STATUS_DESTROYING is un-used
FAIL: Disk.TYPE_NOT_APPLICABLE is un-used
FAIL: JobStatus.STOPPED is un-used
FAIL: ErrorNumber.VOLUME_BUSY is un-used
FAIL: ErrorNumber.STORAGE_SDK_BUG is un-used
FAIL: ErrorNumber.SIZE_LIMIT_REACHED is un-used
Removed

FAIL: Capabilities.ACCESS_GROUP_INITIATOR_ADD_MIX is un-used
Removed, add later if needed

FAIL: Capabilities.VOLUME_THIN is un-used
Not used, however should this be retained as couldn't we be using this:

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)
# Check to see if thin is supported and denote that too?
if DMTF.SCS_CAP_SUP_THIN_ST_VOLUME in element_types:
cap.set(Capabilities.VOLUME_THIN)

FAIL: Volume.PROVISION_FULL is un-used
This isn't referenced, however the other constants are so I think we should keep
for completeness.

Regards,
Tony

Signed-off-by: Tony Asleson <***@redhat.com>
---
c_binding/include/libstoragemgmt/libstoragemgmt_capabilities.h | 1 -
c_binding/include/libstoragemgmt/libstoragemgmt_error.h | 3 ---
c_binding/include/libstoragemgmt/libstoragemgmt_types.h | 10 +---------
c_binding/lsm_datatypes.cpp | 2 +-
plugin/ontap/ontap.py | 2 +-
plugin/smispy/smis.py | 2 ++
python_binding/lsm/_common.py | 6 +-----
python_binding/lsm/_data.py | 9 ---------
tools/lsmcli/data_display.py | 6 ------
9 files changed, 6 insertions(+), 35 deletions(-)

diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_capabilities.h b/c_binding/include/libstoragemgmt/libstoragemgmt_capabilities.h
index 62c25ac..323db98 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_capabilities.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_capabilities.h
@@ -74,7 +74,6 @@ typedef enum {

LSM_CAP_ACCESS_GROUP_CREATE_ISCSI_IQN = 47, /**< Create iSCSI access group */
LSM_CAP_ACCESS_GROUP_INITIATOR_ADD_ISCSI_IQN = 48, /**< For empty access group, this indicates it can add iSCSI IQN to it */
- LSM_CAP_ACCESS_GROUP_INITIATOR_ADD_MIX = 49, /**< Allowing add different initiator type that existing one */

LSM_CAP_VOLUME_ISCSI_CHAP_AUTHENTICATION = 53, /**< If you can configure iSCSI chap authentication */

diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_error.h b/c_binding/include/libstoragemgmt/libstoragemgmt_error.h
index 42e5547..2ea1eda 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_error.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_error.h
@@ -35,7 +35,6 @@ typedef enum {
LSM_ERR_OK = 0, /**< OK */
LSM_ERR_LIB_BUG = 1, /**< Library BUG */
LSM_ERR_PLUGIN_BUG = 2, /**< Plugin BUG */
- LSM_ERR_STORAGE_SDK_BUG = 3, /**< Storage SDK BUG */
LSM_ERR_JOB_STARTED = 7, /**< Operation has started */
LSM_ERR_TIMEOUT = 11, /**< Plug-in is un-responsive */
LSM_ERR_DAEMON_NOT_RUNNING = 12, /**< Daemon is not running */
@@ -81,13 +80,11 @@ typedef enum {
LSM_ERR_NOT_ENOUGH_SPACE = 350, /**< Insufficient space */

LSM_ERR_SIZE_TOO_SMALL = 353, /**< Size specified is too small */
- LSM_ERR_SIZE_LIMIT_REACHED = 354, /**< Limit has been reached */

LSM_ERR_TRANSPORT_COMMUNICATION = 400, /**< Error comunicating with plug-in */
LSM_ERR_TRANSPORT_SERIALIZATION = 401, /**< Transport serialization error */
LSM_ERR_TRANSPORT_INVALID_ARG = 402, /**< Parameter transported over IPC is invalid */

- LSM_ERR_VOLUME_BUSY = 501, /* Volume already in use */
LSM_ERR_ACCESS_GROUP_MASKED = 502,


diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_types.h b/c_binding/include/libstoragemgmt/libstoragemgmt_types.h
index 653c1fa..cb10163 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_types.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_types.h
@@ -162,14 +162,12 @@ typedef enum {
typedef enum {
LSM_JOB_INPROGRESS = 1, /**< Job is in progress */
LSM_JOB_COMPLETE = 2, /**< Job is complete */
- LSM_JOB_STOPPED = 3, /**< Job is stopped */
- LSM_JOB_ERROR = 4 /**< Job has errored */
+ LSM_JOB_ERROR = 3 /**< Job has errored */
} lsm_job_status;

typedef enum {
LSM_DISK_TYPE_UNKNOWN = 0,
LSM_DISK_TYPE_OTHER = 1,
- LSM_DISK_TYPE_NOT_APPLICABLE = 2,
LSM_DISK_TYPE_ATA = 3,
LSM_DISK_TYPE_SATA = 4,
LSM_DISK_TYPE_SAS = 5,
@@ -206,17 +204,12 @@ typedef enum {
#define LSM_POOL_STATUS_OTHER 0x0000000000000004
#define LSM_POOL_STATUS_DEGRADED 0x0000000000000010
#define LSM_POOL_STATUS_ERROR 0x0000000000000020
-/*#define LSM_POOL_AVAILABLE 0x0000000000000040 */
-#define LSM_POOL_STATUS_STARTING 0x0000000000000080
-#define LSM_POOL_STATUS_STOPPING 0x0000000000000100
#define LSM_POOL_STATUS_STOPPED 0x0000000000000200
#define LSM_POOL_STATUS_RECONSTRUCTING 0x0000000000001000
#define LSM_POOL_STATUS_VERIFYING 0x0000000000002000
#define LSM_POOL_STATUS_INITIALIZING 0x0000000000004000
#define LSM_POOL_STATUS_GROWING 0x0000000000008000
-#define LSM_POOL_STATUS_DESTROYING 0x0000000000020000

-#define LSM_POOL_ELEMENT_TYPE_UNKNOWN 0x0000000000000001
#define LSM_POOL_ELEMENT_TYPE_POOL 0x0000000000000002
#define LSM_POOL_ELEMENT_TYPE_VOLUME 0x0000000000000004
#define LSM_POOL_ELEMENT_TYPE_FS 0x0000000000000008
@@ -227,7 +220,6 @@ typedef enum {
#define LSM_POOL_UNSUPPORTED_VOLUME_SHRINK 0x0000000000000002

typedef enum {
- LSM_TARGET_PORT_TYPE_UNKNOWN = 0,
LSM_TARGET_PORT_TYPE_OTHER = 1,
LSM_TARGET_PORT_TYPE_FC = 2,
LSM_TARGET_PORT_TYPE_FCOE = 3,
diff --git a/c_binding/lsm_datatypes.cpp b/c_binding/lsm_datatypes.cpp
index 8363326..c8475e6 100644
--- a/c_binding/lsm_datatypes.cpp
+++ b/c_binding/lsm_datatypes.cpp
@@ -1890,7 +1890,7 @@ lsm_target_port LSM_DLL_EXPORT *lsm_target_port_copy(lsm_target_port *tp)
}

MEMBER_FUNC_GET(const char *, lsm_target_port_id_get, lsm_target_port *tp, tp, LSM_IS_TARGET_PORT, id, NULL)
-MEMBER_FUNC_GET(lsm_target_port_type, lsm_target_port_type_get, lsm_target_port *tp, tp, LSM_IS_TARGET_PORT, port_type, LSM_TARGET_PORT_TYPE_UNKNOWN)
+MEMBER_FUNC_GET(lsm_target_port_type, lsm_target_port_type_get, lsm_target_port *tp, tp, LSM_IS_TARGET_PORT, port_type, LSM_TARGET_PORT_TYPE_OTHER)
MEMBER_FUNC_GET(const char *, lsm_target_port_service_address_get, lsm_target_port *tp, tp, LSM_IS_TARGET_PORT, service_address, NULL)
MEMBER_FUNC_GET(const char *, lsm_target_port_network_address_get, lsm_target_port *tp, tp, LSM_IS_TARGET_PORT, network_address, NULL)
MEMBER_FUNC_GET(const char *, lsm_target_port_physical_address_get, lsm_target_port *tp, tp, LSM_IS_TARGET_PORT, physical_address, NULL)
diff --git a/plugin/ontap/ontap.py b/plugin/ontap/ontap.py
index 6e18c47..c275f63 100644
--- a/plugin/ontap/ontap.py
+++ b/plugin/ontap/ontap.py
@@ -111,7 +111,7 @@ class Ontap(IStorageAreaNetwork, INfs):
'online': Pool.STATUS_OK,
'restricted': Pool.STATUS_OTHER,
'unknown': Pool.STATUS_UNKNOWN,
- 'creating': Pool.STATUS_STOPPING,
+ 'creating': Pool.STATUS_INITIALIZING,
'failed': Pool.STATUS_ERROR,
'partial': Pool.STATUS_ERROR,

diff --git a/plugin/smispy/smis.py b/plugin/smispy/smis.py
index 6f43c14..937e7e3 100644
--- a/plugin/smispy/smis.py
+++ b/plugin/smispy/smis.py
@@ -687,6 +687,8 @@ class Smis(IStorageAreaNetwork):
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:
+ cap.set(Capabilities.VOLUME_THIN)

if DMTF.SCS_CAP_VOLUME_CREATE in sup_actions:
cap.set(Capabilities.VOLUME_CREATE)
diff --git a/python_binding/lsm/_common.py b/python_binding/lsm/_common.py
index 5089565..383c9e0 100644
--- a/python_binding/lsm/_common.py
+++ b/python_binding/lsm/_common.py
@@ -418,7 +418,6 @@ class ErrorNumber(object):
OK = 0
LIB_BUG = 1
PLUGIN_BUG = 2
- STORAGE_SDK_BUG = 3
JOB_STARTED = 7
TIMEOUT = 11
DAEMON_NOT_RUNNING = 12
@@ -465,13 +464,11 @@ class ErrorNumber(object):

NOT_ENOUGH_SPACE = 350
SIZE_TOO_SMALL = 353
- SIZE_LIMIT_REACHED = 354

TRANSPORT_COMMUNICATION = 400
TRANSPORT_SERIALIZATION = 401
TRANSPORT_INVALID_ARG = 402

- VOLUME_BUSY = 501
ACCESS_GROUP_MASKED = 502 # refuse to remove the last initiator from
# access group which have volume masked or
# allow an access group to be deleted
@@ -494,8 +491,7 @@ class ErrorNumber(object):
class JobStatus(object):
INPROGRESS = 1
COMPLETE = 2
- STOPPED = 3
- ERROR = 4
+ ERROR = 3


def type_compare(method_name, exp_type, act_val):
diff --git a/python_binding/lsm/_data.py b/python_binding/lsm/_data.py
index 3d902f3..dbe77a5 100644
--- a/python_binding/lsm/_data.py
+++ b/python_binding/lsm/_data.py
@@ -163,7 +163,6 @@ class Disk(IData):

TYPE_UNKNOWN = 0
TYPE_OTHER = 1
- TYPE_NOT_APPLICABLE = 2
TYPE_ATA = 3 # IDE disk which is seldomly used.
TYPE_SATA = 4
TYPE_SAS = 5
@@ -323,7 +322,6 @@ class Pool(IData):
# * Another Pool
# * Volume (aka, LUN)
# * System Reserved Pool.
- ELEMENT_TYPE_UNKNOWN = 1 << 0
ELEMENT_TYPE_POOL = 1 << 1
ELEMENT_TYPE_VOLUME = 1 << 2
ELEMENT_TYPE_FS = 1 << 3
@@ -340,14 +338,11 @@ class Pool(IData):
STATUS_OTHER = 1 << 2
STATUS_DEGRADED = 1 << 4
STATUS_ERROR = 1 << 5
- STATUS_STARTING = 1 << 7
- STATUS_STOPPING = 1 << 8
STATUS_STOPPED = 1 << 9
STATUS_RECONSTRUCTING = 1 << 12
STATUS_VERIFYING = 1 << 13
STATUS_INITIALIZING = 1 << 14
STATUS_GROWING = 1 << 15
- STATUS_DESTROYING = 1 << 17

def __init__(self, _id, _name, _element_type, _unsupported_actions,
_total_space, _free_space,
@@ -565,7 +560,6 @@ class AccessGroup(IData):
class TargetPort(IData):
SUPPORTED_SEARCH_KEYS = ['id', 'system_id']

- TYPE_UNKNOWN = 0
TYPE_OTHER = 1
TYPE_FC = 2
TYPE_FCOE = 3
@@ -653,9 +647,6 @@ class Capabilities(IData):
ACCESS_GROUP_INITIATOR_ADD_ISCSI_IQN = 48
# For empty access group, this indicate it can add iSCSI IQN into it.

- ACCESS_GROUP_INITIATOR_ADD_MIX = 49
- # Allowing add different initiator type than existing one
-
VOLUME_ISCSI_CHAP_AUTHENTICATION = 53

VOLUME_THIN = 55
diff --git a/tools/lsmcli/data_display.py b/tools/lsmcli/data_display.py
index 080f6fa..2ba7ef3 100644
--- a/tools/lsmcli/data_display.py
+++ b/tools/lsmcli/data_display.py
@@ -95,14 +95,11 @@ _POOL_STATUS_CONV = {
Pool.STATUS_OTHER: 'Other',
Pool.STATUS_DEGRADED: 'Degraded',
Pool.STATUS_ERROR: 'Error',
- Pool.STATUS_STARTING: 'Starting',
- Pool.STATUS_STOPPING: 'Stopping',
Pool.STATUS_STOPPED: 'Stopped',
Pool.STATUS_RECONSTRUCTING: 'Reconstructing',
Pool.STATUS_VERIFYING: 'Verifying',
Pool.STATUS_INITIALIZING: 'Initializing',
Pool.STATUS_GROWING: 'Growing',
- Pool.STATUS_DESTROYING: 'Destroying',
}


@@ -111,7 +108,6 @@ def pool_status_to_str(pool_status):


_POOL_ELEMENT_TYPE_CONV = {
- Pool.ELEMENT_TYPE_UNKNOWN: 'UNKNOWN',
Pool.ELEMENT_TYPE_POOL: 'POOL',
Pool.ELEMENT_TYPE_VOLUME: 'VOLUME',
Pool.ELEMENT_TYPE_FS: 'FILE_SYSTEM',
@@ -172,7 +168,6 @@ def vol_rep_type_str_to_type(vol_rep_type_str):
_DISK_TYPE_CONV = {
Disk.TYPE_UNKNOWN: 'UNKNOWN',
Disk.TYPE_OTHER: 'Other',
- Disk.TYPE_NOT_APPLICABLE: 'Not applicable',
Disk.TYPE_ATA: 'ATA',
Disk.TYPE_SATA: 'SATA',
Disk.TYPE_SAS: 'SAS',
@@ -229,7 +224,6 @@ def ag_init_type_str_to_lsm(init_type_str):


_TGT_PORT_TYPE_CONV = {
- TargetPort.TYPE_UNKNOWN: 'Unknown',
TargetPort.TYPE_OTHER: 'Other',
TargetPort.TYPE_FC: 'FC',
TargetPort.TYPE_FCOE: 'FCoE',
--
1.8.2.1
Loading...