Tony Asleson
2014-04-15 00:00:37 UTC
First step in changing pool_create* to take objects instead
of object ids.
Signed-off-by: Tony Asleson <***@redhat.com>
---
include/libstoragemgmt/libstoragemgmt.h | 17 +++++-----
.../libstoragemgmt/libstoragemgmt_plug_interface.h | 19 ++++++-----
lsm/lsm/_client.py | 4 +--
lsm/lsm/_cmdline.py | 12 ++++---
lsm/lsm/simulator.py | 16 ++++-----
plugin/simc_lsmplugin.c | 22 ++++++-------
src/lsm_mgmt.cpp | 38 ++++++++++++++--------
src/lsm_plugin_ipc.cpp | 29 +++++++++--------
test/tester.c | 35 ++++++++++++--------
9 files changed, 111 insertions(+), 81 deletions(-)
diff --git a/include/libstoragemgmt/libstoragemgmt.h b/include/libstoragemgmt/libstoragemgmt.h
index 109b511..34fb781 100644
--- a/include/libstoragemgmt/libstoragemgmt.h
+++ b/include/libstoragemgmt/libstoragemgmt.h
@@ -237,7 +237,7 @@ extern "C" {
/**
* Create new pool allowing the array to make the most decisions.
* @param [in] conn Valid connection @see lsm_connect_password
- * @param [in] system_id System ID of where pool will reside
+ * @param [in] system System of where pool will reside
* @param [in] pool_name Name of new pool
* @param [in] size_bytes Size of new pool in bytes
* @param [in] raid_type Optional. If defined, new pool should
@@ -256,7 +256,8 @@ extern "C" {
* @return LSM_ERR_OK on success, LSM_ERR_JOB_STARTED if async.,
* else error code
*/
- int LSM_DLL_EXPORT lsm_pool_create(lsm_connect *conn, const char *system_id,
+ int LSM_DLL_EXPORT lsm_pool_create(lsm_connect *conn,
+ lsm_system *system,
const char *pool_name, uint64_t size_bytes,
lsm_pool_raid_type raid_type,
lsm_pool_member_type member_type, lsm_pool** pool,
@@ -265,7 +266,7 @@ extern "C" {
/**
* Create a pool specifying specific disks to use.
* @param [in] conn Valid connection @see lsm_connect_password
- * @param [in] system_id System ID of where pool will reside
+ * @param [in] system System of where pool will reside
* @param [in] pool_name The name of the new pool, will not fail
* if request name cannot be fulfilled
* @param [in] member_ids The IDs of disks to create new pool from
@@ -281,7 +282,7 @@ extern "C" {
* else error code
*/
int LSM_DLL_EXPORT lsm_pool_create_from_disks(lsm_connect *conn,
- const char *system_id, const char *pool_name,
+ lsm_system *system, const char *pool_name,
lsm_string_list *member_ids, lsm_pool_raid_type raid_type,
lsm_pool** pool, char **job, lsm_flag flags);
@@ -289,7 +290,7 @@ extern "C" {
* Create new pool in by specifying which volumes should be used for pool
* creation.
* @param [in] conn Valid connection @see lsm_connect_password
- * @param [in] system_id System ID of where pool will reside
+ * @param [in] system System of where pool will reside
* @param [in] pool_name The name of the new pool, will not fail
* if request name cannot be fulfilled
* @param [in] member_ids The IDs of volumes to create new pool from
@@ -305,14 +306,14 @@ extern "C" {
* else error code
*/
int LSM_DLL_EXPORT lsm_pool_create_from_volumes(lsm_connect *conn,
- const char *system_id, const char *pool_name,
+ lsm_system *system, const char *pool_name,
lsm_string_list *member_ids, lsm_pool_raid_type raid_type,
lsm_pool** pool, char **job, lsm_flag flags);
/**
* Create new pool from an existing pool
* @param [in] conn Valid connection @see lsm_connect_password
- * @param [in] system_id System ID of where pool will reside
+ * @param [in] system System of where pool will reside
* @param [in] pool_name The name of the new pool, will not fail
* if request name cannot be fulfilled
* @param [in] member_id The ID of pool to create new pool from
@@ -324,7 +325,7 @@ extern "C" {
* else error code
*/
int LSM_DLL_EXPORT lsm_pool_create_from_pool(lsm_connect *conn,
- const char *system_id, const char *pool_name,
+ lsm_system *system, const char *pool_name,
const char *member_id, uint64_t size_bytes,
lsm_pool** pool, char **job, lsm_flag flags);
diff --git a/include/libstoragemgmt/libstoragemgmt_plug_interface.h b/include/libstoragemgmt/libstoragemgmt_plug_interface.h
index 6117437..6b685bc 100644
--- a/include/libstoragemgmt/libstoragemgmt_plug_interface.h
+++ b/include/libstoragemgmt/libstoragemgmt_plug_interface.h
@@ -218,7 +218,7 @@ typedef int (*lsm_plug_disk_list)( lsm_plugin_ptr c, lsm_disk **disk_array[],
/**
* Create a pool.
* @param[in] c Valid lsm plug-in pointer
- * @param[in] system_id System id
+ * @param[in] system System
* @param[in] pool_name Human name of pool
* @param[in] size_bytes Desired size of pool
* @param[in] raid_type Raid type for pool
@@ -227,7 +227,7 @@ typedef int (*lsm_plug_disk_list)( lsm_plugin_ptr c, lsm_disk **disk_array[],
* @param[out] job Job id if execution is async.
* @return LSM_ERR_OK, else error reason
*/
-typedef int (*lsm_plug_pool_create)( lsm_plugin_ptr c, const char* system_id,
+typedef int (*lsm_plug_pool_create)( lsm_plugin_ptr c, lsm_system* system,
const char *pool_name, uint64_t size_bytes,
lsm_pool_raid_type raid_type, lsm_pool_member_type member_type,
lsm_pool **pool, char **job, lsm_flag flags);
@@ -235,7 +235,7 @@ typedef int (*lsm_plug_pool_create)( lsm_plugin_ptr c, const char* system_id,
/**
* Create a pool and specifying disks to use.
* @param[in] c Valid lsm plug-in pointer
- * @param[in] system_id System id
+ * @param[in] system System
* @param[in] pool_name Human name of pool
* @param[in] member_ids List of disk IDs to create pool from
* @param[in] raid_type Raid type for pool
@@ -243,7 +243,8 @@ typedef int (*lsm_plug_pool_create)( lsm_plugin_ptr c, const char* system_id,
* @param[out] job Job id if execution is async.
* @return LSM_ERR_OK, else error reason
*/
-typedef int (*lsm_plug_pool_create_from_disks)( lsm_plugin_ptr c, const char *system_id,
+typedef int (*lsm_plug_pool_create_from_disks)( lsm_plugin_ptr c,
+ lsm_system *system,
const char *pool_name, lsm_string_list *member_ids,
lsm_pool_raid_type raid_type, lsm_pool **pool, char **job,
lsm_flag flags);
@@ -251,7 +252,7 @@ typedef int (*lsm_plug_pool_create_from_disks)( lsm_plugin_ptr c, const char *sy
/**
* Create a pool and specifying volumes to use.
* @param[in] c Valid lsm plug-in pointer
- * @param[in] system_id System id
+ * @param[in] system System
* @param[in] pool_name Human name of pool
* @param[in] member_ids List of volume IDs to create pool from
* @param[in] raid_type Raid type for pool
@@ -259,7 +260,8 @@ typedef int (*lsm_plug_pool_create_from_disks)( lsm_plugin_ptr c, const char *sy
* @param[out] job Job id if execution is async.
* @return LSM_ERR_OK, else error reason
*/
-typedef int (*lsm_plug_pool_create_from_volumes)( lsm_plugin_ptr c, const char *system_id,
+typedef int (*lsm_plug_pool_create_from_volumes)( lsm_plugin_ptr c,
+ lsm_system *system,
const char *pool_name, lsm_string_list *member_ids,
lsm_pool_raid_type raid_type, lsm_pool** pool, char **job,
lsm_flag flags);
@@ -267,7 +269,7 @@ typedef int (*lsm_plug_pool_create_from_volumes)( lsm_plugin_ptr c, const char *
/**
* Create a pool and specifying pool to use.
* @param[in] c Valid lsm plug-in pointer
- * @param[in] system_id System id
+ * @param[in] system System id
* @param[in] pool_name Human name of pool
* @param[in] member_id ID of pool to create pool from
* @param[in] size_bytes Size of pool
@@ -275,7 +277,8 @@ typedef int (*lsm_plug_pool_create_from_volumes)( lsm_plugin_ptr c, const char *
* @param[out] job Job id if execution is async.
* @return LSM_ERR_OK, else error reason
*/
-typedef int (*lsm_plug_pool_create_from_pool)( lsm_plugin_ptr c, const char *system_id,
+typedef int (*lsm_plug_pool_create_from_pool)( lsm_plugin_ptr c,
+ lsm_system *system,
const char *pool_name, const char *member_id,
uint64_t size_bytes, lsm_pool **pool, char **job,
lsm_flag flags );
diff --git a/lsm/lsm/_client.py b/lsm/lsm/_client.py
index 8dc7693..9d86994 100644
--- a/lsm/lsm/_client.py
+++ b/lsm/lsm/_client.py
@@ -298,7 +298,7 @@ class Client(INetworkAttachedStorage):
## sample codes.
## Return the newly created pool object.
# @param self The this pointer
- # @param system_id The id of system where new pool should reside.
+ # @param system The system where new pool should reside.
# @param pool_name The name for new pool. Will not fail if created
# pool_name is not the same as requested.
# @param size_bytes The size in bytes for new pool.
@@ -317,7 +317,7 @@ class Client(INetworkAttachedStorage):
# @returns A tuple (job_id, new_pool), when one is None the other is
# valid.
@_return_requires(unicode, Pool)
- def pool_create(self, system_id, pool_name, size_bytes,
+ def pool_create(self, system, pool_name, size_bytes,
raid_type=Pool.RAID_TYPE_UNKNOWN,
member_type=Pool.MEMBER_TYPE_UNKNOWN, flags=0):
"""
diff --git a/lsm/lsm/_cmdline.py b/lsm/lsm/_cmdline.py
index 0f5e3de..a679583 100644
--- a/lsm/lsm/_cmdline.py
+++ b/lsm/lsm/_cmdline.py
@@ -1654,6 +1654,7 @@ class CmdLine:
## Creates a pool
def pool_create(self, args):
+ system = _get_item(self.c.systems(), args.sys, "system id")
pool_name = args.name
raid_type = Pool.RAID_TYPE_UNKNOWN
member_type = Pool.MEMBER_TYPE_UNKNOWN
@@ -1674,7 +1675,7 @@ class CmdLine:
args.member_type)
pool = self._wait_for_it("pool-create",
- *self.c.pool_create(self.args.sys,
+ *self.c.pool_create(system,
pool_name,
size_bytes,
raid_type,
@@ -1683,6 +1684,7 @@ class CmdLine:
self.display_data([pool])
def pool_create_from_disks(self, args):
+ system = _get_item(self.c.systems(), args.sys, "system id")
if len(args.member_id) <= 0:
raise ArgError("No disk ID was provided for new pool")
@@ -1704,10 +1706,11 @@ class CmdLine:
pool = self._wait_for_it(
"pool-create-from-disks",
*self.c.pool_create_from_disks(
- self.args.sys, pool_name, member_ids, raid_type, 0))
+ system, pool_name, member_ids, raid_type, 0))
self.display_data([pool])
def pool_create_from_volumes(self, args):
+ system = _get_item(self.c.systems(), args.sys, "system id")
if len(args.member_id) <= 0:
raise ArgError("No volume ID was provided for new pool")
@@ -1729,10 +1732,11 @@ class CmdLine:
pool = self._wait_for_it(
"pool-create-from-volumes",
*self.c.pool_create_from_volumes(
- self.args.sys, pool_name, member_ids, raid_type, 0))
+ system, pool_name, member_ids, raid_type, 0))
self.display_data([pool])
def pool_create_from_pool(self, args):
+ system = _get_item(self.c.systems(), args.sys, "system id")
if len(args.member_id) <= 0:
raise ArgError("No volume ID was provided for new pool")
@@ -1755,7 +1759,7 @@ class CmdLine:
pool = self._wait_for_it(
"pool-create-from-pool",
*self.c.pool_create_from_pool(
- self.args.sys, pool_name, member_id, size_bytes, 0))
+ system, pool_name, member_id, size_bytes, 0))
self.display_data([pool])
def _read_configfile(self):
diff --git a/lsm/lsm/simulator.py b/lsm/lsm/simulator.py
index 76f40c9..e5a3630 100644
--- a/lsm/lsm/simulator.py
+++ b/lsm/lsm/simulator.py
@@ -89,26 +89,26 @@ class SimPlugin(INfs, IStorageAreaNetwork):
sim_pools = self.sim_array.pools(flags)
return [SimPlugin._sim_data_2_lsm(p) for p in sim_pools]
- def pool_create(self, system_id, pool_name, size_bytes,
+ def pool_create(self, system, pool_name, size_bytes,
raid_type=Pool.RAID_TYPE_UNKNOWN,
member_type=Pool.MEMBER_TYPE_UNKNOWN, flags=0):
return self.sim_array.pool_create(
- system_id, pool_name, size_bytes, raid_type, member_type, flags)
+ system.id, pool_name, size_bytes, raid_type, member_type, flags)
- def pool_create_from_disks(self, system_id, pool_name, member_ids,
+ def pool_create_from_disks(self, system, pool_name, member_ids,
raid_type, flags=0):
return self.sim_array.pool_create_from_disks(
- system_id, pool_name, member_ids, raid_type, flags)
+ system.id, pool_name, member_ids, raid_type, flags)
- def pool_create_from_volumes(self, system_id, pool_name, member_ids,
+ def pool_create_from_volumes(self, system, pool_name, member_ids,
raid_type, flags=0):
return self.sim_array.pool_create_from_volumes(
- system_id, pool_name, member_ids, raid_type, flags)
+ system.id, pool_name, member_ids, raid_type, flags)
- def pool_create_from_pool(self, system_id, pool_name, member_id,
+ def pool_create_from_pool(self, system, pool_name, member_id,
size_bytes, flags=0):
return self.sim_array.pool_create_from_pool(
- system_id, pool_name, member_id, size_bytes, flags)
+ system.id, pool_name, member_id, size_bytes, flags)
def pool_delete(self, pool, flags=0):
return self.sim_array.pool_delete(pool.id, flags)
diff --git a/plugin/simc_lsmplugin.c b/plugin/simc_lsmplugin.c
index 726e7e2..3269506 100644
--- a/plugin/simc_lsmplugin.c
+++ b/plugin/simc_lsmplugin.c
@@ -973,7 +973,7 @@ static int _volume_delete(lsm_plugin_ptr c, const char *volume_id)
return rc;
}
-static int _pool_create(lsm_plugin_ptr c, const char *system_id,
+static int _pool_create(lsm_plugin_ptr c, lsm_system *system,
const char *pool_name, uint64_t size_bytes,
lsm_pool **pool, char **job)
{
@@ -984,14 +984,14 @@ static int _pool_create(lsm_plugin_ptr c, const char *system_id,
char *key = NULL;
/* Verify system id */
- if( strcmp(system_id, lsm_system_id_get(pd->system[0])) == 0 ) {
+ if( strcmp(lsm_system_id_get(system), lsm_system_id_get(pd->system[0])) == 0 ) {
/* Verify that we don't already have a pool by that name */
new_pool = find_pool_name(pd, pool_name);
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, "",
- system_id);
+ lsm_system_id_get(system));
pool_to_store = lsm_pool_record_copy(new_pool);
key = strdup(lsm_pool_id_get(pool_to_store));
@@ -1019,16 +1019,16 @@ static int _pool_create(lsm_plugin_ptr c, const char *system_id,
}
-static int pool_create(lsm_plugin_ptr c, const char *system_id,
+static int pool_create(lsm_plugin_ptr c, lsm_system *system,
const char *pool_name, uint64_t size_bytes,
lsm_pool_raid_type raid_type,
lsm_pool_member_type member_type, lsm_pool** pool,
char **job, lsm_flag flags)
{
- return _pool_create(c, system_id, pool_name, size_bytes, pool, job);
+ return _pool_create(c, system, pool_name, size_bytes, pool, job);
}
-static int pool_create_from_disks( lsm_plugin_ptr c, const char *system_id,
+static int pool_create_from_disks( lsm_plugin_ptr c, lsm_system *system,
const char *pool_name, lsm_string_list *member_ids,
lsm_pool_raid_type raid_type, lsm_pool **pool, char **job,
lsm_flag flags)
@@ -1052,7 +1052,7 @@ static int pool_create_from_disks( lsm_plugin_ptr c, const char *system_id,
}
}
- rc = _pool_create(c, system_id, pool_name, size, pool, job);
+ rc = _pool_create(c, system, pool_name, size, pool, job);
} else {
rc = lsm_log_error_basic(c, LSM_ERR_INVALID_ARGUMENT, "No disks provided");
}
@@ -1060,7 +1060,7 @@ bail:
return rc;
}
-static int pool_create_from_volumes( lsm_plugin_ptr c, const char *system_id,
+static int pool_create_from_volumes( lsm_plugin_ptr c, lsm_system *system,
const char *pool_name, lsm_string_list *member_ids,
lsm_pool_raid_type raid_type, lsm_pool **pool, char **job,
lsm_flag flags)
@@ -1086,7 +1086,7 @@ static int pool_create_from_volumes( lsm_plugin_ptr c, const char *system_id,
}
}
- rc = _pool_create(c, system_id, pool_name, size, pool, job);
+ rc = _pool_create(c, system, pool_name, size, pool, job);
} else {
rc = lsm_log_error_basic(c, LSM_ERR_INVALID_ARGUMENT, "No disks provided");
}
@@ -1094,7 +1094,7 @@ bail:
return rc;
}
-static int pool_create_from_pool(lsm_plugin_ptr c, const char *system_id,
+static int pool_create_from_pool(lsm_plugin_ptr c, lsm_system *system,
const char *pool_name, const char *member_id,
uint64_t size_bytes, lsm_pool **pool, char **job,
lsm_flag flags )
@@ -1105,7 +1105,7 @@ static int pool_create_from_pool(lsm_plugin_ptr c, const char *system_id,
lsm_pool *p = find_pool(pd, member_id);
if( p ) {
- rc = _pool_create(c, system_id, pool_name, size_bytes, pool, job);
+ rc = _pool_create(c, system, pool_name, size_bytes, pool, job);
} else {
rc = lsm_log_error_basic(c, LSM_ERR_NOT_FOUND_POOL, "Pool not found");
}
diff --git a/src/lsm_mgmt.cpp b/src/lsm_mgmt.cpp
index ca3ccba..09497f1 100644
--- a/src/lsm_mgmt.cpp
+++ b/src/lsm_mgmt.cpp
@@ -913,7 +913,7 @@ static int valid_pool_member_type(lsm_pool_member_type validate)
return 1;
}
-int lsm_pool_create(lsm_connect *c, const char *system_id,
+int lsm_pool_create(lsm_connect *c, lsm_system *system,
const char *pool_name, uint64_t size_bytes,
lsm_pool_raid_type raid_type,
lsm_pool_member_type member_type, lsm_pool** pool,
@@ -921,7 +921,11 @@ int lsm_pool_create(lsm_connect *c, const char *system_id,
{
CONN_SETUP(c);
- if( CHECK_STR(system_id) || CHECK_STR(pool_name) || !size_bytes ||
+ if( !LSM_IS_SYSTEM(system) ) {
+ return LSM_ERR_INVALID_SYSTEM;
+ }
+
+ if( CHECK_STR(pool_name) || !size_bytes ||
CHECK_RP(pool)|| CHECK_RP(job) || LSM_FLAG_UNUSED_CHECK(flags) ||
!valid_pool_raid_type(raid_type) ||
!valid_pool_member_type(member_type)) {
@@ -929,7 +933,7 @@ int lsm_pool_create(lsm_connect *c, const char *system_id,
}
std::map<std::string, Value> p;
- p["system_id"] = Value(system_id);
+ p["system"] = system_to_value(system);
p["pool_name"] = Value(pool_name);
p["size_bytes"] = Value(size_bytes);
p["raid_type"] = Value((int32_t)raid_type);
@@ -949,14 +953,18 @@ int lsm_pool_create(lsm_connect *c, const char *system_id,
static int lsm_pool_create_from(lsm_connect *c,
- const char *system_id, const char *pool_name,
+ lsm_system *system, const char *pool_name,
lsm_string_list *member_ids, lsm_pool_raid_type raid_type,
lsm_pool** pool, char **job, lsm_flag flags,
const char *method)
{
CONN_SETUP(c);
- if( CHECK_STR(system_id) || CHECK_STR(pool_name) ||
+ if( !LSM_IS_SYSTEM(system) ) {
+ return LSM_ERR_INVALID_SYSTEM;
+ }
+
+ if( CHECK_STR(pool_name) ||
CHECK_RP(pool)|| CHECK_RP(job) || LSM_FLAG_UNUSED_CHECK(flags) ||
!valid_pool_raid_type(raid_type) ) {
return LSM_ERR_INVALID_ARGUMENT;
@@ -967,7 +975,7 @@ static int lsm_pool_create_from(lsm_connect *c,
}
std::map<std::string, Value> p;
- p["system_id"] = Value(system_id);
+ p["system"] = system_to_value(system);
p["pool_name"] = Value(pool_name);
p["member_ids"] = string_list_to_value(member_ids);
p["raid_type"] = Value((int32_t)raid_type);
@@ -985,40 +993,44 @@ static int lsm_pool_create_from(lsm_connect *c,
}
int LSM_DLL_EXPORT lsm_pool_create_from_disks(lsm_connect *c,
- const char *system_id, const char *pool_name,
+ lsm_system *system, const char *pool_name,
lsm_string_list *member_ids, lsm_pool_raid_type raid_type,
lsm_pool** pool, char **job, lsm_flag flags)
{
- return lsm_pool_create_from(c, system_id, pool_name, member_ids, raid_type,
+ return lsm_pool_create_from(c, system, pool_name, member_ids, raid_type,
pool, job, flags, "pool_create_from_disks");
}
int LSM_DLL_EXPORT lsm_pool_create_from_volumes(lsm_connect *c,
- const char *system_id, const char *pool_name,
+ lsm_system *system, const char *pool_name,
lsm_string_list *member_ids, lsm_pool_raid_type raid_type,
lsm_pool** pool, char **job, lsm_flag flags)
{
- return lsm_pool_create_from(c, system_id, pool_name, member_ids, raid_type,
+ return lsm_pool_create_from(c, system, pool_name, member_ids, raid_type,
pool, job, flags,
"pool_create_from_volumes");
}
- int lsm_pool_create_from_pool(lsm_connect *c, const char *system_id,
+ int lsm_pool_create_from_pool(lsm_connect *c, lsm_system *system,
const char *pool_name, const char *member_id,
uint64_t size_bytes, lsm_pool **pool, char **job,
lsm_flag flags)
{
CONN_SETUP(c);
- if( CHECK_STR(system_id) || CHECK_STR(pool_name) || CHECK_STR(member_id) ||
+ if( !LSM_IS_SYSTEM(system) ) {
+ return LSM_ERR_INVALID_SYSTEM;
+ }
+
+ if( CHECK_STR(pool_name) || CHECK_STR(member_id) ||
!size_bytes || CHECK_RP(pool)|| CHECK_RP(job) ||
LSM_FLAG_UNUSED_CHECK(flags) ) {
return LSM_ERR_INVALID_ARGUMENT;
}
std::map<std::string, Value> p;
- p["system_id"] = Value(system_id);
+ p["system"] = system_to_value(system);
p["pool_name"] = Value(pool_name);
p["size_bytes"] = Value(size_bytes);
p["member_id"] = Value(member_id);
diff --git a/src/lsm_plugin_ipc.cpp b/src/lsm_plugin_ipc.cpp
index c7d7f73..7e8b676 100644
--- a/src/lsm_plugin_ipc.cpp
+++ b/src/lsm_plugin_ipc.cpp
@@ -482,20 +482,20 @@ static int handle_pool_create(lsm_plugin_ptr p, Value ¶ms, Value &response)
int rc = LSM_ERR_NO_SUPPORT;
if( p && p->san_ops && p->san_ops->pool_create ) {
- Value v_sys_id = params["system_id"];
+ Value v_sys = params["system"];
Value v_pool_name = params["pool_name"];
Value v_size = params["size_bytes"];
Value v_raid_t = params["raid_type"];
Value v_member_t = params["member_type"];
- if( Value::string_t == v_sys_id.valueType() &&
+ if( Value::object_t == v_sys.valueType() &&
Value::string_t == v_pool_name.valueType() &&
Value::numeric_t == v_size.valueType() &&
Value::numeric_t == v_raid_t.valueType() &&
Value::numeric_t == v_member_t.valueType() &&
LSM_FLAG_EXPECTED_TYPE(params)) {
- const char *sys_id = v_sys_id.asC_str();
+ lsm_system *system = value_to_system(v_sys);
const char *pool_name = v_pool_name.asC_str();
uint64_t size = v_size.asUint64_t();
lsm_pool_raid_type raid_type = (lsm_pool_raid_type)v_raid_t.asInt32_t();
@@ -503,13 +503,14 @@ static int handle_pool_create(lsm_plugin_ptr p, Value ¶ms, Value &response)
lsm_pool *pool = NULL;
char *job = NULL;
- rc = p->san_ops->pool_create(p, sys_id, pool_name, size, raid_type,
+ rc = p->san_ops->pool_create(p, system, pool_name, size, raid_type,
member_type, &pool, &job,
LSM_FLAG_GET_VALUE(params));
Value p = pool_to_value(pool);
response = job_handle(p, job);
lsm_pool_record_free(pool);
+ lsm_system_record_free(system);
free(job);
} else {
rc = LSM_ERR_TRANSPORT_INVALID_ARG;
@@ -519,7 +520,7 @@ static int handle_pool_create(lsm_plugin_ptr p, Value ¶ms, Value &response)
}
typedef int (*lsmPlugPoolCreateFrom)( lsm_plugin_ptr c,
- const char *system_id,
+ lsm_system *system,
const char *pool_name, lsm_string_list *member_ids,
lsm_pool_raid_type raid_type, lsm_pool** pool, char **job,
lsm_flag flags);
@@ -532,12 +533,12 @@ static int handle_pool_create_from( lsm_plugin_ptr p, Value ¶ms,
int rc = LSM_ERR_NO_SUPPORT;
if( pool_create_from ) {
- Value v_sys_id = params["system_id"];
+ Value v_sys = params["system"];
Value v_pool_name = params["pool_name"];
Value v_member_ids = params["member_ids"];
Value v_raid_t = params["raid_type"];
- if( Value::string_t == v_sys_id.valueType() &&
+ if( Value::object_t == v_sys.valueType() &&
Value::string_t == v_pool_name.valueType() &&
Value::array_t == v_member_ids.valueType() &&
Value::numeric_t == v_raid_t.valueType() &&
@@ -546,20 +547,21 @@ static int handle_pool_create_from( lsm_plugin_ptr p, Value ¶ms,
lsm_string_list *members = value_to_string_list(v_member_ids);
if( members ) {
- const char *sys_id = v_sys_id.asC_str();
+ lsm_system *sys = value_to_system(v_sys);
const char *pool_name = v_pool_name.asC_str();
lsm_pool_raid_type raid_type = (lsm_pool_raid_type)v_raid_t.asInt32_t();
lsm_pool *pool = NULL;
char *job = NULL;
- rc = pool_create_from(p, sys_id, pool_name, members, raid_type,
+ rc = pool_create_from(p, sys, pool_name, members, raid_type,
&pool, &job, LSM_FLAG_GET_VALUE(params));
Value p = pool_to_value(pool);
response = job_handle(p, job);
lsm_string_list_free(members);
lsm_pool_record_free(pool);
+ lsm_system_record_free(sys);
free(job);
} else {
rc = LSM_ERR_NO_MEMORY;
@@ -594,18 +596,18 @@ static int handle_pool_create_from_pool(lsm_plugin_ptr p, Value ¶ms, Value &
int rc = LSM_ERR_NO_SUPPORT;
if( p && p->san_ops && p->san_ops->pool_create_from_pool ) {
- Value v_sys_id = params["system_id"];
+ Value v_sys = params["system"];
Value v_pool_name = params["pool_name"];
Value v_member_id = params["member_id"];
Value v_size = params["size_bytes"];
- if( Value::string_t == v_sys_id.valueType() &&
+ if( Value::object_t == v_sys.valueType() &&
Value::string_t == v_pool_name.valueType() &&
Value::string_t == v_member_id.valueType() &&
Value::numeric_t == v_size.valueType() &&
LSM_FLAG_EXPECTED_TYPE(params)) {
- const char *sys_id = v_sys_id.asC_str();
+ lsm_system *sys = value_to_system(v_sys);
const char *pool_name = v_pool_name.asC_str();
const char *member_id = v_member_id.asC_str();
uint64_t size = v_size.asUint64_t();
@@ -613,13 +615,14 @@ static int handle_pool_create_from_pool(lsm_plugin_ptr p, Value ¶ms, Value &
lsm_pool *pool = NULL;
char *job = NULL;
- rc = p->san_ops->pool_create_from_pool(p, sys_id, pool_name,
+ rc = p->san_ops->pool_create_from_pool(p, sys, pool_name,
member_id, size, &pool, &job,
LSM_FLAG_GET_VALUE(params));
Value p = pool_to_value(pool);
response = job_handle(p, job);
lsm_pool_record_free(pool);
+ lsm_system_record_free(sys);
free(job);
} else {
rc = LSM_ERR_TRANSPORT_INVALID_ARG;
diff --git a/test/tester.c b/test/tester.c
index eeefa7b..b7742b6 100644
--- a/test/tester.c
+++ b/test/tester.c
@@ -342,7 +342,7 @@ void create_volumes(lsm_connect *c, lsm_pool *p, int num)
}
}
-lsm_system *get_system()
+lsm_system *get_system(lsm_connect *c)
{
lsm_system *rc_sys = NULL;
lsm_system **sys=NULL;
@@ -455,7 +455,7 @@ START_TEST(test_smoke_test)
uint32_t bs = 0;
- lsm_system * system = get_system();
+ lsm_system * system = get_system(c);
int rep_bs = lsm_volume_replicate_range_block_size(c, system, &bs, LSM_FLAG_RSVD);
fail_unless(LSM_ERR_OK == rep_bs, "%d", rep_bs);
@@ -1766,39 +1766,40 @@ START_TEST(test_invalid_input)
int member_type = 65535;
uint64_t size = 0;
int flags = 10;
+ lsm_system *system = get_system(c);
rc = lsm_pool_create(NULL, NULL, NULL, size, raid_type, member_type, NULL, NULL, flags);
fail_unless(rc == LSM_ERR_INVALID_CONN, "rc = %d", rc);
rc = lsm_pool_create(c, NULL, NULL, size, raid_type, member_type, NULL, NULL, flags);
- fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_SYSTEM, "rc = %d", rc);
- rc = lsm_pool_create(c, SYSTEM_ID, NULL, size, raid_type, member_type, NULL, NULL, flags);
+ rc = lsm_pool_create(c, system, NULL, size, raid_type, member_type, NULL, NULL, flags);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
- rc = lsm_pool_create(c, SYSTEM_ID, "pool name", size, raid_type, member_type, NULL, NULL, flags);
+ rc = lsm_pool_create(c, system, "pool name", size, raid_type, member_type, NULL, NULL, flags);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
size = 1024*1024*1024;
- rc = lsm_pool_create(c, SYSTEM_ID, "pool name", size, raid_type, member_type, NULL, NULL, flags);
+ rc = lsm_pool_create(c, system, "pool name", size, raid_type, member_type, NULL, NULL, flags);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
raid_type = LSM_POOL_RAID_TYPE_0;
- rc = lsm_pool_create(c, SYSTEM_ID, "pool name", size, raid_type, member_type, NULL, NULL, flags);
+ rc = lsm_pool_create(c, system, "pool name", size, raid_type, member_type, NULL, NULL, flags);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
member_type = LSM_POOL_MEMBER_TYPE_DISK;
- rc = lsm_pool_create(c, SYSTEM_ID, "pool name", size, raid_type, member_type, NULL, NULL, flags);
+ rc = lsm_pool_create(c, system, "pool name", size, raid_type, member_type, NULL, NULL, flags);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
lsm_pool *pcp = NULL;
- rc = lsm_pool_create(c, SYSTEM_ID, "pool name", size, raid_type, member_type, &pcp, NULL, flags);
+ rc = lsm_pool_create(c, system, "pool name", size, raid_type, member_type, &pcp, NULL, flags);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
char *pcj = NULL;
- rc = lsm_pool_create(c, SYSTEM_ID, "pool name", size, raid_type, member_type, &pcp, &pcj, flags);
+ rc = lsm_pool_create(c, system, "pool name", size, raid_type, member_type, &pcp, &pcj, flags);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
@@ -2457,11 +2458,12 @@ START_TEST(test_pool_create)
uint32_t num_disks = 0;
lsm_string_list *member_ids = lsm_string_list_alloc(0);
char *pool_one = NULL;
+ lsm_system *system = get_system(c);
/*
* Test basic pool create option.
*/
- rc = lsm_pool_create(c, SYSTEM_ID, "pool_create_unit_test", 1024*1024*1024,
+ rc = lsm_pool_create(c, system, "pool_create_unit_test", 1024*1024*1024,
LSM_POOL_RAID_TYPE_0, LSM_POOL_MEMBER_TYPE_DISK, &pool,
&job, LSM_FLAG_RSVD);
@@ -2497,7 +2499,7 @@ START_TEST(test_pool_create)
lsm_disk_record_array_free(disks, num_disks);
}
- rc = lsm_pool_create_from_disks(c, SYSTEM_ID, "pool_create_from_disks",
+ rc = lsm_pool_create_from_disks(c, system, "pool_create_from_disks",
member_ids, LSM_POOL_RAID_TYPE_0, &pool, &job,
LSM_FLAG_RSVD);
@@ -2567,7 +2569,7 @@ START_TEST(test_pool_create)
pool = NULL;
job = NULL;
- rc = lsm_pool_create_from_volumes(c, SYSTEM_ID,
+ rc = lsm_pool_create_from_volumes(c, system,
"pool_create_from_volumes", member_ids,
LSM_POOL_RAID_TYPE_0, &pool, &job,
LSM_FLAG_RSVD);
@@ -2596,7 +2598,7 @@ START_TEST(test_pool_create)
pool = NULL;
job = NULL;
- rc = lsm_pool_create_from_pool(c, SYSTEM_ID, "New pool from pool",
+ rc = lsm_pool_create_from_pool(c, system, "New pool from pool",
pool_one, 1024*1024*1024, &pool,
&job, LSM_FLAG_RSVD);
@@ -2615,6 +2617,11 @@ START_TEST(test_pool_create)
pool_one = NULL;
}
}
+
+ if( system ) {
+ lsm_system_record_free(system);
+ system = NULL;
+ }
}
END_TEST
of object ids.
Signed-off-by: Tony Asleson <***@redhat.com>
---
include/libstoragemgmt/libstoragemgmt.h | 17 +++++-----
.../libstoragemgmt/libstoragemgmt_plug_interface.h | 19 ++++++-----
lsm/lsm/_client.py | 4 +--
lsm/lsm/_cmdline.py | 12 ++++---
lsm/lsm/simulator.py | 16 ++++-----
plugin/simc_lsmplugin.c | 22 ++++++-------
src/lsm_mgmt.cpp | 38 ++++++++++++++--------
src/lsm_plugin_ipc.cpp | 29 +++++++++--------
test/tester.c | 35 ++++++++++++--------
9 files changed, 111 insertions(+), 81 deletions(-)
diff --git a/include/libstoragemgmt/libstoragemgmt.h b/include/libstoragemgmt/libstoragemgmt.h
index 109b511..34fb781 100644
--- a/include/libstoragemgmt/libstoragemgmt.h
+++ b/include/libstoragemgmt/libstoragemgmt.h
@@ -237,7 +237,7 @@ extern "C" {
/**
* Create new pool allowing the array to make the most decisions.
* @param [in] conn Valid connection @see lsm_connect_password
- * @param [in] system_id System ID of where pool will reside
+ * @param [in] system System of where pool will reside
* @param [in] pool_name Name of new pool
* @param [in] size_bytes Size of new pool in bytes
* @param [in] raid_type Optional. If defined, new pool should
@@ -256,7 +256,8 @@ extern "C" {
* @return LSM_ERR_OK on success, LSM_ERR_JOB_STARTED if async.,
* else error code
*/
- int LSM_DLL_EXPORT lsm_pool_create(lsm_connect *conn, const char *system_id,
+ int LSM_DLL_EXPORT lsm_pool_create(lsm_connect *conn,
+ lsm_system *system,
const char *pool_name, uint64_t size_bytes,
lsm_pool_raid_type raid_type,
lsm_pool_member_type member_type, lsm_pool** pool,
@@ -265,7 +266,7 @@ extern "C" {
/**
* Create a pool specifying specific disks to use.
* @param [in] conn Valid connection @see lsm_connect_password
- * @param [in] system_id System ID of where pool will reside
+ * @param [in] system System of where pool will reside
* @param [in] pool_name The name of the new pool, will not fail
* if request name cannot be fulfilled
* @param [in] member_ids The IDs of disks to create new pool from
@@ -281,7 +282,7 @@ extern "C" {
* else error code
*/
int LSM_DLL_EXPORT lsm_pool_create_from_disks(lsm_connect *conn,
- const char *system_id, const char *pool_name,
+ lsm_system *system, const char *pool_name,
lsm_string_list *member_ids, lsm_pool_raid_type raid_type,
lsm_pool** pool, char **job, lsm_flag flags);
@@ -289,7 +290,7 @@ extern "C" {
* Create new pool in by specifying which volumes should be used for pool
* creation.
* @param [in] conn Valid connection @see lsm_connect_password
- * @param [in] system_id System ID of where pool will reside
+ * @param [in] system System of where pool will reside
* @param [in] pool_name The name of the new pool, will not fail
* if request name cannot be fulfilled
* @param [in] member_ids The IDs of volumes to create new pool from
@@ -305,14 +306,14 @@ extern "C" {
* else error code
*/
int LSM_DLL_EXPORT lsm_pool_create_from_volumes(lsm_connect *conn,
- const char *system_id, const char *pool_name,
+ lsm_system *system, const char *pool_name,
lsm_string_list *member_ids, lsm_pool_raid_type raid_type,
lsm_pool** pool, char **job, lsm_flag flags);
/**
* Create new pool from an existing pool
* @param [in] conn Valid connection @see lsm_connect_password
- * @param [in] system_id System ID of where pool will reside
+ * @param [in] system System of where pool will reside
* @param [in] pool_name The name of the new pool, will not fail
* if request name cannot be fulfilled
* @param [in] member_id The ID of pool to create new pool from
@@ -324,7 +325,7 @@ extern "C" {
* else error code
*/
int LSM_DLL_EXPORT lsm_pool_create_from_pool(lsm_connect *conn,
- const char *system_id, const char *pool_name,
+ lsm_system *system, const char *pool_name,
const char *member_id, uint64_t size_bytes,
lsm_pool** pool, char **job, lsm_flag flags);
diff --git a/include/libstoragemgmt/libstoragemgmt_plug_interface.h b/include/libstoragemgmt/libstoragemgmt_plug_interface.h
index 6117437..6b685bc 100644
--- a/include/libstoragemgmt/libstoragemgmt_plug_interface.h
+++ b/include/libstoragemgmt/libstoragemgmt_plug_interface.h
@@ -218,7 +218,7 @@ typedef int (*lsm_plug_disk_list)( lsm_plugin_ptr c, lsm_disk **disk_array[],
/**
* Create a pool.
* @param[in] c Valid lsm plug-in pointer
- * @param[in] system_id System id
+ * @param[in] system System
* @param[in] pool_name Human name of pool
* @param[in] size_bytes Desired size of pool
* @param[in] raid_type Raid type for pool
@@ -227,7 +227,7 @@ typedef int (*lsm_plug_disk_list)( lsm_plugin_ptr c, lsm_disk **disk_array[],
* @param[out] job Job id if execution is async.
* @return LSM_ERR_OK, else error reason
*/
-typedef int (*lsm_plug_pool_create)( lsm_plugin_ptr c, const char* system_id,
+typedef int (*lsm_plug_pool_create)( lsm_plugin_ptr c, lsm_system* system,
const char *pool_name, uint64_t size_bytes,
lsm_pool_raid_type raid_type, lsm_pool_member_type member_type,
lsm_pool **pool, char **job, lsm_flag flags);
@@ -235,7 +235,7 @@ typedef int (*lsm_plug_pool_create)( lsm_plugin_ptr c, const char* system_id,
/**
* Create a pool and specifying disks to use.
* @param[in] c Valid lsm plug-in pointer
- * @param[in] system_id System id
+ * @param[in] system System
* @param[in] pool_name Human name of pool
* @param[in] member_ids List of disk IDs to create pool from
* @param[in] raid_type Raid type for pool
@@ -243,7 +243,8 @@ typedef int (*lsm_plug_pool_create)( lsm_plugin_ptr c, const char* system_id,
* @param[out] job Job id if execution is async.
* @return LSM_ERR_OK, else error reason
*/
-typedef int (*lsm_plug_pool_create_from_disks)( lsm_plugin_ptr c, const char *system_id,
+typedef int (*lsm_plug_pool_create_from_disks)( lsm_plugin_ptr c,
+ lsm_system *system,
const char *pool_name, lsm_string_list *member_ids,
lsm_pool_raid_type raid_type, lsm_pool **pool, char **job,
lsm_flag flags);
@@ -251,7 +252,7 @@ typedef int (*lsm_plug_pool_create_from_disks)( lsm_plugin_ptr c, const char *sy
/**
* Create a pool and specifying volumes to use.
* @param[in] c Valid lsm plug-in pointer
- * @param[in] system_id System id
+ * @param[in] system System
* @param[in] pool_name Human name of pool
* @param[in] member_ids List of volume IDs to create pool from
* @param[in] raid_type Raid type for pool
@@ -259,7 +260,8 @@ typedef int (*lsm_plug_pool_create_from_disks)( lsm_plugin_ptr c, const char *sy
* @param[out] job Job id if execution is async.
* @return LSM_ERR_OK, else error reason
*/
-typedef int (*lsm_plug_pool_create_from_volumes)( lsm_plugin_ptr c, const char *system_id,
+typedef int (*lsm_plug_pool_create_from_volumes)( lsm_plugin_ptr c,
+ lsm_system *system,
const char *pool_name, lsm_string_list *member_ids,
lsm_pool_raid_type raid_type, lsm_pool** pool, char **job,
lsm_flag flags);
@@ -267,7 +269,7 @@ typedef int (*lsm_plug_pool_create_from_volumes)( lsm_plugin_ptr c, const char *
/**
* Create a pool and specifying pool to use.
* @param[in] c Valid lsm plug-in pointer
- * @param[in] system_id System id
+ * @param[in] system System id
* @param[in] pool_name Human name of pool
* @param[in] member_id ID of pool to create pool from
* @param[in] size_bytes Size of pool
@@ -275,7 +277,8 @@ typedef int (*lsm_plug_pool_create_from_volumes)( lsm_plugin_ptr c, const char *
* @param[out] job Job id if execution is async.
* @return LSM_ERR_OK, else error reason
*/
-typedef int (*lsm_plug_pool_create_from_pool)( lsm_plugin_ptr c, const char *system_id,
+typedef int (*lsm_plug_pool_create_from_pool)( lsm_plugin_ptr c,
+ lsm_system *system,
const char *pool_name, const char *member_id,
uint64_t size_bytes, lsm_pool **pool, char **job,
lsm_flag flags );
diff --git a/lsm/lsm/_client.py b/lsm/lsm/_client.py
index 8dc7693..9d86994 100644
--- a/lsm/lsm/_client.py
+++ b/lsm/lsm/_client.py
@@ -298,7 +298,7 @@ class Client(INetworkAttachedStorage):
## sample codes.
## Return the newly created pool object.
# @param self The this pointer
- # @param system_id The id of system where new pool should reside.
+ # @param system The system where new pool should reside.
# @param pool_name The name for new pool. Will not fail if created
# pool_name is not the same as requested.
# @param size_bytes The size in bytes for new pool.
@@ -317,7 +317,7 @@ class Client(INetworkAttachedStorage):
# @returns A tuple (job_id, new_pool), when one is None the other is
# valid.
@_return_requires(unicode, Pool)
- def pool_create(self, system_id, pool_name, size_bytes,
+ def pool_create(self, system, pool_name, size_bytes,
raid_type=Pool.RAID_TYPE_UNKNOWN,
member_type=Pool.MEMBER_TYPE_UNKNOWN, flags=0):
"""
diff --git a/lsm/lsm/_cmdline.py b/lsm/lsm/_cmdline.py
index 0f5e3de..a679583 100644
--- a/lsm/lsm/_cmdline.py
+++ b/lsm/lsm/_cmdline.py
@@ -1654,6 +1654,7 @@ class CmdLine:
## Creates a pool
def pool_create(self, args):
+ system = _get_item(self.c.systems(), args.sys, "system id")
pool_name = args.name
raid_type = Pool.RAID_TYPE_UNKNOWN
member_type = Pool.MEMBER_TYPE_UNKNOWN
@@ -1674,7 +1675,7 @@ class CmdLine:
args.member_type)
pool = self._wait_for_it("pool-create",
- *self.c.pool_create(self.args.sys,
+ *self.c.pool_create(system,
pool_name,
size_bytes,
raid_type,
@@ -1683,6 +1684,7 @@ class CmdLine:
self.display_data([pool])
def pool_create_from_disks(self, args):
+ system = _get_item(self.c.systems(), args.sys, "system id")
if len(args.member_id) <= 0:
raise ArgError("No disk ID was provided for new pool")
@@ -1704,10 +1706,11 @@ class CmdLine:
pool = self._wait_for_it(
"pool-create-from-disks",
*self.c.pool_create_from_disks(
- self.args.sys, pool_name, member_ids, raid_type, 0))
+ system, pool_name, member_ids, raid_type, 0))
self.display_data([pool])
def pool_create_from_volumes(self, args):
+ system = _get_item(self.c.systems(), args.sys, "system id")
if len(args.member_id) <= 0:
raise ArgError("No volume ID was provided for new pool")
@@ -1729,10 +1732,11 @@ class CmdLine:
pool = self._wait_for_it(
"pool-create-from-volumes",
*self.c.pool_create_from_volumes(
- self.args.sys, pool_name, member_ids, raid_type, 0))
+ system, pool_name, member_ids, raid_type, 0))
self.display_data([pool])
def pool_create_from_pool(self, args):
+ system = _get_item(self.c.systems(), args.sys, "system id")
if len(args.member_id) <= 0:
raise ArgError("No volume ID was provided for new pool")
@@ -1755,7 +1759,7 @@ class CmdLine:
pool = self._wait_for_it(
"pool-create-from-pool",
*self.c.pool_create_from_pool(
- self.args.sys, pool_name, member_id, size_bytes, 0))
+ system, pool_name, member_id, size_bytes, 0))
self.display_data([pool])
def _read_configfile(self):
diff --git a/lsm/lsm/simulator.py b/lsm/lsm/simulator.py
index 76f40c9..e5a3630 100644
--- a/lsm/lsm/simulator.py
+++ b/lsm/lsm/simulator.py
@@ -89,26 +89,26 @@ class SimPlugin(INfs, IStorageAreaNetwork):
sim_pools = self.sim_array.pools(flags)
return [SimPlugin._sim_data_2_lsm(p) for p in sim_pools]
- def pool_create(self, system_id, pool_name, size_bytes,
+ def pool_create(self, system, pool_name, size_bytes,
raid_type=Pool.RAID_TYPE_UNKNOWN,
member_type=Pool.MEMBER_TYPE_UNKNOWN, flags=0):
return self.sim_array.pool_create(
- system_id, pool_name, size_bytes, raid_type, member_type, flags)
+ system.id, pool_name, size_bytes, raid_type, member_type, flags)
- def pool_create_from_disks(self, system_id, pool_name, member_ids,
+ def pool_create_from_disks(self, system, pool_name, member_ids,
raid_type, flags=0):
return self.sim_array.pool_create_from_disks(
- system_id, pool_name, member_ids, raid_type, flags)
+ system.id, pool_name, member_ids, raid_type, flags)
- def pool_create_from_volumes(self, system_id, pool_name, member_ids,
+ def pool_create_from_volumes(self, system, pool_name, member_ids,
raid_type, flags=0):
return self.sim_array.pool_create_from_volumes(
- system_id, pool_name, member_ids, raid_type, flags)
+ system.id, pool_name, member_ids, raid_type, flags)
- def pool_create_from_pool(self, system_id, pool_name, member_id,
+ def pool_create_from_pool(self, system, pool_name, member_id,
size_bytes, flags=0):
return self.sim_array.pool_create_from_pool(
- system_id, pool_name, member_id, size_bytes, flags)
+ system.id, pool_name, member_id, size_bytes, flags)
def pool_delete(self, pool, flags=0):
return self.sim_array.pool_delete(pool.id, flags)
diff --git a/plugin/simc_lsmplugin.c b/plugin/simc_lsmplugin.c
index 726e7e2..3269506 100644
--- a/plugin/simc_lsmplugin.c
+++ b/plugin/simc_lsmplugin.c
@@ -973,7 +973,7 @@ static int _volume_delete(lsm_plugin_ptr c, const char *volume_id)
return rc;
}
-static int _pool_create(lsm_plugin_ptr c, const char *system_id,
+static int _pool_create(lsm_plugin_ptr c, lsm_system *system,
const char *pool_name, uint64_t size_bytes,
lsm_pool **pool, char **job)
{
@@ -984,14 +984,14 @@ static int _pool_create(lsm_plugin_ptr c, const char *system_id,
char *key = NULL;
/* Verify system id */
- if( strcmp(system_id, lsm_system_id_get(pd->system[0])) == 0 ) {
+ if( strcmp(lsm_system_id_get(system), lsm_system_id_get(pd->system[0])) == 0 ) {
/* Verify that we don't already have a pool by that name */
new_pool = find_pool_name(pd, pool_name);
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, "",
- system_id);
+ lsm_system_id_get(system));
pool_to_store = lsm_pool_record_copy(new_pool);
key = strdup(lsm_pool_id_get(pool_to_store));
@@ -1019,16 +1019,16 @@ static int _pool_create(lsm_plugin_ptr c, const char *system_id,
}
-static int pool_create(lsm_plugin_ptr c, const char *system_id,
+static int pool_create(lsm_plugin_ptr c, lsm_system *system,
const char *pool_name, uint64_t size_bytes,
lsm_pool_raid_type raid_type,
lsm_pool_member_type member_type, lsm_pool** pool,
char **job, lsm_flag flags)
{
- return _pool_create(c, system_id, pool_name, size_bytes, pool, job);
+ return _pool_create(c, system, pool_name, size_bytes, pool, job);
}
-static int pool_create_from_disks( lsm_plugin_ptr c, const char *system_id,
+static int pool_create_from_disks( lsm_plugin_ptr c, lsm_system *system,
const char *pool_name, lsm_string_list *member_ids,
lsm_pool_raid_type raid_type, lsm_pool **pool, char **job,
lsm_flag flags)
@@ -1052,7 +1052,7 @@ static int pool_create_from_disks( lsm_plugin_ptr c, const char *system_id,
}
}
- rc = _pool_create(c, system_id, pool_name, size, pool, job);
+ rc = _pool_create(c, system, pool_name, size, pool, job);
} else {
rc = lsm_log_error_basic(c, LSM_ERR_INVALID_ARGUMENT, "No disks provided");
}
@@ -1060,7 +1060,7 @@ bail:
return rc;
}
-static int pool_create_from_volumes( lsm_plugin_ptr c, const char *system_id,
+static int pool_create_from_volumes( lsm_plugin_ptr c, lsm_system *system,
const char *pool_name, lsm_string_list *member_ids,
lsm_pool_raid_type raid_type, lsm_pool **pool, char **job,
lsm_flag flags)
@@ -1086,7 +1086,7 @@ static int pool_create_from_volumes( lsm_plugin_ptr c, const char *system_id,
}
}
- rc = _pool_create(c, system_id, pool_name, size, pool, job);
+ rc = _pool_create(c, system, pool_name, size, pool, job);
} else {
rc = lsm_log_error_basic(c, LSM_ERR_INVALID_ARGUMENT, "No disks provided");
}
@@ -1094,7 +1094,7 @@ bail:
return rc;
}
-static int pool_create_from_pool(lsm_plugin_ptr c, const char *system_id,
+static int pool_create_from_pool(lsm_plugin_ptr c, lsm_system *system,
const char *pool_name, const char *member_id,
uint64_t size_bytes, lsm_pool **pool, char **job,
lsm_flag flags )
@@ -1105,7 +1105,7 @@ static int pool_create_from_pool(lsm_plugin_ptr c, const char *system_id,
lsm_pool *p = find_pool(pd, member_id);
if( p ) {
- rc = _pool_create(c, system_id, pool_name, size_bytes, pool, job);
+ rc = _pool_create(c, system, pool_name, size_bytes, pool, job);
} else {
rc = lsm_log_error_basic(c, LSM_ERR_NOT_FOUND_POOL, "Pool not found");
}
diff --git a/src/lsm_mgmt.cpp b/src/lsm_mgmt.cpp
index ca3ccba..09497f1 100644
--- a/src/lsm_mgmt.cpp
+++ b/src/lsm_mgmt.cpp
@@ -913,7 +913,7 @@ static int valid_pool_member_type(lsm_pool_member_type validate)
return 1;
}
-int lsm_pool_create(lsm_connect *c, const char *system_id,
+int lsm_pool_create(lsm_connect *c, lsm_system *system,
const char *pool_name, uint64_t size_bytes,
lsm_pool_raid_type raid_type,
lsm_pool_member_type member_type, lsm_pool** pool,
@@ -921,7 +921,11 @@ int lsm_pool_create(lsm_connect *c, const char *system_id,
{
CONN_SETUP(c);
- if( CHECK_STR(system_id) || CHECK_STR(pool_name) || !size_bytes ||
+ if( !LSM_IS_SYSTEM(system) ) {
+ return LSM_ERR_INVALID_SYSTEM;
+ }
+
+ if( CHECK_STR(pool_name) || !size_bytes ||
CHECK_RP(pool)|| CHECK_RP(job) || LSM_FLAG_UNUSED_CHECK(flags) ||
!valid_pool_raid_type(raid_type) ||
!valid_pool_member_type(member_type)) {
@@ -929,7 +933,7 @@ int lsm_pool_create(lsm_connect *c, const char *system_id,
}
std::map<std::string, Value> p;
- p["system_id"] = Value(system_id);
+ p["system"] = system_to_value(system);
p["pool_name"] = Value(pool_name);
p["size_bytes"] = Value(size_bytes);
p["raid_type"] = Value((int32_t)raid_type);
@@ -949,14 +953,18 @@ int lsm_pool_create(lsm_connect *c, const char *system_id,
static int lsm_pool_create_from(lsm_connect *c,
- const char *system_id, const char *pool_name,
+ lsm_system *system, const char *pool_name,
lsm_string_list *member_ids, lsm_pool_raid_type raid_type,
lsm_pool** pool, char **job, lsm_flag flags,
const char *method)
{
CONN_SETUP(c);
- if( CHECK_STR(system_id) || CHECK_STR(pool_name) ||
+ if( !LSM_IS_SYSTEM(system) ) {
+ return LSM_ERR_INVALID_SYSTEM;
+ }
+
+ if( CHECK_STR(pool_name) ||
CHECK_RP(pool)|| CHECK_RP(job) || LSM_FLAG_UNUSED_CHECK(flags) ||
!valid_pool_raid_type(raid_type) ) {
return LSM_ERR_INVALID_ARGUMENT;
@@ -967,7 +975,7 @@ static int lsm_pool_create_from(lsm_connect *c,
}
std::map<std::string, Value> p;
- p["system_id"] = Value(system_id);
+ p["system"] = system_to_value(system);
p["pool_name"] = Value(pool_name);
p["member_ids"] = string_list_to_value(member_ids);
p["raid_type"] = Value((int32_t)raid_type);
@@ -985,40 +993,44 @@ static int lsm_pool_create_from(lsm_connect *c,
}
int LSM_DLL_EXPORT lsm_pool_create_from_disks(lsm_connect *c,
- const char *system_id, const char *pool_name,
+ lsm_system *system, const char *pool_name,
lsm_string_list *member_ids, lsm_pool_raid_type raid_type,
lsm_pool** pool, char **job, lsm_flag flags)
{
- return lsm_pool_create_from(c, system_id, pool_name, member_ids, raid_type,
+ return lsm_pool_create_from(c, system, pool_name, member_ids, raid_type,
pool, job, flags, "pool_create_from_disks");
}
int LSM_DLL_EXPORT lsm_pool_create_from_volumes(lsm_connect *c,
- const char *system_id, const char *pool_name,
+ lsm_system *system, const char *pool_name,
lsm_string_list *member_ids, lsm_pool_raid_type raid_type,
lsm_pool** pool, char **job, lsm_flag flags)
{
- return lsm_pool_create_from(c, system_id, pool_name, member_ids, raid_type,
+ return lsm_pool_create_from(c, system, pool_name, member_ids, raid_type,
pool, job, flags,
"pool_create_from_volumes");
}
- int lsm_pool_create_from_pool(lsm_connect *c, const char *system_id,
+ int lsm_pool_create_from_pool(lsm_connect *c, lsm_system *system,
const char *pool_name, const char *member_id,
uint64_t size_bytes, lsm_pool **pool, char **job,
lsm_flag flags)
{
CONN_SETUP(c);
- if( CHECK_STR(system_id) || CHECK_STR(pool_name) || CHECK_STR(member_id) ||
+ if( !LSM_IS_SYSTEM(system) ) {
+ return LSM_ERR_INVALID_SYSTEM;
+ }
+
+ if( CHECK_STR(pool_name) || CHECK_STR(member_id) ||
!size_bytes || CHECK_RP(pool)|| CHECK_RP(job) ||
LSM_FLAG_UNUSED_CHECK(flags) ) {
return LSM_ERR_INVALID_ARGUMENT;
}
std::map<std::string, Value> p;
- p["system_id"] = Value(system_id);
+ p["system"] = system_to_value(system);
p["pool_name"] = Value(pool_name);
p["size_bytes"] = Value(size_bytes);
p["member_id"] = Value(member_id);
diff --git a/src/lsm_plugin_ipc.cpp b/src/lsm_plugin_ipc.cpp
index c7d7f73..7e8b676 100644
--- a/src/lsm_plugin_ipc.cpp
+++ b/src/lsm_plugin_ipc.cpp
@@ -482,20 +482,20 @@ static int handle_pool_create(lsm_plugin_ptr p, Value ¶ms, Value &response)
int rc = LSM_ERR_NO_SUPPORT;
if( p && p->san_ops && p->san_ops->pool_create ) {
- Value v_sys_id = params["system_id"];
+ Value v_sys = params["system"];
Value v_pool_name = params["pool_name"];
Value v_size = params["size_bytes"];
Value v_raid_t = params["raid_type"];
Value v_member_t = params["member_type"];
- if( Value::string_t == v_sys_id.valueType() &&
+ if( Value::object_t == v_sys.valueType() &&
Value::string_t == v_pool_name.valueType() &&
Value::numeric_t == v_size.valueType() &&
Value::numeric_t == v_raid_t.valueType() &&
Value::numeric_t == v_member_t.valueType() &&
LSM_FLAG_EXPECTED_TYPE(params)) {
- const char *sys_id = v_sys_id.asC_str();
+ lsm_system *system = value_to_system(v_sys);
const char *pool_name = v_pool_name.asC_str();
uint64_t size = v_size.asUint64_t();
lsm_pool_raid_type raid_type = (lsm_pool_raid_type)v_raid_t.asInt32_t();
@@ -503,13 +503,14 @@ static int handle_pool_create(lsm_plugin_ptr p, Value ¶ms, Value &response)
lsm_pool *pool = NULL;
char *job = NULL;
- rc = p->san_ops->pool_create(p, sys_id, pool_name, size, raid_type,
+ rc = p->san_ops->pool_create(p, system, pool_name, size, raid_type,
member_type, &pool, &job,
LSM_FLAG_GET_VALUE(params));
Value p = pool_to_value(pool);
response = job_handle(p, job);
lsm_pool_record_free(pool);
+ lsm_system_record_free(system);
free(job);
} else {
rc = LSM_ERR_TRANSPORT_INVALID_ARG;
@@ -519,7 +520,7 @@ static int handle_pool_create(lsm_plugin_ptr p, Value ¶ms, Value &response)
}
typedef int (*lsmPlugPoolCreateFrom)( lsm_plugin_ptr c,
- const char *system_id,
+ lsm_system *system,
const char *pool_name, lsm_string_list *member_ids,
lsm_pool_raid_type raid_type, lsm_pool** pool, char **job,
lsm_flag flags);
@@ -532,12 +533,12 @@ static int handle_pool_create_from( lsm_plugin_ptr p, Value ¶ms,
int rc = LSM_ERR_NO_SUPPORT;
if( pool_create_from ) {
- Value v_sys_id = params["system_id"];
+ Value v_sys = params["system"];
Value v_pool_name = params["pool_name"];
Value v_member_ids = params["member_ids"];
Value v_raid_t = params["raid_type"];
- if( Value::string_t == v_sys_id.valueType() &&
+ if( Value::object_t == v_sys.valueType() &&
Value::string_t == v_pool_name.valueType() &&
Value::array_t == v_member_ids.valueType() &&
Value::numeric_t == v_raid_t.valueType() &&
@@ -546,20 +547,21 @@ static int handle_pool_create_from( lsm_plugin_ptr p, Value ¶ms,
lsm_string_list *members = value_to_string_list(v_member_ids);
if( members ) {
- const char *sys_id = v_sys_id.asC_str();
+ lsm_system *sys = value_to_system(v_sys);
const char *pool_name = v_pool_name.asC_str();
lsm_pool_raid_type raid_type = (lsm_pool_raid_type)v_raid_t.asInt32_t();
lsm_pool *pool = NULL;
char *job = NULL;
- rc = pool_create_from(p, sys_id, pool_name, members, raid_type,
+ rc = pool_create_from(p, sys, pool_name, members, raid_type,
&pool, &job, LSM_FLAG_GET_VALUE(params));
Value p = pool_to_value(pool);
response = job_handle(p, job);
lsm_string_list_free(members);
lsm_pool_record_free(pool);
+ lsm_system_record_free(sys);
free(job);
} else {
rc = LSM_ERR_NO_MEMORY;
@@ -594,18 +596,18 @@ static int handle_pool_create_from_pool(lsm_plugin_ptr p, Value ¶ms, Value &
int rc = LSM_ERR_NO_SUPPORT;
if( p && p->san_ops && p->san_ops->pool_create_from_pool ) {
- Value v_sys_id = params["system_id"];
+ Value v_sys = params["system"];
Value v_pool_name = params["pool_name"];
Value v_member_id = params["member_id"];
Value v_size = params["size_bytes"];
- if( Value::string_t == v_sys_id.valueType() &&
+ if( Value::object_t == v_sys.valueType() &&
Value::string_t == v_pool_name.valueType() &&
Value::string_t == v_member_id.valueType() &&
Value::numeric_t == v_size.valueType() &&
LSM_FLAG_EXPECTED_TYPE(params)) {
- const char *sys_id = v_sys_id.asC_str();
+ lsm_system *sys = value_to_system(v_sys);
const char *pool_name = v_pool_name.asC_str();
const char *member_id = v_member_id.asC_str();
uint64_t size = v_size.asUint64_t();
@@ -613,13 +615,14 @@ static int handle_pool_create_from_pool(lsm_plugin_ptr p, Value ¶ms, Value &
lsm_pool *pool = NULL;
char *job = NULL;
- rc = p->san_ops->pool_create_from_pool(p, sys_id, pool_name,
+ rc = p->san_ops->pool_create_from_pool(p, sys, pool_name,
member_id, size, &pool, &job,
LSM_FLAG_GET_VALUE(params));
Value p = pool_to_value(pool);
response = job_handle(p, job);
lsm_pool_record_free(pool);
+ lsm_system_record_free(sys);
free(job);
} else {
rc = LSM_ERR_TRANSPORT_INVALID_ARG;
diff --git a/test/tester.c b/test/tester.c
index eeefa7b..b7742b6 100644
--- a/test/tester.c
+++ b/test/tester.c
@@ -342,7 +342,7 @@ void create_volumes(lsm_connect *c, lsm_pool *p, int num)
}
}
-lsm_system *get_system()
+lsm_system *get_system(lsm_connect *c)
{
lsm_system *rc_sys = NULL;
lsm_system **sys=NULL;
@@ -455,7 +455,7 @@ START_TEST(test_smoke_test)
uint32_t bs = 0;
- lsm_system * system = get_system();
+ lsm_system * system = get_system(c);
int rep_bs = lsm_volume_replicate_range_block_size(c, system, &bs, LSM_FLAG_RSVD);
fail_unless(LSM_ERR_OK == rep_bs, "%d", rep_bs);
@@ -1766,39 +1766,40 @@ START_TEST(test_invalid_input)
int member_type = 65535;
uint64_t size = 0;
int flags = 10;
+ lsm_system *system = get_system(c);
rc = lsm_pool_create(NULL, NULL, NULL, size, raid_type, member_type, NULL, NULL, flags);
fail_unless(rc == LSM_ERR_INVALID_CONN, "rc = %d", rc);
rc = lsm_pool_create(c, NULL, NULL, size, raid_type, member_type, NULL, NULL, flags);
- fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
+ fail_unless(rc == LSM_ERR_INVALID_SYSTEM, "rc = %d", rc);
- rc = lsm_pool_create(c, SYSTEM_ID, NULL, size, raid_type, member_type, NULL, NULL, flags);
+ rc = lsm_pool_create(c, system, NULL, size, raid_type, member_type, NULL, NULL, flags);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
- rc = lsm_pool_create(c, SYSTEM_ID, "pool name", size, raid_type, member_type, NULL, NULL, flags);
+ rc = lsm_pool_create(c, system, "pool name", size, raid_type, member_type, NULL, NULL, flags);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
size = 1024*1024*1024;
- rc = lsm_pool_create(c, SYSTEM_ID, "pool name", size, raid_type, member_type, NULL, NULL, flags);
+ rc = lsm_pool_create(c, system, "pool name", size, raid_type, member_type, NULL, NULL, flags);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
raid_type = LSM_POOL_RAID_TYPE_0;
- rc = lsm_pool_create(c, SYSTEM_ID, "pool name", size, raid_type, member_type, NULL, NULL, flags);
+ rc = lsm_pool_create(c, system, "pool name", size, raid_type, member_type, NULL, NULL, flags);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
member_type = LSM_POOL_MEMBER_TYPE_DISK;
- rc = lsm_pool_create(c, SYSTEM_ID, "pool name", size, raid_type, member_type, NULL, NULL, flags);
+ rc = lsm_pool_create(c, system, "pool name", size, raid_type, member_type, NULL, NULL, flags);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
lsm_pool *pcp = NULL;
- rc = lsm_pool_create(c, SYSTEM_ID, "pool name", size, raid_type, member_type, &pcp, NULL, flags);
+ rc = lsm_pool_create(c, system, "pool name", size, raid_type, member_type, &pcp, NULL, flags);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
char *pcj = NULL;
- rc = lsm_pool_create(c, SYSTEM_ID, "pool name", size, raid_type, member_type, &pcp, &pcj, flags);
+ rc = lsm_pool_create(c, system, "pool name", size, raid_type, member_type, &pcp, &pcj, flags);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);
@@ -2457,11 +2458,12 @@ START_TEST(test_pool_create)
uint32_t num_disks = 0;
lsm_string_list *member_ids = lsm_string_list_alloc(0);
char *pool_one = NULL;
+ lsm_system *system = get_system(c);
/*
* Test basic pool create option.
*/
- rc = lsm_pool_create(c, SYSTEM_ID, "pool_create_unit_test", 1024*1024*1024,
+ rc = lsm_pool_create(c, system, "pool_create_unit_test", 1024*1024*1024,
LSM_POOL_RAID_TYPE_0, LSM_POOL_MEMBER_TYPE_DISK, &pool,
&job, LSM_FLAG_RSVD);
@@ -2497,7 +2499,7 @@ START_TEST(test_pool_create)
lsm_disk_record_array_free(disks, num_disks);
}
- rc = lsm_pool_create_from_disks(c, SYSTEM_ID, "pool_create_from_disks",
+ rc = lsm_pool_create_from_disks(c, system, "pool_create_from_disks",
member_ids, LSM_POOL_RAID_TYPE_0, &pool, &job,
LSM_FLAG_RSVD);
@@ -2567,7 +2569,7 @@ START_TEST(test_pool_create)
pool = NULL;
job = NULL;
- rc = lsm_pool_create_from_volumes(c, SYSTEM_ID,
+ rc = lsm_pool_create_from_volumes(c, system,
"pool_create_from_volumes", member_ids,
LSM_POOL_RAID_TYPE_0, &pool, &job,
LSM_FLAG_RSVD);
@@ -2596,7 +2598,7 @@ START_TEST(test_pool_create)
pool = NULL;
job = NULL;
- rc = lsm_pool_create_from_pool(c, SYSTEM_ID, "New pool from pool",
+ rc = lsm_pool_create_from_pool(c, system, "New pool from pool",
pool_one, 1024*1024*1024, &pool,
&job, LSM_FLAG_RSVD);
@@ -2615,6 +2617,11 @@ START_TEST(test_pool_create)
pool_one = NULL;
}
}
+
+ if( system ) {
+ lsm_system_record_free(system);
+ system = NULL;
+ }
}
END_TEST
--
1.8.2.1
1.8.2.1