* Python, added these constants:
System.FLAG_RETRIEVE_FULL_INFO
Pool.FLAG_RETRIEVE_FULL_INFO
# This is a rename.
Volume.FLAG_RETRIEVE_FULL_INFO
Disk.FLAG_RETRIEVE_FULL_INFO
# This is a rename and value change from 2 to '1 << 0'
AccessGroup.FLAG_RETRIEVE_FULL_INFO
FileSystem.FLAG_RETRIEVE_FULL_INFO
NfsExport.FLAG_RETRIEVE_FULL_INFO
FsSnapshot.FLAG_RETRIEVE_FULL_INFO
* C, added these constants:
LSM_SYSTEM_FLAG_RETRIEVE_FULL_INFO
LSM_POOL_FLAG_RETRIEVE_FULL_INFO
LSM_VOLUME_FLAG_RETRIEVE_FULL_INFO
LSM_DISK_FLAG_RETRIEVE_FULL_INFO
LSM_ACCESS_GROUP_FLAG_RETRIEVE_FULL_INFO
LSM_FS_FLAG_RETRIEVE_FULL_INFO
LSM_NFS_FLAG_RETRIEVE_FULL_INFO
LSM_FS_SNAPSHOT_FLAG_RETRIEVE_FULL_INFO
* Remove LSM_FLAG_UNUSED_CHECK for query methods in C library.
Signed-off-by: Gris Ge <***@redhat.com>
---
c_binding/include/libstoragemgmt/libstoragemgmt.h | 33 ++++++++------
.../include/libstoragemgmt/libstoragemgmt_types.h | 49 +++++++++++++++++++-
c_binding/lsm_mgmt.cpp | 15 +++----
python_binding/lsm/_client.py | 4 +-
python_binding/lsm/_data.py | 52 +++++++---------------
5 files changed, 93 insertions(+), 60 deletions(-)
diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt.h b/c_binding/include/libstoragemgmt/libstoragemgmt.h
index af082b9..c646899 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt.h
@@ -230,7 +230,8 @@ extern "C" {
* @param[in] search_value Search value
* @param[out] pool_array Array of storage pools
* @param[out] count Number of storage pools
- * @param[in] flags Reserved for future use, must be zero.
+ * @param[in] flags Use LSM_POOL_FLAG_RETRIEVE_FULL_INFO
+ * for all data, else 0
* @return LSM_ERR_OK on success else error reason
*/
int LSM_DLL_EXPORT lsm_pool_list(lsm_connect *conn, char *search_key,
@@ -371,7 +372,8 @@ extern "C" {
* @param[in] search_value Search value
* @param[out] volumes An array of lsm_volume
* @param[out] count Number of elements in the lsm_volume array
- * @param[in] flags Reserved for future use, must be zero.
+ * @param[in] flags Use LSM_VOLUME_FLAG_RETRIEVE_FULL_INFO
+ * for all data, else 0
* @return LSM_ERR_OK on success else error reason
*/
int LSM_DLL_EXPORT lsm_volume_list(lsm_connect *conn,
@@ -388,8 +390,8 @@ extern "C" {
* @param[in] search_value Search value
* @param [out] disks An array of lsm_disk types
* @param [out] count Number of disks
- * @param [in] flags Use LSM_DISK_RETRIEVE_FULL_INFO for all
- * data, else 0
+ * @param [in] flags Use LSM_DISK_FLAG_RETRIEVE_FULL_INFO
+ * for all data, else 0
* @return LSM_ERR_OK on success else error reason
*/
int LSM_DLL_EXPORT lsm_disk_list(lsm_connect *conn, const char * search_key,
@@ -568,7 +570,8 @@ extern "C" {
* @param[in] search_value Search value
* @param[out] groups Array of access groups
* @param[out] group_count Size of array
- * @param[in] flags Reserved for future use, must be zero.
+ * @param[in] flags Use LSM_ACCESS_GROUP_FLAG_RETRIEVE_FULL_INFO
+ * for all data, else 0
* @return LSM_ERR_OK on success, else error reason.
*/
int LSM_DLL_EXPORT lsm_access_group_list(lsm_connect *conn,
@@ -753,7 +756,8 @@ extern "C" {
* @param[in] conn Valid connection
* @param[out] systems Array of lsm_system
* @param[out] system_count Number of systems
- * @param[in] flags Reserved for future use, must be zero.
+ * @param[in] flags Use LSM_SYSTEM_FLAG_RETRIEVE_FULL_INFO
+ * for all data, else 0
* @return LSM_ERR_OK on success, else error reason
*/
int LSM_DLL_EXPORT lsm_system_list(lsm_connect *conn, lsm_system **systems[],
@@ -766,7 +770,8 @@ extern "C" {
* @param[in] search_value Search value
* @param[out] fs Array of lsm_fs
* @param[out] fs_count Number of file systems
- * @param[in] flags Reserved for future use, must be zero.
+ * @param[in] flags Use LSM_FS_FLAG_RETRIEVE_FULL_INFO
+ * for all data, else 0
* @return LSM_ERR_OK on success, else error reason
*/
int LSM_DLL_EXPORT lsm_fs_list(lsm_connect *conn, const char *search_key,
@@ -881,11 +886,12 @@ extern "C" {
/**
* Return a list of snapshots
- * @param[in] conn Valid connection
- * @param[in] fs File system to check for snapshots
- * @param[out] ss An array of snapshot pointers
- * @param[out] ss_count Number of elements in the array
- * @param[in] flags Reserved for future use, must be zero.
+ * @param[in] conn Valid connection
+ * @param[in] fs File system to check for snapshots
+ * @param[out] ss An array of snapshot pointers
+ * @param[out] ss_count Number of elements in the array
+ * @param[in] flags Use LSM_FS_SNAPSHOT_FLAG_RETRIEVE_FULL_INFO
+ * for all data, else 0
* @return LSM_ERR_OK on success, else error reason
*/
int LSM_DLL_EXPORT lsm_fs_ss_list(lsm_connect *conn, lsm_fs *fs,
@@ -959,7 +965,8 @@ extern "C" {
* @param[in] search_value Search value
* @param[out] exports An array of lsm_nfs_export
* @param[out] count Number of items in array
- * @param[in] flags Reserved for future use, must be zero.
+ * @param[in] flags Use LSM_NFS_FLAG_RETRIEVE_FULL_INFO
+ * for all data, else 0
* @return LSM_ERR_OK on success else error code.
*/
int LSM_DLL_EXPORT lsm_nfs_list(lsm_connect *c, const char *search_key,
diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_types.h b/c_binding/include/libstoragemgmt/libstoragemgmt_types.h
index eb22df4..5ac7db3 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_types.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_types.h
@@ -152,6 +152,12 @@ typedef enum {
#define LSM_VOLUME_OP_STATUS_DORMANT 0x10 /**< Volume is inactive or quiesced */
/**
+ * Used by 'flags' parameter of lsm_volume_list() function to retrieve
+ * optional data also.
+ */
+#define LSM_VOLUME_FLAG_RETRIEVE_FULL_INFO 0x0000000000000001
+
+/**
* Different states a system status can be in.
* Bit field, can be in multiple states at the same time.
*/
@@ -166,6 +172,13 @@ typedef enum {
#define LSM_SYSTEM_STATUS_STOPPED 0x00000100 /**< Stopped by admin */
#define LSM_SYSTEM_STATUS_OTHER 0x00000200 /**< Vendor specific */
+
+/**
+ * Used by 'flags' parameter of lsm_system_list() function to retrieve
+ * optional data also.
+ */
+#define LSM_SYSTEM_FLAG_RETRIEVE_FULL_INFO 0x0000000000000001
+
/**< \enum lsm_initiator_type Different types of initiator IDs */
typedef enum {
LSM_INITIATOR_OTHER = 1, /**< Other or unspecified */
@@ -187,6 +200,12 @@ typedef enum {
INIT_TYPE_ISCSI_WWPN_MIXED = 7 /**< More than 1 type */
} lsm_access_group_init_type;
+/**
+ * Used by 'flags' parameter of lsm_access_group_list() function to
+ * retrieve optional data also.
+ */
+#define LSM_ACCESS_GROUP_FLAG_RETRIEVE_FULL_INFO 0x0000000000000001
+
/**< \enum lsm_job_type Different types of jobs */
typedef enum {
LSM_JOB_VOL_CREATE = 1, /**< Volume create */
@@ -214,7 +233,11 @@ typedef enum {
LSM_DISK_TYPE_SCSI = 8
} lsm_disk_type;
-#define LSM_DISK_RETRIEVE_FULL_INFO 0x02
+/**
+ * Used by 'flags' parameter of lsm_disk_list() function to retrieve
+ * optional data also.
+ */
+#define LSM_DISK_FLAG_RETRIEVE_FULL_INFO 0x0000000000000001
#define LSM_DISK_STATUS_UNKNOWN 0x0000000000000001
#define LSM_DISK_STATUS_OK 0x0000000000000002
@@ -247,6 +270,12 @@ typedef enum {
#define LSM_POOL_STATUS_SHRINKING 0x0000000000010000
#define LSM_POOL_STATUS_DESTROYING 0x0000000000020000
+/**
+ * Used by 'flags' parameter of lsm_pool_list() function to retrieve
+ * optional data also.
+ */
+#define LSM_POOL_FLAG_RETRIEVE_FULL_INFO 0x0000000000000001
+
typedef enum {
LSM_POOL_MEMBER_TYPE_UNKNOWN = 0,
LSM_POOL_MEMBER_TYPE_DISK = 1,
@@ -285,6 +314,24 @@ typedef enum {
LSM_POOL_RAID_TYPE_MIXED = 23
} lsm_pool_raid_type;
+/**
+ * Used by 'flags' parameter of lsm_fs_list() function to retrieve
+ * optional data also.
+ */
+#define LSM_FS_FLAG_RETRIEVE_FULL_INFO 0x0000000000000001
+
+/**
+ * Used by 'flags' parameter of lsm_nfs_list() function to retrieve
+ * optional data also.
+ */
+#define LSM_NFS_FLAG_RETRIEVE_FULL_INFO 0x0000000000000001
+
+/**
+ * Used by 'flags' parameter of lsm_fs_ss_list() function to retrieve
+ * optional data also.
+ */
+#define LSM_FS_SNAPSHOT_FLAG_RETRIEVE_FULL_INFO 0x0000000000000001
+
#ifdef __cplusplus
}
#endif
diff --git a/c_binding/lsm_mgmt.cpp b/c_binding/lsm_mgmt.cpp
index 54bdc33..8b3d468 100644
--- a/c_binding/lsm_mgmt.cpp
+++ b/c_binding/lsm_mgmt.cpp
@@ -682,7 +682,7 @@ int lsm_pool_list(lsm_connect *c, char *search_key, char *search_value,
int rc = LSM_ERR_OK;
CONN_SETUP(c);
- if( !poolArray || !count || CHECK_RP(poolArray) || LSM_FLAG_UNUSED_CHECK(flags) ) {
+ if( !poolArray || !count || CHECK_RP(poolArray) ) {
return LSM_ERR_INVALID_ARGUMENT;
}
@@ -801,8 +801,7 @@ int lsm_volume_list(lsm_connect *c, const char *search_key,
{
CONN_SETUP(c);
- if( !volumes || !count || CHECK_RP(volumes) ||
- LSM_FLAG_UNUSED_CHECK(flags) ) {
+ if( !volumes || !count || CHECK_RP(volumes)){
return LSM_ERR_INVALID_ARGUMENT;
}
@@ -1547,7 +1546,7 @@ int lsm_access_group_list(lsm_connect *c, const char *search_key,
{
CONN_SETUP(c);
- if( !groups || !groupCount || LSM_FLAG_UNUSED_CHECK(flags) ) {
+ if( !groups || !groupCount ) {
return LSM_ERR_INVALID_ARGUMENT;
}
@@ -1885,7 +1884,7 @@ int lsm_system_list(lsm_connect *c, lsm_system **systems[],
int rc = LSM_ERR_OK;
CONN_SETUP(c);
- if( !systems || ! systemCount || LSM_FLAG_UNUSED_CHECK(flags) ) {
+ if( !systems || ! systemCount ) {
return LSM_ERR_INVALID_ARGUMENT;
}
@@ -1937,7 +1936,7 @@ int lsm_fs_list(lsm_connect *c, const char *search_key,
int rc = LSM_ERR_OK;
CONN_SETUP(c);
- if( !fs || !fsCount || LSM_FLAG_UNUSED_CHECK(flags) ) {
+ if( !fs || !fsCount ) {
return LSM_ERR_INVALID_ARGUMENT;
}
@@ -2222,7 +2221,7 @@ int lsm_fs_ss_list(lsm_connect *c, lsm_fs *fs, lsm_fs_ss **ss[],
return LSM_ERR_INVALID_FS;
}
- if( CHECK_RP(ss) || !ssCount || LSM_FLAG_UNUSED_CHECK(flags) ) {
+ if( CHECK_RP(ss) || !ssCount ) {
return LSM_ERR_INVALID_ARGUMENT;
}
@@ -2385,7 +2384,7 @@ int lsm_nfs_list( lsm_connect *c, const char *search_key,
int rc = LSM_ERR_OK;
CONN_SETUP(c);
- if( CHECK_RP(exports) || !count || LSM_FLAG_UNUSED_CHECK(flags) ) {
+ if( CHECK_RP(exports) || !count ) {
return LSM_ERR_INVALID_ARGUMENT;
}
diff --git a/python_binding/lsm/_client.py b/python_binding/lsm/_client.py
index 11acd01..3942b8d 100644
--- a/python_binding/lsm/_client.py
+++ b/python_binding/lsm/_client.py
@@ -284,7 +284,7 @@ class Client(INetworkAttachedStorage):
## Returns an array of pool objects.
# @param self The this pointer
- # @param flags When equal to Pool.RETRIEVE_FULL_INFO,
+ # @param flags When equal to Pool.FLAG_RETRIEVE_FULL_INFO,
# returned objects will contain optional data.
# If not defined, only the mandatory properties will
# returned.
@@ -671,7 +671,7 @@ class Client(INetworkAttachedStorage):
## Returns an array of disk objects
# @param self The this pointer
- # @param flags When equal to DISK.RETRIEVE_FULL_INFO
+ # @param flags When equal to DISK.FLAG_RETRIEVE_FULL_INFO
# returned objects will contain optional data.
# If not defined, only the mandatory properties will
# be returned.
diff --git a/python_binding/lsm/_data.py b/python_binding/lsm/_data.py
index f7929f1..6104ec4 100644
--- a/python_binding/lsm/_data.py
+++ b/python_binding/lsm/_data.py
@@ -208,7 +208,7 @@ class Disk(IData):
Represents a disk.
"""
SUPPORTED_SEARCH_KEYS = ['id', 'system_id']
- RETRIEVE_FULL_INFO = 2 # Used by _client.py for disks() call.
+ FLAG_RETRIEVE_FULL_INFO = 1 << 0
# We use '-1' to indicate we failed to get the requested number.
# For example, when block found is undetectable, we use '-1' instead of
@@ -302,20 +302,8 @@ class Disk(IData):
self._num_of_blocks = _num_of_blocks
self._status = _status
self._system_id = _system_id
-
- if _optional_data is None:
- self._optional_data = OptionalData()
- else:
- #Make sure the properties only contain ones we permit
- allowed = set(Disk.OPT_PROPERTIES)
- actual = set(_optional_data.list())
-
- if actual <= allowed:
- self._optional_data = _optional_data
- else:
- raise LsmError(ErrorNumber.INVALID_ARGUMENT,
- "Property keys are invalid: %s" %
- "".join(actual - allowed))
+ self._optional_data = _check_opt_data(_optional_data,
+ self.OPT_PROPERTIES)
@property
def size_bytes(self):
@@ -342,6 +330,8 @@ class Volume(IData):
"""
Represents a volume.
"""
+ FLAG_RETRIEVE_FULL_INFO = 1 << 0
+
SUPPORTED_SEARCH_KEYS = ['id', 'system_id', 'pool_id']
# Volume status Note: Volumes can have multiple status bits set at same
# time.
@@ -379,7 +369,7 @@ class Volume(IData):
self._system_id = _system_id # System id this volume belongs
self._pool_id = _pool_id # Pool id this volume belongs
self._optional_data = _check_opt_data(_optional_data,
- Volume.OPT_PROPERTIES)
+ self.OPT_PROPERTIES)
self._plugin_data = _plugin_data
@property
@@ -467,6 +457,8 @@ The lsm.System class does not have any extra constants.
The lsm.System class does not have class methods.
"""
+ FLAG_RETRIEVE_FULL_INFO = 1 << 0
+
STATUS_UNKNOWN = 1 << 0
STATUS_OK = 1 << 1
STATUS_ERROR = 1 << 2
@@ -502,9 +494,7 @@ class Pool(IData):
"""
Pool specific information
"""
- RETRIEVE_FULL_INFO = 1 # Used by _client.py for pools() call.
- # This might not be a good place, please
- # suggest a better one.
+ FLAG_RETRIEVE_FULL_INFO = 1 << 0
SUPPORTED_SEARCH_KEYS = ['id', 'system_id']
TOTAL_SPACE_NOT_FOUND = -1
@@ -701,21 +691,8 @@ class Pool(IData):
self._status_info = _status_info # Additional status text of pool
self._system_id = _system_id # System id this pool belongs
self._plugin_data = _plugin_data # Plugin private data
-
- if _optional_data is None:
- self._optional_data = OptionalData()
- else:
- #Make sure the properties only contain ones we permit
- allowed = set(Pool.OPT_PROPERTIES)
- actual = set(_optional_data.list())
-
- if actual <= allowed:
- self._optional_data = _optional_data
- else:
- raise LsmError(ErrorNumber.INVALID_ARGUMENT,
- "Property keys are invalid: %s" %
- "".join(actual - allowed))
-
+ self._optional_data = _check_opt_data(_optional_data,
+ self.OPT_PROPERTIES)
@default_property('id', doc="Unique identifier")
@default_property('name', doc="File system name")
@@ -726,6 +703,7 @@ class Pool(IData):
@default_property("optional_data", "Optional data")
@default_property("plugin_data", "Private plugin data")
class FileSystem(IData):
+ FLAG_RETRIEVE_FULL_INFO = 1 << 0
SUPPORTED_SEARCH_KEYS = ['id', 'system_id', 'pool_id']
def __init__(self, _id, _name, _total_space, _free_space, _pool_id,
@@ -747,6 +725,7 @@ class FileSystem(IData):
@default_property("optional_data", "Optional data")
@default_property("plugin_data", "Private plugin data")
class FsSnapshot(IData):
+ FLAG_RETRIEVE_FULL_INFO = 1 << 0
def __init__(self, _id, _name, _ts, _optional_data=None,
_plugin_data=None):
self._id = _id
@@ -770,6 +749,7 @@ class FsSnapshot(IData):
@default_property('optional_data', doc="Optional data")
@default_property('plugin_data', doc="Plugin private data")
class NfsExport(IData):
+ FLAG_RETRIEVE_FULL_INFO = 1 << 0
SUPPORTED_SEARCH_KEYS = ['id', 'fs_id']
ANON_UID_GID_NA = -1
ANON_UID_GID_ERROR = (ANON_UID_GID_NA - 1)
@@ -795,7 +775,6 @@ class NfsExport(IData):
self._plugin_data = _plugin_data
-
@default_property('src_block', doc="Source logical block address")
@default_property('dest_block', doc="Destination logical block address")
@default_property('block_count', doc="Number of blocks")
@@ -814,6 +793,7 @@ class BlockRange(IData):
@default_property('optional_data', doc="Optional data")
@default_property('plugin_data', doc="Plugin private data")
class AccessGroup(IData):
+ FLAG_RETRIEVE_FULL_INFO = 1 << 0
SUPPORTED_SEARCH_KEYS = ['id', 'system_id']
INIT_TYPE_UNKNOWN = 0
@@ -834,7 +814,7 @@ class AccessGroup(IData):
self._system_id = _system_id # System id this group belongs
self._plugin_data = _plugin_data
self._optional_data = _check_opt_data(_optional_data,
- AccessGroup.OPT_PROPERTIES)
+ self.OPT_PROPERTIES)
class OptionalData(IData):
--
1.8.3.1