Tony Asleson
2014-02-20 20:37:16 UTC
This was an oversight and should have been included
from the beginning as all the other classes have the
ability to report status.
Signed-off-by: Tony Asleson <***@redhat.com>
---
.../libstoragemgmt/libstoragemgmt_plug_interface.h | 2 ++
include/libstoragemgmt/libstoragemgmt_pool.h | 8 ++++++++
include/libstoragemgmt/libstoragemgmt_types.h | 20 ++++++++++++++++++++
plugin/simc_lsmplugin.c | 13 +++++++++----
src/lsm_convert.cpp | 2 ++
src/lsm_datatypes.cpp | 13 ++++++++++++-
src/lsm_datatypes.hpp | 1 +
test/tester.c | 3 +++
8 files changed, 57 insertions(+), 5 deletions(-)
diff --git a/include/libstoragemgmt/libstoragemgmt_plug_interface.h b/include/libstoragemgmt/libstoragemgmt_plug_interface.h
index c0e29a3..4517763 100644
--- a/include/libstoragemgmt/libstoragemgmt_plug_interface.h
+++ b/include/libstoragemgmt/libstoragemgmt_plug_interface.h
@@ -965,12 +965,14 @@ void LSM_DLL_EXPORT lsmPoolFreeSpaceSet(lsmPool *p, uint64_t free_space);
* @param name Human readable name
* @param totalSpace Total space
* @param freeSpace Space available
+ * @param status Pool status, bit field (See LSM_POOL_STATUS_XXXX constants)
* @param system_id System id
* @return LSM_ERR_OK on success, else error reason.
*/
lsmPool LSM_DLL_EXPORT *lsmPoolRecordAlloc(const char *id, const char *name,
uint64_t totalSpace,
uint64_t freeSpace,
+ uint64_t status,
const char *system_id);
/**
diff --git a/include/libstoragemgmt/libstoragemgmt_pool.h b/include/libstoragemgmt/libstoragemgmt_pool.h
index 67b4788..d54a2e6 100644
--- a/include/libstoragemgmt/libstoragemgmt_pool.h
+++ b/include/libstoragemgmt/libstoragemgmt_pool.h
@@ -78,6 +78,14 @@ uint64_t LSM_DLL_EXPORT lsmPoolTotalSpaceGet( lsmPool *p );
uint64_t LSM_DLL_EXPORT lsmPoolFreeSpaceGet( lsmPool *p );
/**
+ * Retrieve the status for the Pool.
+ * @param s Pool to retrieve status for
+ * @return Pool status which is a bit sensitive field, returns UINT64_MAX on
+ * bad pool pointer.
+ */
+uint64_t lsmPoolStatusGet( lsmPool *s );
+
+/**
* Retrieve the system id for the specified pool.
* @param p Pool pointer
* @return System ID
diff --git a/include/libstoragemgmt/libstoragemgmt_types.h b/include/libstoragemgmt/libstoragemgmt_types.h
index 320577c..acb9009 100644
--- a/include/libstoragemgmt/libstoragemgmt_types.h
+++ b/include/libstoragemgmt/libstoragemgmt_types.h
@@ -218,6 +218,26 @@ typedef enum {
#define LSM_DISK_STATUS_INITIALIZING 0x0000000000000100
#define LSM_DISK_STATUS_RECONSTRUCTING 0x0000000000000200
+
+#define LSM_POOL_STATUS_UNKNOWN 0x0000000000000001
+#define LSM_POOL_STATUS_OK 0x0000000000000002
+#define LSM_POOL_STATUS_OTHER 0x0000000000000004
+#define LSM_POOL_STATUS_STRESSED 0x0000000000000008
+#define LSM_POOL_STATUS_DEGRADED 0x0000000000000010
+#define LSM_POOL_STATUS_ERROR 0x0000000000000020
+#define LSM_POOL_STATUS_OFFLINE 0x0000000000000040
+#define LSM_POOL_STATUS_STARTING 0x0000000000000080
+#define LSM_POOL_STATUS_STOPPING 0x0000000000000100
+#define LSM_POOL_STATUS_STOPPED 0x0000000000000200
+#define LSM_POOL_STATUS_READ_ONLY 0x0000000000000400
+#define LSM_POOL_STATUS_DORMAT 0x0000000000000800
+#define LSM_POOL_STATUS_RECONSTRUCTING 0x0000000000001000
+#define LSM_POOL_STATUS_VERIFYING 0x0000000000002000
+#define LSM_POOL_STATUS_INITIALIZING 0x0000000000004000
+#define LSM_POOL_STATUS_GROWING 0x0000000000008000
+#define LSM_POOL_STATUS_SHRINKING 0x0000000000010000
+#define LSM_POOL_STATUS_DESTROYING 0x0000000000020000
+
#ifdef __cplusplus
}
#endif
diff --git a/plugin/simc_lsmplugin.c b/plugin/simc_lsmplugin.c
index e12c630..e7d445f 100644
--- a/plugin/simc_lsmplugin.c
+++ b/plugin/simc_lsmplugin.c
@@ -2199,13 +2199,18 @@ int load( lsmPluginPtr c, xmlURIPtr uri, const char *password,
data->num_pools = MAX_POOLS;
data->pool[0] = lsmPoolRecordAlloc("POOL_0", "POOL_ZERO", UINT64_MAX,
- UINT64_MAX, sys_id);
+ UINT64_MAX, LSM_POOL_STATUS_OK,
+ sys_id);
data->pool[1] = lsmPoolRecordAlloc("POOL_1", "POOL_ONE", UINT64_MAX,
- UINT64_MAX, sys_id);
+ UINT64_MAX, LSM_POOL_STATUS_OK,
+ sys_id);
data->pool[2] = lsmPoolRecordAlloc("POOL_2", "POOL_TWO", UINT64_MAX,
- UINT64_MAX, sys_id);
+ UINT64_MAX, LSM_POOL_STATUS_OK,
+ sys_id);
data->pool[3] = lsmPoolRecordAlloc("POOL_3", "lsm_test_aggr",
- UINT64_MAX, UINT64_MAX, sys_id);
+ UINT64_MAX, UINT64_MAX,
+ LSM_POOL_STATUS_OK,
+ sys_id);
data->access_groups = g_hash_table_new_full(g_str_hash, g_str_equal,
free, free_allocated_ag);
diff --git a/src/lsm_convert.cpp b/src/lsm_convert.cpp
index 242efe9..630386e 100644
--- a/src/lsm_convert.cpp
+++ b/src/lsm_convert.cpp
@@ -165,6 +165,7 @@ lsmPool *valueToPool(Value &pool)
i["name"].asString().c_str(),
i["total_space"].asUint64_t(),
i["free_space"].asUint64_t(),
+ i["status"].asUint64_t(),
i["system_id"].asString().c_str());
}
return rc;
@@ -179,6 +180,7 @@ Value poolToValue(lsmPool *pool)
p["name"] = Value(pool->name);
p["total_space"] = Value(pool->totalSpace);
p["free_space"] = Value(pool->freeSpace);
+ p["status"] = Value(pool->status);
p["system_id"] = Value(pool->system_id);
return Value(p);
}
diff --git a/src/lsm_datatypes.cpp b/src/lsm_datatypes.cpp
index 18d6d8f..d2064ea 100644
--- a/src/lsm_datatypes.cpp
+++ b/src/lsm_datatypes.cpp
@@ -496,7 +496,8 @@ void name( record_type pa[], uint32_t size) \
CREATE_ALLOC_ARRAY_FUNC(lsmPoolRecordAllocArray, lsmPool *)
lsmPool *lsmPoolRecordAlloc(const char *id, const char *name,
- uint64_t totalSpace, uint64_t freeSpace, const char *system_id)
+ uint64_t totalSpace, uint64_t freeSpace, uint64_t status,
+ const char *system_id)
{
lsmPool *rc = (lsmPool *)malloc(sizeof(lsmPool));
if (rc) {
@@ -506,6 +507,7 @@ lsmPool *lsmPoolRecordAlloc(const char *id, const char *name,
rc->name = strdup(name);
rc->totalSpace = totalSpace;
rc->freeSpace = freeSpace;
+ rc->status = status;
rc->system_id = strdup(system_id);
if( !rc->id || !rc->name || !rc->system_id ) {
@@ -529,6 +531,7 @@ lsmPool * lsmPoolRecordCopy( lsmPool *toBeCopied)
return lsmPoolRecordAlloc(toBeCopied->id, toBeCopied->name,
toBeCopied->totalSpace,
toBeCopied->freeSpace,
+ toBeCopied->status,
toBeCopied->system_id);
}
return NULL;
@@ -590,6 +593,14 @@ uint64_t lsmPoolFreeSpaceGet(lsmPool *p)
return 0;
}
+uint64_t lsmPoolStatusGet( lsmPool *p )
+{
+ if (LSM_IS_POOL(p)) {
+ return p->status;
+ }
+ return UINT64_MAX;
+}
+
char *lsmPoolSystemIdGet( lsmPool *p )
{
if (LSM_IS_POOL(p)) {
diff --git a/src/lsm_datatypes.hpp b/src/lsm_datatypes.hpp
index 91d2320..a4558cc 100644
--- a/src/lsm_datatypes.hpp
+++ b/src/lsm_datatypes.hpp
@@ -69,6 +69,7 @@ struct LSM_DLL_LOCAL _lsmPool {
char *name; /**< Human recognizeable name */
uint64_t totalSpace; /**< Total size */
uint64_t freeSpace; /**< Free space available */
+ uint64_t status; /**< Status of pool */
char *system_id; /**< system id */
};
diff --git a/test/tester.c b/test/tester.c
index a3136d1..2b23dce 100644
--- a/test/tester.c
+++ b/test/tester.c
@@ -355,6 +355,9 @@ START_TEST(test_smoke_test)
lsmPoolTotalSpaceGet(pools[i]),
lsmPoolFreeSpaceGet(pools[i]));
+ fail_unless(lsmPoolStatusGet(pools[i]) == LSM_POOL_STATUS_OK,
+ "%"PRIu64, lsmPoolStatusGet(pools[i]));
+
if (lsmPoolFreeSpaceGet(pools[i]) > 20000000) {
poolToUse = i;
}
from the beginning as all the other classes have the
ability to report status.
Signed-off-by: Tony Asleson <***@redhat.com>
---
.../libstoragemgmt/libstoragemgmt_plug_interface.h | 2 ++
include/libstoragemgmt/libstoragemgmt_pool.h | 8 ++++++++
include/libstoragemgmt/libstoragemgmt_types.h | 20 ++++++++++++++++++++
plugin/simc_lsmplugin.c | 13 +++++++++----
src/lsm_convert.cpp | 2 ++
src/lsm_datatypes.cpp | 13 ++++++++++++-
src/lsm_datatypes.hpp | 1 +
test/tester.c | 3 +++
8 files changed, 57 insertions(+), 5 deletions(-)
diff --git a/include/libstoragemgmt/libstoragemgmt_plug_interface.h b/include/libstoragemgmt/libstoragemgmt_plug_interface.h
index c0e29a3..4517763 100644
--- a/include/libstoragemgmt/libstoragemgmt_plug_interface.h
+++ b/include/libstoragemgmt/libstoragemgmt_plug_interface.h
@@ -965,12 +965,14 @@ void LSM_DLL_EXPORT lsmPoolFreeSpaceSet(lsmPool *p, uint64_t free_space);
* @param name Human readable name
* @param totalSpace Total space
* @param freeSpace Space available
+ * @param status Pool status, bit field (See LSM_POOL_STATUS_XXXX constants)
* @param system_id System id
* @return LSM_ERR_OK on success, else error reason.
*/
lsmPool LSM_DLL_EXPORT *lsmPoolRecordAlloc(const char *id, const char *name,
uint64_t totalSpace,
uint64_t freeSpace,
+ uint64_t status,
const char *system_id);
/**
diff --git a/include/libstoragemgmt/libstoragemgmt_pool.h b/include/libstoragemgmt/libstoragemgmt_pool.h
index 67b4788..d54a2e6 100644
--- a/include/libstoragemgmt/libstoragemgmt_pool.h
+++ b/include/libstoragemgmt/libstoragemgmt_pool.h
@@ -78,6 +78,14 @@ uint64_t LSM_DLL_EXPORT lsmPoolTotalSpaceGet( lsmPool *p );
uint64_t LSM_DLL_EXPORT lsmPoolFreeSpaceGet( lsmPool *p );
/**
+ * Retrieve the status for the Pool.
+ * @param s Pool to retrieve status for
+ * @return Pool status which is a bit sensitive field, returns UINT64_MAX on
+ * bad pool pointer.
+ */
+uint64_t lsmPoolStatusGet( lsmPool *s );
+
+/**
* Retrieve the system id for the specified pool.
* @param p Pool pointer
* @return System ID
diff --git a/include/libstoragemgmt/libstoragemgmt_types.h b/include/libstoragemgmt/libstoragemgmt_types.h
index 320577c..acb9009 100644
--- a/include/libstoragemgmt/libstoragemgmt_types.h
+++ b/include/libstoragemgmt/libstoragemgmt_types.h
@@ -218,6 +218,26 @@ typedef enum {
#define LSM_DISK_STATUS_INITIALIZING 0x0000000000000100
#define LSM_DISK_STATUS_RECONSTRUCTING 0x0000000000000200
+
+#define LSM_POOL_STATUS_UNKNOWN 0x0000000000000001
+#define LSM_POOL_STATUS_OK 0x0000000000000002
+#define LSM_POOL_STATUS_OTHER 0x0000000000000004
+#define LSM_POOL_STATUS_STRESSED 0x0000000000000008
+#define LSM_POOL_STATUS_DEGRADED 0x0000000000000010
+#define LSM_POOL_STATUS_ERROR 0x0000000000000020
+#define LSM_POOL_STATUS_OFFLINE 0x0000000000000040
+#define LSM_POOL_STATUS_STARTING 0x0000000000000080
+#define LSM_POOL_STATUS_STOPPING 0x0000000000000100
+#define LSM_POOL_STATUS_STOPPED 0x0000000000000200
+#define LSM_POOL_STATUS_READ_ONLY 0x0000000000000400
+#define LSM_POOL_STATUS_DORMAT 0x0000000000000800
+#define LSM_POOL_STATUS_RECONSTRUCTING 0x0000000000001000
+#define LSM_POOL_STATUS_VERIFYING 0x0000000000002000
+#define LSM_POOL_STATUS_INITIALIZING 0x0000000000004000
+#define LSM_POOL_STATUS_GROWING 0x0000000000008000
+#define LSM_POOL_STATUS_SHRINKING 0x0000000000010000
+#define LSM_POOL_STATUS_DESTROYING 0x0000000000020000
+
#ifdef __cplusplus
}
#endif
diff --git a/plugin/simc_lsmplugin.c b/plugin/simc_lsmplugin.c
index e12c630..e7d445f 100644
--- a/plugin/simc_lsmplugin.c
+++ b/plugin/simc_lsmplugin.c
@@ -2199,13 +2199,18 @@ int load( lsmPluginPtr c, xmlURIPtr uri, const char *password,
data->num_pools = MAX_POOLS;
data->pool[0] = lsmPoolRecordAlloc("POOL_0", "POOL_ZERO", UINT64_MAX,
- UINT64_MAX, sys_id);
+ UINT64_MAX, LSM_POOL_STATUS_OK,
+ sys_id);
data->pool[1] = lsmPoolRecordAlloc("POOL_1", "POOL_ONE", UINT64_MAX,
- UINT64_MAX, sys_id);
+ UINT64_MAX, LSM_POOL_STATUS_OK,
+ sys_id);
data->pool[2] = lsmPoolRecordAlloc("POOL_2", "POOL_TWO", UINT64_MAX,
- UINT64_MAX, sys_id);
+ UINT64_MAX, LSM_POOL_STATUS_OK,
+ sys_id);
data->pool[3] = lsmPoolRecordAlloc("POOL_3", "lsm_test_aggr",
- UINT64_MAX, UINT64_MAX, sys_id);
+ UINT64_MAX, UINT64_MAX,
+ LSM_POOL_STATUS_OK,
+ sys_id);
data->access_groups = g_hash_table_new_full(g_str_hash, g_str_equal,
free, free_allocated_ag);
diff --git a/src/lsm_convert.cpp b/src/lsm_convert.cpp
index 242efe9..630386e 100644
--- a/src/lsm_convert.cpp
+++ b/src/lsm_convert.cpp
@@ -165,6 +165,7 @@ lsmPool *valueToPool(Value &pool)
i["name"].asString().c_str(),
i["total_space"].asUint64_t(),
i["free_space"].asUint64_t(),
+ i["status"].asUint64_t(),
i["system_id"].asString().c_str());
}
return rc;
@@ -179,6 +180,7 @@ Value poolToValue(lsmPool *pool)
p["name"] = Value(pool->name);
p["total_space"] = Value(pool->totalSpace);
p["free_space"] = Value(pool->freeSpace);
+ p["status"] = Value(pool->status);
p["system_id"] = Value(pool->system_id);
return Value(p);
}
diff --git a/src/lsm_datatypes.cpp b/src/lsm_datatypes.cpp
index 18d6d8f..d2064ea 100644
--- a/src/lsm_datatypes.cpp
+++ b/src/lsm_datatypes.cpp
@@ -496,7 +496,8 @@ void name( record_type pa[], uint32_t size) \
CREATE_ALLOC_ARRAY_FUNC(lsmPoolRecordAllocArray, lsmPool *)
lsmPool *lsmPoolRecordAlloc(const char *id, const char *name,
- uint64_t totalSpace, uint64_t freeSpace, const char *system_id)
+ uint64_t totalSpace, uint64_t freeSpace, uint64_t status,
+ const char *system_id)
{
lsmPool *rc = (lsmPool *)malloc(sizeof(lsmPool));
if (rc) {
@@ -506,6 +507,7 @@ lsmPool *lsmPoolRecordAlloc(const char *id, const char *name,
rc->name = strdup(name);
rc->totalSpace = totalSpace;
rc->freeSpace = freeSpace;
+ rc->status = status;
rc->system_id = strdup(system_id);
if( !rc->id || !rc->name || !rc->system_id ) {
@@ -529,6 +531,7 @@ lsmPool * lsmPoolRecordCopy( lsmPool *toBeCopied)
return lsmPoolRecordAlloc(toBeCopied->id, toBeCopied->name,
toBeCopied->totalSpace,
toBeCopied->freeSpace,
+ toBeCopied->status,
toBeCopied->system_id);
}
return NULL;
@@ -590,6 +593,14 @@ uint64_t lsmPoolFreeSpaceGet(lsmPool *p)
return 0;
}
+uint64_t lsmPoolStatusGet( lsmPool *p )
+{
+ if (LSM_IS_POOL(p)) {
+ return p->status;
+ }
+ return UINT64_MAX;
+}
+
char *lsmPoolSystemIdGet( lsmPool *p )
{
if (LSM_IS_POOL(p)) {
diff --git a/src/lsm_datatypes.hpp b/src/lsm_datatypes.hpp
index 91d2320..a4558cc 100644
--- a/src/lsm_datatypes.hpp
+++ b/src/lsm_datatypes.hpp
@@ -69,6 +69,7 @@ struct LSM_DLL_LOCAL _lsmPool {
char *name; /**< Human recognizeable name */
uint64_t totalSpace; /**< Total size */
uint64_t freeSpace; /**< Free space available */
+ uint64_t status; /**< Status of pool */
char *system_id; /**< system id */
};
diff --git a/test/tester.c b/test/tester.c
index a3136d1..2b23dce 100644
--- a/test/tester.c
+++ b/test/tester.c
@@ -355,6 +355,9 @@ START_TEST(test_smoke_test)
lsmPoolTotalSpaceGet(pools[i]),
lsmPoolFreeSpaceGet(pools[i]));
+ fail_unless(lsmPoolStatusGet(pools[i]) == LSM_POOL_STATUS_OK,
+ "%"PRIu64, lsmPoolStatusGet(pools[i]));
+
if (lsmPoolFreeSpaceGet(pools[i]) > 20000000) {
poolToUse = i;
}
--
1.8.2.1
1.8.2.1