Signed-off-by: Tony Asleson <***@redhat.com>
---
.../libstoragemgmt/libstoragemgmt_plug_interface.h | 3 +-
include/libstoragemgmt/libstoragemgmt_pool.h | 7 ++
lsm/lsm/_data.py | 20 +++---
lsm/lsm/ibmv7k.py | 2 +-
lsm/lsm/nstor.py | 2 +-
lsm/lsm/simarray.py | 14 +++-
lsm/lsm/smis.py | 3 +-
lsm/lsm/targetd.py | 2 +-
plugin/simc_lsmplugin.c | 6 +-
src/lsm_convert.cpp | 5 +-
src/lsm_datatypes.cpp | 22 ++++++-
src/lsm_datatypes.hpp | 1 +
test/tester.c | 76 ++++++++++++----------
13 files changed, 104 insertions(+), 59 deletions(-)
diff --git a/include/libstoragemgmt/libstoragemgmt_plug_interface.h b/include/libstoragemgmt/libstoragemgmt_plug_interface.h
index 1e7273c..6117437 100644
--- a/include/libstoragemgmt/libstoragemgmt_plug_interface.h
+++ b/include/libstoragemgmt/libstoragemgmt_plug_interface.h
@@ -1049,13 +1049,14 @@ void LSM_DLL_EXPORT lsm_pool_free_space_set(lsm_pool *p, uint64_t free_space);
* @param total_space Total space
* @param free_space Space available
* @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
* @return LSM_ERR_OK on success, else error reason.
*/
lsm_pool LSM_DLL_EXPORT *lsm_pool_record_alloc(const char *id, const char *name,
uint64_t total_space,
uint64_t free_space,
- uint64_t status,
+ uint64_t status, const char* status_info,
const char *system_id);
/**
diff --git a/include/libstoragemgmt/libstoragemgmt_pool.h b/include/libstoragemgmt/libstoragemgmt_pool.h
index e631594..d809561 100644
--- a/include/libstoragemgmt/libstoragemgmt_pool.h
+++ b/include/libstoragemgmt/libstoragemgmt_pool.h
@@ -87,6 +87,13 @@ uint64_t LSM_DLL_EXPORT lsm_pool_free_space_get( lsm_pool *p );
uint64_t LSM_DLL_EXPORT lsm_pool_status_get( lsm_pool *s );
/**
+ * Retrieve the status info for the Pool.
+ * @param s Pool to retrieve status for
+ * @return Pool status info which is a character string.
+ */
+const char LSM_DLL_EXPORT *lsm_pool_status_info_get( lsm_pool *s );
+
+/**
* Retrieve the system id for the specified pool.
* @param p Pool pointer
* @return System ID
diff --git a/lsm/lsm/_data.py b/lsm/lsm/_data.py
index 8756d03..f85ba72 100644
--- a/lsm/lsm/_data.py
+++ b/lsm/lsm/_data.py
@@ -764,6 +764,7 @@ The lsm.System class does not have class methods.
@default_property('total_space', doc="Total space in bytes")
@default_property('free_space', doc="Free space in bytes")
@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")
class Pool(IData):
@@ -1144,13 +1145,17 @@ class Pool(IData):
# total_space: All spaces in bytes could be allocated to user.
'free_space': 'Free Space',
# free_space: Free spaces in bytes could be allocated to user.
- 'status': 'Status',
+ 'status': 'Status',
# status: Indicate the status of Pool.
+ 'status_info': 'Status Info',
+ # status_info: A string explaining the detail of current status.
+ # Check comments above about Pool.STATUS_XXX for
+ # what info you should save in it.
'system_id': 'System ID',
# system_id: Identifier of belonging system.
}
_MAN_PROPERTIES_SEQUENCE = ['id', 'name', 'total_space', 'free_space',
- 'status', 'system_id']
+ 'status', 'status_info', 'system_id']
_OPT_PROPERTIES_2_HEADER = {
'raid_type': 'RAID Type',
@@ -1170,12 +1175,6 @@ class Pool(IData):
# not implemented at current pool level.
# If we really need to identify the under algorithm some
# day, we will expand to THINP_TYPE_THIN_ALLOCATED and etc
- 'status': 'Status',
- # status: The status of this pool, OK, Data Lose, or etc.
- 'status_info': 'Status Info',
- # status_info: A string explaining the detail of current status.
- # Check comments above about Pool.STATUS_XXX for
- # what info you should save in it.
'element_type': 'Element Type',
# element_type: That kind of items can this pool create:
# ELEMENT_TYPE_VOLUME
@@ -1190,7 +1189,7 @@ class Pool(IData):
}
_OPT_PROPERTIES_SEQUENCE = ['raid_type', 'member_type', 'member_ids',
- 'element_type', 'thinp_type', 'status_info']
+ 'element_type', 'thinp_type']
def _value_convert(self, key_name, value, human, enum_as_number,
list_convert):
@@ -1215,12 +1214,13 @@ class Pool(IData):
return value
def __init__(self, _id, _name, _total_space, _free_space, _status,
- _system_id, _optional_data=None):
+ _status_info, _system_id, _optional_data=None):
self._id = _id # Identifier
self._name = _name # Human recognisable name
self._total_space = _total_space # Total size
self._free_space = _free_space # Free space available
self._status = _status # Status of pool.
+ self._status_info = _status_info # Additional status text of pool
self._system_id = _system_id # System id this pool belongs
if _optional_data is None:
diff --git a/lsm/lsm/ibmv7k.py b/lsm/lsm/ibmv7k.py
index 37c3243..e33f880 100644
--- a/lsm/lsm/ibmv7k.py
+++ b/lsm/lsm/ibmv7k.py
@@ -192,7 +192,7 @@ class IbmV7k(IStorageAreaNetwork):
def _pool(self, p):
return Pool(p['id'], p['name'], int(p['capacity']),
- int(p['free_capacity']), Pool.STATUS_UNKNOWN,
+ int(p['free_capacity']), Pool.STATUS_UNKNOWN, '',
self.sys_info.id)
def _get_volumes(self):
diff --git a/lsm/lsm/nstor.py b/lsm/lsm/nstor.py
index c6d5f01..4d70bf9 100644
--- a/lsm/lsm/nstor.py
+++ b/lsm/lsm/nstor.py
@@ -115,7 +115,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,
+ Pool.STATUS_UNKNOWN, '',
self.system.id))
return pools
diff --git a/lsm/lsm/simarray.py b/lsm/lsm/simarray.py
index 0d964cf..a563ee4 100644
--- a/lsm/lsm/simarray.py
+++ b/lsm/lsm/simarray.py
@@ -156,6 +156,7 @@ class SimArray(object):
total_space = self.data.pool_total_space(pool_id)
free_space = self.data.pool_free_space(pool_id)
status = sim_pool['status']
+ status_info = sim_pool['status_info']
sys_id = sim_pool['sys_id']
opt_data = OptionalData()
if flags == Pool.RETRIEVE_FULL_INFO:
@@ -163,11 +164,10 @@ class SimArray(object):
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('status_info', '')
opt_data.set('element_type', sim_pool['element_type'])
- return Pool(pool_id, name, total_space, free_space, status, sys_id,
- opt_data)
+ return Pool(pool_id, name, total_space, free_space, status,
+ status_info, sys_id, opt_data)
def pools(self, flags=0):
rc = []
@@ -539,6 +539,7 @@ class SimData(object):
SIM_DATA_INIT_NAME = 'NULL'
SIM_DATA_TMO = 30000 # ms
SIM_DATA_POOL_STATUS = Pool.STATUS_OK
+ SIM_DATA_POOL_STATUS_INFO = ''
SIM_DATA_DISK_DEFAULT_RAID = Pool.RAID_TYPE_RAID0
SIM_DATA_VOLUME_DEFAULT_RAID = Pool.RAID_TYPE_RAID0
SIM_DATA_POOL_ELEMENT_TYPE = Pool.ELEMENT_TYPE_FS \
@@ -607,6 +608,7 @@ class SimData(object):
'member_ids': [SimData._disk_id(0), SimData._disk_id(1)],
'raid_type': Pool.RAID_TYPE_RAID1,
'status': SimData.SIM_DATA_POOL_STATUS,
+ 'status_info': SimData.SIM_DATA_POOL_STATUS_INFO,
'sys_id': SimData.SIM_DATA_SYS_ID,
'element_type': SimData.SIM_DATA_SYS_POOL_ELEMENT_TYPE,
},
@@ -618,6 +620,7 @@ class SimData(object):
'member_size': pool_size_200g,
'raid_type': Pool.RAID_TYPE_NOT_APPLICABLE,
'status': Pool.STATUS_OK,
+ 'status_info': SimData.SIM_DATA_POOL_STATUS_INFO,
'sys_id': SimData.SIM_DATA_SYS_ID,
'element_type': SimData.SIM_DATA_POOL_ELEMENT_TYPE,
},
@@ -629,6 +632,7 @@ class SimData(object):
'member_ids': [SimData._disk_id(2), SimData._disk_id(3)],
'raid_type': Pool.RAID_TYPE_RAID0,
'status': Pool.STATUS_OK,
+ 'status_info': SimData.SIM_DATA_POOL_STATUS_INFO,
'sys_id': SimData.SIM_DATA_SYS_ID,
'element_type': SimData.SIM_DATA_POOL_ELEMENT_TYPE,
},
@@ -690,6 +694,7 @@ class SimData(object):
],
'raid_type': Pool.RAID_TYPE_RAID1,
'status': Pool.STATUS_OK,
+ 'status_info': SimData.SIM_DATA_POOL_STATUS_INFO,
'sys_id': SimData.SIM_DATA_SYS_ID,
'element_type': SimData.SIM_DATA_POOL_ELEMENT_TYPE,
}
@@ -1652,6 +1657,7 @@ class SimData(object):
sim_pool['sys_id'] = SimData.SIM_DATA_SYS_ID
sim_pool['element_type'] = SimData.SIM_DATA_POOL_ELEMENT_TYPE
sim_pool['status'] = SimData.SIM_DATA_POOL_STATUS
+ sim_pool['status_info'] = SimData.SIM_DATA_POOL_STATUS_INFO
self.pool_dict[pool_id] = sim_pool
return sim_pool
@@ -1749,6 +1755,7 @@ class SimData(object):
sim_pool['sys_id'] = SimData.SIM_DATA_SYS_ID
sim_pool['element_type'] = SimData.SIM_DATA_POOL_ELEMENT_TYPE
sim_pool['status'] = SimData.SIM_DATA_POOL_STATUS
+ sim_pool['status_info'] = SimData.SIM_DATA_POOL_STATUS_INFO
self.pool_dict[pool_id] = sim_pool
return sim_pool
@@ -1794,6 +1801,7 @@ class SimData(object):
sim_pool['sys_id'] = SimData.SIM_DATA_SYS_ID
sim_pool['element_type'] = SimData.SIM_DATA_POOL_ELEMENT_TYPE
sim_pool['status'] = SimData.SIM_DATA_POOL_STATUS
+ sim_pool['status_info'] = SimData.SIM_DATA_POOL_STATUS_INFO
self.pool_dict[pool_id] = sim_pool
return sim_pool
diff --git a/lsm/lsm/smis.py b/lsm/lsm/smis.py
index 2050fe7..55ca58d 100644
--- a/lsm/lsm/smis.py
+++ b/lsm/lsm/smis.py
@@ -1471,7 +1471,8 @@ class Smis(IStorageAreaNetwork):
if 'OperationalStatus' in cim_pool:
status = Smis._pool_status_of(cim_pool)[0]
- return Pool(pool_id, name, total_space, free_space, status, system_id)
+ return Pool(pool_id, name, total_space, free_space, status, '',
+ system_id)
@staticmethod
def _cim_sys_2_lsm_sys(cim_sys):
diff --git a/lsm/lsm/targetd.py b/lsm/lsm/targetd.py
index 3344006..23b8cf0 100644
--- a/lsm/lsm/targetd.py
+++ b/lsm/lsm/targetd.py
@@ -165,7 +165,7 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
pools = []
for pool in self._jsonrequest("pool_list"):
pools.append(Pool(pool['name'], pool['name'], pool['size'],
- pool['free_size'], Pool.STATUS_UNKNOWN,
+ pool['free_size'], Pool.STATUS_UNKNOWN, '',
'targetd'))
return pools
diff --git a/plugin/simc_lsmplugin.c b/plugin/simc_lsmplugin.c
index 61876b7..726e7e2 100644
--- a/plugin/simc_lsmplugin.c
+++ b/plugin/simc_lsmplugin.c
@@ -990,7 +990,7 @@ static int _pool_create(lsm_plugin_ptr c, const char *system_id,
if( !new_pool ) {
/* Create the pool */
new_pool = lsm_pool_record_alloc(md5(pool_name), pool_name, size_bytes,
- size_bytes, LSM_POOL_STATUS_OK,
+ size_bytes, LSM_POOL_STATUS_OK, "",
system_id);
pool_to_store = lsm_pool_record_copy(new_pool);
@@ -2485,7 +2485,7 @@ int load( lsm_plugin_ptr c, const char *uri, const char *password,
p = lsm_pool_record_alloc("POOL_3", "lsm_test_aggr",
UINT64_MAX, UINT64_MAX,
- LSM_POOL_STATUS_OK,
+ LSM_POOL_STATUS_OK, "",
sys_id);
if( p ) {
pd->pools = g_hash_table_new_full(g_str_hash, g_str_equal, free,
@@ -2498,7 +2498,7 @@ int load( lsm_plugin_ptr c, const char *uri, const char *password,
snprintf(name, sizeof(name), "POOL_%d", i);
p = lsm_pool_record_alloc(name, name, UINT64_MAX,
- UINT64_MAX, LSM_POOL_STATUS_OK,
+ UINT64_MAX, LSM_POOL_STATUS_OK, "",
sys_id);
if( p ) {
diff --git a/src/lsm_convert.cpp b/src/lsm_convert.cpp
index bdcbc51..ff717df 100644
--- a/src/lsm_convert.cpp
+++ b/src/lsm_convert.cpp
@@ -160,12 +160,12 @@ lsm_pool *value_to_pool(Value &pool)
if (is_expected_object(pool, "Pool")) {
std::map<std::string, Value> i = pool.asObject();
- rc = lsm_pool_record_alloc(
- i["id"].asString().c_str(),
+ rc = lsm_pool_record_alloc(i["id"].asString().c_str(),
i["name"].asString().c_str(),
i["total_space"].asUint64_t(),
i["free_space"].asUint64_t(),
i["status"].asUint64_t(),
+ i["status_info"].asString().c_str(),
i["system_id"].asString().c_str());
}
return rc;
@@ -181,6 +181,7 @@ Value pool_to_value(lsm_pool *pool)
p["total_space"] = Value(pool->total_space);
p["free_space"] = Value(pool->free_space);
p["status"] = Value(pool->status);
+ p["status_info"] = Value(pool->status_info);
p["system_id"] = Value(pool->system_id);
return Value(p);
}
diff --git a/src/lsm_datatypes.cpp b/src/lsm_datatypes.cpp
index bce00a2..e98590f 100644
--- a/src/lsm_datatypes.cpp
+++ b/src/lsm_datatypes.cpp
@@ -468,6 +468,9 @@ rtype *name(uint32_t size) \
if (size > 0) { \
size_t s = sizeof(rtype) * size; \
rc = (rtype *) malloc(s); \
+ if( rc ) { \
+ memset(rc, 0, s); \
+ } \
} \
return rc; \
}
@@ -498,7 +501,7 @@ int name( record_type pa[], uint32_t size) \
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,
+ uint64_t totalSpace, uint64_t freeSpace, uint64_t status, const char* status_info,
const char *system_id)
{
lsm_pool *rc = (lsm_pool *)malloc(sizeof(lsm_pool));
@@ -510,9 +513,10 @@ lsm_pool *lsm_pool_record_alloc(const char *id, const char *name,
rc->total_space = totalSpace;
rc->free_space = freeSpace;
rc->status = status;
+ rc->status_info = strdup(status_info);
rc->system_id = strdup(system_id);
- if( !rc->id || !rc->name || !rc->system_id ) {
+ if( !rc->id || !rc->name || !rc->system_id || !rc->status_info ) {
lsm_pool_record_free(rc);
rc = NULL;
}
@@ -534,6 +538,7 @@ lsm_pool * lsm_pool_record_copy( lsm_pool *toBeCopied)
toBeCopied->total_space,
toBeCopied->free_space,
toBeCopied->status,
+ toBeCopied->status_info,
toBeCopied->system_id);
}
return NULL;
@@ -548,6 +553,11 @@ int lsm_pool_record_free(lsm_pool *p)
p->name = NULL;
}
+ if( p->status_info ) {
+ free(p->status_info);
+ p->status_info = NULL;
+ }
+
if (p->id) {
free(p->id);
p->id = NULL;
@@ -606,6 +616,14 @@ uint64_t lsm_pool_status_get( lsm_pool *p )
return UINT64_MAX;
}
+const char LSM_DLL_EXPORT *lsm_pool_status_info_get( lsm_pool *p )
+{
+ if (LSM_IS_POOL(p)) {
+ return p->status_info;
+ }
+ return NULL;
+}
+
char *lsm_pool_system_id_get( lsm_pool *p )
{
if (LSM_IS_POOL(p)) {
diff --git a/src/lsm_datatypes.hpp b/src/lsm_datatypes.hpp
index 8d78a50..9dc9dc7 100644
--- a/src/lsm_datatypes.hpp
+++ b/src/lsm_datatypes.hpp
@@ -70,6 +70,7 @@ struct LSM_DLL_LOCAL _lsm_pool {
uint64_t total_space; /**< Total size */
uint64_t free_space; /**< Free space available */
uint64_t status; /**< Status of pool */
+ char *status_info; /**< Status info for pool */
char *system_id; /**< system id */
};
diff --git a/test/tester.c b/test/tester.c
index 25de3c1..eeefa7b 100644
--- a/test/tester.c
+++ b/test/tester.c
@@ -1107,55 +1107,63 @@ START_TEST(test_nfs_exports)
fail_unless(NULL != test_pool);
- rc = lsm_fs_create(c, test_pool, "C_unit_test_nfs_export", 50000000, &nfs, &job, LSM_FLAG_RSVD);
+ if( test_pool ) {
+ rc = lsm_fs_create(c, test_pool, "C_unit_test_nfs_export", 50000000, &nfs, &job, LSM_FLAG_RSVD);
- if( LSM_ERR_JOB_STARTED == rc ) {
- nfs = wait_for_job_fs(c, &job);
- } else {
- fail_unless(LSM_ERR_OK == rc, "RC = %d", rc);
- }
+ if( LSM_ERR_JOB_STARTED == rc ) {
+ nfs = wait_for_job_fs(c, &job);
+ } else {
+ fail_unless(LSM_ERR_OK == rc, "RC = %d", rc);
+ }
- fail_unless(nfs != NULL);
- lsm_nfs_export **exports = NULL;
- uint32_t count = 0;
+ fail_unless(nfs != NULL);
+ lsm_nfs_export **exports = NULL;
+ uint32_t count = 0;
- rc = lsm_nfs_list(c, &exports, &count, LSM_FLAG_RSVD);
+ if( nfs ) {
+ rc = lsm_nfs_list(c, &exports, &count, LSM_FLAG_RSVD);
- fail_unless(LSM_ERR_OK == rc, "lsmNfsList rc= %d\n", rc);
- fail_unless(count == 0);
- fail_unless(NULL == exports);
+ fail_unless(LSM_ERR_OK == rc, "lsmNfsList rc= %d\n", rc);
+ fail_unless(count == 0);
+ fail_unless(NULL == exports);
- lsm_string_list *access = lsm_string_list_alloc(1);
- fail_unless(NULL != access);
+ lsm_string_list *access = lsm_string_list_alloc(1);
+ fail_unless(NULL != access);
- lsm_string_list_elem_set(access, 0, "192.168.2.29");
+ lsm_string_list_elem_set(access, 0, "192.168.2.29");
- lsm_nfs_export *e = NULL;
+ lsm_nfs_export *e = NULL;
- rc = lsm_nfs_export_fs(c, lsm_fs_id_get(nfs), NULL, access, access, NULL,
- ANON_UID_GID_NA, ANON_UID_GID_NA, NULL, NULL, &e, LSM_FLAG_RSVD);
- fail_unless(LSM_ERR_OK == rc, "lsmNfsExportFs %d\n", rc);
+ rc = lsm_nfs_export_fs(c, lsm_fs_id_get(nfs), NULL, access,
+ access, NULL, ANON_UID_GID_NA,
+ ANON_UID_GID_NA, NULL, NULL, &e,
+ LSM_FLAG_RSVD);
+ fail_unless(LSM_ERR_OK == rc, "lsmNfsExportFs %d\n", rc);
- lsm_nfs_export_record_free(e);
- e=NULL;
+ lsm_nfs_export_record_free(e);
+ e=NULL;
- rc = lsm_nfs_list(c, &exports, &count, LSM_FLAG_RSVD);
- fail_unless( LSM_ERR_OK == rc);
- fail_unless( exports != NULL);
- fail_unless( count == 1 );
+ rc = lsm_nfs_list(c, &exports, &count, LSM_FLAG_RSVD);
+ fail_unless( LSM_ERR_OK == rc);
+ fail_unless( exports != NULL);
+ fail_unless( count == 1 );
- rc = lsm_nfs_export_delete(c, exports[0], LSM_FLAG_RSVD);
- fail_unless( LSM_ERR_OK == rc, "lsmNfsExportRemove %d\n", rc );
- lsm_nfs_export_record_array_free(exports, count);
+ if( count ) {
+ rc = lsm_nfs_export_delete(c, exports[0], LSM_FLAG_RSVD);
+ fail_unless( LSM_ERR_OK == rc, "lsmNfsExportRemove %d\n", rc );
+ lsm_nfs_export_record_array_free(exports, count);
- exports = NULL;
+ exports = NULL;
- rc = lsm_nfs_list(c, &exports, &count, LSM_FLAG_RSVD);
+ rc = lsm_nfs_list(c, &exports, &count, LSM_FLAG_RSVD);
- fail_unless(LSM_ERR_OK == rc, "lsmNfsList rc= %d\n", rc);
- fail_unless(count == 0);
- fail_unless(NULL == exports);
+ fail_unless(LSM_ERR_OK == rc, "lsmNfsList rc= %d\n", rc);
+ fail_unless(count == 0);
+ fail_unless(NULL == exports);
+ }
+ }
+ }
}
END_TEST
--
1.8.2.1