After discussion on the mailing list it came to light that the
whole notion of optional data is more of a hinderence than a
benefit. This library needs to be easy and straight forward
to use.
I renamed the C lsm_optional_data to lsm_hash as we are using it
for parsing uri and use the hash for query string parameters.
"No matter how far down the wrong road you’ve gone, turn back."
Signed-off-by: Tony Asleson <***@redhat.com>
---
c_binding/include/libstoragemgmt/libstoragemgmt.h | 27 +-
.../include/libstoragemgmt/libstoragemgmt_disk.h | 8 -
.../include/libstoragemgmt/libstoragemgmt_error.h | 2 +-
.../include/libstoragemgmt/libstoragemgmt_fs.h | 7 -
.../libstoragemgmt/libstoragemgmt_nfsexport.h | 11 -
.../libstoragemgmt/libstoragemgmt_optionaldata.h | 144 +-------
.../libstoragemgmt/libstoragemgmt_plug_interface.h | 27 +-
.../include/libstoragemgmt/libstoragemgmt_pool.h | 7 -
.../libstoragemgmt/libstoragemgmt_snapshot.h | 7 -
.../libstoragemgmt/libstoragemgmt_systems.h | 6 -
.../include/libstoragemgmt/libstoragemgmt_types.h | 48 +--
.../libstoragemgmt/libstoragemgmt_volumes.h | 8 -
c_binding/lsm_convert.cpp | 172 +--------
c_binding/lsm_convert.hpp | 14 -
c_binding/lsm_datatypes.cpp | 393 +++------------------
c_binding/lsm_datatypes.hpp | 28 +-
c_binding/lsm_plugin_ipc.cpp | 8 +-
doc/man/lsmcli.1.in | 7 +-
plugin/nstor/nstor.py | 41 +--
plugin/ontap/ontap.py | 88 ++---
plugin/sim/simarray.py | 55 ++-
plugin/sim/simulator.py | 3 +-
plugin/simc/simc_lsmplugin.c | 67 ++--
plugin/smispy/smis.py | 102 +-----
plugin/targetd/targetd.py | 33 +-
plugin/v7k/ibmv7k.py | 3 +-
python_binding/lsm/__init__.py | 2 +-
python_binding/lsm/_common.py | 1 -
python_binding/lsm/_data.py | 91 +----
test/plugin_test.py | 13 +-
test/tester.c | 122 +------
tools/lsmcli/cmdline.py | 78 +---
tools/lsmcli/data_display.py | 82 -----
33 files changed, 253 insertions(+), 1452 deletions(-)
diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt.h b/c_binding/include/libstoragemgmt/libstoragemgmt.h
index c646899..754dca0 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt.h
@@ -31,7 +31,6 @@
#include "libstoragemgmt_fs.h"
#include "libstoragemgmt_initiators.h"
#include "libstoragemgmt_nfsexport.h"
-#include "libstoragemgmt_optionaldata.h"
#include "libstoragemgmt_pool.h"
#include "libstoragemgmt_snapshot.h"
#include "libstoragemgmt_systems.h"
@@ -230,8 +229,7 @@ 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 Use LSM_POOL_FLAG_RETRIEVE_FULL_INFO
- * for all data, else 0
+ * @param[in] flags Reserved, set to 0
* @return LSM_ERR_OK on success else error reason
*/
int LSM_DLL_EXPORT lsm_pool_list(lsm_connect *conn, char *search_key,
@@ -372,8 +370,7 @@ 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 Use LSM_VOLUME_FLAG_RETRIEVE_FULL_INFO
- * for all data, else 0
+ * @param[in] flags Reserved set to 0
* @return LSM_ERR_OK on success else error reason
*/
int LSM_DLL_EXPORT lsm_volume_list(lsm_connect *conn,
@@ -390,8 +387,7 @@ 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_FLAG_RETRIEVE_FULL_INFO
- * for all data, else 0
+ * @param [in] flags Reserved set to zero
* @return LSM_ERR_OK on success else error reason
*/
int LSM_DLL_EXPORT lsm_disk_list(lsm_connect *conn, const char * search_key,
@@ -570,8 +566,7 @@ 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 Use LSM_ACCESS_GROUP_FLAG_RETRIEVE_FULL_INFO
- * for all data, else 0
+ * @param[in] flags Reserved set to zero
* @return LSM_ERR_OK on success, else error reason.
*/
int LSM_DLL_EXPORT lsm_access_group_list(lsm_connect *conn,
@@ -755,9 +750,8 @@ extern "C" {
* NOTE: Free returned systems by calling to lsm
* @param[in] conn Valid connection
* @param[out] systems Array of lsm_system
- * @param[out] system_count Number of systems
- * @param[in] flags Use LSM_SYSTEM_FLAG_RETRIEVE_FULL_INFO
- * for all data, else 0
+ * @param[out] system_count Number of systems
+ * @param[in] flags Reserved set to zero
* @return LSM_ERR_OK on success, else error reason
*/
int LSM_DLL_EXPORT lsm_system_list(lsm_connect *conn, lsm_system **systems[],
@@ -770,8 +764,7 @@ 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 Use LSM_FS_FLAG_RETRIEVE_FULL_INFO
- * for all data, else 0
+ * @param[in] flags Reserved set to zero
* @return LSM_ERR_OK on success, else error reason
*/
int LSM_DLL_EXPORT lsm_fs_list(lsm_connect *conn, const char *search_key,
@@ -890,8 +883,7 @@ extern "C" {
* @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
+ * @param[in] flags Reserved set to zero
* @return LSM_ERR_OK on success, else error reason
*/
int LSM_DLL_EXPORT lsm_fs_ss_list(lsm_connect *conn, lsm_fs *fs,
@@ -965,8 +957,7 @@ 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 Use LSM_NFS_FLAG_RETRIEVE_FULL_INFO
- * for all data, else 0
+ * @param[in] flags Reserved set to zero
* @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_disk.h b/c_binding/include/libstoragemgmt/libstoragemgmt_disk.h
index 5deb36a..f59c302 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_disk.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_disk.h
@@ -112,14 +112,6 @@ uint64_t LSM_DLL_EXPORT lsm_disk_status_get(lsm_disk *d);
*/
const char LSM_DLL_EXPORT *lsm_disk_system_id_get(lsm_disk *d);
-/**
- * Retrieve optional data for this disk
- * @param d Valid lsm_disk pointer
- * @return NULL if no optional data exists.
- */
-lsm_optional_data LSM_DLL_EXPORT *lsm_disk_optional_data_get(lsm_disk *d);
-
-
#ifdef __cplusplus
}
#endif
diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_error.h b/c_binding/include/libstoragemgmt/libstoragemgmt_error.h
index 68954c8..eab9d2c 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_error.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_error.h
@@ -79,7 +79,7 @@ typedef enum {
LSM_ERR_INVALID_SYSTEM = 117, /**< Invalid system pointer */
LSM_ERR_INVALID_IQN = 118, /**< Invalid IQN */
LSM_ERR_INVALID_DISK = 119, /**< Invalid disk */
- LSM_ERR_INVALID_OPTIONAL_DATA = 120,/**< Invalid optional data */
+ LSM_ERR_INVALID_HASH = 120, /**< Invalid optional data */
LSM_ERR_INVALID_BLOCK_RANGE = 121, /**< Invalud block range */
LSM_ERR_IS_MAPPED = 125, /**< Mapping already exists */
diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_fs.h b/c_binding/include/libstoragemgmt/libstoragemgmt_fs.h
index 5524603..b400453 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_fs.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_fs.h
@@ -90,13 +90,6 @@ uint64_t LSM_DLL_EXPORT lsm_fs_total_space_get(lsm_fs *fs);
*/
uint64_t LSM_DLL_EXPORT lsm_fs_free_space_get(lsm_fs *fs);
-/**
- * Retrieves the optional data for a file system.
- * @param fs fs ptr.
- * @return Optional_data, else NULL if not present.
- */
-lsm_optional_data LSM_DLL_EXPORT *lsm_fs_optional_data_get( lsm_fs *fs );
-
#ifdef __cplusplus
}
#endif
diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_nfsexport.h b/c_binding/include/libstoragemgmt/libstoragemgmt_nfsexport.h
index b42d9a5..fedba24 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_nfsexport.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_nfsexport.h
@@ -44,7 +44,6 @@ extern "C" {
* @param anongid Group id that should be mapped to anonymous
* (Valid or set to ANON_UID_GID_NA)
* @param options String of options passed to array
- * @param optional_data Optional data
* @param plugin_data Reserved for plug-in use
* @return Valid export pointer, else NULL on error.
*/
@@ -58,7 +57,6 @@ lsm_nfs_export LSM_DLL_EXPORT * lsm_nfs_export_record_alloc(const char *id,
uint64_t anonuid,
uint64_t anongid,
const char *options,
- lsm_optional_data * optional_data,
const char * plugin_data);
/**
@@ -180,15 +178,6 @@ const char LSM_DLL_EXPORT *lsm_nfs_export_options_get( lsm_nfs_export *exp);
int LSM_DLL_EXPORT lsm_nfs_export_options_set( lsm_nfs_export *exp,
const char *value);
-
-/**
- * Retrieve optional data.
- * @param exp Valid nfs export
- * @return optional data, else NULL
- */
-lsm_optional_data LSM_DLL_EXPORT *lsm_nfs_export_optional_data_get(
- lsm_nfs_export *exp );
-
#ifdef __cplusplus
}
#endif
diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_optionaldata.h b/c_binding/include/libstoragemgmt/libstoragemgmt_optionaldata.h
index 5128609..b9f11bf 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_optionaldata.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_optionaldata.h
@@ -18,8 +18,8 @@
*
*/
-#ifndef LIBSTORAGEMGMT_OPTIONALDATA_H
-#define LIBSTORAGEMGMT_OPTIONALDATA_H
+#ifndef LIBSTORAGEMGMT_HASH_H
+#define LIBSTORAGEMGMT_HASH_H
#include "libstoragemgmt_common.h"
@@ -27,40 +27,30 @@
extern "C" {
#endif
-typedef enum {
- LSM_OPTIONAL_DATA_INVALID = -2, /**< Invalid */
- LSM_OPTIONAL_DATA_NOT_FOUND = -1, /**< Key not found */
- LSM_OPTIONAL_DATA_STRING = 1, /**< Contains a string */
- LSM_OPTIONAL_DATA_SIGN_INT = 2, /**< Contains a signed int */
- LSM_OPTIONAL_DATA_UNSIGNED_INT = 3, /**< Contains an unsigned int */
- LSM_OPTIONAL_DATA_REAL = 4, /**< Contains a real number */
- LSM_OPTIONAL_DATA_STRING_LIST = 10 /**< Contains a list of strings*/
-} lsm_optional_data_type;
-
+/**
+ * Simple hash table which only stores character strings.
+ */
/**
- * Returns the type of data stored.
- * @param op Record
- * @param key Key to lookup
- * @return One of the enumerated types above.
+ * Allocate storage for hash.
+ * @return Allocated record or NULL on memory allocation failure
*/
-lsm_optional_data_type LSM_DLL_EXPORT lsm_optional_data_type_get(
- lsm_optional_data *op, const char *key);
+lsm_hash LSM_DLL_EXPORT *lsm_hash_alloc(void);
/**
- * Free a optional data record
+ * Free a lsm hash
* @param op Record to free.
* @return LSM_ERR_OK on success, else error reason.
*/
-int LSM_DLL_EXPORT lsm_optional_data_record_free(lsm_optional_data *op);
+int LSM_DLL_EXPORT lsm_hash_free(lsm_hash *op);
/**
- * Get the list of 'keys' available in the optional data
+ * Get the list of 'keys' available in the hash
* @param [in] op Valid optional data pointer
* @param [out] l String list pointer
* @return LSM_ERR_OK on success, else error reason
*/
-int LSM_DLL_EXPORT lsm_optional_data_keys(lsm_optional_data *op,
+int LSM_DLL_EXPORT lsm_hash_keys(lsm_hash *op,
lsm_string_list **l);
/**
@@ -70,7 +60,7 @@ int LSM_DLL_EXPORT lsm_optional_data_keys(lsm_optional_data *op,
* @return Pointer to value, pointer valid until optional data memory
* gets released.
*/
-const char LSM_DLL_EXPORT *lsm_optional_data_string_get(lsm_optional_data *op,
+const char LSM_DLL_EXPORT *lsm_hash_string_get(lsm_hash *op,
const char *key);
/**
@@ -81,117 +71,19 @@ const char LSM_DLL_EXPORT *lsm_optional_data_string_get(lsm_optional_data *op,
* @param [in] value Value of new key (string is duped)
* @return LSM_ERR_OK on success, else error reason
*/
-int LSM_DLL_EXPORT lsm_optional_data_string_set(lsm_optional_data *op,
+int LSM_DLL_EXPORT lsm_hash_string_set(lsm_hash *op,
const char *key,
const char *value);
/**
- * Does a copy of an lsm_optional_data
- * @param src lsm_optional_data to copy
+ * Does a copy of an lsm_hash
+ * @param src lsm_hash to copy
* @return NULL on error/memory allocation failure, else copy
*/
-lsm_optional_data LSM_DLL_EXPORT *lsm_optional_data_record_copy(
- lsm_optional_data *src);
-
-/**
- * Set the value of a key with a signed integer
- * @param[in] op Valid optional data pointer
- * @param[in] key Key to set value for (key is copied)
- * @param[in] value Value to set
- * @return LSM_ERR_OK on success, else error reason
- */
-int LSM_DLL_EXPORT lsm_optional_data_int64_set(lsm_optional_data *op,
- const char *key,
- int64_t value);
-
-/**
- * Get the value of the key which is a int64.
- * Note: lsm_optional_data_type_get needs to return LSM_OPTIONAL_DATA_SIGN_INT
- * before it is valid to call this function.
- * @param op
- * @param key
- * @return Value, MAX on errors. To determine if value is valid call
- * lsm_optional_data_type_get first, then you are ensured return value is
- * correct.
- */
-int64_t LSM_DLL_EXPORT lsm_optional_data_int64_get(lsm_optional_data *op,
- const char *key);
-
-/**
- * Set the value of a key with an unsigned integer
- * @param[in] op Valid optional data pointer
- * @param[in] key Key to set value for (key is copied)
- * @param[in] value Value to set
- * @return LSM_ERR_OK on success, else error reason
- */
-int LSM_DLL_EXPORT lsm_optional_data_uint64_set(lsm_optional_data *op,
- const char *key,
- uint64_t value);
-
-/**
- * Get the value of the key which is a uint64.
- * Note: lsm_optional_data_type_get needs to return
- * LSM_OPTIONAL_DATA_UNSIGNED_INT before it is valid to call this function.
- * @param [in] op Valid optional data pointer
- * @param [in] key Key that exists
- * @return Value, MAX on errors. To determine if value is valid call
- * lsm_optional_data_type_get first, then you are ensured return value is
- * correct.
- */
-uint64_t LSM_DLL_EXPORT lsm_optional_data_uint64_get(lsm_optional_data *op,
- const char *key);
-
-/**
- * Set the value of a key with a real number
- * @param[in] op Valid optional data pointer
- * @param[in] key Key to set value for (key is copied)
- * @param[in] value Value to set
- * @return LSM_ERR_OK on success, else error reason
- */
-int LSM_DLL_EXPORT lsm_optional_data_real_set(lsm_optional_data *op,
- const char *key,
- long double value);
-
-/**
- * Get the value of the key which is a real.
- * Note: lsm_optional_data_type_get needs to return
- * LSM_OPTIONAL_DATA_REAL before it is valid to call this function.
- * @param [in] op Valid optional data pointer
- * @param [in] key Key that exists
- * @return Value, MAX on errors. To determine if value is valid call
- * lsm_optional_data_type_get first, then you are ensured return value is
- * correct.
- */
-long double LSM_DLL_EXPORT lsm_optional_data_real_get(lsm_optional_data *op,
- const char *key);
-
-
-/**
- * Set the value of a key with a string list
- * @param[in] op Valid optional data pointer
- * @param[in] key Key to set value for (key is copied)
- * @param[in] value Value to set
- * @return LSM_ERR_OK on success, else error reason
- */
-int LSM_DLL_EXPORT lsm_optional_data_string_list_set(lsm_optional_data *op,
- const char *key,
- lsm_string_list *sl);
-
-/**
- * Get the value of the key which is a string list.
- * Note: lsm_optional_data_type_get needs to return
- * LSM_OPTIONAL_DATA_STRING_LIST before it is valid to call this function.
- * @param [in] op Valid optional data pointer
- * @param [in] key Key that exists
- * @return Value, NULL on errors. To determine if value is valid call
- * lsm_optional_data_type_get first, then you are ensured return value is
- * correct.
- */
-lsm_string_list LSM_DLL_EXPORT *lsm_optional_data_string_list_get(
- lsm_optional_data *op, const char *key);
+lsm_hash LSM_DLL_EXPORT *lsm_hash_copy(lsm_hash *src);
#ifdef __cplusplus
}
#endif
-#endif /* LIBSTORAGEMGMT_OPTIONALDATA_H */
+#endif /* LIBSTORAGEMGMT_HASH_H */
diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h b/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h
index e762685..d22fb15 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h
@@ -29,6 +29,7 @@
#include "libstoragemgmt_fs.h"
#include "libstoragemgmt_initiators.h"
#include "libstoragemgmt_nfsexport.h"
+#include "libstoragemgmt_optionaldata.h"
#include "libstoragemgmt_pool.h"
#include "libstoragemgmt_snapshot.h"
#include "libstoragemgmt_systems.h"
@@ -1078,7 +1079,6 @@ void LSM_DLL_EXPORT lsm_pool_free_space_set(lsm_pool *p, uint64_t free_space);
* @param status Pool status, bit field (See LSM_POOL_STATUS_XXXX constants)
* @param status_info Additional textual information on status
* @param system_id System id
- * @param optiona_data Optional data
* @param plugin_data Reserved for plugin writer use
* @return LSM_ERR_OK on success, else error reason.
*/
@@ -1087,7 +1087,6 @@ lsm_pool LSM_DLL_EXPORT *lsm_pool_record_alloc(const char *id, const char *name,
uint64_t free_space,
uint64_t status, const char* status_info,
const char *system_id,
- lsm_optional_data *optional_data,
const char * plugin_data);
/**
@@ -1139,14 +1138,12 @@ lsm_disk LSM_DLL_EXPORT **lsm_disk_record_array_alloc( uint32_t size );
* @param block_size Number of bytes per logical block
* @param block_count Number of blocks for disk
* @param disk_status Status
- * @param op lsm_optional_data can be NULL if not available
- * NOTE: op gets copied internally
* @param system_id System id this disk resides in
* @return Pointer to allocated disk record or NULL on memory error.
*/
lsm_disk LSM_DLL_EXPORT *lsm_disk_record_alloc(const char *id, const char *name,
lsm_disk_type disk_type, uint64_t block_size, uint64_t block_count,
- uint64_t disk_status, lsm_optional_data *op, const char *system_id);
+ uint64_t disk_status, const char *system_id);
/**
* Allocated the storage needed for one volume record.
@@ -1158,7 +1155,6 @@ lsm_disk LSM_DLL_EXPORT *lsm_disk_record_alloc(const char *id, const char *name,
* @param status Volume status
* @param system_id System id
* @param pool_id Pool id this volume is created from
- * @param optional_data Optional data
* @param plugin_data Private data for plugin use
* @return Allocated memory or NULL on error.
*/
@@ -1169,7 +1165,6 @@ lsm_volume LSM_DLL_EXPORT *lsm_volume_record_alloc(const char *id,
uint32_t status,
const char *system_id,
const char *pool_id,
- lsm_optional_data* optional_data,
const char* plugin_data);
/**
@@ -1192,7 +1187,6 @@ lsm_system LSM_DLL_EXPORT **lsm_system_record_array_alloc( uint32_t size );
* @param[in] name System name (human readable)
* @param[in] status Status of the system
* @oaram[in] status_info Additional text for status
- * @param[in] optional_data Optional data
* @param[in] plugin_data Private plugin data
* @return Allocated memory or NULL on error.
*/
@@ -1200,7 +1194,6 @@ lsm_system LSM_DLL_EXPORT *lsm_system_record_alloc(const char *id,
const char *name,
uint32_t status,
const char *status_info,
- lsm_optional_data *optional_data,
const char* plugin_data);
/**
@@ -1224,7 +1217,6 @@ lsm_access_group LSM_DLL_EXPORT **lsm_access_group_record_array_alloc( uint32_t
* @param name Name of access group
* @param initiators List of initiators, can be NULL
* @param system_id System id
- * @param optional_data Optional data
* @param plugin_data Reserved for plug-in use only
* @return NULL on error, else valid lsm_access_group pointer.
*/
@@ -1233,7 +1225,6 @@ lsm_access_group LSM_DLL_EXPORT * lsm_access_group_record_alloc(const char *id,
lsm_string_list *initiators,
lsm_access_group_init_type init_type,
const char *system_id,
- lsm_optional_data *optional_data,
const char *plugin_data);
@@ -1253,7 +1244,6 @@ void LSM_DLL_EXPORT lsm_access_group_initiator_id_set( lsm_access_group *group,
* @param free_space Free space
* @param pool_id Pool id
* @param system_id System id
- * @param optional_data Optional data
* @param plugin_data Reserved for plug-in use only
* @return lsm_fs, NULL on error
*/
@@ -1262,7 +1252,6 @@ lsm_fs LSM_DLL_EXPORT *lsm_fs_record_alloc(const char *id, const char *name,
uint64_t free_space,
const char *pool_id,
const char *system_id,
- lsm_optional_data * optional_data,
const char* plugin_data);
/**
@@ -1284,14 +1273,12 @@ const char *lsm_fs_plugin_data_get(lsm_fs *fs);
* @param id ID
* @param name Name
* @param ts Epoch time stamp when snapshot was created
- * @param optional_data Optional data
* @param plugin_data Private plugin data
* @return Allocated memory, NULL on error
*/
lsm_fs_ss LSM_DLL_EXPORT *lsm_fs_ss_record_alloc(const char *id,
const char *name,
uint64_t ts,
- lsm_optional_data *optional_data,
const char * plugin_data);
/**
@@ -1337,14 +1324,6 @@ int LSM_DLL_EXPORT lsm_capability_set_n( lsm_storage_capabilities *cap,
*/
lsm_storage_capabilities LSM_DLL_EXPORT *lsm_capability_record_alloc(char const *value);
-
-/**
- * Allocate storage for optional data.
- * @return Allocated record or NULL on memory allocation failure
- */
-lsm_optional_data LSM_DLL_EXPORT *lsm_optional_data_record_alloc(void);
-
-
/**
* Convenience function for plug-in writer.
* Note: Make sure to free returned items to prevent memory leaks.
@@ -1358,7 +1337,7 @@ lsm_optional_data LSM_DLL_EXPORT *lsm_optional_data_record_alloc(void);
*/
int LSM_DLL_EXPORT lsm_uri_parse(const char *uri, char **scheme, char **user,
char **server, int *port, char **path,
- lsm_optional_data **query_params);
+ lsm_hash **query_params);
/**
* Provides for volume filtering when an array doesn't support this natively.
diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_pool.h b/c_binding/include/libstoragemgmt/libstoragemgmt_pool.h
index 1e8f0a5..61ebccf 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_pool.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_pool.h
@@ -100,13 +100,6 @@ const char LSM_DLL_EXPORT *lsm_pool_status_info_get( lsm_pool *s );
*/
char LSM_DLL_EXPORT *lsm_pool_system_id_get( lsm_pool *p );
-/**
- * Retrieve the optional data for the specified pool
- * @param p Pool pointer
- * @return Pointer to optional data
- */
-lsm_optional_data *lsm_pool_optional_data_get( lsm_pool *p );
-
#ifdef __cplusplus
}
#endif
diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_snapshot.h b/c_binding/include/libstoragemgmt/libstoragemgmt_snapshot.h
index 144ed0b..393596b 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_snapshot.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_snapshot.h
@@ -69,13 +69,6 @@ const char LSM_DLL_EXPORT *lsm_fs_ss_name_get(lsm_fs_ss *ss);
*/
uint64_t LSM_DLL_EXPORT lsm_fs_ss_time_stamp_get(lsm_fs_ss *ss);
-/**
- * Retrieve the optional data
- * @param ss The file system snapshot record
- * @return optional data, else NULL if it doesn't exist.
- */
-lsm_optional_data LSM_DLL_EXPORT *lsm_fs_ss_optional_data_get(lsm_fs_ss *ss);
-
#ifdef __cplusplus
}
#endif
diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_systems.h b/c_binding/include/libstoragemgmt/libstoragemgmt_systems.h
index e700e25..c2bca11 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_systems.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_systems.h
@@ -75,12 +75,6 @@ const char LSM_DLL_EXPORT *lsm_system_name_get(lsm_system *s);
*/
uint32_t LSM_DLL_EXPORT lsm_system_status_get(lsm_system *s);
-/**
- * Retrieve the optional data for the system.
- * @param s System to retrieve optional data
- * @return optional_data, NULL if none exists
- */
-lsm_optional_data LSM_DLL_EXPORT *lsm_system_optional_data_get(lsm_system *s);
#ifdef __cplusplus
}
diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_types.h b/c_binding/include/libstoragemgmt/libstoragemgmt_types.h
index 533f887..fb2f99a 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_types.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_types.h
@@ -107,7 +107,7 @@ typedef struct _lsm_disk lsm_disk;
/**
* Optional data type
*/
-typedef struct _lsm_optional_data lsm_optional_data;
+typedef struct _lsm_hash lsm_hash;
/**< \enum lsm_replication_type Different types of replications that can be created */
typedef enum {
@@ -152,12 +152,6 @@ 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.
*/
@@ -173,12 +167,6 @@ typedef enum {
#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 */
@@ -200,11 +188,6 @@ 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 {
@@ -238,11 +221,6 @@ typedef enum {
LSM_DISK_TYPE_HYBRID = 54,
} lsm_disk_type;
-/**
- * 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
@@ -276,12 +254,6 @@ 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,
@@ -321,24 +293,6 @@ 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/include/libstoragemgmt/libstoragemgmt_volumes.h b/c_binding/include/libstoragemgmt/libstoragemgmt_volumes.h
index 5d77844..303d287 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_volumes.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_volumes.h
@@ -107,14 +107,6 @@ char LSM_DLL_EXPORT *lsm_volume_system_id_get( lsm_volume *v);
*/
char LSM_DLL_EXPORT *lsm_volume_pool_id_get( lsm_volume *v);
-
-/**
- * Retrieves the optional data for a volume.
- * @param v Volume ptr.
- * @return Optional_data, else NULL if not present.
- */
-lsm_optional_data LSM_DLL_EXPORT *lsm_volume_optional_data_get( lsm_volume *v );
-
#ifdef __cplusplus
}
#endif
diff --git a/c_binding/lsm_convert.cpp b/c_binding/lsm_convert.cpp
index 8bb8684..8ab943f 100644
--- a/c_binding/lsm_convert.cpp
+++ b/c_binding/lsm_convert.cpp
@@ -19,7 +19,6 @@
#include "lsm_convert.hpp"
#include "libstoragemgmt/libstoragemgmt_accessgroups.h"
-#include "libstoragemgmt/libstoragemgmt_optionaldata.h"
#include <libstoragemgmt/libstoragemgmt_blockrange.h>
#include <libstoragemgmt/libstoragemgmt_nfsexport.h>
@@ -35,21 +34,12 @@ static bool is_expected_object(Value &obj, std::string class_name)
return false;
}
-static lsm_optional_data *get_optional(std::map<std::string, Value> &v)
-{
- lsm_optional_data *op = NULL;
- Value opv = v["optional_data"];
- op = value_to_optional_data(opv);
- return op;
-}
-
lsm_volume *value_to_volume(Value &vol)
{
lsm_volume *rc = NULL;
if (is_expected_object(vol, "Volume")) {
std::map<std::string, Value> v = vol.asObject();
- lsm_optional_data *op = get_optional(v);
rc = lsm_volume_record_alloc(v["id"].asString().c_str(),
v["name"].asString().c_str(),
@@ -59,11 +49,7 @@ lsm_volume *value_to_volume(Value &vol)
v["status"].asUint32_t(),
v["system_id"].asString().c_str(),
v["pool_id"].asString().c_str(),
- op,
v["plugin_data"].asC_str());
-
- /* Optional data gets copied so free */
- lsm_optional_data_record_free(op);
}
return rc;
@@ -82,7 +68,6 @@ Value volume_to_value(lsm_volume *vol)
v["status"] = Value(vol->status);
v["system_id"] = Value(vol->system_id);
v["pool_id"] = Value(vol->pool_id);
- v["optional_data"] = optional_data_to_value(vol->optional_data);
v["plugin_data"] = Value(vol->plugin_data);
return Value(v);
}
@@ -130,21 +115,15 @@ lsm_disk *value_to_disk(Value &disk)
lsm_disk *rc = NULL;
if (is_expected_object(disk, "Disk")) {
std::map<std::string, Value> d = disk.asObject();
- lsm_optional_data *op = get_optional(d);
- rc = lsm_disk_record_alloc(
- d["id"].asString().c_str(),
+ rc = lsm_disk_record_alloc(d["id"].asString().c_str(),
d["name"].asString().c_str(),
(lsm_disk_type)d["disk_type"].asInt32_t(),
d["block_size"].asUint64_t(),
d["num_of_blocks"].asUint64_t(),
d["status"].asUint64_t(),
- op,
d["system_id"].asString().c_str()
);
-
- /* Optional data gets copied in lsmDiskRecordAlloc */
- lsm_optional_data_record_free(op);
}
return rc;
}
@@ -162,7 +141,6 @@ Value disk_to_value(lsm_disk *disk)
d["num_of_blocks"] = Value(disk->block_count);
d["status"] = Value(disk->disk_status);
d["system_id"] = Value(disk->system_id);
- d["optional_data"] = optional_data_to_value(disk->optional_data);
return Value(d);
}
@@ -238,7 +216,6 @@ lsm_pool *value_to_pool(Value &pool)
if (is_expected_object(pool, "Pool")) {
std::map<std::string, Value> i = pool.asObject();
- lsm_optional_data *op = get_optional(i);
rc = lsm_pool_record_alloc(i["id"].asString().c_str(),
i["name"].asString().c_str(),
@@ -247,10 +224,7 @@ lsm_pool *value_to_pool(Value &pool)
i["status"].asUint64_t(),
i["status_info"].asString().c_str(),
i["system_id"].asString().c_str(),
- op,
i["plugin_data"].asC_str());
-
- lsm_optional_data_record_free(op);
}
return rc;
}
@@ -267,7 +241,6 @@ Value pool_to_value(lsm_pool *pool)
p["status"] = Value(pool->status);
p["status_info"] = Value(pool->status_info);
p["system_id"] = Value(pool->system_id);
- p["optional_data"] = optional_data_to_value(pool->optional_data);
p["plugin_data"] = Value(pool->plugin_data);
return Value(p);
}
@@ -279,16 +252,12 @@ lsm_system *value_to_system(Value &system)
lsm_system *rc = NULL;
if (is_expected_object(system, "System")) {
std::map<std::string, Value> i = system.asObject();
- lsm_optional_data *op = get_optional(i);
rc = lsm_system_record_alloc(i["id"].asString().c_str(),
i["name"].asString().c_str(),
i["status"].asUint32_t(),
i["status_info"].asString().c_str(),
- op,
i["plugin_data"].asC_str());
-
- lsm_optional_data_record_free(op);
}
return rc;
}
@@ -302,7 +271,6 @@ Value system_to_value(lsm_system *system)
s["name"] = Value(system->name);
s["status"] = Value(system->status);
s["status_info"] = Value(system->status_info);
- s["optional_data"] = optional_data_to_value(system->optional_data);
s["plugin_data"] = Value(system->plugin_data);
return Value(s);
}
@@ -348,26 +316,21 @@ lsm_access_group *value_to_access_group( Value &group )
{
lsm_string_list *il = NULL;
lsm_access_group *ag = NULL;
- lsm_optional_data *op = NULL;
if( is_expected_object(group, "AccessGroup")) {
std::map<std::string, Value> vAg = group.asObject();
il = value_to_string_list(vAg["init_ids"]);
- op = get_optional(vAg);
if( il ) {
- ag = lsm_access_group_record_alloc(
- vAg["id"].asString().c_str(),
+ ag = lsm_access_group_record_alloc(vAg["id"].asString().c_str(),
vAg["name"].asString().c_str(),
il,
(lsm_access_group_init_type)vAg["init_type"].asInt32_t(),
vAg["system_id"].asString().c_str(),
- op,
vAg["plugin_data"].asC_str());
}
/* This stuff is copied in lsm_access_group_record_alloc */
lsm_string_list_free(il);
- lsm_optional_data_record_free(op);
}
return ag;
}
@@ -383,7 +346,6 @@ Value access_group_to_value( lsm_access_group *group )
ag["init_type"] = Value(group->init_type);
ag["system_id"] = Value(group->system_id);
ag["plugin_data"] = Value(group->plugin_data);
- ag["optional_data"] = optional_data_to_value(group->optional_data);
return Value(ag);
}
return Value();
@@ -490,7 +452,6 @@ lsm_fs *value_to_fs(Value &fs)
lsm_fs *rc = NULL;
if( is_expected_object(fs, "FileSystem") ) {
std::map<std::string, Value> f = fs.asObject();
- lsm_optional_data *op = get_optional(f);
rc = lsm_fs_record_alloc(f["id"].asString().c_str(),
f["name"].asString().c_str(),
@@ -498,10 +459,7 @@ lsm_fs *value_to_fs(Value &fs)
f["free_space"].asUint64_t(),
f["pool_id"].asString().c_str(),
f["system_id"].asString().c_str(),
- op,
f["plugin_data"].asC_str());
-
- lsm_optional_data_record_free(op);
}
return rc;
}
@@ -517,7 +475,6 @@ Value fs_to_value(lsm_fs *fs)
f["free_space"] = Value(fs->free_space);
f["pool_id"] = Value(fs->pool_id);
f["system_id"] = Value(fs->system_id);
- f["optional_data"] = optional_data_to_value(fs->optional_data);
f["plugin_data"] = Value(fs->plugin_data);
return Value(f);
}
@@ -530,14 +487,11 @@ lsm_fs_ss *value_to_ss(Value &ss)
lsm_fs_ss *rc = NULL;
if( is_expected_object(ss, "FsSnapshot") ) {
std::map<std::string, Value> f = ss.asObject();
- lsm_optional_data *op = get_optional(f);
rc = lsm_fs_ss_record_alloc(f["id"].asString().c_str(),
f["name"].asString().c_str(),
- f["ts"].asUint64_t(), op,
+ f["ts"].asUint64_t(),
f["plugin_data"].asC_str());
-
- lsm_optional_data_record_free(op);
}
return rc;
}
@@ -550,7 +504,6 @@ Value ss_to_value(lsm_fs_ss *ss)
f["id"] = Value(ss->id);
f["name"] = Value(ss->name);
f["ts"] = Value(ss->ts);
- f["optional_data"] = optional_data_to_value(ss->optional_data);
f["plugin_data"] = Value(ss->plugin_data);
return Value(f);
}
@@ -589,8 +542,6 @@ lsm_nfs_export *value_to_nfs_export(Value &exp)
}
if( ok ) {
- lsm_optional_data *op = get_optional(i);
-
rc = lsm_nfs_export_record_alloc(i["id"].asC_str(),
i["fs_id"].asC_str(),
i["export_path"].asC_str(),
@@ -601,13 +552,11 @@ lsm_nfs_export *value_to_nfs_export(Value &exp)
i["anonuid"].asUint64_t(),
i["anongid"].asUint64_t(),
i["options"].asC_str(),
- op,
i["plugin_data"].asC_str());
lsm_string_list_free(root);
lsm_string_list_free(rw);
lsm_string_list_free(ro);
- lsm_optional_data_record_free(op);
}
}
return rc;
@@ -628,7 +577,6 @@ Value nfs_export_to_value(lsm_nfs_export *exp)
f["anonuid"] = Value(exp->anonuid);
f["anongid"] = Value(exp->anongid);
f["options"] = Value(exp->options);
- f["optional_data"] = optional_data_to_value(exp->optional_data);
f["plugin_data"] = Value(exp->plugin_data);
return Value(f);
}
@@ -658,117 +606,3 @@ Value capabilities_to_value(lsm_storage_capabilities *cap)
}
return Value();
}
-
-lsm_optional_data *value_to_optional_data(Value &op)
-{
- lsm_optional_data *rc = NULL;
- int set_result = 0;
- if( is_expected_object(op, "OptionalData") ) {
- rc = lsm_optional_data_record_alloc();
- if ( rc ) {
- std::map<std::string, Value> v = op["values"].asObject();
- std::map<std::string, Value>::iterator itr;
- for(itr=v.begin(); itr != v.end(); ++itr) {
- const char *key = itr->first.c_str();
- Value v = itr->second;
-
- //TODO: Check return codes of all these sets!
- switch(v.valueType()){
- case(Value::string_t): {
- set_result =
- lsm_optional_data_string_set(rc, key, v.asC_str());
- break;
- }
- case(Value::numeric_t): {
- int num_rc = 0;
- int64_t si = 0;
- uint64_t ui = 0;
- long double d = 0;
-
- num_rc = number_convert(v.asNumString(), &si, &ui, &d);
- if( num_rc > 0 ) {
- if( 1 == num_rc ) {
- set_result =
- lsm_optional_data_int64_set(rc, key, si);
- } else if( 2 == num_rc ) {
- set_result =
- lsm_optional_data_uint64_set(rc, key, ui);
- } else if( 3 == num_rc ) {
- set_result =
- lsm_optional_data_real_set(rc, key, ui);
- }
- }
- break;
- }
- case(Value::array_t): {
- lsm_string_list *sl = value_to_string_list(v);
- if( sl ) {
- set_result =
- lsm_optional_data_string_list_set(rc, key, sl);
- lsm_string_list_free(sl);
- }
- break;
- }
- default:
- break;
- }
-
- /* If the set failed free results and bail */
- if( LSM_ERR_OK != set_result ) {
- lsm_optional_data_record_free(rc);
- rc = NULL;
- break;
- }
- }
- }
- }
- return rc;
-}
-
-Value optional_data_to_value(lsm_optional_data *op)
-{
- GHashTableIter iter;
- gpointer key;
- gpointer value;
-
- if( LSM_IS_OPTIONAL_DATA(op) ) {
- std::map<std::string, Value> c;
- std::map<std::string, Value> embedded_values;
-
- g_hash_table_iter_init(&iter, op->data);
- while(g_hash_table_iter_next(&iter, &key, &value)) {
- struct optional_data *od = (struct optional_data *)value;
- switch( od->t ) {
- case( LSM_OPTIONAL_DATA_STRING ): {
- embedded_values[(const char*)key] = Value(od->v.s);
- break;
- }
- case( LSM_OPTIONAL_DATA_STRING_LIST ): {
- embedded_values[(const char*)key] =
- string_list_to_value(od->v.sl);
- break;
- }
- case( LSM_OPTIONAL_DATA_SIGN_INT ): {
- embedded_values[(const char*)key] = Value(od->v.si);
- break;
- }
- case( LSM_OPTIONAL_DATA_UNSIGNED_INT ): {
- embedded_values[(const char*)key] = Value(od->v.ui);
- break;
- }
- case( LSM_OPTIONAL_DATA_REAL ): {
- embedded_values[(const char*)key] = Value(od->v.d);
- break;
- }
- default:
- break;
- }
- }
-
- c["class"] = Value("OptionalData");
- c["values"] = Value(embedded_values);
-
- return Value(c);
- }
- return Value();
-}
diff --git a/c_binding/lsm_convert.hpp b/c_binding/lsm_convert.hpp
index 49d1310..c5563f8 100644
--- a/c_binding/lsm_convert.hpp
+++ b/c_binding/lsm_convert.hpp
@@ -245,18 +245,4 @@ lsm_storage_capabilities *value_to_capabilities(Value &exp);
*/
Value capabilities_to_value(lsm_storage_capabilities *cap);
-/**
- * Converts a value to optional data
- * @param op Value to convert to optional data
- * @return lsm_optional_data pointer or NULL on error
- */
-lsm_optional_data *value_to_optional_data(Value &op);
-
-/**
- * Converts a lsm_optional_data pointer to a value
- * @param[in] op optional data pointer to convert
- * @return Value representing optional data
- */
-Value optional_data_to_value(lsm_optional_data *op);
-
#endif
diff --git a/c_binding/lsm_datatypes.cpp b/c_binding/lsm_datatypes.cpp
index 9b004a9..6fca8b1 100644
--- a/c_binding/lsm_datatypes.cpp
+++ b/c_binding/lsm_datatypes.cpp
@@ -32,7 +32,6 @@
#include <libstoragemgmt/libstoragemgmt_fs.h>
#include <libstoragemgmt/libstoragemgmt_initiators.h>
#include <libstoragemgmt/libstoragemgmt_nfsexport.h>
-#include <libstoragemgmt/libstoragemgmt_optionaldata.h>
#include <libstoragemgmt/libstoragemgmt_plug_interface.h>
#include <libstoragemgmt/libstoragemgmt_pool.h>
#include <libstoragemgmt/libstoragemgmt_snapshot.h>
@@ -45,9 +44,6 @@
#include <unistd.h>
#include <dlfcn.h>
#include <glib.h>
-#include <errno.h>
-#include <float.h>
-#include <inttypes.h>
#ifdef __cplusplus
extern "C" {
@@ -507,7 +503,7 @@ CREATE_ALLOC_ARRAY_FUNC(lsm_pool_record_array_alloc, lsm_pool *)
lsm_pool *lsm_pool_record_alloc(const char *id, const char *name,
uint64_t totalSpace, uint64_t freeSpace, uint64_t status, const char* status_info,
- const char *system_id, lsm_optional_data* optional_data, const char * plugin_data)
+ const char *system_id, const char * plugin_data)
{
lsm_pool *rc = (lsm_pool *)calloc(1, sizeof(lsm_pool));
if (rc) {
@@ -519,14 +515,12 @@ lsm_pool *lsm_pool_record_alloc(const char *id, const char *name,
rc->status = status;
rc->status_info = strdup(status_info);
rc->system_id = strdup(system_id);
- rc->optional_data = lsm_optional_data_record_copy(optional_data);
if( plugin_data ) {
rc->plugin_data = strdup(plugin_data);
}
if( !rc->id || !rc->name || !rc->system_id || !rc->status_info ||
- (optional_data && !rc->optional_data) ||
(plugin_data && !rc->plugin_data)) {
lsm_pool_record_free(rc);
rc = NULL;
@@ -551,7 +545,6 @@ lsm_pool * lsm_pool_record_copy( lsm_pool *toBeCopied)
toBeCopied->status,
toBeCopied->status_info,
toBeCopied->system_id,
- toBeCopied->optional_data,
toBeCopied->plugin_data);
}
return NULL;
@@ -581,8 +574,6 @@ int lsm_pool_record_free(lsm_pool *p)
p->system_id = NULL;
}
- lsm_optional_data_record_free(p->optional_data);
- p->optional_data = NULL;
free(p->plugin_data);
p->plugin_data = NULL;
@@ -651,9 +642,6 @@ char *lsm_pool_system_id_get( lsm_pool *p )
return NULL;
}
-MEMBER_FUNC_GET(lsm_optional_data *, lsm_pool_optional_data_get, lsm_pool *p,
- p, LSM_IS_POOL, optional_data, NULL)
-
MEMBER_FUNC_GET(const char *, lsm_pool_plugin_data_get, lsm_pool *p,
p, LSM_IS_POOL, plugin_data, NULL)
@@ -734,8 +722,7 @@ CREATE_ALLOC_ARRAY_FUNC(lsm_volume_record_array_alloc, lsm_volume *)
lsm_volume * lsm_volume_record_alloc(const char *id, const char *name,
const char *vpd83, uint64_t blockSize,
uint64_t numberOfBlocks,
- uint32_t status, const char *system_id, const char *pool_id,
- lsm_optional_data* optional_data, const char* plugin_data)
+ uint32_t status, const char *system_id, const char *pool_id, const char* plugin_data)
{
lsm_volume *rc = (lsm_volume *)calloc(1, sizeof(lsm_volume));
if (rc) {
@@ -748,14 +735,13 @@ lsm_volume * lsm_volume_record_alloc(const char *id, const char *name,
rc->status = status;
rc->system_id = strdup(system_id);
rc->pool_id = strdup(pool_id);
- rc->optional_data = lsm_optional_data_record_copy(optional_data);
if( plugin_data ) {
rc->plugin_data = strdup(plugin_data);
}
if( !rc->id || !rc->name || !rc->vpd83 || !rc->system_id ||
- !rc->pool_id || (optional_data && !rc->optional_data) ||
+ !rc->pool_id ||
(plugin_data && !rc->plugin_data)) {
lsm_volume_record_free(rc);
rc = NULL;
@@ -768,7 +754,7 @@ CREATE_ALLOC_ARRAY_FUNC(lsm_disk_record_array_alloc, lsm_disk *)
lsm_disk *lsm_disk_record_alloc(const char *id, const char *name,
lsm_disk_type disk_type, uint64_t block_size, uint64_t block_count,
- uint64_t disk_status, lsm_optional_data *op, const char *system_id)
+ uint64_t disk_status, const char *system_id)
{
lsm_disk *rc = (lsm_disk *)malloc(sizeof(lsm_disk));
if( rc ) {
@@ -779,7 +765,6 @@ lsm_disk *lsm_disk_record_alloc(const char *id, const char *name,
rc->block_size = block_size;
rc->block_count = block_count;
rc->disk_status = disk_status;
- rc->optional_data = lsm_optional_data_record_copy(op);
rc->system_id = strdup(system_id);
if( !rc->id || !rc->name || !rc->system_id ) {
@@ -794,7 +779,6 @@ CREATE_ALLOC_ARRAY_FUNC(lsm_system_record_array_alloc, lsm_system *)
lsm_system *lsm_system_record_alloc(const char *id, const char *name,
uint32_t status, const char *status_info,
- lsm_optional_data *optional_data,
const char* plugin_data)
{
lsm_system *rc = (lsm_system *)calloc(1, sizeof(lsm_system));
@@ -804,14 +788,12 @@ lsm_system *lsm_system_record_alloc(const char *id, const char *name,
rc->name = strdup(name);
rc->status = status;
rc->status_info = strdup(status_info);
- rc->optional_data = lsm_optional_data_record_copy(optional_data);
if( plugin_data ) {
rc->plugin_data = strdup(plugin_data);
}
if( !rc->name || !rc->id || !rc->status_info ||
- (optional_data && !rc->optional_data) ||
(plugin_data && !rc->plugin_data)) {
lsm_system_record_free(rc);
rc = NULL;
@@ -840,7 +822,6 @@ int lsm_system_record_free(lsm_system *s)
s->status_info = NULL;
}
- lsm_optional_data_record_free(s->optional_data);
free(s->plugin_data);
free(s);
@@ -856,8 +837,7 @@ lsm_system *lsm_system_record_copy(lsm_system *s)
{
lsm_system *rc = NULL;
if( LSM_IS_SYSTEM(s) ) {
- rc = lsm_system_record_alloc(s->id, s->name, s->status, s->status_info,
- s->optional_data, s->plugin_data);
+ rc = lsm_system_record_alloc(s->id, s->name, s->status, s->status_info, s->plugin_data);
}
return rc;
}
@@ -886,9 +866,6 @@ uint32_t lsm_system_status_get(lsm_system *s)
return UINT32_MAX;
}
-MEMBER_FUNC_GET(lsm_optional_data *, lsm_system_optional_data_get,
- lsm_system *s, s, LSM_IS_SYSTEM, optional_data, NULL)
-
MEMBER_FUNC_GET(const char *, lsm_system_plugin_data_get, lsm_system *s,
s, LSM_IS_SYSTEM, plugin_data, NULL)
@@ -898,8 +875,7 @@ lsm_volume *lsm_volume_record_copy(lsm_volume *vol)
if( LSM_IS_VOL(vol) ) {
rc = lsm_volume_record_alloc(vol->id, vol->name, vol->vpd83,
vol->block_size, vol->number_of_blocks,
- vol->status, vol->system_id, vol->pool_id,
- vol->optional_data, vol->plugin_data);
+ vol->status, vol->system_id, vol->pool_id, vol->plugin_data);
}
return rc;
}
@@ -934,8 +910,6 @@ int lsm_volume_record_free(lsm_volume *v)
v->pool_id = NULL;
}
- lsm_optional_data_record_free(v->optional_data);
- v->optional_data = NULL;
free(v->plugin_data);
v->plugin_data = NULL;
@@ -952,8 +926,7 @@ lsm_disk *lsm_disk_record_copy(lsm_disk *disk)
{
if( LSM_IS_DISK(disk) ) {
return lsm_disk_record_alloc(disk->id, disk->name, disk->disk_type,
- disk->block_size, disk->block_count, disk->disk_status,
- disk->optional_data, disk->system_id);
+ disk->block_size, disk->block_count, disk->disk_status, disk->system_id);
}
return NULL;
}
@@ -972,9 +945,6 @@ int lsm_disk_record_free(lsm_disk *d)
free(d->system_id);
d->system_id = NULL;
- lsm_optional_data_record_free(d->optional_data);
- d->optional_data = NULL;
-
free(d);
return LSM_ERR_OK;
}
@@ -1051,7 +1021,6 @@ char *lsm_volume_pool_id_get( lsm_volume *v)
MEMBER_GET(v, LSM_IS_VOL, pool_id, NULL);
}
-MEMBER_FUNC_GET(lsm_optional_data *, lsm_volume_optional_data_get, lsm_volume *v, v, LSM_IS_VOL, optional_data, NULL)
MEMBER_FUNC_GET(const char *, lsm_volume_plugin_data_get, lsm_volume *v, v, LSM_IS_VOL, plugin_data, NULL)
const char *lsm_disk_id_get( lsm_disk *d)
@@ -1089,11 +1058,6 @@ const char *lsm_disk_system_id_get( lsm_disk *d)
MEMBER_GET(d, LSM_IS_DISK, system_id, NULL);
}
-lsm_optional_data *lsm_disk_optional_data_get(lsm_disk *d)
-{
- MEMBER_GET(d, LSM_IS_DISK, optional_data, NULL);
-}
-
CREATE_ALLOC_ARRAY_FUNC(lsm_access_group_record_array_alloc, lsm_access_group *)
lsm_access_group *lsm_access_group_record_alloc(const char *id,
@@ -1101,7 +1065,6 @@ lsm_access_group *lsm_access_group_record_alloc(const char *id,
lsm_string_list *initiators,
lsm_access_group_init_type init_type,
const char *system_id,
- lsm_optional_data *optional_data,
const char *plugin_data)
{
lsm_access_group *rc = NULL;
@@ -1114,7 +1077,6 @@ lsm_access_group *lsm_access_group_record_alloc(const char *id,
rc->system_id = strdup(system_id);
rc->initiators = lsm_string_list_copy(initiators);
rc->init_type = init_type;
- rc->optional_data = lsm_optional_data_record_copy(optional_data);
if( plugin_data ) {
rc->plugin_data = strdup(plugin_data);
@@ -1123,7 +1085,6 @@ lsm_access_group *lsm_access_group_record_alloc(const char *id,
}
if( !rc->id || !rc->name || !rc->system_id ||
- (optional_data && !rc->optional_data) ||
(plugin_data && !rc->plugin_data)) {
lsm_access_group_record_free(rc);
rc = NULL;
@@ -1139,8 +1100,7 @@ lsm_access_group *lsm_access_group_record_copy( lsm_access_group *ag )
if( LSM_IS_ACCESS_GROUP(ag) ) {
rc = lsm_access_group_record_alloc(ag->id, ag->name,
ag->initiators, ag->init_type,
- ag->system_id,
- ag->optional_data, ag->plugin_data);
+ ag->system_id, ag->plugin_data);
}
return rc;
}
@@ -1153,7 +1113,6 @@ int lsm_access_group_record_free(lsm_access_group *ag)
free(ag->name);
free(ag->system_id);
lsm_string_list_free(ag->initiators);
- lsm_optional_data_record_free(ag->optional_data);
free(ag->plugin_data);
free(ag);
return LSM_ERR_OK;
@@ -1278,7 +1237,6 @@ lsm_fs * lsm_fs_record_alloc(const char *id, const char *name,
uint64_t free_space,
const char *pool_id,
const char *system_id,
- lsm_optional_data *optional_data,
const char* plugin_data)
{
lsm_fs *rc = NULL;
@@ -1291,14 +1249,12 @@ lsm_fs * lsm_fs_record_alloc(const char *id, const char *name,
rc->system_id = strdup(system_id);
rc->total_space = total_space;
rc->free_space = free_space;
- rc->optional_data = lsm_optional_data_record_copy(optional_data);
if( plugin_data ) {
rc->plugin_data = strdup(plugin_data);
}
if( !rc->id || !rc->name || !rc->pool_id || !rc->system_id ||
- (optional_data && !rc->optional_data) ||
(plugin_data && !rc->plugin_data)) {
lsm_fs_record_free(rc);
rc = NULL;
@@ -1315,7 +1271,6 @@ int lsm_fs_record_free( lsm_fs *fs)
free(fs->name);
free(fs->pool_id);
free(fs->system_id);
- lsm_optional_data_record_free(fs->optional_data);
free(fs->plugin_data);
free(fs);
return LSM_ERR_OK;
@@ -1331,7 +1286,7 @@ lsm_fs *lsm_fs_record_copy(lsm_fs *source)
dest = lsm_fs_record_alloc(source->id, source->name,
source->total_space, source->free_space,
source->pool_id,
- source->system_id, source->optional_data,
+ source->system_id,
source->plugin_data);
}
return dest;
@@ -1370,15 +1325,11 @@ uint64_t lsm_fs_free_space_get(lsm_fs *fs)
MEMBER_GET(fs, LSM_IS_FS, free_space, 0);
}
-MEMBER_FUNC_GET(lsm_optional_data *, lsm_fs_optional_data_get, lsm_fs *fs,
- fs, LSM_IS_POOL, optional_data, NULL)
-
MEMBER_FUNC_GET(const char *, lsm_fs_plugin_data_get, lsm_fs *fs,
fs, LSM_IS_POOL, plugin_data, NULL)
lsm_fs_ss * lsm_fs_ss_record_alloc(const char *id, const char *name,
uint64_t ts,
- lsm_optional_data *optional_data,
const char * plugin_data)
{
lsm_fs_ss *rc = (lsm_fs_ss *) calloc(1, sizeof(lsm_fs_ss));
@@ -1387,12 +1338,11 @@ lsm_fs_ss * lsm_fs_ss_record_alloc(const char *id, const char *name,
rc->id = strdup(id);
rc->name = strdup(name);
rc->ts = ts;
- rc->optional_data = lsm_optional_data_record_copy(optional_data);
if( plugin_data ) {
rc->plugin_data = strdup(plugin_data);
}
- if( !rc->id || ! rc->name || (optional_data && !rc->optional_data) ||
+ if( !rc->id || ! rc->name ||
(plugin_data && !rc->plugin_data)) {
lsm_fs_ss_record_free(rc);
rc = NULL;
@@ -1407,8 +1357,7 @@ lsm_fs_ss *lsm_fs_ss_record_copy(lsm_fs_ss *source)
if( LSM_IS_SS(source) ) {
rc = lsm_fs_ss_record_alloc(source->id,
source->name,
- source->ts,
- source->optional_data, source->plugin_data);
+ source->ts, source->plugin_data);
}
return rc;
}
@@ -1419,7 +1368,6 @@ int lsm_fs_ss_record_free( lsm_fs_ss *ss)
ss->magic = LSM_DEL_MAGIC(LSM_SS_MAGIC);
free(ss->id);
free(ss->name);
- lsm_optional_data_record_free(ss->optional_data);
free(ss->plugin_data);
free(ss);
@@ -1447,9 +1395,6 @@ uint64_t lsm_fs_ss_time_stamp_get(lsm_fs_ss *ss)
MEMBER_GET(ss, LSM_IS_SS, ts, 0);
}
-MEMBER_FUNC_GET(lsm_optional_data *, lsm_fs_ss_optional_data_get, lsm_fs_ss *ss,
- ss, LSM_IS_SS, optional_data, NULL)
-
MEMBER_FUNC_GET(const char *, lsm_fs_ss_plugin_data_get, lsm_fs_ss *ss,
ss, LSM_IS_SS, plugin_data, NULL)
@@ -1463,7 +1408,6 @@ lsm_nfs_export *lsm_nfs_export_record_alloc(const char *id,
uint64_t anonuid,
uint64_t anongid,
const char *options,
- lsm_optional_data * optional_data,
const char * plugin_data)
{
lsm_nfs_export *rc = NULL;
@@ -1483,7 +1427,6 @@ lsm_nfs_export *lsm_nfs_export_record_alloc(const char *id,
rc->anonuid = anonuid;
rc->anongid = anongid;
rc->options = (options) ? strdup(options) : NULL;
- rc->optional_data = lsm_optional_data_record_copy(optional_data);
if( plugin_data ) {
rc->plugin_data = strdup(plugin_data);
@@ -1497,7 +1440,6 @@ lsm_nfs_export *lsm_nfs_export_record_alloc(const char *id,
(rw && !rc->rw) ||
(ro && !rc->ro) ||
(options && !rc->options) ||
- (optional_data && !rc->optional_data) ||
(plugin_data && !rc->plugin_data)) {
lsm_nfs_export_record_free(rc);
rc = NULL;
@@ -1520,7 +1462,6 @@ int lsm_nfs_export_record_free( lsm_nfs_export *exp )
lsm_string_list_free(exp->rw);
lsm_string_list_free(exp->ro);
free(exp->options);
- lsm_optional_data_record_free(exp->optional_data);
free(exp->plugin_data);
free(exp);
@@ -1535,8 +1476,7 @@ lsm_nfs_export *lsm_nfs_export_record_copy( lsm_nfs_export *s )
if(LSM_IS_NFS_EXPORT(s)) {
return lsm_nfs_export_record_alloc(s->id, s->fs_id, s->export_path,
s->auth_type, s->root, s->rw, s->ro, s->anonuid,
- s->anongid, s->options, s->optional_data,
- s->plugin_data);
+ s->anongid, s->options, s->plugin_data);
}
return NULL;
}
@@ -1655,9 +1595,6 @@ int lsm_nfs_export_options_set( lsm_nfs_export *exp, const char *value )
LSM_ERR_INVALID_NFS);
}
-MEMBER_FUNC_GET(lsm_optional_data *, lsm_nfs_export_optional_data_get,
- lsm_nfs_export *exp, exp, LSM_IS_NFS_EXPORT, optional_data, NULL)
-
MEMBER_FUNC_GET(const char *, lsm_nfs_export_plugin_data_get,
lsm_nfs_export *exp, exp, LSM_IS_NFS_EXPORT, plugin_data, NULL)
@@ -1825,87 +1762,40 @@ char* capability_string(lsm_storage_capabilities *c)
return rc;
}
-void optional_data_free(void *d)
-{
- struct optional_data *op = (struct optional_data *)d;
- if (op->t == LSM_OPTIONAL_DATA_STRING_LIST ) {
- lsm_string_list_free(op->v.sl);
- } else if( op->t == LSM_OPTIONAL_DATA_STRING ) {
- free(op->v.s);
- }
-
- free(d);
-}
-
-struct optional_data *optional_data_copy(struct optional_data *op)
+lsm_hash *lsm_hash_alloc(void)
{
- struct optional_data *copy = (struct optional_data*)
- calloc(1, sizeof(optional_data));
-
- if( copy ) {
- copy->t = op->t;
- copy->v = op->v;
+ lsm_hash *rc = NULL;
- if( op->t == LSM_OPTIONAL_DATA_STRING) {
- copy->v.s = strdup(op->v.s);
- if( !copy->v.s ) {
- optional_data_free(copy);
- copy = NULL;
- }
- } else if( op->t == LSM_OPTIONAL_DATA_STRING_LIST) {
- copy->v.sl = lsm_string_list_copy(op->v.sl);
- if( !copy->v.sl ) {
- optional_data_free(copy);
- copy = NULL;
- }
- }
- }
- return copy;
-}
-
-lsm_optional_data *lsm_optional_data_record_alloc(void)
-{
- lsm_optional_data *rc = NULL;
-
- rc = (lsm_optional_data *)malloc(sizeof(lsm_optional_data));
+ rc = (lsm_hash *)malloc(sizeof(lsm_hash));
if( rc ) {
- rc->magic = LSM_OPTIONAL_DATA_MAGIC;
- rc->data = g_hash_table_new_full(g_str_hash, g_str_equal, free,
- optional_data_free);
+ rc->magic = LSM_HASH_MAGIC;
+ rc->data = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
if ( !rc->data ) {
- lsm_optional_data_record_free(rc);
+ lsm_hash_free(rc);
rc = NULL;
}
}
return rc;
}
-lsm_optional_data *lsm_optional_data_record_copy(lsm_optional_data *src)
+lsm_hash *lsm_hash_copy(lsm_hash *src)
{
GHashTableIter iter;
gpointer key;
gpointer value;
- lsm_optional_data *dest = NULL;
- if( LSM_IS_OPTIONAL_DATA(src) ) {
- dest = lsm_optional_data_record_alloc();
+ lsm_hash *dest = NULL;
+ if( LSM_IS_HASH(src) ) {
+ dest = lsm_hash_alloc();
if( dest ) {
/* Walk through each from src and duplicate it to dest*/
g_hash_table_iter_init(&iter, src->data);
while(g_hash_table_iter_next(&iter, &key, &value)) {
- char *k_value = strdup((char*)key);
- struct optional_data *d_value =
- optional_data_copy((struct optional_data*)value);
-
- if( k_value && d_value ) {
- g_hash_table_insert(dest->data, (gpointer)k_value,
- (gpointer)d_value);
- } else {
- free(k_value);
- optional_data_free(d_value);
- lsm_optional_data_record_free(dest);
+ if( LSM_ERR_OK != lsm_hash_string_set(dest,
+ (const char*)key, (const char*)value))
+ {
+ lsm_hash_free(dest);
dest = NULL;
- break;
}
}
}
@@ -1913,10 +1803,10 @@ lsm_optional_data *lsm_optional_data_record_copy(lsm_optional_data *src)
return dest;
}
-int lsm_optional_data_record_free(lsm_optional_data *op)
+int lsm_hash_free(lsm_hash *op)
{
- if( LSM_IS_OPTIONAL_DATA(op) ) {
- op->magic = LSM_DEL_MAGIC(LSM_OPTIONAL_DATA_MAGIC);
+ if( LSM_IS_HASH(op) ) {
+ op->magic = LSM_DEL_MAGIC(LSM_HASH_MAGIC);
if( op->data ) {
g_hash_table_destroy(op->data);
@@ -1925,25 +1815,24 @@ int lsm_optional_data_record_free(lsm_optional_data *op)
free(op);
return LSM_ERR_OK;
}
- return LSM_ERR_INVALID_OPTIONAL_DATA;
+ return LSM_ERR_INVALID_HASH;
}
-int lsm_optional_data_keys(lsm_optional_data *op, lsm_string_list **l)
+int lsm_hash_keys(lsm_hash *op, lsm_string_list **l)
{
GHashTableIter iter;
gpointer key;
gpointer value;
- uint32_t size = 0;
- if( LSM_IS_OPTIONAL_DATA(op) ) {
- size = g_hash_table_size(op->data);
- if( size ) {
+ if( LSM_IS_HASH(op) ) {
+ int count = g_hash_table_size(op->data);
+
+ if( count ) {
*l = lsm_string_list_alloc(0);
g_hash_table_iter_init(&iter, op->data);
while(g_hash_table_iter_next(&iter, &key, &value)) {
if(LSM_ERR_OK != lsm_string_list_append(*l, (char *)key) ) {
- size = 0;
lsm_string_list_free(*l);
*l = NULL;
return LSM_ERR_NO_MEMORY;
@@ -1952,219 +1841,37 @@ int lsm_optional_data_keys(lsm_optional_data *op, lsm_string_list **l)
}
return LSM_ERR_OK;
}
- return LSM_ERR_INVALID_OPTIONAL_DATA;
+ return LSM_ERR_INVALID_HASH;
}
-lsm_optional_data_type lsm_optional_data_type_get(lsm_optional_data *op,
+const char *lsm_hash_string_get(lsm_hash *op,
const char *key)
{
- if( LSM_IS_OPTIONAL_DATA(op) ) {
- struct optional_data *od = (struct optional_data *)
- g_hash_table_lookup(op->data, key);
- if( od ) {
- return od->t;
- }
- return LSM_OPTIONAL_DATA_NOT_FOUND;
- }
- return LSM_OPTIONAL_DATA_INVALID;
-}
-
-
-#define OP_GETTER(name, return_type, type_value, member, error_value) \
-return_type name(lsm_optional_data *op, const char *key) \
-{ \
- if( LSM_IS_OPTIONAL_DATA(op) ) { \
- struct optional_data *od = (struct optional_data *) \
- g_hash_table_lookup(op->data, key); \
- if( od ) { \
- if( od->t == type_value ) { \
- return od->v.member; \
- } \
- } \
- } \
- return error_value; \
-} \
-
-OP_GETTER(lsm_optional_data_string_list_get, lsm_string_list *,
- LSM_OPTIONAL_DATA_STRING_LIST, sl, NULL)
-OP_GETTER(lsm_optional_data_string_get, const char *, LSM_OPTIONAL_DATA_STRING,
- s, NULL)
-OP_GETTER(lsm_optional_data_int64_get, int64_t, LSM_OPTIONAL_DATA_SIGN_INT, si,
- LLONG_MAX)
-OP_GETTER(lsm_optional_data_uint64_get, uint64_t,
- LSM_OPTIONAL_DATA_UNSIGNED_INT, ui, ULLONG_MAX)
-OP_GETTER(lsm_optional_data_real_get, long double, LSM_OPTIONAL_DATA_REAL, d,
- LDBL_MAX)
-
-static void insert_value(GHashTable *ht, const char *key,
- struct optional_data *value)
-{
- g_hash_table_remove(ht, (gpointer)key);
- g_hash_table_insert(ht, (gpointer)key, (gpointer)value);
-}
-
-int lsm_optional_data_string_set(lsm_optional_data *op,
- const char *key,
- const char *value)
-{
- if( LSM_IS_OPTIONAL_DATA(op) ) {
- char *k_value = strdup(key);
- char *op_value = strdup(value);
- struct optional_data *d_value =
- (struct optional_data *)calloc(1, sizeof(struct optional_data));
-
- if( k_value && op_value && d_value) {
- d_value->t = LSM_OPTIONAL_DATA_STRING;
- d_value->v.s = op_value;
- insert_value(op->data, k_value, d_value);
- return LSM_ERR_OK;
- } else {
- free(k_value);
- free(op_value);
- free(d_value);
- return LSM_ERR_NO_MEMORY;
- }
- }
- return LSM_ERR_INVALID_OPTIONAL_DATA;
-}
-
-int lsm_optional_data_string_list_set(lsm_optional_data *op, const char *key,
- lsm_string_list *value)
-{
- int rc = LSM_ERR_INVALID_OPTIONAL_DATA;
- if( LSM_IS_OPTIONAL_DATA(op) ) {
- char *k_value = strdup(key);
- lsm_string_list *copy = lsm_string_list_copy(value);
- struct optional_data *d_value =
- (struct optional_data *)calloc(1, sizeof(struct optional_data));
-
- if( k_value && copy && d_value ) {
- d_value->t = LSM_OPTIONAL_DATA_STRING_LIST;
- d_value->v.sl = copy;
- insert_value(op->data, k_value, d_value);
- rc = LSM_ERR_OK;
- } else {
- free(k_value);
- free(d_value);
- lsm_string_list_free(copy);
- rc = LSM_ERR_NO_MEMORY;
- }
- }
- return rc;
-}
-
-int lsm_optional_data_int64_set(lsm_optional_data *op, const char *key,
- int64_t value)
-{
- int rc = LSM_ERR_INVALID_OPTIONAL_DATA;
- if( LSM_IS_OPTIONAL_DATA(op) ) {
- char *k_value = strdup(key);
- struct optional_data *d_value =
- (struct optional_data *)calloc(1, sizeof(struct optional_data));
-
- if( k_value && d_value ) {
- d_value->t = LSM_OPTIONAL_DATA_SIGN_INT;
- d_value->v.si = value;
- insert_value(op->data, k_value, d_value);
- rc = LSM_ERR_OK;
- } else {
- free(k_value);
- free(d_value);
- rc = LSM_ERR_NO_MEMORY;
- }
- }
- return rc;
-}
-
-int lsm_optional_data_uint64_set(lsm_optional_data *op, const char *key,
- uint64_t value)
-{
- int rc = LSM_ERR_INVALID_OPTIONAL_DATA;
- if( LSM_IS_OPTIONAL_DATA(op) ) {
- char *k_value = strdup(key);
- struct optional_data *d_value =
- (struct optional_data *)calloc(1, sizeof(struct optional_data));
-
- if( k_value && d_value ) {
- d_value->t = LSM_OPTIONAL_DATA_UNSIGNED_INT;
- d_value->v.ui = value;
- insert_value(op->data, k_value, d_value);
- rc = LSM_ERR_OK;
- } else {
- free(k_value);
- free(d_value);
- rc = LSM_ERR_NO_MEMORY;
- }
+ if( LSM_IS_HASH(op) ) {
+ return (const char*)g_hash_table_lookup(op->data, key);
}
- return rc;
+ return NULL;
}
-int lsm_optional_data_real_set(lsm_optional_data *op, const char *key,
- long double value)
+int lsm_hash_string_set(lsm_hash *op,
+ const char *key,
+ const char *value)
{
- int rc = LSM_ERR_INVALID_OPTIONAL_DATA;
- if( LSM_IS_OPTIONAL_DATA(op) ) {
+ if( LSM_IS_HASH(op) ) {
char *k_value = strdup(key);
- struct optional_data *d_value =
- (struct optional_data *)calloc(1, sizeof(struct optional_data));
+ char *d_value = strdup(value);
if( k_value && d_value ) {
- d_value->t = LSM_OPTIONAL_DATA_REAL;
- d_value->v.d = value;
- insert_value(op->data, k_value, d_value);
- rc = LSM_ERR_OK;
+ g_hash_table_remove(op->data, (gpointer)k_value);
+ g_hash_table_insert(op->data, (gpointer)k_value, (gpointer)d_value);
+ return LSM_ERR_OK;
} else {
free(k_value);
free(d_value);
- rc = LSM_ERR_NO_MEMORY;
- }
- }
- return rc;
-}
-
-int number_convert(const char *str_num, int64_t *si, uint64_t *ui,
- long double *d)
-{
- int rc = -1;
- char *end = NULL;
-
- if( str_num && str_num != '\0' && strlen(str_num) ) {
- *si = 0;
- *ui = 0;
- *d = 0.0;
-
- errno = 0;
- *si = strtoll(str_num, &end, 10);
- if( errno == 0 && *end == '\0' ) {
- rc = 1; /* Signed number */
- }
-
- /* strtoull will convert negative, not wanted so skip if it has '-' */
- if( -1 == rc && str_num[0] != '-') {
- end = NULL;
- errno = 0;
- *ui = strtoull(str_num, &end, 10);
-
- if( errno == 0 && *end == '\0' ) {
- rc = 2; /* Unsigned number */
- }
- }
-
- if( -1 == rc ) {
- end = NULL;
- errno = 0;
-
- *d = strtold(str_num, &end);
- if( errno == 0 && *end == '\0' ) {
- rc = 3; /* Real number */
- }
- }
-
- if( -1 == rc ) {
- rc = 0; /* Not a number */
+ return LSM_ERR_NO_MEMORY;
}
}
- return rc;
+ return LSM_ERR_INVALID_HASH;
}
#ifdef __cplusplus
diff --git a/c_binding/lsm_datatypes.hpp b/c_binding/lsm_datatypes.hpp
index c6ac9c5..5c42c08 100644
--- a/c_binding/lsm_datatypes.hpp
+++ b/c_binding/lsm_datatypes.hpp
@@ -67,7 +67,6 @@ struct LSM_DLL_LOCAL _lsm_volume {
uint32_t status; /**< Status */
char *system_id; /**< System this volume belongs */
char *pool_id; /**< Pool this volume is derived from */
- lsm_optional_data *optional_data; /**< Optional data */
char *plugin_data; /**< Private data for plugin */
};
@@ -86,7 +85,6 @@ struct LSM_DLL_LOCAL _lsm_pool {
uint64_t status; /**< Status of pool */
char *status_info; /**< Status info for pool */
char *system_id; /**< system id */
- lsm_optional_data *optional_data; /**< Optional data */
char *plugin_data; /**< Private data for plugin */
};
@@ -116,7 +114,6 @@ struct _lsm_access_group {
char *system_id; /**< System id */
lsm_access_group_init_type init_type; /**< Init type */
lsm_string_list *initiators; /**< List of initiators */
- lsm_optional_data *optional_data; /**< Optional data */
char *plugin_data; /**< Reserved for the plugin to use */
};
@@ -138,7 +135,6 @@ struct _lsm_nfs_export {
uint64_t anonuid; /**< Uid that should map to anonymous */
uint64_t anongid; /**< Gid that should map to anonymous */
char *options; /**< Options */
- lsm_optional_data *optional_data; /**< Optional data */
char *plugin_data; /**< Reserved for the plugin to use */
};
@@ -181,8 +177,7 @@ struct _lsm_system {
char *name; /**< Name */
uint32_t status; /**< Enumerated status value */
char *status_info; /**< System status text */
- lsm_optional_data *optional_data; /**< Optional data */
- char *plugin_data; /**< Reserved for the plugin to use */
+ char *plugin_data; /**< Reserved for the plugin to use */
};
#define LSM_CONNECT_MAGIC 0xAA7A000A
@@ -267,7 +262,6 @@ struct LSM_DLL_LOCAL _lsm_fs {
uint64_t total_space; /**< Total space */
uint64_t free_space; /**< Free space */
char *system_id; /**< System ID */
- lsm_optional_data *optional_data; /**< Optional data */
char *plugin_data; /**< Plugin private data */
};
@@ -278,7 +272,6 @@ struct LSM_DLL_LOCAL _lsm_fs_ss {
char *id;
char *name;
uint64_t ts;
- lsm_optional_data *optional_data; /**< Optional data */
char *plugin_data; /**< Reserved for the plugin to use */
};
@@ -292,29 +285,16 @@ struct LSM_DLL_LOCAL _lsm_disk {
uint64_t block_size;
uint64_t block_count;
uint64_t disk_status; /* Bit field */
- lsm_optional_data *optional_data;
char *system_id;
};
-#define LSM_OPTIONAL_DATA_MAGIC 0xAA7A0011
-#define LSM_IS_OPTIONAL_DATA(obj) MAGIC_CHECK(obj, LSM_OPTIONAL_DATA_MAGIC)
-struct LSM_DLL_LOCAL _lsm_optional_data {
+#define LSM_HASH_MAGIC 0xAA7A0011
+#define LSM_IS_HASH(obj) MAGIC_CHECK(obj, LSM_HASH_MAGIC)
+struct LSM_DLL_LOCAL _lsm_hash {
uint32_t magic;
GHashTable *data;
};
-union optional_value {
- char *s;
- long double d;
- int64_t si;
- uint64_t ui;
- lsm_string_list *sl;
-};
-struct optional_data {
- lsm_optional_data_type t;
- union optional_value v;
-};
-
/**
* Returns a pointer to a newly created connection structure.
* @return NULL on memory exhaustion, else new connection.
diff --git a/c_binding/lsm_plugin_ipc.cpp b/c_binding/lsm_plugin_ipc.cpp
index 90e4e30..5058054 100644
--- a/c_binding/lsm_plugin_ipc.cpp
+++ b/c_binding/lsm_plugin_ipc.cpp
@@ -2611,7 +2611,7 @@ do { \
int LSM_DLL_EXPORT lsm_uri_parse(const char *uri, char **scheme, char **user,
char **server, int *port, char **path,
- lsm_optional_data **query_params)
+ lsm_hash **query_params)
{
int rc = LSM_ERR_INVALID_URI;
xmlURIPtr u = NULL;
@@ -2632,7 +2632,7 @@ int LSM_DLL_EXPORT lsm_uri_parse(const char *uri, char **scheme, char **user,
STR_D(*path, u->path);
*port = u->port;
- *query_params = lsm_optional_data_record_alloc();
+ *query_params = lsm_hash_alloc();
if( *query_params ) {
int i;
struct qparam_set *qp = NULL;
@@ -2640,7 +2640,7 @@ int LSM_DLL_EXPORT lsm_uri_parse(const char *uri, char **scheme, char **user,
if( qp ) {
for( i = 0; i < qp->n; ++i ) {
- rc = lsm_optional_data_string_set(*query_params,
+ rc = lsm_hash_string_set(*query_params,
qp->p[i].name,
qp->p[i].value);
if( LSM_ERR_OK != rc ) {
@@ -2669,7 +2669,7 @@ int LSM_DLL_EXPORT lsm_uri_parse(const char *uri, char **scheme, char **user,
*port = -1;
free(*path);
*path = NULL;
- lsm_optional_data_record_free(*query_params);
+ lsm_hash_free(*query_params);
*query_params = NULL;
}
diff --git a/doc/man/lsmcli.1.in b/doc/man/lsmcli.1.in
index 697ec75..34cbc95 100644
--- a/doc/man/lsmcli.1.in
+++ b/doc/man/lsmcli.1.in
@@ -144,9 +144,7 @@ Please note:
.br
Due to console text width limitation(78), NOT all mandatory properties will be
displayed in column way(default display way).
-But all mandatory properties will be displayed in script way. When with "-o,
---optional", both mandatory properties and optional properties will be
-displayed.
+But all mandatory properties will be displayed in script way.
.SH COMMANDS
.SS list
@@ -166,9 +164,6 @@ Required for \fB--type\fR=\fBSNAPSHOTS\fR. List the snapshots of certain
filesystem.
PLUGINS will list all supported plugins of LSM, not only the current one.
.TP
-\fB-o\fR, \fB--optional\fR
-Optional. Retrive and display optional data in '--script, -s' display way.
-.TP
\fB--sys\fR \fI<SYS_ID>\fR
Search resources from system with SYS_ID. Only supported when querying these
types of resources: \fBVOLUMES\fR, \fBPOOLS\fR, \fBFS\fR,
diff --git a/plugin/nstor/nstor.py b/plugin/nstor/nstor.py
index c47a670..983af5f 100644
--- a/plugin/nstor/nstor.py
+++ b/plugin/nstor/nstor.py
@@ -134,8 +134,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
pools.append(Pool(pool_info['name'], pool_info['name'],
NexentaStor._to_bytes(pool_info['size']),
NexentaStor._to_bytes(pool_info['free']),
- Pool.STATUS_UNKNOWN, '',
- self.system.id))
+ Pool.STATUS_UNKNOWN, '', self.system.id))
return search_property(pools, search_key, search_value)
@@ -155,11 +154,10 @@ class NexentaStor(INfs, IStorageAreaNetwork):
pools[pool_name] = pool_info
else:
pool_info = pools[pool_name]
- fss.append(FileSystem(fs, fs,
- NexentaStor._to_bytes(pool_info['size']),
- self._to_bytes(pool_info['available']),
- pool_name,
- fs))
+ fss.append(
+ FileSystem(fs, fs, NexentaStor._to_bytes(pool_info['size']),
+ self._to_bytes(pool_info['available']), pool_name,
+ fs))
return search_property(fss, search_key, search_value)
@@ -327,8 +325,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
self._request("clone", "folder", [snapshot.name, dest])
pool_id = NexentaStor._get_pool_id(dest)
pool_info = self._request("get_child_props", "volume", [pool_id, ""])
- fs = FileSystem(dest, dest,
- NexentaStor._to_bytes(pool_info['size']),
+ fs = FileSystem(dest, dest, NexentaStor._to_bytes(pool_info['size']),
NexentaStor._to_bytes(pool_info['available']), pool_id,
self.system.id)
return None, fs
@@ -394,12 +391,10 @@ class NexentaStor(INfs, IStorageAreaNetwork):
for e in exp_list:
opts = self._request("get_shareopts", "netstorsvc",
['svc:/network/nfs/server:default', e])
- exports.append(NfsExport(md5(opts['name']),
- e, opts['name'], opts['auth_type'],
- opts['root'],
+ exports.append(NfsExport(md5(opts['name']), e, opts['name'],
+ opts['auth_type'], opts['root'],
opts['read_write'], opts['read_only'],
- 'N/A', 'N/A',
- opts['extra_options']))
+ 'N/A', 'N/A', opts['extra_options']))
return search_property(exports, search_key, search_value)
@@ -433,9 +428,8 @@ class NexentaStor(INfs, IStorageAreaNetwork):
result = self._request("share_folder", "netstorsvc",
['svc:/network/nfs/server:default',
fs_id, fs_dict])
- return NfsExport(md5_id, fs_id, export_path, auth_type,
- root_list, rw_list, ro_list, anon_uid, anon_gid,
- options)
+ return NfsExport(md5_id, fs_id, export_path, auth_type, root_list,
+ rw_list, ro_list, anon_uid, anon_gid, options)
@handle_nstor_errors
def export_remove(self, export, flags=0):
"""
@@ -493,11 +487,9 @@ class NexentaStor(INfs, IStorageAreaNetwork):
else:
state = Volume.STATUS_UNKNOWN
- vol_list.append(Volume(lu, lu, lu_props['guid'],
- block_size, num_of_blocks,
- state,
- 'N/A',
- NexentaStor._get_pool_id(lu)))
+ vol_list.append(
+ Volume(lu, lu, lu_props['guid'], block_size, num_of_blocks,
+ state, 'N/A', NexentaStor._get_pool_id(lu)))
return search_property(vol_list, search_key, search_value)
@@ -536,7 +528,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
new_volume = Volume(name, name, '', 8192, size_bytes / 8192,
Volume.STATUS_OK, '',
- pool.id) # FIXhttp://192.168.0.1/st_wlan.phpME
+ pool.id) # FIXhttp://192.168.0.1/st_wlan.phpME
# replace with list request
return None, new_volume
@@ -702,8 +694,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
for hg in hg_list:
init_ids = self._request("list_hostgroup_members", "stmf", [hg])
ag_list.append(
- AccessGroup(hg, hg, init_ids,
- AccessGroup.INIT_TYPE_ISCSI_IQN,
+ AccessGroup(hg, hg, init_ids, AccessGroup.INIT_TYPE_ISCSI_IQN,
self.system.id))
return search_property(ag_list, search_key, search_value)
diff --git a/plugin/ontap/ontap.py b/plugin/ontap/ontap.py
index 203dfe7..7f5e08d 100644
--- a/plugin/ontap/ontap.py
+++ b/plugin/ontap/ontap.py
@@ -24,7 +24,7 @@ import sys
import na
from lsm import (Volume, FileSystem, FsSnapshot, NfsExport,
- AccessGroup, System, Capabilities, Disk, Pool, OptionalData,
+ AccessGroup, System, Capabilities, Disk, Pool,
IStorageAreaNetwork, INfs, LsmError, ErrorNumber, JobStatus,
md5, Error, VERSION, common_urllib2_error_handler,
search_property)
@@ -201,9 +201,9 @@ class Ontap(IStorageAreaNetwork, INfs):
num_blocks = int(l['size']) / block_size
#TODO: Need to retrieve actual volume status
return Volume(l['serial-number'], l['path'],
- Ontap._create_vpd(l['serial-number']),
- block_size, num_blocks, Volume.STATUS_OK,
- self.sys_info.id, l['aggr'])
+ Ontap._create_vpd(l['serial-number']), block_size,
+ num_blocks, Volume.STATUS_OK, self.sys_info.id,
+ l['aggr'])
def _vol(self, v, pools=None):
pool_name = v['containing-aggregate']
@@ -292,21 +292,11 @@ class Ontap(IStorageAreaNetwork, INfs):
return status_info
def _disk(self, d, flag):
- opt_data = OptionalData()
status = Ontap._status_of_na_disk(d)
- if flag & Disk.FLAG_RETRIEVE_FULL_INFO:
- opt_data.set('sn', d['serial-number'])
- opt_data.set('model', d['disk-model'])
- opt_data.set('vendor', d['vendor-id'])
- opt_data.set('status_info', Ontap._status_info_of_na_disk(d))
-
- return Disk(self._disk_id(d),
- d['name'],
+ return Disk(self._disk_id(d), d['name'],
Ontap._disk_type(d['disk-type']),
- int(d['bytes-per-sector']),
- int(d['physical-blocks']),
- status,
- self.sys_info.id, opt_data)
+ int(d['bytes-per-sector']), int(d['physical-blocks']),
+ status, self.sys_info.id)
@handle_ontap_errors
def volumes(self, search_key=None, search_value=None, flags=0):
@@ -361,33 +351,18 @@ class Ontap(IStorageAreaNetwork, INfs):
free_space = int(na_aggr['size-available'])
system_id = self.sys_info.id
status = self._status_of_na_aggr(na_aggr)
- opt_data = OptionalData()
- if flags & Pool.FLAG_RETRIEVE_FULL_INFO:
- opt_data.set('member_type', Pool.MEMBER_TYPE_DISK)
- member_ids = []
- for na_disk in na_disks:
- if 'aggregate' in na_disk and \
- na_disk['aggregate'] == pool_name:
- member_ids.extend([self._disk_id(na_disk)])
- opt_data.set('member_ids', member_ids)
- opt_data.set('raid_type', self._raid_type_of_na_aggr(na_aggr))
- if na_aggr['type'] == 'aggr':
- opt_data.set('thinp_type', Pool.THINP_TYPE_THIN)
- elif na_aggr['type'] == 'trad':
- opt_data.set('thinp_type', Pool.THINP_TYPE_THICK)
- else:
- opt_data.set('thinp_type', Pool.THINP_TYPE_UNKNOWN)
- element_type = (
- Pool.ELEMENT_TYPE_POOL |
- Pool.ELEMENT_TYPE_FS |
- Pool.ELEMENT_TYPE_VOLUME)
- if pool_name == 'aggr0':
- element_type = element_type | Pool.ELEMENT_TYPE_SYS_RESERVED
- opt_data.set('element_type', element_type)
+
+ # We will be adding this back as mandatory
+ # element_type = (
+ # Pool.ELEMENT_TYPE_POOL |
+ # Pool.ELEMENT_TYPE_FS |
+ # Pool.ELEMENT_TYPE_VOLUME)
+ #if pool_name == 'aggr0':
+ # element_type = element_type | Pool.ELEMENT_TYPE_SYS_RESERVED
+ #opt_data.set('element_type', element_type)
return Pool(pool_id, pool_name, total_space, free_space, status,
- self._status_info_of_na_aggr(na_aggr),
- system_id, opt_data)
+ self._status_info_of_na_aggr(na_aggr), system_id)
@staticmethod
def _status_of_na_vol(na_vol):
@@ -418,28 +393,11 @@ class Ontap(IStorageAreaNetwork, INfs):
free_space = int(na_vol['size-available'])
system_id = self.sys_info.id
status = self._status_of_na_vol(na_vol)
- opt_data = OptionalData()
- if flags & Pool.FLAG_RETRIEVE_FULL_INFO:
- opt_data.set('member_type', Pool.MEMBER_TYPE_POOL)
- parent_aggr_name = na_vol['containing-aggregate']
- for na_aggr in na_aggrs:
- if na_aggr['name'] == parent_aggr_name:
- opt_data.set('member_ids', [self._pool_id(na_aggr)])
- break
- opt_data.set('raid_type', Pool.RAID_TYPE_NOT_APPLICABLE)
- if na_vol['type'] == 'flex':
- opt_data.set('thinp_type', Pool.THINP_TYPE_THIN)
- elif na_vol['type'] == 'trad':
- opt_data.set('thinp_type', Pool.THINP_TYPE_THICK)
- else:
- opt_data.set('thinp_type', Pool.THINP_TYPE_UNKNOWN)
- opt_data.set('status_info', self._status_info_of_na_vol(na_vol))
- opt_data.set('element_type', Pool.ELEMENT_TYPE_VOLUME)
+ # opt_data.set('element_type', Pool.ELEMENT_TYPE_VOLUME)
return Pool(pool_id, pool_name, total_space, free_space, status,
- self._status_info_of_na_vol(na_vol),
- system_id, opt_data)
+ self._status_info_of_na_vol(na_vol), system_id)
@handle_ontap_errors
def capabilities(self, system, flags=0):
@@ -1011,16 +969,12 @@ class Ontap(IStorageAreaNetwork, INfs):
vol_name = Ontap._get_volume_from_path(path)
fs_id = Ontap._get_volume_id(volumes, vol_name)
- return NfsExport(md5(vol_name + fs_id),
- fs_id,
- export,
+ return NfsExport(md5(vol_name + fs_id), fs_id, export,
e['sec-flavor']['sec-flavor-info']['flavor'],
Ontap._get_group('root', e),
Ontap._get_group('read-write', e),
Ontap._get_group('read-only', e),
- Ontap._get_value('anon', e),
- None,
- None)
+ Ontap._get_value('anon', e), None, None)
@handle_ontap_errors
def exports(self, search_key=None, search_value=None, flags=0):
diff --git a/plugin/sim/simarray.py b/plugin/sim/simarray.py
index 0ccc4dc..f2ba105 100644
--- a/plugin/sim/simarray.py
+++ b/plugin/sim/simarray.py
@@ -27,7 +27,7 @@ import time
from lsm import (size_human_2_size_bytes, size_bytes_2_size_human)
from lsm import (System, Volume, Disk, Pool, FileSystem, AccessGroup,
- FsSnapshot, NfsExport, OptionalData, md5, LsmError,
+ FsSnapshot, NfsExport, md5, LsmError,
ErrorNumber, JobStatus)
# Used for format width for disks
@@ -142,8 +142,7 @@ class SimArray(object):
return Volume(sim_vol['vol_id'], sim_vol['name'], sim_vol['vpd83'],
SimData.SIM_DATA_BLK_SIZE,
int(sim_vol['total_space'] / SimData.SIM_DATA_BLK_SIZE),
- Volume.STATUS_OK, sim_vol['sys_id'],
- sim_vol['pool_id'])
+ Volume.STATUS_OK, sim_vol['sys_id'], sim_vol['pool_id'])
def volumes(self):
sim_vols = self.data.volumes()
@@ -158,16 +157,8 @@ class SimArray(object):
status = sim_pool['status']
status_info = sim_pool['status_info']
sys_id = sim_pool['sys_id']
- opt_data = OptionalData()
- if flags & Pool.FLAG_RETRIEVE_FULL_INFO:
- opt_data.set('raid_type', sim_pool['raid_type'])
- opt_data.set('member_type', sim_pool['member_type'])
- opt_data.set('member_ids', sim_pool['member_ids'])
- opt_data.set('thinp_type', Pool.THINP_TYPE_THIN)
- opt_data.set('element_type', sim_pool['element_type'])
-
return Pool(pool_id, name, total_space, free_space, status,
- status_info, sys_id, opt_data)
+ status_info, sys_id)
def pools(self, flags=0):
rc = []
@@ -182,28 +173,28 @@ class SimArray(object):
sim_pool = self.data.pool_create(
sys_id, pool_name, size_bytes, raid_type, member_type, flags)
return self.data.job_create(
- self._sim_pool_2_lsm(sim_pool, Pool.FLAG_RETRIEVE_FULL_INFO))
+ self._sim_pool_2_lsm(sim_pool))
def pool_create_from_disks(self, sys_id, pool_name, disks_ids, raid_type,
flags=0):
sim_pool = self.data.pool_create_from_disks(
sys_id, pool_name, disks_ids, raid_type, flags)
return self.data.job_create(
- self._sim_pool_2_lsm(sim_pool, Pool.FLAG_RETRIEVE_FULL_INFO))
+ self._sim_pool_2_lsm(sim_pool))
def pool_create_from_volumes(self, sys_id, pool_name, member_ids,
raid_type, flags=0):
sim_pool = self.data.pool_create_from_volumes(
sys_id, pool_name, member_ids, raid_type, flags)
return self.data.job_create(
- self._sim_pool_2_lsm(sim_pool, Pool.FLAG_RETRIEVE_FULL_INFO))
+ self._sim_pool_2_lsm(sim_pool))
def pool_create_from_pool(self, sys_id, pool_name, member_id, size_bytes,
flags=0):
sim_pool = self.data.pool_create_from_pool(
sys_id, pool_name, member_id, size_bytes, flags)
return self.data.job_create(
- self._sim_pool_2_lsm(sim_pool, Pool.FLAG_RETRIEVE_FULL_INFO))
+ self._sim_pool_2_lsm(sim_pool))
def pool_delete(self, pool_id, flags=0):
return self.data.job_create(self.data.pool_delete(pool_id, flags))[0]
@@ -215,8 +206,8 @@ class SimArray(object):
disk = Disk(sim_disk['disk_id'], sim_disk['name'],
sim_disk['disk_type'], SimData.SIM_DATA_BLK_SIZE,
int(sim_disk['total_space'] /
- SimData.SIM_DATA_BLK_SIZE),
- Disk.STATUS_OK, sim_disk['sys_id'])
+ SimData.SIM_DATA_BLK_SIZE), Disk.STATUS_OK,
+ sim_disk['sys_id'])
rc.extend([disk])
return SimArray._sort_by_id(rc)
@@ -296,7 +287,7 @@ class SimArray(object):
@staticmethod
def _sim_snap_2_lsm(sim_snap):
return FsSnapshot(sim_snap['snap_id'], sim_snap['name'],
- sim_snap['timestamp'])
+ sim_snap['timestamp'])
def fs_snapshots(self, fs_id, flags=0):
sim_snaps = self.data.fs_snapshots(fs_id, flags)
@@ -327,11 +318,11 @@ class SimArray(object):
@staticmethod
def _sim_exp_2_lsm(sim_exp):
- return NfsExport(
- sim_exp['exp_id'], sim_exp['fs_id'], sim_exp['exp_path'],
- sim_exp['auth_type'], sim_exp['root_hosts'], sim_exp['rw_hosts'],
- sim_exp['ro_hosts'], sim_exp['anon_uid'], sim_exp['anon_gid'],
- sim_exp['options'])
+ return NfsExport(sim_exp['exp_id'], sim_exp['fs_id'],
+ sim_exp['exp_path'], sim_exp['auth_type'],
+ sim_exp['root_hosts'], sim_exp['rw_hosts'],
+ sim_exp['ro_hosts'], sim_exp['anon_uid'],
+ sim_exp['anon_gid'], sim_exp['options'])
def exports(self, flags=0):
sim_exps = self.data.exports(flags)
@@ -350,9 +341,8 @@ class SimArray(object):
@staticmethod
def _sim_ag_2_lsm(sim_ag):
- return AccessGroup(sim_ag['ag_id'], sim_ag['name'],
- sim_ag['init_ids'], sim_ag['init_type'],
- sim_ag['sys_id'])
+ return AccessGroup(sim_ag['ag_id'], sim_ag['name'], sim_ag['init_ids'],
+ sim_ag['init_type'], sim_ag['sys_id'])
def ags(self):
sim_ags = self.data.ags()
@@ -564,9 +554,9 @@ class SimData(object):
self.job_dict = {
# id: SimJob
}
- self.syss = [System(SimData.SIM_DATA_SYS_ID,
- 'LSM simulated storage plug-in',
- System.STATUS_OK, '')]
+ self.syss = [
+ System(SimData.SIM_DATA_SYS_ID, 'LSM simulated storage plug-in',
+ System.STATUS_OK, '')]
pool_size_200g = size_human_2_size_bytes('200GiB')
self.pool_dict = {
'POO1': {
@@ -1121,8 +1111,9 @@ class SimData(object):
def iscsi_chap_auth(self, init_id, in_user, in_pass, out_user, out_pass,
flags=0):
# to_code
- if self.init_dict[init_id]['init_type'] != Initiator.TYPE_ISCSI:
- raise LsmError(ErrorNumber.UNSUPPORTED_INITIATOR_TYPE,
+ if self.init_dict[init_id]['init_type'] != \
+ AccessGroup.INIT_TYPE_ISCSI_IQN:
+ raise LsmError(ErrorNumber.NO_SUPPORT,
"Initiator %s is not an iSCSI IQN" % init_id)
# No iscsi chap query API yet
return None
diff --git a/plugin/sim/simulator.py b/plugin/sim/simulator.py
index b452b6a..45bed3c 100644
--- a/plugin/sim/simulator.py
+++ b/plugin/sim/simulator.py
@@ -17,10 +17,11 @@
# Gris Ge <***@redhat.com>
from lsm import (uri_parse, VERSION, Capabilities, Pool, INfs,
- IStorageAreaNetwork, Error, search_property)
+ IStorageAreaNetwork, search_property)
from simarray import SimArray
+
class SimPlugin(INfs, IStorageAreaNetwork):
"""
Simple class that implements enough to allow the framework to be exercised.
diff --git a/plugin/simc/simc_lsmplugin.c b/plugin/simc/simc_lsmplugin.c
index 045a360..72ec0e6 100644
--- a/plugin/simc/simc_lsmplugin.c
+++ b/plugin/simc/simc_lsmplugin.c
@@ -805,7 +805,7 @@ static int volume_create(lsm_plugin_ptr c, lsm_pool *pool,
lsm_volume *v = lsm_volume_record_alloc(id, volume_name,
"VPD", BS, allocated_size/BS, 0, sys_id,
- lsm_pool_id_get(pool), NULL, NULL);
+ lsm_pool_id_get(pool), NULL);
lsm_volume *to_store = lsm_volume_record_copy(v);
struct allocated_volume *av = malloc(sizeof(struct allocated_volume));
@@ -933,7 +933,7 @@ static int volume_resize(lsm_plugin_ptr c, lsm_volume *volume,
lsm_volume_vpd83_get(v),
lsm_volume_block_size_get(v),
resized_size/BS, 0, sys_id,
- lsm_volume_pool_id_get(volume), NULL, NULL);
+ lsm_volume_pool_id_get(volume), NULL);
if( vp ) {
av->v = vp;
@@ -1008,7 +1008,7 @@ static int _pool_create(lsm_plugin_ptr c, lsm_system *system,
/* Create the pool */
new_pool = lsm_pool_record_alloc(md5(pool_name), pool_name, size_bytes,
size_bytes, LSM_POOL_STATUS_OK, "",
- lsm_system_id_get(system), NULL, NULL);
+ lsm_system_id_get(system), NULL);
pool_to_store = lsm_pool_record_copy(new_pool);
key = strdup(lsm_pool_id_get(pool_to_store));
@@ -1255,7 +1255,7 @@ static int access_group_create(lsm_plugin_ptr c,
if( initiators && id &&
(LSM_ERR_OK == lsm_string_list_elem_set(initiators, 0, initiator_id))) {
ag = lsm_access_group_record_alloc(id, name, initiators, id_type,
- system_id, NULL, NULL);
+ system_id, NULL);
aag = alloc_allocated_ag(ag, id_type);
if( ag && aag ) {
g_hash_table_insert(pd->access_groups, (gpointer)id,
@@ -1943,7 +1943,7 @@ static int fs_create(lsm_plugin_ptr c, lsm_pool *pool, const char *name,
/* Make a copy to store and a copy to hand back to caller */
lsm_fs *tfs = lsm_fs_record_alloc(id, name, allocated_size,
- allocated_size, lsm_pool_id_get(pool), sys_id, NULL, NULL);
+ allocated_size, lsm_pool_id_get(pool), sys_id, NULL);
new_fs = lsm_fs_record_copy(tfs);
/* Allocate the memory to keep the associations */
@@ -2017,7 +2017,7 @@ static int fs_resize(lsm_plugin_ptr c, lsm_fs *fs,
new_size_bytes,
new_size_bytes,
lsm_fs_pool_id_get(tfs),
- lsm_fs_system_id_get(tfs), NULL, NULL);
+ lsm_fs_system_id_get(tfs), NULL);
lsm_fs *returned_copy = lsm_fs_record_copy(resized);
if( resized && returned_copy ) {
@@ -2179,7 +2179,7 @@ static int ss_create(lsm_plugin_ptr c, lsm_fs *fs,
if( !g_hash_table_lookup(find->ss, md5(name)) ) {
char *id = strdup(md5(name));
if( id ) {
- lsm_fs_ss *ss = lsm_fs_ss_record_alloc(id, name, time(NULL), NULL, NULL);
+ lsm_fs_ss *ss = lsm_fs_ss_record_alloc(id, name, time(NULL), NULL);
lsm_fs_ss *new_shot = lsm_fs_ss_record_copy(ss);
if( ss && new_shot ) {
g_hash_table_insert(find->ss, (gpointer)id, (gpointer)ss);
@@ -2378,7 +2378,7 @@ static int nfs_export_create( lsm_plugin_ptr c,
ro_list,
anon_uid,
anon_gid,
- options, NULL, NULL);
+ options, NULL);
lsm_nfs_export *value = lsm_nfs_export_record_copy(*exported);
@@ -2513,12 +2513,12 @@ int load( lsm_plugin_ptr c, const char *uri, const char *password,
pd->num_systems = 1;
pd->system[0] = lsm_system_record_alloc(sys_id,
"LSM simulated storage plug-in",
- LSM_SYSTEM_STATUS_OK, "", NULL, NULL);
+ LSM_SYSTEM_STATUS_OK, "", NULL);
p = lsm_pool_record_alloc("POOL_3", "lsm_test_aggr",
UINT64_MAX, UINT64_MAX,
LSM_POOL_STATUS_OK, "",
- sys_id, NULL, NULL);
+ sys_id, NULL);
if( p ) {
pd->pools = g_hash_table_new_full(g_str_hash, g_str_equal, free,
free_pool_record);
@@ -2531,7 +2531,7 @@ int load( lsm_plugin_ptr c, const char *uri, const char *password,
p = lsm_pool_record_alloc(name, name, UINT64_MAX,
UINT64_MAX, LSM_POOL_STATUS_OK, "",
- sys_id, NULL, NULL);
+ sys_id, NULL);
if( p ) {
g_hash_table_insert(pd->pools, strdup(lsm_pool_id_get(p)), p);
@@ -2563,42 +2563,31 @@ int load( lsm_plugin_ptr c, const char *uri, const char *password,
pd->disks = g_hash_table_new_full(g_str_hash, g_str_equal, free,
free_disk);
- /* Create disks */
- lsm_optional_data *od = lsm_optional_data_record_alloc();
- if( od ) {
- for( i = 0; i < 10; ++i ) {
- lsm_disk *d = NULL;
- char name[17];
- char sn[32];
- char *key = NULL;
+ for( i = 0; i < 10; ++i ) {
+ lsm_disk *d = NULL;
+ char name[17];
+ char *key = NULL;
+ snprintf(name, sizeof(name), "Sim C disk %d", i);
- snprintf(name, sizeof(name), "Sim C disk %d", i);
- snprintf(sn, sizeof(sn), "SIMDISKSN00000%04d", i);
-
- lsm_optional_data_string_set(od, "sn", sn);
-
- d = lsm_disk_record_alloc(md5(name), name, LSM_DISK_TYPE_SOP, 512,
- 0x8000000000000, LSM_DISK_STATUS_OK, od, sys_id);
-
- key = strdup(lsm_disk_id_get(d));
+ d = lsm_disk_record_alloc(md5(name), name, LSM_DISK_TYPE_SOP, 512,
+ 0x8000000000000, LSM_DISK_STATUS_OK, sys_id);
- if( !key || !d ) {
- g_hash_table_destroy(pd->disks);
- pd->disks = NULL;
+ key = strdup(lsm_disk_id_get(d));
- lsm_disk_record_free(d);
- d = NULL;
+ if( !key || !d ) {
+ g_hash_table_destroy(pd->disks);
+ pd->disks = NULL;
- break;
- }
-
- g_hash_table_insert(pd->disks, key, d);
+ lsm_disk_record_free(d);
d = NULL;
+
+ break;
}
- lsm_optional_data_record_free(od);
- }
+ g_hash_table_insert(pd->disks, key, d);
+ d = NULL;
+ }
if( !pd->system[0] || !pd->volumes || !pd->pools || !pd->access_groups
|| !pd->group_grant || !pd->fs || !pd->jobs || !pd->disks ) {
diff --git a/plugin/smispy/smis.py b/plugin/smispy/smis.py
index 6d10973..dea6da7 100644
--- a/plugin/smispy/smis.py
+++ b/plugin/smispy/smis.py
@@ -26,7 +26,7 @@ from pywbem import CIMError
from lsm import (IStorageAreaNetwork, Error, uri_parse, LsmError, ErrorNumber,
JobStatus, md5, Pool, Volume, AccessGroup, System,
- Capabilities, Disk, OptionalData, txt_a, VERSION,
+ Capabilities, Disk, txt_a, VERSION,
search_property)
## Variable Naming scheme:
@@ -131,8 +131,6 @@ def _dmtf_init_type_to_lsm(cim_init):
return _INIT_TYPE_CONV[cim_init['IDType']]
return AccessGroup.INIT_TYPE_UNKNOWN
-def _lsm_init_type_to_dmtf(lsm_init_type):
- return _get_key(_INIT_TYPE_CONV, lsm_init_type)
def _get_key(dictionary, value):
keys = [k for k, v in dictionary.items() if v == value]
@@ -147,7 +145,7 @@ def _lsm_init_type_to_dmtf(init_type):
raise LsmError(ErrorNumber.NO_SUPPORT,
"Does not support provided init_type: %d" % init_type)
else:
- return key
+ return key
class SNIA(object):
@@ -247,10 +245,10 @@ class Smis(IStorageAreaNetwork):
_DMTF_DISK_TYPE_2_LSM = {
DMTF_DISK_TYPE_UNKNOWN: Disk.DISK_TYPE_UNKNOWN,
- DMTF_DISK_TYPE_OTHER: Disk.DISK_TYPE_OTHER,
- DMTF_DISK_TYPE_HDD: Disk.DISK_TYPE_HDD,
- DMTF_DISK_TYPE_SSD: Disk.DISK_TYPE_SSD,
- DMTF_DISK_TYPE_HYBRID: Disk.DISK_TYPE_HYBRID,
+ DMTF_DISK_TYPE_OTHER: Disk.DISK_TYPE_OTHER,
+ DMTF_DISK_TYPE_HDD: Disk.DISK_TYPE_HDD,
+ DMTF_DISK_TYPE_SSD: Disk.DISK_TYPE_SSD,
+ DMTF_DISK_TYPE_HYBRID: Disk.DISK_TYPE_HYBRID,
}
@staticmethod
@@ -925,7 +923,6 @@ class Smis(IStorageAreaNetwork):
"Smis._cim_class_name_of() got unknown " +
"class_type %s" % class_type)
-
@staticmethod
def _property_list_of_id(class_type, extra_properties=None):
"""
@@ -950,8 +947,8 @@ class Smis(IStorageAreaNetwork):
rc = ['StorageID']
else:
raise LsmError(ErrorNumber.LSM_BUG,
- "Smis._cim_class_name_of() got unknown " +
- "class_type %s" % class_type)
+ "Smis._cim_class_name_of() got unknown " +
+ "class_type %s" % class_type)
if extra_properties:
rc = _merge_list(rc, extra_properties)
@@ -1398,7 +1395,7 @@ class Smis(IStorageAreaNetwork):
return [p for p in cim_pools if not p["Primordial"]]
- def _new_pool_cim_pool_pros(self, flag_full_info=False):
+ def _new_pool_cim_pool_pros(self):
"""
Return a list of properties for creating new pool.
"""
@@ -1406,9 +1403,6 @@ class Smis(IStorageAreaNetwork):
pool_pros.extend(['ElementName', 'TotalManagedSpace',
'RemainingManagedSpace', 'Usage',
'OperationalStatus'])
- if flag_full_info:
- pool_pros.extend(['SpaceLimitDetermination',
- 'ThinProvisionMetaDataSpace'])
return pool_pros
@handle_cim_errors
@@ -1427,8 +1421,7 @@ class Smis(IStorageAreaNetwork):
profile.
"""
rc = []
- cim_pool_pros = self._new_pool_cim_pool_pros(
- bool(flags & Pool.FLAG_RETRIEVE_FULL_INFO))
+ cim_pool_pros = self._new_pool_cim_pool_pros()
cim_sys_pros = self._property_list_of_id("System")
cim_syss = self._root_cim_syss(cim_sys_pros)
@@ -1465,10 +1458,6 @@ class Smis(IStorageAreaNetwork):
pool = self._new_pool(cim_pool, system_id)
if pool:
rc.extend([pool])
- if flags & Pool.FLAG_RETRIEVE_FULL_INFO:
- opt_pro_dict = self._pool_opt_data(cim_pool)
- for key, value in opt_pro_dict.items():
- pool.optional_data.set(key, value)
else:
raise LsmError(ErrorNumber.LSM_BUG,
"Failed to retrieve pool information " +
@@ -2096,10 +2085,8 @@ class Smis(IStorageAreaNetwork):
"_initiator_create(): Got more than one "
"CIM_StorageHardwareIDManagementService")
- in_params = {#'ElementName': init_id,
- 'StorageID': init_id,
+ in_params = {'StorageID': init_id,
'IDType': pywbem.Uint16(dmtf_id_type)}
- print in_params
(rc, out) = self._c.InvokeMethod('CreateStorageHardwareID',
cim_hw_srvs[0], **in_params)
@@ -2129,7 +2116,7 @@ class Smis(IStorageAreaNetwork):
# Check to see if we have this initiator already, if we don't create
# it and then add to the view.
if self._get_cim_instance_by_id(
- 'Initiator', init_id, raise_error=False) is None:
+ 'Initiator', init_id, raise_error=False) is None:
dmtf_id_type = _lsm_init_type_to_dmtf(init_type)
if dmtf_id_type is None:
raise LsmError(ErrorNumber.NO_SUPPORT,
@@ -2232,7 +2219,7 @@ class Smis(IStorageAreaNetwork):
cim_ext = self._pri_cim_ext_of_cim_disk(cim_disk.path,
cim_ext_pros)
- rc.extend([self._new_disk(cim_disk, cim_ext, flags)])
+ rc.extend([self._new_disk(cim_disk, cim_ext)])
return search_property(rc, search_key, search_value)
@staticmethod
@@ -2242,8 +2229,6 @@ class Smis(IStorageAreaNetwork):
"""
pros = ['OperationalStatus', 'Name', 'SystemName',
'Caption', 'InterconnectType', 'DiskType']
- if flag & Disk.FLAG_RETRIEVE_FULL_INFO:
- pros.extend(['ErrorDescription', 'ErrorCleared'])
return pros
@staticmethod
@@ -2255,19 +2240,6 @@ class Smis(IStorageAreaNetwork):
return ['BlockSize', 'NumberOfBlocks']
@staticmethod
- def _new_disk_cim_phy_pkg_pros(flag=0):
- """
- Return all CIM_PhysicalPackage Properties needed to create a Disk
- object.
- """
- pros = [] # we don't need CIM_PhysicalPackage when not
- # FLAG_RETRIEVE_FULL_INFO
- if flag & Disk.FLAG_RETRIEVE_FULL_INFO:
- pros.extend(['SerialNumber', 'PartNumber', 'Manufacturer',
- 'Model'])
- return pros
-
- @staticmethod
def _disk_status_of(cim_disk):
"""
Converting CIM_StorageDisk['OperationalStatus'] LSM Disk.status.
@@ -2291,7 +2263,7 @@ class Smis(IStorageAreaNetwork):
Smis._DMTF_STAUTS_TO_DISK_STATUS_INFO[dmtf_status])
return (status, status_info)
- def _new_disk(self, cim_disk, cim_ext, flag_full_info=0):
+ def _new_disk(self, cim_disk, cim_ext):
"""
Takes a CIM_DiskDrive and CIM_StorageExtent, returns a lsm Disk
Assuming cim_disk and cim_ext already contained the correct
@@ -2345,52 +2317,8 @@ class Smis(IStorageAreaNetwork):
if ccn == 'LSIESG_TargetSASProtocolEndpoint':
disk_type = Disk.DISK_TYPE_SAS
- optionals = OptionalData()
- if flag_full_info & Disk.FLAG_RETRIEVE_FULL_INFO:
- opt_pro_dict = {
- 'sn': '',
- 'part_num': '',
- 'vendor': '',
- 'model': '',
- 'status_info': '',
- }
- cim_phy_pkg_pros = Smis._new_disk_cim_phy_pkg_pros(flag_full_info)
- cim_phy_pkgs = self._c.Associators(
- cim_disk.path,
- AssocClass='CIM_Realizes',
- ResultClass='CIM_PhysicalPackage',
- PropertyList=cim_phy_pkg_pros)
- if not (cim_phy_pkgs and cim_phy_pkgs[0]):
- raise LsmError(ErrorNumber.LSM_BUG,
- "Failed to find out the CIM_PhysicalPackage " +
- "of CIM_DiskDrive %s" % cim_disk.path)
- cim_phy_pkg = cim_phy_pkgs[0]
- if 'Manufacturer' in cim_phy_pkg and cim_phy_pkg['Manufacturer']:
- opt_pro_dict['vendor'] = cim_phy_pkg['Manufacturer']
- if 'Model' in cim_phy_pkg and cim_phy_pkg['Model']:
- opt_pro_dict['model'] = cim_phy_pkg['Model']
- if 'SerialNumber' in cim_phy_pkg and cim_phy_pkg['SerialNumber']:
- opt_pro_dict['sn'] = cim_phy_pkg['SerialNumber']
- if 'PartNumber' in cim_phy_pkg and cim_phy_pkg['PartNumber']:
- opt_pro_dict['part_num'] = cim_phy_pkg['PartNumber']
- if 'ErrorCleared' in cim_disk:
- if not cim_disk['ErrorCleared']:
- if 'ErrorDescription' in cim_disk:
- opt_pro_dict['status_info'] = txt_a(
- status_info,
- cim_disk['ErrorDescription'])
- else:
- raise LsmError(ErrorNumber.LSM_BUG,
- "CIM_DiskDrive %s " % cim_disk.id +
- "has ErrorCleared == False but " +
- "does not have " +
- "CIM_DiskDrive['ErrorDescription']")
-
- for opt_pro_name in opt_pro_dict.keys():
- optionals.set(opt_pro_name, opt_pro_dict[opt_pro_name])
-
new_disk = Disk(self._disk_id(cim_disk), name, disk_type, block_size,
- num_of_block, status, sys_id, optionals)
+ num_of_block, status, sys_id)
return new_disk
diff --git a/plugin/targetd/targetd.py b/plugin/targetd/targetd.py
index ed4c945..d04bb00 100644
--- a/plugin/targetd/targetd.py
+++ b/plugin/targetd/targetd.py
@@ -151,10 +151,9 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
p['type'] == 'block'):
for vol in self._jsonrequest("vol_list", dict(pool=p_name)):
volumes.append(
- Volume(vol['uuid'], vol['name'], vol['uuid'],
- 512, vol['size'] / 512,
- Volume.STATUS_OK,
- self.system.id, p_name))
+ Volume(vol['uuid'], vol['name'], vol['uuid'], 512,
+ vol['size'] / 512, Volume.STATUS_OK, self.system.id,
+ p_name))
return search_property(volumes, search_key, search_value)
@handle_errors
@@ -176,9 +175,8 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
ag_name = 'N/A'
init_ids = [init_id]
rc.extend(
- [AccessGroup(
- ag_id, ag_name, init_ids, init_type,
- self.system.id)])
+ [AccessGroup(ag_id, ag_name, init_ids, init_type,
+ self.system.id)])
return search_property(rc, search_key, search_value)
def _mask_infos(self):
@@ -264,9 +262,9 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
vol = [v for v in self._jsonrequest("vol_list", dict(pool=pool_id))
if v['name'] == volume_name][0]
- return Volume(vol['uuid'], vol['name'], vol['uuid'],
- 512, vol['size'] / 512, Volume.STATUS_OK,
- self.system.id, pool_id)
+ return Volume(vol['uuid'], vol['name'], vol['uuid'], 512,
+ vol['size'] / 512, Volume.STATUS_OK, self.system.id,
+ pool_id)
def _get_fs(self, pool_id, fs_name):
fs = self.fs()
@@ -344,8 +342,7 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
for fs in self._jsonrequest("fs_list"):
#self, id, name, total_space, free_space, pool_id, system_id
rc.append(FileSystem(fs['uuid'], fs['name'], fs['total_space'],
- fs['free_space'], fs['pool'],
- self.system.id))
+ fs['free_space'], fs['pool'], self.system.id))
return search_property(rc, search_key, search_value)
@handle_errors
@@ -495,12 +492,12 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
if gid is not None:
anongid = gid
- exports.append(NfsExport(
- TargetdStorage._calculate_export_md5(export['path'],
- options),
- fs_full_paths[export['path']]['uuid'],
- export['path'], sec, root, rw, ro, anonuid,
- anongid, TargetdStorage._option_string(options)))
+ exports.append(
+ NfsExport(TargetdStorage._calculate_export_md5(export['path'],
+ options),
+ fs_full_paths[export['path']]['uuid'],
+ export['path'], sec, root, rw, ro, anonuid, anongid,
+ TargetdStorage._option_string(options)))
return search_property(exports, search_key, search_value)
diff --git a/plugin/v7k/ibmv7k.py b/plugin/v7k/ibmv7k.py
index de63a99..5d7233c 100644
--- a/plugin/v7k/ibmv7k.py
+++ b/plugin/v7k/ibmv7k.py
@@ -220,8 +220,7 @@ class IbmV7k(IStorageAreaNetwork):
return Volume(v['id'], v['name'], v['vdisk_UID'], bs,
(float(v['capacity']) / bs), vol_status,
- self.sys_info.id,
- v['mdisk_grp_id'])
+ self.sys_info.id, v['mdisk_grp_id'])
def _create_volume(self, pool, vol_name, size_bytes, prov):
ssh_cmd = ('mkvdisk -name %s -mdiskgrp %s -iogrp 0 -size %s'
diff --git a/python_binding/lsm/__init__.py b/python_binding/lsm/__init__.py
index e1f6c36..b1f059b 100644
--- a/python_binding/lsm/__init__.py
+++ b/python_binding/lsm/__init__.py
@@ -6,7 +6,7 @@ from _common import Error, Info, LsmError, ErrorLevel, ErrorNumber, \
JobStatus, uri_parse, md5, Proxy, size_bytes_2_size_human, \
common_urllib2_error_handler, size_human_2_size_bytes
from _data import (Disk, Volume, Pool, System, FileSystem, FsSnapshot,
- NfsExport, BlockRange, AccessGroup, OptionalData,
+ NfsExport, BlockRange, AccessGroup,
Capabilities, txt_a)
from _iplugin import IPlugin, IStorageAreaNetwork, INetworkAttachedStorage, \
INfs
diff --git a/python_binding/lsm/_common.py b/python_binding/lsm/_common.py
index 1cec9d0..452f8fd 100644
--- a/python_binding/lsm/_common.py
+++ b/python_binding/lsm/_common.py
@@ -456,7 +456,6 @@ class ErrorNumber(object):
INVALID_SYSTEM = 117
INVALID_IQN = 118
INVALID_DISK = 119
- INVALID_OPTIONAL_DATA = 120
INVALID_BLOCK_RANGE = 121
IS_MAPPED = 125
diff --git a/python_binding/lsm/_data.py b/python_binding/lsm/_data.py
index f86d283..979007f 100644
--- a/python_binding/lsm/_data.py
+++ b/python_binding/lsm/_data.py
@@ -24,7 +24,6 @@ except ImportError:
import json
from json.decoder import WHITESPACE
-from lsm import LsmError, ErrorNumber
from _common import get_class, default_property
@@ -159,21 +158,6 @@ class IData(object):
"""
return str(self._to_dict())
- def _check_opt_data(self, optional_data):
- if optional_data is None:
- return OptionalData()
- else:
- #Make sure the properties only contain ones we permit
- allowed = set(self.OPT_PROPERTIES)
- actual = set(optional_data.keys())
-
- if actual <= allowed:
- return optional_data
- else:
- raise LsmError(ErrorNumber.INVALID_ARGUMENT,
- "Property keys are not supported: %s" %
- "".join(actual - allowed))
-
@default_property('id', doc="Unique identifier")
@default_property('name', doc="Disk name (aka. vendor)")
@@ -182,14 +166,12 @@ class IData(object):
@default_property('num_of_blocks', doc="Total number of blocks")
@default_property('status', doc="Enumerated status")
@default_property('system_id', doc="System identifier")
-@default_property("optional_data", doc="Optional data")
@default_property("plugin_data", doc="Private plugin data")
class Disk(IData):
"""
Represents a disk.
"""
SUPPORTED_SEARCH_KEYS = ['id', 'system_id']
- 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
@@ -232,7 +214,7 @@ class Disk(IData):
OPT_PROPERTIES = ['sn', 'part_num', 'vendor', 'model']
def __init__(self, _id, _name, _disk_type, _block_size, _num_of_blocks,
- _status, _system_id, _optional_data=None, _plugin_data=None):
+ _status, _system_id, _plugin_data=None):
self._id = _id
self._name = _name
self._disk_type = _disk_type
@@ -240,7 +222,6 @@ class Disk(IData):
self._num_of_blocks = _num_of_blocks
self._status = _status
self._system_id = _system_id
- self._optional_data = self._check_opt_data(_optional_data)
self._plugin_data = _plugin_data
@property
@@ -262,14 +243,11 @@ class Disk(IData):
@default_property('status', doc="Enumerated volume status")
@default_property('system_id', doc="System identifier")
@default_property('pool_id', doc="Pool identifier")
-@default_property("optional_data", doc="Optional data")
@default_property("plugin_data", doc="Private plugin data")
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.
@@ -286,8 +264,7 @@ class Volume(IData):
(-1, 1, 2, 3)
def __init__(self, _id, _name, _vpd83, _block_size, _num_of_blocks,
- _status, _system_id, _pool_id, _optional_data=None,
- _plugin_data=None):
+ _status, _system_id, _pool_id, _plugin_data=None):
self._id = _id # Identifier
self._name = _name # Human recognisable name
self._vpd83 = _vpd83 # SCSI page 83 unique ID
@@ -296,7 +273,6 @@ class Volume(IData):
self._status = _status # Status
self._system_id = _system_id # System id this volume belongs
self._pool_id = _pool_id # Pool id this volume belongs
- self._optional_data = self._check_opt_data(_optional_data)
self._plugin_data = _plugin_data
@property
@@ -314,7 +290,6 @@ class Volume(IData):
@default_property('name', doc="User defined system name")
@default_property('status', doc="Enumerated status of system")
@default_property('status_info', doc="Detail status information of system")
-@default_property("optional_data", doc="Optional data")
@default_property("plugin_data", doc="Private plugin data")
class System(IData):
"""
@@ -372,10 +347,6 @@ class System(IData):
String. Free form string used for explaining system status. For example:
"Disk <disk_id> is in Offline state. Battery X is near end of life"
-##### 11.3.2 System Optional Properties
-
-The lsm.System class does not have any optional properties yet.
-
##### 11.3.3 System Extra Constants
The lsm.System class does not have any extra constants.
@@ -384,8 +355,6 @@ 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
@@ -397,13 +366,11 @@ The lsm.System class does not have class methods.
STATUS_STOPPED = 1 << 8
STATUS_OTHER = 1 << 9
- def __init__(self, _id, _name, _status, _status_info, _optional_data=None,
- _plugin_data=None):
+ def __init__(self, _id, _name, _status, _status_info, _plugin_data=None):
self._id = _id
self._name = _name
self._status = _status
self._status_info = _status_info
- self._optional_data = self._check_opt_data(_optional_data)
self._plugin_data = _plugin_data
@@ -414,13 +381,11 @@ The lsm.System class does not have class methods.
@default_property('status', doc="Enumerated status")
@default_property('status_info', doc="Text explaining status")
@default_property('system_id', doc="System identifier")
-@default_property("optional_data", doc="Optional data")
@default_property("plugin_data", doc="Plug-in private data")
class Pool(IData):
"""
Pool specific information
"""
- FLAG_RETRIEVE_FULL_INFO = 1 << 0
SUPPORTED_SEARCH_KEYS = ['id', 'system_id']
TOTAL_SPACE_NOT_FOUND = -1
@@ -609,8 +574,7 @@ class Pool(IData):
'element_type', 'thinp_type']
def __init__(self, _id, _name, _total_space, _free_space, _status,
- _status_info, _system_id, _optional_data=None,
- _plugin_data=None):
+ _status_info, _system_id, _plugin_data=None):
self._id = _id # Identifier
self._name = _name # Human recognisable name
self._total_space = _total_space # Total size
@@ -619,7 +583,6 @@ 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
- self._optional_data = self._check_opt_data(_optional_data)
@default_property('id', doc="Unique identifier")
@@ -628,38 +591,31 @@ class Pool(IData):
@default_property('free_space', doc="Free space available")
@default_property('pool_id', doc="What pool the file system resides on")
@default_property('system_id', doc="System ID")
-@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,
- _system_id, _optional_data=None, _plugin_data=None):
+ _system_id, _plugin_data=None):
self._id = _id
self._name = _name
self._total_space = _total_space
self._free_space = _free_space
self._pool_id = _pool_id
self._system_id = _system_id
- self._optional_data = self._check_opt_data(_optional_data)
self._plugin_data = _plugin_data
@default_property('id', doc="Unique identifier")
@default_property('name', doc="Snapshot name")
@default_property('ts', doc="Time stamp the snapshot was created")
-@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):
+ def __init__(self, _id, _name, _ts, _plugin_data=None):
self._id = _id
self._name = _name
self._ts = int(_ts)
- self._optional_data = self._check_opt_data(_optional_data)
self._plugin_data = _plugin_data
@@ -673,17 +629,14 @@ class FsSnapshot(IData):
@default_property('anonuid', doc="UID for anonymous user id")
@default_property('anongid', doc="GID for anonymous group id")
@default_property('options', doc="String containing advanced options")
-@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)
def __init__(self, _id, _fs_id, _export_path, _auth, _root, _rw, _ro,
- _anonuid, _anongid, _options, _optional_data=None,
- _plugin_data=None):
+ _anonuid, _anongid, _options, _plugin_data=None):
assert (_fs_id is not None)
assert (_export_path is not None)
@@ -697,7 +650,6 @@ class NfsExport(IData):
self._anonuid = _anonuid # uid for anonymous user id
self._anongid = _anongid # gid for anonymous group id
self._options = _options # NFS options
- self._optional_data = self._check_opt_data(_optional_data)
self._plugin_data = _plugin_data
@@ -716,10 +668,8 @@ class BlockRange(IData):
@default_property('init_ids', doc="List of initiator IDs")
@default_property('init_type', doc="Initiator type")
@default_property('system_id', doc="System identifier")
-@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
@@ -731,37 +681,14 @@ class AccessGroup(IData):
INIT_TYPE_SAS = 6
INIT_TYPE_ISCSI_WWPN_MIXED = 7
- def __init__(self, _id, _name, _init_ids, _init_type,
- _system_id, _optional_data=None, _plugin_data=None):
+ def __init__(self, _id, _name, _init_ids, _init_type, _system_id,
+ _plugin_data=None):
self._id = _id
self._name = _name # AccessGroup name
self._init_ids = _init_ids # List of initiator IDs
self._init_type = _init_type
self._system_id = _system_id # System id this group belongs
self._plugin_data = _plugin_data
- self._optional_data = self._check_opt_data(_optional_data)
-
-
-class OptionalData(IData):
- def _column_data(self, human=False, enum_as_number=False):
- return [sorted(self._values.iterkeys(),
- key=lambda k: self._values[k][1])]
-
- def __init__(self, _values=None):
- if _values is not None:
- self._values = _values
- else:
- self._values = {}
-
- def keys(self):
- rc = self._values.keys()
- return rc
-
- def get(self, key):
- return self._values[key]
-
- def set(self, key, value):
- self._values[str(key)] = value
class Capabilities(IData):
diff --git a/test/plugin_test.py b/test/plugin_test.py
index 089449d..04adda4 100755
--- a/test/plugin_test.py
+++ b/test/plugin_test.py
@@ -253,9 +253,10 @@ class TestPlugin(unittest.TestCase):
def _get_pool_by_usage(self, system_id, element_type):
for p in self.pool_by_sys_id[system_id]:
- if 'element_type' in p.optional_data.keys():
- if int(p.optional_data.get('element_type')) == element_type:
- return p
+ return p
+ #if 'element_type' in p.optional_data.keys():
+ # if int(p.optional_data.get('element_type')) == element_type:
+ # return p
return None
def tearDown(self):
@@ -327,9 +328,9 @@ class TestPlugin(unittest.TestCase):
pools = self.pool_by_sys_id[system_id]
for p in pools:
- if p.free_space > mb_in_bytes(250) and \
- int(p.optional_data.get('element_type')) & \
- lsm.Pool.ELEMENT_TYPE_FS:
+ if p.free_space > mb_in_bytes(250): #and \
+ #int(p.optional_data.get('element_type')) & \
+ #lsm.Pool.ELEMENT_TYPE_FS:
fs_size = min(p.free_space / 10, mb_in_bytes(512))
fs = self.c.fs_create(p, rs('fs'), fs_size)[1]
self.assertTrue(self._fs_exists(fs.id))
diff --git a/test/tester.c b/test/tester.c
index 926d05a..ff52fd1 100644
--- a/test/tester.c
+++ b/test/tester.c
@@ -1035,16 +1035,10 @@ START_TEST(test_disks)
const char *name;
const char *system_id;
int i = 0;
- lsm_string_list *keys = NULL;
- const char *key = NULL;
- const char *data = NULL;
- lsm_optional_data *od = NULL;
- uint32_t j;
fail_unless(c!=NULL);
- int rc = lsm_disk_list(c, NULL, NULL, &d, &count,
- LSM_DISK_FLAG_RETRIEVE_FULL_INFO);
+ int rc = lsm_disk_list(c, NULL, NULL, &d, &count, 0);
if( LSM_ERR_OK == rc ) {
fail_unless(LSM_ERR_OK == rc, "%d", rc);
@@ -1074,47 +1068,6 @@ START_TEST(test_disks)
fail_unless( lsm_disk_block_size_get(d[i]) >= 1);
fail_unless( lsm_disk_status_get(d[i]) >= 1);
- od = lsm_disk_optional_data_get(d[i]);
- if( od ) {
- lsm_optional_data_type t;
-
- /* Iterate through the keys, grabbing the data */
- rc = lsm_optional_data_keys(od, &keys);
- if( LSM_ERR_OK == rc && keys != NULL &&
- lsm_string_list_size(keys) > 0 ) {
- for(j = 0; j < lsm_string_list_size(keys); ++j ) {
- key = lsm_string_list_elem_get(keys, j);
-
- fail_unless(key != NULL && strlen(key) > 0);
-
- t = lsm_optional_data_type_get(od, key);
- if( LSM_OPTIONAL_DATA_STRING == t ) {
- data = lsm_optional_data_string_get(od, key);
- printf("Key=%s, Data=%s\n", key, data);
- fail_unless(data != NULL && strlen(data) > 0);
- } else if( LSM_OPTIONAL_DATA_STRING_LIST == t ) {
- lsm_string_list *sl = lsm_optional_data_string_list_get(od, key);
- if( sl ) {
- int size = lsm_string_list_size(sl);
- int j;
-
- printf("Key=%s, Data=", key);
-
- for( j = 0; j < size; j++ ) {
- printf("%s ", lsm_string_list_elem_get(sl, j));
- }
- printf("\n");
- }
- }
- }
-
- if( keys ) {
- rc = lsm_string_list_free(keys);
- fail_unless(LSM_ERR_OK == rc, "rc = %d", rc);
- }
- }
- lsm_optional_data_record_free(od);
- }
}
lsm_disk_record_array_free(d, count);
} else {
@@ -2272,7 +2225,7 @@ START_TEST(test_nfs_export_funcs)
lsm_nfs_export *export = lsm_nfs_export_record_alloc(id, fs_id, export_path, auth,
- root, rw, ro, anonuid, anongid, options, NULL, p_data);
+ root, rw, ro, anonuid, anongid, options, p_data);
lsm_nfs_export *copy = lsm_nfs_export_record_copy(export);
@@ -2607,7 +2560,7 @@ START_TEST(test_uri_parse)
char *server = NULL;
char *path = NULL;
int port = 0;
- lsm_optional_data *qp = NULL;
+ lsm_hash *qp = NULL;
int rc = lsm_uri_parse(uri_g, &scheme, &user, &server, &port, &path, &qp);
fail_unless(LSM_ERR_OK == rc, "lsm_uri_parse %d", rc);
@@ -2622,15 +2575,15 @@ START_TEST(test_uri_parse)
fail_unless(qp != NULL);
if( qp ) {
fail_unless(strcmp("root/uber",
- lsm_optional_data_string_get(qp, "namespace")) == 0,
- "%s", lsm_optional_data_string_get(qp, "namespace"));
+ lsm_hash_string_get(qp, "namespace")) == 0,
+ "%s", lsm_hash_string_get(qp, "namespace"));
}
free(scheme);
free(user);
free(server);
free(path);
- lsm_optional_data_record_free(qp);
+ lsm_hash_free(qp);
}
}
END_TEST
@@ -3003,68 +2956,6 @@ START_TEST(test_search_fs)
}
END_TEST
-START_TEST(test_pool_listing)
-{
- lsm_pool **pools = NULL;
- uint32_t count = 0;
- lsm_optional_data *op = NULL;
- uint32_t i,j = 0;
- lsm_optional_data_type t;
- lsm_string_list *keys = NULL;
-
- int rc = lsm_pool_list(c, NULL, NULL, &pools, &count,
- LSM_POOL_FLAG_RETRIEVE_FULL_INFO);
- if( LSM_ERR_OK == rc ) {
- for( i = 0; i < count; ++i ) {
- op = lsm_pool_optional_data_get(pools[i]);
-
- if( op ) {
- rc = lsm_optional_data_keys(op, &keys);
- fail_unless(LSM_ERR_OK == rc, "lsm_optional_data_keys %d", rc);
-
- if(LSM_ERR_OK == rc ) {
-
- for(j = 0; j < lsm_string_list_size(keys); ++j ) {
- const char *key = lsm_string_list_elem_get(keys, j);
- t = lsm_optional_data_type_get(op, key);
- if( LSM_OPTIONAL_DATA_STRING == t ) {
- const char *value = lsm_optional_data_string_get(op, key);
- fail_unless(value != NULL && strlen(value) > 0);
- printf("%s=%s\n", key, value);
- } else if( LSM_OPTIONAL_DATA_STRING_LIST == t ) {
- lsm_string_list *v = lsm_optional_data_string_list_get(op, key);
- if( v ) {
- uint32_t k;
-
- printf("%s=[", key);
- for( k = 0; k < lsm_string_list_size(v); ++k ) {
- printf("%s ",
- lsm_string_list_elem_get(v, k));
- }
- printf("]\n");
- lsm_string_list_free(v);
- }
- } else if( LSM_OPTIONAL_DATA_SIGN_INT == t ) {
- int64_t value = lsm_optional_data_int64_get(op, key);
- printf("%s:%" PRId64 "\n", key, value);
- }
- }
-
- rc = lsm_string_list_free(keys);
- fail_unless(LSM_ERR_OK == rc, "lsm_string_list_free %d", rc);
- }
-
- rc = lsm_optional_data_record_free(op);
- fail_unless(LSM_ERR_OK == rc, "lsm_optional_data_record_free %d", rc);
- }
- }
-
- rc = lsm_pool_record_array_free(pools, count);
- fail_unless(LSM_ERR_OK == rc, "lsm_pool_record_array_free %d", rc);
- }
-}
-END_TEST
-
Suite * lsm_suite(void)
{
Suite *s = suite_create("libStorageMgmt");
@@ -3072,7 +2963,6 @@ Suite * lsm_suite(void)
TCase *basic = tcase_create("Basic");
tcase_add_checked_fixture (basic, setup, teardown);
- tcase_add_test(basic, test_pool_listing);
tcase_add_test(basic, test_search_fs);
tcase_add_test(basic, test_search_access_groups);
tcase_add_test(basic, test_search_disks);
diff --git a/tools/lsmcli/cmdline.py b/tools/lsmcli/cmdline.py
index 27c673f..47e058d 100644
--- a/tools/lsmcli/cmdline.py
+++ b/tools/lsmcli/cmdline.py
@@ -29,7 +29,7 @@ from argparse import RawTextHelpFormatter
from lsm import (Client, Pool, VERSION, LsmError, Capabilities, Disk,
Volume, JobStatus, ErrorNumber, BlockRange,
uri_parse, Proxy, size_human_2_size_bytes,
- AccessGroup, FileSystem, NfsExport, System, FsSnapshot)
+ AccessGroup, FileSystem, NfsExport)
from lsm.lsmcli.data_display import (
DisplayData, PlugData, out,
@@ -71,6 +71,7 @@ def getch():
termios.tcsetattr(fd, termios.TCSADRAIN, prev)
return ch
+
## This class represents a command line argument error
class ArgError(Exception):
def __init__(self, message, *args, **kwargs):
@@ -104,7 +105,7 @@ list_choices = ['VOLUMES', 'POOLS', 'FS', 'SNAPSHOTS',
init_types = ('WWPN', 'WWNN', 'ISCSI', 'HOSTNAME', 'SAS')
init_id_help = "Access Group Initiator type: " + \
- ", ".join(init_types)
+ ", ".join(init_types)
provision_types = ('DEFAULT', 'THIN', 'FULL')
provision_help = "provisioning type: " + ", ".join(provision_types)
@@ -187,12 +188,6 @@ cmds = (
type=str.upper),
],
optional=[
- dict(name=('-o', '--optional'),
- help='Retrieve both mandatory and optional properties.\n'
- 'Once define, will use "-s, --script" display way',
- default=False,
- dest='optional',
- action='store_true'),
dict(sys_id_filter_opt),
dict(pool_id_filter_opt),
dict(vol_id_filter_opt),
@@ -603,10 +598,6 @@ cmds = (
dict(name="--member-type", metavar='<MEMBER_TYPE>',
help=member_help,
choices=member_types),
- dict(name=('-o', '--optional'),
- help='Retrieve additional optional info if available',
- default=False,
- action='store_true'),
],
),
@@ -626,12 +617,6 @@ cmds = (
choices=raid_types,
type=str.upper),
],
- optional=[
- dict(name=('-o', '--optional'),
- help='Retrieve additional optional info if available',
- default=False,
- action='store_true'),
- ],
),
dict(
@@ -650,12 +635,6 @@ cmds = (
choices=raid_types,
type=str.upper),
],
- optional=[
- dict(name=('-o', '--optional'),
- help='Retrieve additional optional info if available',
- default=False,
- action='store_true'),
- ],
),
dict(
@@ -671,12 +650,6 @@ cmds = (
dict(name="--size", metavar='<SIZE>',
help='The size of new pool'),
],
- optional=[
- dict(name=('-o', '--optional'),
- help='Retrieve additional optional info if available',
- default=False,
- action='store_true'),
- ],
),
dict(
@@ -724,16 +697,13 @@ class CmdLine:
# Tries to make the output better when it varies considerably from
# plug-in to plug-in.
# @param objects Data, first row is header all other data.
- def display_data(self, objects, extra_properties=None):
+ def display_data(self, objects):
display_all = False
if len(objects) == 0:
return
display_way = DisplayData.DISPLAY_WAY_DEFAULT
- if hasattr(self.args, 'optional') and self.args.optional:
- display_all = True
- display_way = DisplayData.DISPLAY_WAY_SCRIPT
flag_with_header = True
if self.args.sep:
@@ -746,7 +716,7 @@ class CmdLine:
DisplayData.display_data(
objects, display_way=display_way, flag_human=self.args.human,
- flag_enum=self.args.enum, extra_properties=extra_properties,
+ flag_enum=self.args.enum,
splitter=self.args.sep, flag_with_header=flag_with_header,
flag_dsp_all_data=display_all)
@@ -867,7 +837,6 @@ class CmdLine:
def list(self, args):
search_key = None
search_value = None
- flags = 0
if args.sys:
search_key = 'system_id'
search_value = args.sys
@@ -891,8 +860,6 @@ class CmdLine:
search_value = args.nfs_export
if args.type == 'VOLUMES':
- if args.optional:
- flags |= Volume.FLAG_RETRIEVE_FULL_INFO
if search_key == 'volume_id':
search_key = 'id'
if search_key == 'access_group_id':
@@ -900,56 +867,45 @@ class CmdLine:
"Access Group ID", raise_error=False)
if lsm_ag:
return self.display_data(
- self.c.volumes_accessible_by_access_group(lsm_ag, flags))
+ self.c.volumes_accessible_by_access_group(lsm_ag))
else:
return self.display_data([])
elif search_key and search_key not in Volume.SUPPORTED_SEARCH_KEYS:
raise ArgError("Search key '%s' is not supported by "
"volume listing." % search_key)
- self.display_data(self.c.volumes(search_key, search_value, flags))
+ self.display_data(self.c.volumes(search_key, search_value))
elif args.type == 'POOLS':
if search_key == 'pool_id':
search_key = 'id'
if search_key and search_key not in Pool.SUPPORTED_SEARCH_KEYS:
raise ArgError("Search key '%s' is not supported by "
"pool listing." % search_key)
- if args.optional:
- flags |= Pool.FLAG_RETRIEVE_FULL_INFO
self.display_data(
- self.c.pools(search_key, search_value, flags))
+ self.c.pools(search_key, search_value))
elif args.type == 'FS':
- if args.optional:
- flags |= FileSystem.FLAG_RETRIEVE_FULL_INFO
if search_key == 'fs_id':
search_key = 'id'
if search_key and \
search_key not in FileSystem.SUPPORTED_SEARCH_KEYS:
raise ArgError("Search key '%s' is not supported by "
"volume listing." % search_key)
- self.display_data(self.c.fs(search_key, search_value, flags))
+ self.display_data(self.c.fs(search_key, search_value))
elif args.type == 'SNAPSHOTS':
if args.fs is None:
raise ArgError("--fs <file system id> required")
-
- if args.optional:
- flags |= FsSnapshot.FLAG_RETRIEVE_FULL_INFO
fs = _get_item(self.c.fs(), args.fs, 'filesystem')
- self.display_data(self.c.fs_snapshots(fs, flags))
+ self.display_data(self.c.fs_snapshots(fs))
elif args.type == 'EXPORTS':
- if args.optional:
- flags |= NfsExport.FLAG_RETRIEVE_FULL_INFO
if search_key == 'nfs_export_id':
search_key = 'id'
if search_key and \
search_key not in NfsExport.SUPPORTED_SEARCH_KEYS:
raise ArgError("Search key '%s' is not supported by "
"NFS Export listing" % search_key)
- self.display_data(self.c.exports(search_key, search_value, flags))
+ self.display_data(self.c.exports(search_key, search_value))
elif args.type == 'NFS_CLIENT_AUTH':
self.display_nfs_client_authentication()
elif args.type == 'ACCESS_GROUPS':
- if args.optional:
- flags |= AccessGroup.FLAG_RETRIEVE_FULL_INFO
if search_key == 'access_group_id':
search_key = 'id'
if search_key == 'volume_id':
@@ -957,7 +913,7 @@ class CmdLine:
"Volume ID", raise_error=False)
if lsm_vol:
return self.display_data(
- self.c.access_groups_granted_to_volume(lsm_vol, flags))
+ self.c.access_groups_granted_to_volume(lsm_vol))
else:
return self.display_data([])
elif search_key and \
@@ -965,23 +921,19 @@ class CmdLine:
raise ArgError("Search key '%s' is not supported by "
"Access Group listing" % search_key)
self.display_data(
- self.c.access_groups(search_key,search_value, flags))
+ self.c.access_groups(search_key, search_value))
elif args.type == 'SYSTEMS':
- if args.optional:
- flags |= System.FLAG_RETRIEVE_FULL_INFO
if search_key:
raise ArgError("System listing with search is not supported")
- self.display_data(self.c.systems(flags))
+ self.display_data(self.c.systems())
elif args.type == 'DISKS':
if search_key == 'disk_id':
search_key = 'id'
if search_key and search_key not in Disk.SUPPORTED_SEARCH_KEYS:
raise ArgError("Search key '%s' is not supported by "
"disk listing" % search_key)
- if args.optional:
- flags |= Disk.FLAG_RETRIEVE_FULL_INFO
self.display_data(
- self.c.disks(search_key, search_value, flags))
+ self.c.disks(search_key, search_value))
elif args.type == 'PLUGINS':
self.display_available_plugins()
else:
diff --git a/tools/lsmcli/data_display.py b/tools/lsmcli/data_display.py
index ba79de2..20da86d 100644
--- a/tools/lsmcli/data_display.py
+++ b/tools/lsmcli/data_display.py
@@ -333,16 +333,12 @@ class DisplayData(object):
SYSTEM_MAN_HEADER['status'] = 'Status'
SYSTEM_MAN_HEADER['status_info'] = 'Status Info'
- SYSTEM_OPT_HEADER = OrderedDict()
-
SYSTEM_COLUMN_KEYS = SYSTEM_MAN_HEADER.keys()
# SYSTEM_COLUMN_KEYS should be subset of SYSTEM_MAN_HEADER.keys()
# XXX_COLUMN_KEYS contain a list of mandatory properties which will be
# displayed in column way. It was used to limit the output of properties
# in sure the column display way does not exceeded the column width 78.
# All mandatory_headers will be displayed in script way.
- # if '-o' define, both mandatory_headers and optional_headers will be
- # displayed in script way.
SYSTEM_VALUE_CONV_ENUM = {
'status': system_status_to_str,
@@ -353,7 +349,6 @@ class DisplayData(object):
VALUE_CONVERT[System] = {
'mandatory_headers': SYSTEM_MAN_HEADER,
'column_keys': SYSTEM_COLUMN_KEYS,
- 'optional_headers': SYSTEM_OPT_HEADER,
'value_conv_enum': SYSTEM_VALUE_CONV_ENUM,
'value_conv_human': SYSTEM_VALUE_CONV_HUMAN,
}
@@ -364,14 +359,12 @@ class DisplayData(object):
PLUG_DATA_COLUMN_KEYS = PLUG_DATA_MAN_HEADER.keys()
- PLUG_DATA_OPT_HEADER = OrderedDict()
PLUG_DATA_VALUE_CONV_ENUM = {}
PLUG_DATA_VALUE_CONV_HUMAN = []
VALUE_CONVERT[PlugData] = {
'mandatory_headers': PLUG_DATA_MAN_HEADER,
'column_keys': PLUG_DATA_COLUMN_KEYS,
- 'optional_headers': PLUG_DATA_OPT_HEADER,
'value_conv_enum': PLUG_DATA_VALUE_CONV_ENUM,
'value_conv_human': PLUG_DATA_VALUE_CONV_HUMAN,
}
@@ -388,13 +381,6 @@ class DisplayData(object):
POOL_COLUMN_KEYS = POOL_MAN_HEADER.keys()
- POOL_OPT_HEADER = OrderedDict()
- POOL_OPT_HEADER['raid_type'] = 'RAID Type'
- POOL_OPT_HEADER['member_type'] = 'Member Type'
- POOL_OPT_HEADER['member_ids'] = 'Member IDs'
- POOL_OPT_HEADER['thinp_type'] = 'Provision Type'
- POOL_OPT_HEADER['element_type'] = 'Element Type'
-
POOL_VALUE_CONV_ENUM = {
'status': pool_status_to_str,
'raid_type': pool_raid_type_to_str,
@@ -408,7 +394,6 @@ class DisplayData(object):
VALUE_CONVERT[Pool] = {
'mandatory_headers': POOL_MAN_HEADER,
'column_keys': POOL_COLUMN_KEYS,
- 'optional_headers': POOL_OPT_HEADER,
'value_conv_enum': POOL_VALUE_CONV_ENUM,
'value_conv_human': POOL_VALUE_CONV_HUMAN,
}
@@ -431,8 +416,6 @@ class DisplayData(object):
if key_name not in ['block_size', 'num_of_blocks', 'system_id']:
VOL_COLUMN_KEYS.extend([key_name])
- VOL_OPT_HEADER = OrderedDict()
-
VOL_VALUE_CONV_ENUM = {
'status': vol_status_to_str,
}
@@ -442,7 +425,6 @@ class DisplayData(object):
VALUE_CONVERT[Volume] = {
'mandatory_headers': VOL_MAN_HEADER,
'column_keys': VOL_COLUMN_KEYS,
- 'optional_headers': VOL_OPT_HEADER,
'value_conv_enum': VOL_VALUE_CONV_ENUM,
'value_conv_human': VOL_VALUE_CONV_HUMAN,
}
@@ -464,12 +446,6 @@ class DisplayData(object):
if key_name not in ['block_size', 'num_of_blocks']:
DISK_COLUMN_KEYS.extend([key_name])
- DISK_OPT_HEADER = OrderedDict()
- DISK_OPT_HEADER['sn'] = 'Serial Number'
- DISK_OPT_HEADER['part_num'] = 'Part Number'
- DISK_OPT_HEADER['vendor'] = 'Vendor'
- DISK_OPT_HEADER['model'] = 'Model'
-
DISK_VALUE_CONV_ENUM = {
'status': disk_status_to_str,
'disk_type': disk_type_to_str,
@@ -480,7 +456,6 @@ class DisplayData(object):
VALUE_CONVERT[Disk] = {
'mandatory_headers': DISK_MAN_HEADER,
'column_keys': DISK_COLUMN_KEYS,
- 'optional_headers': DISK_OPT_HEADER,
'value_conv_enum': DISK_VALUE_CONV_ENUM,
'value_conv_human': DISK_VALUE_CONV_HUMAN,
}
@@ -495,8 +470,6 @@ class DisplayData(object):
AG_COLUMN_KEYS = AG_MAN_HEADER.keys()
- AG_OPT_HEADER = OrderedDict()
-
AG_VALUE_CONV_ENUM = {
'init_type': ag_init_type_to_str,
}
@@ -506,7 +479,6 @@ class DisplayData(object):
VALUE_CONVERT[AccessGroup] = {
'mandatory_headers': AG_MAN_HEADER,
'column_keys': AG_COLUMN_KEYS,
- 'optional_headers': AG_OPT_HEADER,
'value_conv_enum': AG_VALUE_CONV_ENUM,
'value_conv_human': AG_VALUE_CONV_HUMAN,
}
@@ -526,8 +498,6 @@ class DisplayData(object):
if key_name not in ['system_id']:
FS_COLUMN_KEYS.extend([key_name])
- FS_OPT_HEADER = OrderedDict()
-
FS_VALUE_CONV_ENUM = {
}
@@ -536,7 +506,6 @@ class DisplayData(object):
VALUE_CONVERT[FileSystem] = {
'mandatory_headers': FS_MAN_HEADER,
'column_keys': FS_COLUMN_KEYS,
- 'optional_headers': FS_OPT_HEADER,
'value_conv_enum': FS_VALUE_CONV_ENUM,
'value_conv_human': FS_VALUE_CONV_HUMAN,
}
@@ -549,8 +518,6 @@ class DisplayData(object):
FS_SNAP_COLUMN_KEYS = FS_SNAP_MAN_HEADER.keys()
- FS_SNAP_OPT_HEADER = OrderedDict()
-
FS_SNAP_VALUE_CONV_ENUM = {
'ts': datetime.fromtimestamp
}
@@ -560,7 +527,6 @@ class DisplayData(object):
VALUE_CONVERT[FsSnapshot] = {
'mandatory_headers': FS_SNAP_MAN_HEADER,
'column_keys': FS_SNAP_COLUMN_KEYS,
- 'optional_headers': FS_SNAP_OPT_HEADER,
'value_conv_enum': FS_SNAP_VALUE_CONV_ENUM,
'value_conv_human': FS_SNAP_VALUE_CONV_HUMAN,
}
@@ -584,8 +550,6 @@ class DisplayData(object):
if key_name not in ['root', 'anonuid', 'anongid', 'auth']:
NFS_EXPORT_COLUMN_KEYS.extend([key_name])
- NFS_EXPORT_OPT_HEADER = OrderedDict()
-
NFS_EXPORT_VALUE_CONV_ENUM = {}
NFS_EXPORT_VALUE_CONV_HUMAN = []
@@ -593,7 +557,6 @@ class DisplayData(object):
VALUE_CONVERT[NfsExport] = {
'mandatory_headers': NFS_EXPORT_MAN_HEADER,
'column_keys': NFS_EXPORT_COLUMN_KEYS,
- 'optional_headers': NFS_EXPORT_OPT_HEADER,
'value_conv_enum': NFS_EXPORT_VALUE_CONV_ENUM,
'value_conv_human': NFS_EXPORT_VALUE_CONV_HUMAN,
}
@@ -611,18 +574,6 @@ class DisplayData(object):
return value
@staticmethod
- def _get_opt_pro_value(obj, key, value_conv_enum, value_conv_human,
- flag_human, flag_enum):
- value = obj.optional_data.get(key)
- if not flag_enum:
- if key in value_conv_enum.keys():
- value = value_conv_enum[key](value)
- if flag_human:
- if key in value_conv_human:
- value = size_bytes_2_size_human(value)
- return value
-
- @staticmethod
def _find_max_width(two_d_list, column_index):
max_width = 1
for row_index in range(0, len(two_d_list)):
@@ -637,7 +588,6 @@ class DisplayData(object):
data_dict = OrderedDict()
value_convert = DisplayData.VALUE_CONVERT[type(obj)]
mandatory_headers = value_convert['mandatory_headers']
- optional_headers = value_convert['optional_headers']
value_conv_enum = value_convert['value_conv_enum']
value_conv_human = value_convert['value_conv_human']
@@ -658,38 +608,6 @@ class DisplayData(object):
flag_enum)
data_dict[key_str] = value
- if flag_dsp_all_data:
- cur_support_opt_keys = obj.optional_data.keys()
- for key in optional_headers.keys():
- if key not in cur_support_opt_keys:
- continue
- key_str = optional_headers[key]
- value = DisplayData._get_opt_pro_value(
- obj, key, value_conv_enum, value_conv_human, flag_human,
- flag_enum)
- data_dict[key_str] = value
-
- if extra_properties:
- cur_support_opt_keys = obj.optional_data.keys()
- for key in extra_properties:
- if key in data_dict.keys():
- # already contained
- continue
- if key in mandatory_headers.keys():
- key_str = mandatory_headers[key]
- value = DisplayData._get_man_pro_value(
- obj, key, value_conv_enum, value_conv_human,
- flag_human, flag_enum)
- data_dict[key_str] = value
- elif key in optional_headers.keys():
- if key not in cur_support_opt_keys:
- continue
- key_str = optional_headers[key]
- value = DisplayData._get_opt_pro_value(
- obj, key, value_conv_enum, value_conv_human,
- flag_human, flag_enum)
- data_dict[key_str] = value
-
return data_dict
@staticmethod
--
1.8.2.1