Discussion:
[Libstoragemgmt-devel] [PATCH 1/3] simarray.py: Fix missing admin_state for volume_replicate
Tony Asleson
2014-08-22 20:06:24 UTC
Permalink
Signed-off-by: Tony Asleson <***@redhat.com>
---
plugin/sim/simarray.py | 1 +
1 file changed, 1 insertion(+)

diff --git a/plugin/sim/simarray.py b/plugin/sim/simarray.py
index 00c39b2..8d5ddf0 100644
--- a/plugin/sim/simarray.py
+++ b/plugin/sim/simarray.py
@@ -990,6 +990,7 @@ class SimData(object):
sim_vol['sys_id'] = SimData.SIM_DATA_SYS_ID
sim_vol['pool_id'] = dst_pool_id
sim_vol['consume_size'] = size_bytes
+ sim_vol['admin_state'] = Volume.ADMIN_STATE_ENABLED
self.vol_dict[sim_vol['vol_id']] = sim_vol

dst_vol_id = sim_vol['vol_id']
--
1.8.2.1
Tony Asleson
2014-08-22 20:06:25 UTC
Permalink
C bits for Gris's python patch set

Signed-off-by: Tony Asleson <***@redhat.com>
---
c_binding/include/libstoragemgmt/libstoragemgmt.h | 4 ++--
.../libstoragemgmt/libstoragemgmt_plug_interface.h | 8 ++++----
c_binding/lsm_mgmt.cpp | 8 ++++----
c_binding/lsm_plugin_ipc.cpp | 20 ++++++++++----------
plugin/simc/simc_lsmplugin.c | 6 +++---
test/tester.c | 10 +++++-----
6 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt.h b/c_binding/include/libstoragemgmt/libstoragemgmt.h
index e87a305..c0ac404 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt.h
@@ -373,7 +373,7 @@ extern "C" {
* @param[in] flags Reserved for future use, must be zero.
* @return LSM_ERR_OK on success, else error code
*/
- int LSM_DLL_EXPORT lsm_volume_online(lsm_connect *conn, lsm_volume *volume,
+ int LSM_DLL_EXPORT lsm_volume_enable(lsm_connect *conn, lsm_volume *volume,
lsm_flag flags);

/**
@@ -383,7 +383,7 @@ extern "C" {
* @param[in] flags Reserved for future use, must be zero.
* @return LSM_ERR_OK on success, else error code
*/
- int LSM_DLL_EXPORT lsm_volume_offline(lsm_connect *conn,
+ int LSM_DLL_EXPORT lsm_volume_disable(lsm_connect *conn,
lsm_volume *volume, lsm_flag flags);

/**
diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h b/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h
index 1fd1593..ba5fa81 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h
@@ -339,7 +339,7 @@ typedef int (*lsm_plug_volume_status)(lsm_plugin_ptr c, lsm_volume *v,
* @param[in] flags Reserved
* @return LSM_ERR_OK, else error reason
*/
-typedef int (*lsm_plug_volume_online)(lsm_plugin_ptr c, lsm_volume *v,
+typedef int (*lsm_plug_volume_enable)(lsm_plugin_ptr c, lsm_volume *v,
lsm_flag flags);

/**
@@ -349,7 +349,7 @@ typedef int (*lsm_plug_volume_online)(lsm_plugin_ptr c, lsm_volume *v,
* @param flags
* @return LSM_ERR_OK, else error reason
*/
-typedef int (*lsm_plug_volume_offline)(lsm_plugin_ptr c, lsm_volume *v,
+typedef int (*lsm_plug_volume_disable)(lsm_plugin_ptr c, lsm_volume *v,
lsm_flag flags);

/**
@@ -766,8 +766,8 @@ struct lsm_san_ops_v1 {
lsm_plug_volume_replicate_range vol_rep_range; /**< volume replication range */
lsm_plug_volume_resize vol_resize; /**< resizing a volume */
lsm_plug_volume_delete vol_delete; /**< deleting a volume */
- lsm_plug_volume_online vol_online; /**< bringing volume online */
- lsm_plug_volume_offline vol_offline; /**< bringing volume offline */
+ lsm_plug_volume_enable vol_enable; /**< volume is accessible */
+ lsm_plug_volume_disable vol_disable; /**< volume is unaccessible */
lsm_plug_iscsi_chap_auth iscsi_chap_auth; /**< iscsi chap authentication */
lsm_plug_access_group_list ag_list; /**< access groups */
lsm_plug_access_group_create ag_create; /**< access group create */
diff --git a/c_binding/lsm_mgmt.cpp b/c_binding/lsm_mgmt.cpp
index b236549..cb841d4 100644
--- a/c_binding/lsm_mgmt.cpp
+++ b/c_binding/lsm_mgmt.cpp
@@ -1202,14 +1202,14 @@ static int online_offline(lsm_connect *c, lsm_volume *v,
return rpc(c, operation, parameters, response);
}

-int lsm_volume_online(lsm_connect *c, lsm_volume *volume, lsm_flag flags)
+int lsm_volume_enable(lsm_connect *c, lsm_volume *volume, lsm_flag flags)
{
- return online_offline(c, volume, "volume_online", flags);
+ return online_offline(c, volume, "volume_enable", flags);
}

-int lsm_volume_offline(lsm_connect *c, lsm_volume *volume, lsm_flag flags)
+int lsm_volume_disable(lsm_connect *c, lsm_volume *volume, lsm_flag flags)
{
- return online_offline(c, volume, "volume_offline", flags);
+ return online_offline(c, volume, "volume_disable", flags);
}

int lsm_access_group_list(lsm_connect *c, const char *search_key,
diff --git a/c_binding/lsm_plugin_ipc.cpp b/c_binding/lsm_plugin_ipc.cpp
index 24b89ae..8fcca83 100644
--- a/c_binding/lsm_plugin_ipc.cpp
+++ b/c_binding/lsm_plugin_ipc.cpp
@@ -912,13 +912,13 @@ static int handle_volume_delete(lsm_plugin_ptr p, Value &params, Value &response
return rc;
}

-static int handle_vol_online_offline( lsm_plugin_ptr p, Value &params,
+static int handle_vol_enable_disable( lsm_plugin_ptr p, Value &params,
Value &response, int online)
{
int rc = LSM_ERR_NO_SUPPORT;

if( p && p->san_ops &&
- ((online)? p->san_ops->vol_online : p->san_ops->vol_offline)) {
+ ((online)? p->san_ops->vol_enable : p->san_ops->vol_disable)) {

Value v_vol = params["volume"];

@@ -927,10 +927,10 @@ static int handle_vol_online_offline( lsm_plugin_ptr p, Value &params,
lsm_volume *vol = value_to_volume(v_vol);
if( vol ) {
if( online ) {
- rc = p->san_ops->vol_online(p, vol,
+ rc = p->san_ops->vol_enable(p, vol,
LSM_FLAG_GET_VALUE(params));
} else {
- rc = p->san_ops->vol_offline(p, vol,
+ rc = p->san_ops->vol_disable(p, vol,
LSM_FLAG_GET_VALUE(params));
}

@@ -945,14 +945,14 @@ static int handle_vol_online_offline( lsm_plugin_ptr p, Value &params,
return rc;
}

-static int handle_volume_online(lsm_plugin_ptr p, Value &params, Value &response)
+static int handle_volume_enable(lsm_plugin_ptr p, Value &params, Value &response)
{
- return handle_vol_online_offline(p, params, response, 1);
+ return handle_vol_enable_disable(p, params, response, 1);
}

-static int handle_volume_offline(lsm_plugin_ptr p, Value &params, Value &response)
+static int handle_volume_disable(lsm_plugin_ptr p, Value &params, Value &response)
{
- return handle_vol_online_offline(p, params, response, 0);
+ return handle_vol_enable_disable(p, params, response, 0);
}

static int ag_list(lsm_plugin_ptr p, Value &params, Value &response)
@@ -2140,8 +2140,8 @@ static std::map<std::string,handler> dispatch = static_map<std::string,handler>
("volume_child_dependency", volume_dependency)
("volume_create", handle_volume_create)
("volume_delete", handle_volume_delete)
- ("volume_offline", handle_volume_offline)
- ("volume_online", handle_volume_online)
+ ("volume_disable", handle_volume_disable)
+ ("volume_enable", handle_volume_enable)
("volume_replicate", handle_volume_replicate)
("volume_replicate_range_block_size", handle_volume_replicate_range_block_size)
("volume_replicate_range", handle_volume_replicate_range)
diff --git a/plugin/simc/simc_lsmplugin.c b/plugin/simc/simc_lsmplugin.c
index 53fd94b..6b2ddb7 100644
--- a/plugin/simc/simc_lsmplugin.c
+++ b/plugin/simc/simc_lsmplugin.c
@@ -925,7 +925,7 @@ static int volume_delete(lsm_plugin_ptr c, lsm_volume *volume,
return rc;
}

-static int volume_online_offline(lsm_plugin_ptr c, lsm_volume *v,
+static int volume_enable_disable(lsm_plugin_ptr c, lsm_volume *v,
lsm_flag flags)
{
int rc = LSM_ERR_OK;
@@ -1424,8 +1424,8 @@ static struct lsm_san_ops_v1 san_ops = {
volume_replicate_range,
volume_resize,
volume_delete,
- volume_online_offline,
- volume_online_offline,
+ volume_enable_disable,
+ volume_enable_disable,
iscsi_chap_auth,
access_group_list,
access_group_create,
diff --git a/test/tester.c b/test/tester.c
index 41219db..f4e19f4 100644
--- a/test/tester.c
+++ b/test/tester.c
@@ -516,9 +516,9 @@ START_TEST(test_smoke_test)
G(rc, lsm_block_range_record_array_free, range, 3);

int online = 0;
- G(online, lsm_volume_offline, c, n, LSM_FLAG_RSVD);
+ G(online, lsm_volume_disable, c, n, LSM_FLAG_RSVD);

- G(online, lsm_volume_online, c, n, LSM_FLAG_RSVD);
+ G(online, lsm_volume_enable, c, n, LSM_FLAG_RSVD);

char *jobDel = NULL;
int delRc = lsm_volume_delete(c, n, &jobDel, LSM_FLAG_RSVD);
@@ -548,7 +548,7 @@ START_TEST(test_smoke_test)
lsm_volume_vpd83_get(volumes[i]),
lsm_volume_block_size_get(volumes[i]),
lsm_volume_number_of_blocks_get(volumes[i]),
- lsm_volume_op_status_get(volumes[i]));
+ lsm_volume_admin_state_get(volumes[i]));
}

if( count ) {
@@ -1512,10 +1512,10 @@ START_TEST(test_invalid_input)
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);


- rc = lsm_volume_online(c, NULL, LSM_FLAG_RSVD);
+ rc = lsm_volume_enable(c, NULL, LSM_FLAG_RSVD);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

- rc = lsm_volume_offline(c, NULL, LSM_FLAG_RSVD);
+ rc = lsm_volume_disable(c, NULL, LSM_FLAG_RSVD);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
--
1.8.2.1
Tony Asleson
2014-08-22 20:06:26 UTC
Permalink
Volume status or health doesn't have much value as it's really just one
of many items that can be created from a pool which does have a health
status.

There are the C bits to follow on to Gris's python patch set.

Signed-off-by: Tony Asleson <***@redhat.com>
---
c_binding/include/libstoragemgmt/libstoragemgmt_types.h | 11 +++--------
c_binding/include/libstoragemgmt/libstoragemgmt_volumes.h | 8 +++++---
c_binding/lsm_convert.cpp | 4 ++--
c_binding/lsm_datatypes.cpp | 8 ++++----
c_binding/lsm_datatypes.hpp | 2 +-
5 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_types.h b/c_binding/include/libstoragemgmt/libstoragemgmt_types.h
index b665162..8184335 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_types.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_types.h
@@ -146,15 +146,10 @@ typedef enum {
} lsm_volume_status_type;

/**
- * Different states for a volume to be in.
- * Bit field, can be in multiple states at the same time.
+ * Admin state for volume, enabled or disabled
*/
-#define LSM_VOLUME_OP_STATUS_UNKNOWN 0x0 /**< Unknown status */
-#define LSM_VOLUME_OP_STATUS_OK 0x1 /**< Volume is functioning properly */
-#define LSM_VOLUME_OP_STATUS_DEGRADED 0x2 /**< Volume is functioning but not optimal */
-#define LSM_VOLUME_OP_STATUS_ERROR 0x4 /**< Volume is non-functional */
-#define LSM_VOLUME_OP_STATUS_STARTING 0x8 /**< Volume in the process of becomming ready */
-#define LSM_VOLUME_OP_STATUS_DORMANT 0x10 /**< Volume is inactive or quiesced */
+#define LSM_VOLUME_ADMIN_STATE_ENABLED 0x1 /**< Volume accessible */
+#define LSM_VOLUME_ADMIN_STATE_DISABLE 0x0 /**< Volume unaccessible */

/**
* Different states a system status can be in.
diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_volumes.h b/c_binding/include/libstoragemgmt/libstoragemgmt_volumes.h
index 303d287..5d4d798 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_volumes.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_volumes.h
@@ -87,11 +87,13 @@ uint64_t LSM_DLL_EXPORT lsm_volume_block_size_get(lsm_volume *v);
uint64_t LSM_DLL_EXPORT lsm_volume_number_of_blocks_get(lsm_volume *v);

/**
- * Retrieves the operational status of the volume.
+ * Retrieves the admin state of the volume.
* @param v Volume ptr.
- * @return Operational status of the volume, @see lsm_volume_op_status
+ * @return Admin state of volume, see LSM_VOLUME_ADMIN_STATE_ENABLED and
+ * LSM_VOLUME_ADMIN_STATE_DISABLED
+ *
*/
-uint32_t LSM_DLL_EXPORT lsm_volume_op_status_get(lsm_volume *v);
+uint32_t LSM_DLL_EXPORT lsm_volume_admin_state_get(lsm_volume *v);

/**
* Retrieves the system id of the volume.
diff --git a/c_binding/lsm_convert.cpp b/c_binding/lsm_convert.cpp
index 1eb4331..f3693eb 100644
--- a/c_binding/lsm_convert.cpp
+++ b/c_binding/lsm_convert.cpp
@@ -46,7 +46,7 @@ lsm_volume *value_to_volume(Value &vol)
v["vpd83"].asString().c_str(),
v["block_size"].asUint64_t(),
v["num_of_blocks"].asUint64_t(),
- v["status"].asUint32_t(),
+ v["admin_state"].asUint32_t(),
v["system_id"].asString().c_str(),
v["pool_id"].asString().c_str(),
v["plugin_data"].asC_str());
@@ -65,7 +65,7 @@ Value volume_to_value(lsm_volume *vol)
v["vpd83"] = Value(vol->vpd83);
v["block_size"] = Value(vol->block_size);
v["num_of_blocks"] = Value(vol->number_of_blocks);
- v["status"] = Value(vol->status);
+ v["admin_state"] = Value(vol->admin_state);
v["system_id"] = Value(vol->system_id);
v["pool_id"] = Value(vol->pool_id);
v["plugin_data"] = Value(vol->plugin_data);
diff --git a/c_binding/lsm_datatypes.cpp b/c_binding/lsm_datatypes.cpp
index adb10dc..fd77d29 100644
--- a/c_binding/lsm_datatypes.cpp
+++ b/c_binding/lsm_datatypes.cpp
@@ -671,7 +671,7 @@ lsm_volume * lsm_volume_record_alloc(const char *id, const char *name,
rc->vpd83 = strdup(vpd83);
rc->block_size = blockSize;
rc->number_of_blocks = numberOfBlocks;
- rc->status = status;
+ rc->admin_state = status;
rc->system_id = strdup(system_id);
rc->pool_id = strdup(pool_id);

@@ -814,7 +814,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->plugin_data);
+ vol->admin_state, vol->system_id, vol->pool_id, vol->plugin_data);
}
return rc;
}
@@ -945,9 +945,9 @@ uint64_t lsm_volume_number_of_blocks_get(lsm_volume *v)
MEMBER_GET(v, LSM_IS_VOL, number_of_blocks, 0);
}

-uint32_t lsm_volume_op_status_get(lsm_volume *v)
+uint32_t lsm_volume_admin_state_get(lsm_volume *v)
{
- MEMBER_GET(v, LSM_IS_VOL, status, 0);
+ MEMBER_GET(v, LSM_IS_VOL, admin_state, 0);
}

char *lsm_volume_system_id_get( lsm_volume *v)
diff --git a/c_binding/lsm_datatypes.hpp b/c_binding/lsm_datatypes.hpp
index 02f189e..5fbc9c1 100644
--- a/c_binding/lsm_datatypes.hpp
+++ b/c_binding/lsm_datatypes.hpp
@@ -64,7 +64,7 @@ struct LSM_DLL_LOCAL _lsm_volume {
char *vpd83; /**< SCSI page 83 unique ID */
uint64_t block_size; /**< Block size */
uint64_t number_of_blocks; /**< Number of blocks */
- uint32_t status; /**< Status */
+ uint32_t admin_state; /**< Status */
char *system_id; /**< System this volume belongs */
char *pool_id; /**< Pool this volume is derived from */
char *plugin_data; /**< Private data for plugin */
--
1.8.2.1
Loading...