|
|
1f984a |
diff --git include/libstoragemgmt/libstoragemgmt_plug_interface.h include/libstoragemgmt/libstoragemgmt_plug_interface.h
|
|
|
1f984a |
index 24c84d0..c0e29a3 100644
|
|
|
1f984a |
--- include/libstoragemgmt/libstoragemgmt_plug_interface.h
|
|
|
1f984a |
+++ include/libstoragemgmt/libstoragemgmt_plug_interface.h
|
|
|
1f984a |
@@ -1016,6 +1016,7 @@ lsmDisk LSM_DLL_EXPORT **lsmDiskRecordAllocArray( uint32_t size );
|
|
|
1f984a |
* @param block_count Number of blocks for disk
|
|
|
1f984a |
* @param disk_status Status
|
|
|
1f984a |
* @param op OptionalData can be NULL if not available
|
|
|
1f984a |
+ * NOTE: op gets copied internally
|
|
|
1f984a |
* @param system_id System id this disk resides in
|
|
|
1f984a |
* @return Pointer to allocated disk record or NULL on memory error.
|
|
|
1f984a |
*/
|
|
|
1f984a |
diff --git plugin/simc_lsmplugin.c plugin/simc_lsmplugin.c
|
|
|
1f984a |
index f9c4530..e12c630 100644
|
|
|
1f984a |
--- plugin/simc_lsmplugin.c
|
|
|
1f984a |
+++ plugin/simc_lsmplugin.c
|
|
|
1f984a |
@@ -567,7 +567,8 @@ static int _list_initiators(lsmPluginPtr c, lsmInitiator **initArray[],
|
|
|
1f984a |
if( init_key && init_val ) {
|
|
|
1f984a |
g_hash_table_insert(tmp_inits, init_key, init_val);
|
|
|
1f984a |
} else {
|
|
|
1f984a |
- g_hash_table_destroy(tmp_inits);
|
|
|
1f984a |
+ free(init_key);
|
|
|
1f984a |
+ lsmInitiatorRecordFree(init_val);
|
|
|
1f984a |
rc = LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
}
|
|
|
1f984a |
}
|
|
|
1f984a |
@@ -652,12 +653,12 @@ static int list_disks(lsmPluginPtr c, lsmDisk **disks[], uint32_t *count,
|
|
|
1f984a |
{
|
|
|
1f984a |
int i;
|
|
|
1f984a |
int rc = LSM_ERR_OK;
|
|
|
1f984a |
- struct plugin_data *pd = (struct plugin_data*)lsmGetPrivateData(c);
|
|
|
1f984a |
char name[17];
|
|
|
1f984a |
char sn[32];
|
|
|
1f984a |
+ struct plugin_data *pd = (struct plugin_data*)lsmGetPrivateData(c);
|
|
|
1f984a |
lsmOptionalData *od = lsmOptionalDataRecordAlloc();
|
|
|
1f984a |
|
|
|
1f984a |
- if(pd) {
|
|
|
1f984a |
+ if(pd && od) {
|
|
|
1f984a |
// For now we are going to make up some disks to return. Later we will
|
|
|
1f984a |
// try to make a simulated array that makes sense.
|
|
|
1f984a |
*count = 10;
|
|
|
1f984a |
@@ -672,11 +673,12 @@ static int list_disks(lsmPluginPtr c, lsmDisk **disks[], uint32_t *count,
|
|
|
1f984a |
(*disks)[i] = lsmDiskRecordAlloc(md5(name), name, LSM_DISK_TYPE_SOP, 512,
|
|
|
1f984a |
0x8000000000000, LSM_DISK_STATUS_OK, od, sys_id);
|
|
|
1f984a |
}
|
|
|
1f984a |
- lsmOptionalDataRecordFree(od);
|
|
|
1f984a |
+
|
|
|
1f984a |
} else {
|
|
|
1f984a |
rc = LSM_ERR_INVALID_PLUGIN;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
+ lsmOptionalDataRecordFree(od);
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
@@ -1593,6 +1595,7 @@ static int vol_accessible_by_init(lsmPluginPtr c,
|
|
|
1f984a |
lsmVolumeRecordFreeArray(*volumes, alloc_count);
|
|
|
1f984a |
*count = 0;
|
|
|
1f984a |
*volumes = NULL;
|
|
|
1f984a |
+ break;
|
|
|
1f984a |
} else {
|
|
|
1f984a |
alloc_count += 1;
|
|
|
1f984a |
}
|
|
|
1f984a |
@@ -2220,8 +2223,25 @@ int load( lsmPluginPtr c, xmlURIPtr uri, const char *password,
|
|
|
1f984a |
|
|
|
1f984a |
if( !data->system[0] || !data->pool[0] || !data->pool[1] ||
|
|
|
1f984a |
!data->pool[2] || !data->pool[3] || !data->access_groups ||
|
|
|
1f984a |
- !data->group_grant || !data->fs) {
|
|
|
1f984a |
- rc = LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
+ !data->group_grant || !data->fs || !data->jobs ) {
|
|
|
1f984a |
+ rc = LSM_ERR_NO_MEMORY; /* We need to free data and everything else */
|
|
|
1f984a |
+
|
|
|
1f984a |
+ if( data->jobs )
|
|
|
1f984a |
+ g_hash_table_destroy(data->jobs);
|
|
|
1f984a |
+ if( data->fs )
|
|
|
1f984a |
+ g_hash_table_destroy(data->fs);
|
|
|
1f984a |
+ if( data->group_grant )
|
|
|
1f984a |
+ g_hash_table_destroy(data->group_grant);
|
|
|
1f984a |
+ if( data->access_groups )
|
|
|
1f984a |
+ g_hash_table_destroy(data->access_groups);
|
|
|
1f984a |
+ lsmPoolRecordFree(data->pool[3]);
|
|
|
1f984a |
+ lsmPoolRecordFree(data->pool[2]);
|
|
|
1f984a |
+ lsmPoolRecordFree(data->pool[1]);
|
|
|
1f984a |
+ lsmPoolRecordFree(data->pool[0]);
|
|
|
1f984a |
+ lsmSystemRecordFree(data->system[0]);
|
|
|
1f984a |
+ memset(data, 0xAA, sizeof(struct plugin_data));
|
|
|
1f984a |
+ free(data);
|
|
|
1f984a |
+ data = NULL;
|
|
|
1f984a |
} else {
|
|
|
1f984a |
rc = lsmRegisterPluginV1( c, data, &mgmOps,
|
|
|
1f984a |
&sanOps, &fsOps, &nfsOps);
|
|
|
1f984a |
diff --git src/lsm_convert.cpp src/lsm_convert.cpp
|
|
|
1f984a |
index 54100a5..242efe9 100644
|
|
|
1f984a |
--- src/lsm_convert.cpp
|
|
|
1f984a |
+++ src/lsm_convert.cpp
|
|
|
1f984a |
@@ -95,6 +95,9 @@ lsmDisk *valueToDisk(Value &disk)
|
|
|
1f984a |
op,
|
|
|
1f984a |
d["system_id"].asString().c_str()
|
|
|
1f984a |
);
|
|
|
1f984a |
+
|
|
|
1f984a |
+ /* Optional data gets copied in lsmDiskRecordAlloc */
|
|
|
1f984a |
+ lsmOptionalDataRecordFree(op);
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
}
|
|
|
1f984a |
diff --git src/lsm_daemon.c src/lsm_daemon.c
|
|
|
1f984a |
index 670fb17..04eed85 100644
|
|
|
1f984a |
--- src/lsm_daemon.c
|
|
|
1f984a |
+++ src/lsm_daemon.c
|
|
|
1f984a |
@@ -42,6 +42,7 @@
|
|
|
1f984a |
#include <libgen.h>
|
|
|
1f984a |
#include <assert.h>
|
|
|
1f984a |
#include <grp.h>
|
|
|
1f984a |
+#include <limits.h>
|
|
|
1f984a |
|
|
|
1f984a |
#define BASE_DIR "/var/run/lsm"
|
|
|
1f984a |
#define SOCKET_DIR BASE_DIR"/ipc"
|
|
|
1f984a |
@@ -379,7 +380,7 @@ void empty_plugin_list(struct plugin_list *list)
|
|
|
1f984a |
|
|
|
1f984a |
free(item->file_path);
|
|
|
1f984a |
item->file_path = NULL;
|
|
|
1f984a |
- item->fd = -1;
|
|
|
1f984a |
+ item->fd = INT_MAX;
|
|
|
1f984a |
free(item);
|
|
|
1f984a |
}
|
|
|
1f984a |
}
|
|
|
1f984a |
diff --git src/lsm_datatypes.cpp src/lsm_datatypes.cpp
|
|
|
1f984a |
index d989c32..7e6415d 100644
|
|
|
1f984a |
--- src/lsm_datatypes.cpp
|
|
|
1f984a |
+++ src/lsm_datatypes.cpp
|
|
|
1f984a |
@@ -1560,7 +1560,12 @@ static uint8_t *stringToBytes(const char *hex_string, uint32_t *l)
|
|
|
1f984a |
*l = len;
|
|
|
1f984a |
|
|
|
1f984a |
for( i = 0; i < len; ++i ) {
|
|
|
1f984a |
- sscanf(t, "%02hhx", &rc[i]);
|
|
|
1f984a |
+ if( 1 != sscanf(t, "%02hhx", &rc[i])) {
|
|
|
1f984a |
+ free(rc);
|
|
|
1f984a |
+ rc = NULL;
|
|
|
1f984a |
+ *l = 0;
|
|
|
1f984a |
+ break;
|
|
|
1f984a |
+ }
|
|
|
1f984a |
t += 2;
|
|
|
1f984a |
}
|
|
|
1f984a |
}
|
|
|
1f984a |
diff --git src/lsm_ipc.cpp src/lsm_ipc.cpp
|
|
|
1f984a |
index 355abee..4a2d07d 100644
|
|
|
1f984a |
--- src/lsm_ipc.cpp
|
|
|
1f984a |
+++ src/lsm_ipc.cpp
|
|
|
1f984a |
@@ -121,9 +121,13 @@ std::string Transport::recvMsg(int &error_code)
|
|
|
1f984a |
{
|
|
|
1f984a |
std::string msg;
|
|
|
1f984a |
error_code = 0;
|
|
|
1f984a |
+ unsigned long int payload_len = 0;
|
|
|
1f984a |
std::string len = readString(s, HDR_LEN, error_code); //Read the length
|
|
|
1f984a |
if (len.size() && error_code == 0) {
|
|
|
1f984a |
- msg = readString(s, strtoul(len.c_str(), NULL, 10), error_code);
|
|
|
1f984a |
+ payload_len = strtoul(len.c_str(), NULL, 10);
|
|
|
1f984a |
+ if( payload_len < 0x80000000 ) { /* Should be big enough */
|
|
|
1f984a |
+ msg = readString(s, payload_len, error_code);
|
|
|
1f984a |
+ }
|
|
|
1f984a |
//fprintf(stderr, "<<< %s\n", msg.c_str());
|
|
|
1f984a |
}
|
|
|
1f984a |
return msg;
|
|
|
1f984a |
@@ -147,6 +151,7 @@ int Transport::getSocket(const std::string& path, int &error_code)
|
|
|
1f984a |
if (rc != 0) {
|
|
|
1f984a |
error_code = errno;
|
|
|
1f984a |
rc = -1; //Redundant, connect should set to -1 on error
|
|
|
1f984a |
+ ::close(sfd);
|
|
|
1f984a |
} else {
|
|
|
1f984a |
rc = sfd; //We are good to go.
|
|
|
1f984a |
}
|
|
|
1f984a |
diff --git src/lsm_mgmt.cpp src/lsm_mgmt.cpp
|
|
|
1f984a |
index f5c96a1..694e10a 100644
|
|
|
1f984a |
--- src/lsm_mgmt.cpp
|
|
|
1f984a |
+++ src/lsm_mgmt.cpp
|
|
|
1f984a |
@@ -37,6 +37,7 @@
|
|
|
1f984a |
return LSM_ERR_INVALID_CONN; \
|
|
|
1f984a |
} \
|
|
|
1f984a |
lsmErrorFree(c->error); \
|
|
|
1f984a |
+ c->error = NULL; \
|
|
|
1f984a |
} while (0)
|
|
|
1f984a |
|
|
|
1f984a |
/**
|
|
|
1f984a |
@@ -118,7 +119,7 @@ static lsmErrorNumber logException(lsmConnect *c, lsmErrorNumber error,
|
|
|
1f984a |
LSM_ERR_LEVEL_ERROR, message,
|
|
|
1f984a |
exception_msg, NULL,
|
|
|
1f984a |
NULL, 0);
|
|
|
1f984a |
- if( err && c ) {
|
|
|
1f984a |
+ if( err ) {
|
|
|
1f984a |
lsmErrorLog(c, err);
|
|
|
1f984a |
}
|
|
|
1f984a |
return error;
|
|
|
1f984a |
@@ -135,7 +136,7 @@ static int rpc(lsmConnect *c, const char *method, const Value ¶meters,
|
|
|
1f984a |
} catch ( const LsmException &le ) {
|
|
|
1f984a |
return logException(c, (lsmErrorNumber)le.error_code, le.what(),
|
|
|
1f984a |
NULL);
|
|
|
1f984a |
- } catch ( EOFException &eof ) {
|
|
|
1f984a |
+ } catch ( const EOFException &eof ) {
|
|
|
1f984a |
return logException(c, LSM_ERR_TRANSPORT_COMMUNICATION, "Plug-in died",
|
|
|
1f984a |
"Check syslog");
|
|
|
1f984a |
} catch (...) {
|
|
|
1f984a |
@@ -145,30 +146,40 @@ static int rpc(lsmConnect *c, const char *method, const Value ¶meters,
|
|
|
1f984a |
return LSM_ERR_OK;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
-static int jobCheck( int rc, Value &response, char **job )
|
|
|
1f984a |
+static int jobCheck( lsmConnect *c, int rc, Value &response, char **job )
|
|
|
1f984a |
{
|
|
|
1f984a |
- if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
- //We get a value back, either null or job id.
|
|
|
1f984a |
- if( Value::string_t == response.valueType() ) {
|
|
|
1f984a |
- *job = strdup(response.asString().c_str());
|
|
|
1f984a |
-
|
|
|
1f984a |
- if( *job ) {
|
|
|
1f984a |
- rc = LSM_ERR_JOB_STARTED;
|
|
|
1f984a |
+ try {
|
|
|
1f984a |
+ if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
+ //We get a value back, either null or job id.
|
|
|
1f984a |
+ if( Value::string_t == response.valueType() ) {
|
|
|
1f984a |
+ *job = strdup(response.asString().c_str());
|
|
|
1f984a |
+
|
|
|
1f984a |
+ if( *job ) {
|
|
|
1f984a |
+ rc = LSM_ERR_JOB_STARTED;
|
|
|
1f984a |
+ } else {
|
|
|
1f984a |
+ rc = LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
+ }
|
|
|
1f984a |
} else {
|
|
|
1f984a |
- rc = LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
+ *job = NULL;
|
|
|
1f984a |
}
|
|
|
1f984a |
- } else {
|
|
|
1f984a |
- *job = NULL;
|
|
|
1f984a |
}
|
|
|
1f984a |
+ } catch (const ValueException &ve) {
|
|
|
1f984a |
+ rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Wrong type",
|
|
|
1f984a |
+ ve.what());
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
-static int getAccessGroups( int rc, Value &response, lsmAccessGroup **groups[],
|
|
|
1f984a |
- uint32_t *count)
|
|
|
1f984a |
+static int getAccessGroups( lsmConnect *c, int rc, Value &response,
|
|
|
1f984a |
+ lsmAccessGroup **groups[], uint32_t *count)
|
|
|
1f984a |
{
|
|
|
1f984a |
- if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) {
|
|
|
1f984a |
- *groups = valueToAccessGroupList(response, count);
|
|
|
1f984a |
+ try {
|
|
|
1f984a |
+ if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) {
|
|
|
1f984a |
+ *groups = valueToAccessGroupList(response, count);
|
|
|
1f984a |
+ }
|
|
|
1f984a |
+ } catch( const ValueException &ve ) {
|
|
|
1f984a |
+ rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type",
|
|
|
1f984a |
+ ve.what());
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
}
|
|
|
1f984a |
@@ -197,6 +208,7 @@ int lsmConnectClose(lsmConnect *c, lsmFlag_t flags)
|
|
|
1f984a |
int LSM_DLL_EXPORT lsmPluginGetInfo(lsmConnect *c, char **desc,
|
|
|
1f984a |
char **version, lsmFlag_t flags)
|
|
|
1f984a |
{
|
|
|
1f984a |
+ int rc = LSM_ERR_OK;
|
|
|
1f984a |
CONN_SETUP(c);
|
|
|
1f984a |
|
|
|
1f984a |
if( LSM_FLAG_UNUSED_CHECK(flags) ) {
|
|
|
1f984a |
@@ -207,23 +219,32 @@ int LSM_DLL_EXPORT lsmPluginGetInfo(lsmConnect *c, char **desc,
|
|
|
1f984a |
return LSM_ERR_INVALID_ARGUMENT;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
- std::map<std::string, Value> p;
|
|
|
1f984a |
- p["flags"] = Value(flags);
|
|
|
1f984a |
- Value parameters(p);
|
|
|
1f984a |
- Value response;
|
|
|
1f984a |
+ try {
|
|
|
1f984a |
+ std::map<std::string, Value> p;
|
|
|
1f984a |
+ p["flags"] = Value(flags);
|
|
|
1f984a |
+ Value parameters(p);
|
|
|
1f984a |
+ Value response;
|
|
|
1f984a |
|
|
|
1f984a |
- int rc = rpc(c, "plugin_info", parameters, response);
|
|
|
1f984a |
+ rc = rpc(c, "plugin_info", parameters, response);
|
|
|
1f984a |
|
|
|
1f984a |
- if( rc == LSM_ERR_OK ) {
|
|
|
1f984a |
- std::vector<Value> j = response.asArray();
|
|
|
1f984a |
- *desc = strdup(j[0].asC_str());
|
|
|
1f984a |
- *version = strdup(j[1].asC_str());
|
|
|
1f984a |
+ if( rc == LSM_ERR_OK ) {
|
|
|
1f984a |
+ std::vector<Value> j = response.asArray();
|
|
|
1f984a |
+ *desc = strdup(j[0].asC_str());
|
|
|
1f984a |
+ *version = strdup(j[1].asC_str());
|
|
|
1f984a |
|
|
|
1f984a |
- if( !*desc || !*version ) {
|
|
|
1f984a |
- rc = LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
- free(*desc);
|
|
|
1f984a |
- free(*version);
|
|
|
1f984a |
+ if( !*desc || !*version ) {
|
|
|
1f984a |
+ rc = LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
+ free(*desc);
|
|
|
1f984a |
+ free(*version);
|
|
|
1f984a |
+ }
|
|
|
1f984a |
}
|
|
|
1f984a |
+ } catch (const ValueException &ve) {
|
|
|
1f984a |
+ free(*desc);
|
|
|
1f984a |
+ *desc = NULL;
|
|
|
1f984a |
+ free(*version);
|
|
|
1f984a |
+ *version = NULL;
|
|
|
1f984a |
+ rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type",
|
|
|
1f984a |
+ ve.what());
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
@@ -242,16 +263,17 @@ int LSM_DLL_EXPORT lsmGetAvailablePlugins(const char *sep,
|
|
|
1f984a |
char *version = NULL;
|
|
|
1f984a |
char *s = NULL;
|
|
|
1f984a |
const char *uds_dir = uds_path();
|
|
|
1f984a |
- lsmStringList *plugin_list = lsmStringListAlloc(0);
|
|
|
1f984a |
-
|
|
|
1f984a |
- if( !plugin_list ) {
|
|
|
1f984a |
- return LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
- }
|
|
|
1f984a |
+ lsmStringList *plugin_list = NULL;
|
|
|
1f984a |
|
|
|
1f984a |
if( CHECK_STR(sep) || CHECK_RP(plugins) || LSM_FLAG_UNUSED_CHECK(flags)) {
|
|
|
1f984a |
return LSM_ERR_INVALID_ARGUMENT;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
+ plugin_list = lsmStringListAlloc(0);
|
|
|
1f984a |
+ if( !plugin_list ) {
|
|
|
1f984a |
+ return LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
+ }
|
|
|
1f984a |
+
|
|
|
1f984a |
dirp = opendir(uds_dir);
|
|
|
1f984a |
if( dirp ) {
|
|
|
1f984a |
for(;;) {
|
|
|
1f984a |
@@ -277,28 +299,32 @@ int LSM_DLL_EXPORT lsmGetAvailablePlugins(const char *sep,
|
|
|
1f984a |
|
|
|
1f984a |
if( -1 == format ) {
|
|
|
1f984a |
rc = LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
- goto bail;
|
|
|
1f984a |
+ break;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
rc = lsmStringListAppend(plugin_list, s);
|
|
|
1f984a |
free(s);
|
|
|
1f984a |
s = NULL;
|
|
|
1f984a |
if( LSM_ERR_OK != rc ) {
|
|
|
1f984a |
- goto bail;
|
|
|
1f984a |
+ break;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
}
|
|
|
1f984a |
} else {
|
|
|
1f984a |
- goto bail;
|
|
|
1f984a |
+ break;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
freeConnection(c);
|
|
|
1f984a |
c = NULL;
|
|
|
1f984a |
}
|
|
|
1f984a |
}
|
|
|
1f984a |
+ } /* for(;;) */
|
|
|
1f984a |
+
|
|
|
1f984a |
+ if( e ) {
|
|
|
1f984a |
+ lsmErrorFree(e);
|
|
|
1f984a |
+ e = NULL;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
- bail:
|
|
|
1f984a |
if( c ) {
|
|
|
1f984a |
freeConnection(c);
|
|
|
1f984a |
c = NULL;
|
|
|
1f984a |
@@ -309,7 +335,8 @@ int LSM_DLL_EXPORT lsmGetAvailablePlugins(const char *sep,
|
|
|
1f984a |
//log the error
|
|
|
1f984a |
rc = LSM_ERR_INTERNAL_ERROR;
|
|
|
1f984a |
}
|
|
|
1f984a |
- } else {
|
|
|
1f984a |
+
|
|
|
1f984a |
+ } else { /* If dirp == NULL */
|
|
|
1f984a |
//Log the error
|
|
|
1f984a |
rc = LSM_ERR_INTERNAL_ERROR;
|
|
|
1f984a |
}
|
|
|
1f984a |
@@ -318,6 +345,7 @@ int LSM_DLL_EXPORT lsmGetAvailablePlugins(const char *sep,
|
|
|
1f984a |
*plugins = plugin_list;
|
|
|
1f984a |
} else {
|
|
|
1f984a |
lsmStringListFree(plugin_list);
|
|
|
1f984a |
+ plugin_list = NULL;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
@@ -343,20 +371,27 @@ int lsmConnectSetTimeout(lsmConnect *c, uint32_t timeout, lsmFlag_t flags)
|
|
|
1f984a |
|
|
|
1f984a |
int lsmConnectGetTimeout(lsmConnect *c, uint32_t *timeout, lsmFlag_t flags)
|
|
|
1f984a |
{
|
|
|
1f984a |
+ int rc = 0;
|
|
|
1f984a |
CONN_SETUP(c);
|
|
|
1f984a |
|
|
|
1f984a |
if( LSM_FLAG_UNUSED_CHECK(flags) ) {
|
|
|
1f984a |
return LSM_ERR_INVALID_ARGUMENT;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
- std::map<std::string, Value> p;
|
|
|
1f984a |
- p["flags"] = Value(flags);
|
|
|
1f984a |
- Value parameters(p);
|
|
|
1f984a |
- Value response;
|
|
|
1f984a |
-
|
|
|
1f984a |
- int rc = rpc(c, "get_time_out", parameters, response);
|
|
|
1f984a |
- if( rc == LSM_ERR_OK ) {
|
|
|
1f984a |
- *timeout = response.asUint32_t();
|
|
|
1f984a |
+ try {
|
|
|
1f984a |
+ std::map<std::string, Value> p;
|
|
|
1f984a |
+ p["flags"] = Value(flags);
|
|
|
1f984a |
+ Value parameters(p);
|
|
|
1f984a |
+ Value response;
|
|
|
1f984a |
+
|
|
|
1f984a |
+ rc = rpc(c, "get_time_out", parameters, response);
|
|
|
1f984a |
+ if( rc == LSM_ERR_OK ) {
|
|
|
1f984a |
+ *timeout = response.asUint32_t();
|
|
|
1f984a |
+ }
|
|
|
1f984a |
+ }
|
|
|
1f984a |
+ catch( const ValueException &ve ) {
|
|
|
1f984a |
+ rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type",
|
|
|
1f984a |
+ ve.what());
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
}
|
|
|
1f984a |
@@ -365,26 +400,32 @@ static int jobStatus( lsmConnect *c, const char *job,
|
|
|
1f984a |
lsmJobStatus *status, uint8_t *percentComplete,
|
|
|
1f984a |
Value &returned_value, lsmFlag_t flags)
|
|
|
1f984a |
{
|
|
|
1f984a |
+ int rc = 0;
|
|
|
1f984a |
CONN_SETUP(c);
|
|
|
1f984a |
|
|
|
1f984a |
if( !job || !status || !percentComplete ) {
|
|
|
1f984a |
return LSM_ERR_INVALID_ARGUMENT;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
- std::map<std::string, Value> p;
|
|
|
1f984a |
- p["job_id"] = Value(job);
|
|
|
1f984a |
- p["flags"] = Value(flags);
|
|
|
1f984a |
- Value parameters(p);
|
|
|
1f984a |
- Value response;
|
|
|
1f984a |
-
|
|
|
1f984a |
- int rc = rpc(c, "job_status", parameters, response);
|
|
|
1f984a |
- if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
- //We get back an array [status, percent, volume]
|
|
|
1f984a |
- std::vector<Value> j = response.asArray();
|
|
|
1f984a |
- *status = (lsmJobStatus)j[0].asInt32_t();
|
|
|
1f984a |
- *percentComplete = (uint8_t)j[1].asUint32_t();
|
|
|
1f984a |
-
|
|
|
1f984a |
- returned_value = j[2];
|
|
|
1f984a |
+ try {
|
|
|
1f984a |
+ std::map<std::string, Value> p;
|
|
|
1f984a |
+ p["job_id"] = Value(job);
|
|
|
1f984a |
+ p["flags"] = Value(flags);
|
|
|
1f984a |
+ Value parameters(p);
|
|
|
1f984a |
+ Value response;
|
|
|
1f984a |
+
|
|
|
1f984a |
+ rc = rpc(c, "job_status", parameters, response);
|
|
|
1f984a |
+ if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
+ //We get back an array [status, percent, volume]
|
|
|
1f984a |
+ std::vector<Value> j = response.asArray();
|
|
|
1f984a |
+ *status = (lsmJobStatus)j[0].asInt32_t();
|
|
|
1f984a |
+ *percentComplete = (uint8_t)j[1].asUint32_t();
|
|
|
1f984a |
+
|
|
|
1f984a |
+ returned_value = j[2];
|
|
|
1f984a |
+ }
|
|
|
1f984a |
+ } catch( const ValueException &ve ) {
|
|
|
1f984a |
+ rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type",
|
|
|
1f984a |
+ ve.what());
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
}
|
|
|
1f984a |
@@ -408,6 +449,7 @@ int lsmJobStatusVolumeGet( lsmConnect *c, const char *job,
|
|
|
1f984a |
lsmVolume **vol, lsmFlag_t flags)
|
|
|
1f984a |
{
|
|
|
1f984a |
Value rv;
|
|
|
1f984a |
+ int rc = 0;
|
|
|
1f984a |
|
|
|
1f984a |
CONN_SETUP(c);
|
|
|
1f984a |
|
|
|
1f984a |
@@ -415,14 +457,20 @@ int lsmJobStatusVolumeGet( lsmConnect *c, const char *job,
|
|
|
1f984a |
return LSM_ERR_INVALID_ARGUMENT;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
- int rc = jobStatus(c, job, status, percentComplete, rv, flags);
|
|
|
1f984a |
+ try {
|
|
|
1f984a |
|
|
|
1f984a |
- if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
- if( Value::object_t == rv.valueType() ) {
|
|
|
1f984a |
- *vol = valueToVolume(rv);
|
|
|
1f984a |
- } else {
|
|
|
1f984a |
- *vol = NULL;
|
|
|
1f984a |
+ rc = jobStatus(c, job, status, percentComplete, rv, flags);
|
|
|
1f984a |
+
|
|
|
1f984a |
+ if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
+ if( Value::object_t == rv.valueType() ) {
|
|
|
1f984a |
+ *vol = valueToVolume(rv);
|
|
|
1f984a |
+ } else {
|
|
|
1f984a |
+ *vol = NULL;
|
|
|
1f984a |
+ }
|
|
|
1f984a |
}
|
|
|
1f984a |
+ } catch( const ValueException &ve ) {
|
|
|
1f984a |
+ rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type",
|
|
|
1f984a |
+ ve.what());
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
}
|
|
|
1f984a |
@@ -431,20 +479,27 @@ int lsmJobStatusFsGet(lsmConnect *c, const char *job,
|
|
|
1f984a |
lsmJobStatus *status, uint8_t *percentComplete,
|
|
|
1f984a |
lsmFs **fs, lsmFlag_t flags)
|
|
|
1f984a |
{
|
|
|
1f984a |
+ int rc = 0;
|
|
|
1f984a |
Value rv;
|
|
|
1f984a |
|
|
|
1f984a |
if( CHECK_RP(fs) || LSM_FLAG_UNUSED_CHECK(flags) ) {
|
|
|
1f984a |
return LSM_ERR_INVALID_ARGUMENT;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
- int rc = jobStatus(c, job, status, percentComplete, rv, flags);
|
|
|
1f984a |
+ try {
|
|
|
1f984a |
|
|
|
1f984a |
- if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
- if( Value::object_t == rv.valueType() ) {
|
|
|
1f984a |
- *fs = valueToFs(rv);
|
|
|
1f984a |
- } else {
|
|
|
1f984a |
- *fs = NULL;
|
|
|
1f984a |
+ rc = jobStatus(c, job, status, percentComplete, rv, flags);
|
|
|
1f984a |
+
|
|
|
1f984a |
+ if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
+ if( Value::object_t == rv.valueType() ) {
|
|
|
1f984a |
+ *fs = valueToFs(rv);
|
|
|
1f984a |
+ } else {
|
|
|
1f984a |
+ *fs = NULL;
|
|
|
1f984a |
+ }
|
|
|
1f984a |
}
|
|
|
1f984a |
+ } catch( const ValueException &ve) {
|
|
|
1f984a |
+ rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type",
|
|
|
1f984a |
+ ve.what());
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
}
|
|
|
1f984a |
@@ -453,20 +508,27 @@ int lsmJobStatusSsGet(lsmConnect *c, const char *job,
|
|
|
1f984a |
lsmJobStatus *status, uint8_t *percentComplete,
|
|
|
1f984a |
lsmSs **ss, lsmFlag_t flags)
|
|
|
1f984a |
{
|
|
|
1f984a |
+ int rc = 0;
|
|
|
1f984a |
Value rv;
|
|
|
1f984a |
|
|
|
1f984a |
if( CHECK_RP(ss) || LSM_FLAG_UNUSED_CHECK(flags) ) {
|
|
|
1f984a |
return LSM_ERR_INVALID_ARGUMENT;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
- int rc = jobStatus(c, job, status, percentComplete, rv, flags);
|
|
|
1f984a |
+ try {
|
|
|
1f984a |
|
|
|
1f984a |
- if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
- if( Value::object_t == rv.valueType() ) {
|
|
|
1f984a |
- *ss = valueToSs(rv);
|
|
|
1f984a |
- } else {
|
|
|
1f984a |
- *ss = NULL;
|
|
|
1f984a |
+ rc = jobStatus(c, job, status, percentComplete, rv, flags);
|
|
|
1f984a |
+
|
|
|
1f984a |
+ if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
+ if( Value::object_t == rv.valueType() ) {
|
|
|
1f984a |
+ *ss = valueToSs(rv);
|
|
|
1f984a |
+ } else {
|
|
|
1f984a |
+ *ss = NULL;
|
|
|
1f984a |
+ }
|
|
|
1f984a |
}
|
|
|
1f984a |
+ } catch( const ValueException &ve ) {
|
|
|
1f984a |
+ rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type",
|
|
|
1f984a |
+ ve.what());
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
}
|
|
|
1f984a |
@@ -498,6 +560,7 @@ int lsmJobFree(lsmConnect *c, char **job, lsmFlag_t flags)
|
|
|
1f984a |
int lsmCapabilities(lsmConnect *c, lsmSystem *system,
|
|
|
1f984a |
lsmStorageCapabilities **cap, lsmFlag_t flags)
|
|
|
1f984a |
{
|
|
|
1f984a |
+ int rc = 0;
|
|
|
1f984a |
CONN_SETUP(c);
|
|
|
1f984a |
|
|
|
1f984a |
if( !LSM_IS_SYSTEM(system) ) {
|
|
|
1f984a |
@@ -516,10 +579,15 @@ int lsmCapabilities(lsmConnect *c, lsmSystem *system,
|
|
|
1f984a |
Value parameters(p);
|
|
|
1f984a |
Value response;
|
|
|
1f984a |
|
|
|
1f984a |
- int rc = rpc(c, "capabilities", parameters, response);
|
|
|
1f984a |
+ try {
|
|
|
1f984a |
+ rc = rpc(c, "capabilities", parameters, response);
|
|
|
1f984a |
|
|
|
1f984a |
- if( LSM_ERR_OK == rc && Value::object_t == response.valueType() ) {
|
|
|
1f984a |
- *cap = valueToCapabilities(response);
|
|
|
1f984a |
+ if( LSM_ERR_OK == rc && Value::object_t == response.valueType() ) {
|
|
|
1f984a |
+ *cap = valueToCapabilities(response);
|
|
|
1f984a |
+ }
|
|
|
1f984a |
+ } catch( const ValueException &ve ) {
|
|
|
1f984a |
+ rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type",
|
|
|
1f984a |
+ ve.what());
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
@@ -528,56 +596,76 @@ int lsmCapabilities(lsmConnect *c, lsmSystem *system,
|
|
|
1f984a |
int lsmPoolList(lsmConnect *c, lsmPool **poolArray[],
|
|
|
1f984a |
uint32_t *count, lsmFlag_t flags)
|
|
|
1f984a |
{
|
|
|
1f984a |
+ int rc = 0;
|
|
|
1f984a |
CONN_SETUP(c);
|
|
|
1f984a |
|
|
|
1f984a |
if( !poolArray || !count || CHECK_RP(poolArray) || LSM_FLAG_UNUSED_CHECK(flags) ) {
|
|
|
1f984a |
return LSM_ERR_INVALID_ARGUMENT;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
- std::map<std::string, Value> p;
|
|
|
1f984a |
- p["flags"] = Value(flags);
|
|
|
1f984a |
- Value parameters(p);
|
|
|
1f984a |
- Value response;
|
|
|
1f984a |
+ try {
|
|
|
1f984a |
+ std::map<std::string, Value> p;
|
|
|
1f984a |
+ p["flags"] = Value(flags);
|
|
|
1f984a |
+ Value parameters(p);
|
|
|
1f984a |
+ Value response;
|
|
|
1f984a |
|
|
|
1f984a |
- int rc = rpc(c, "pools", parameters, response);
|
|
|
1f984a |
- if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) {
|
|
|
1f984a |
- std::vector<Value> pools = response.asArray();
|
|
|
1f984a |
+ rc = rpc(c, "pools", parameters, response);
|
|
|
1f984a |
+ if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) {
|
|
|
1f984a |
+ std::vector<Value> pools = response.asArray();
|
|
|
1f984a |
|
|
|
1f984a |
- *count = pools.size();
|
|
|
1f984a |
+ *count = pools.size();
|
|
|
1f984a |
|
|
|
1f984a |
- if( pools.size() ) {
|
|
|
1f984a |
- *poolArray = lsmPoolRecordAllocArray(pools.size());
|
|
|
1f984a |
+ if( pools.size() ) {
|
|
|
1f984a |
+ *poolArray = lsmPoolRecordAllocArray(pools.size());
|
|
|
1f984a |
|
|
|
1f984a |
- for( size_t i = 0; i < pools.size(); ++i ) {
|
|
|
1f984a |
- (*poolArray)[i] = valueToPool(pools[i]);
|
|
|
1f984a |
+ for( size_t i = 0; i < pools.size(); ++i ) {
|
|
|
1f984a |
+ (*poolArray)[i] = valueToPool(pools[i]);
|
|
|
1f984a |
+ }
|
|
|
1f984a |
}
|
|
|
1f984a |
}
|
|
|
1f984a |
+ } catch( const ValueException &ve ) {
|
|
|
1f984a |
+ rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type",
|
|
|
1f984a |
+ ve.what());
|
|
|
1f984a |
+ if( *poolArray && *count ) {
|
|
|
1f984a |
+ lsmPoolRecordFreeArray(*poolArray, *count);
|
|
|
1f984a |
+ *poolArray = NULL;
|
|
|
1f984a |
+ *count = 0;
|
|
|
1f984a |
+ }
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
-static int get_initiator_array(int rc, Value &response,
|
|
|
1f984a |
+static int get_initiator_array(lsmConnect *c, int rc, Value &response,
|
|
|
1f984a |
lsmInitiator **initiators[], uint32_t *count)
|
|
|
1f984a |
{
|
|
|
1f984a |
- if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) {
|
|
|
1f984a |
- std::vector<Value> inits = response.asArray();
|
|
|
1f984a |
-
|
|
|
1f984a |
- *count = inits.size();
|
|
|
1f984a |
-
|
|
|
1f984a |
- if( inits.size() ) {
|
|
|
1f984a |
+ try {
|
|
|
1f984a |
+ if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) {
|
|
|
1f984a |
+ std::vector<Value> inits = response.asArray();
|
|
|
1f984a |
|
|
|
1f984a |
- *initiators = lsmInitiatorRecordAllocArray(inits.size());
|
|
|
1f984a |
+ *count = inits.size();
|
|
|
1f984a |
|
|
|
1f984a |
- if( *initiators ) {
|
|
|
1f984a |
+ if( inits.size() ) {
|
|
|
1f984a |
|
|
|
1f984a |
+ *initiators = lsmInitiatorRecordAllocArray(inits.size());
|
|
|
1f984a |
|
|
|
1f984a |
- for( size_t i = 0; i < inits.size(); ++i ) {
|
|
|
1f984a |
- (*initiators)[i] = valueToInitiator(inits[i]);
|
|
|
1f984a |
+ if( *initiators ) {
|
|
|
1f984a |
+ for( size_t i = 0; i < inits.size(); ++i ) {
|
|
|
1f984a |
+ (*initiators)[i] = valueToInitiator(inits[i]);
|
|
|
1f984a |
+ }
|
|
|
1f984a |
+ } else {
|
|
|
1f984a |
+ rc = LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
}
|
|
|
1f984a |
- } else {
|
|
|
1f984a |
- rc = LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
}
|
|
|
1f984a |
}
|
|
|
1f984a |
+ } catch ( const ValueException &ve ) {
|
|
|
1f984a |
+ if( *initiators && *count ) {
|
|
|
1f984a |
+ lsmInitiatorRecordFreeArray(*initiators, *count);
|
|
|
1f984a |
+ *initiators = NULL;
|
|
|
1f984a |
+ *count = 0;
|
|
|
1f984a |
+ }
|
|
|
1f984a |
+
|
|
|
1f984a |
+ rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type",
|
|
|
1f984a |
+ ve.what());
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
}
|
|
|
1f984a |
@@ -598,28 +686,39 @@ int lsmInitiatorList(lsmConnect *c, lsmInitiator **initiators[],
|
|
|
1f984a |
Value response;
|
|
|
1f984a |
|
|
|
1f984a |
int rc = rpc(c, "initiators", parameters, response);
|
|
|
1f984a |
- return get_initiator_array(rc, response, initiators, count);
|
|
|
1f984a |
+ return get_initiator_array(c, rc, response, initiators, count);
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
-static int get_volume_array(int rc, Value response,
|
|
|
1f984a |
+static int get_volume_array(lsmConnect *c, int rc, Value response,
|
|
|
1f984a |
lsmVolume **volumes[], uint32_t *count)
|
|
|
1f984a |
{
|
|
|
1f984a |
- if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) {
|
|
|
1f984a |
- std::vector<Value> vol = response.asArray();
|
|
|
1f984a |
+ try {
|
|
|
1f984a |
+ if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) {
|
|
|
1f984a |
+ std::vector<Value> vol = response.asArray();
|
|
|
1f984a |
|
|
|
1f984a |
- *count = vol.size();
|
|
|
1f984a |
+ *count = vol.size();
|
|
|
1f984a |
|
|
|
1f984a |
- if( vol.size() ) {
|
|
|
1f984a |
- *volumes = lsmVolumeRecordAllocArray(vol.size());
|
|
|
1f984a |
+ if( vol.size() ) {
|
|
|
1f984a |
+ *volumes = lsmVolumeRecordAllocArray(vol.size());
|
|
|
1f984a |
|
|
|
1f984a |
- if( *volumes ){
|
|
|
1f984a |
- for( size_t i = 0; i < vol.size(); ++i ) {
|
|
|
1f984a |
- (*volumes)[i] = valueToVolume(vol[i]);
|
|
|
1f984a |
+ if( *volumes ){
|
|
|
1f984a |
+ for( size_t i = 0; i < vol.size(); ++i ) {
|
|
|
1f984a |
+ (*volumes)[i] = valueToVolume(vol[i]);
|
|
|
1f984a |
+ }
|
|
|
1f984a |
+ } else {
|
|
|
1f984a |
+ rc = LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
}
|
|
|
1f984a |
- } else {
|
|
|
1f984a |
- rc = LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
}
|
|
|
1f984a |
}
|
|
|
1f984a |
+ } catch( const ValueException &ve) {
|
|
|
1f984a |
+ if( *volumes && *count ) {
|
|
|
1f984a |
+ lsmVolumeRecordFreeArray(*volumes, *count);
|
|
|
1f984a |
+ *volumes = NULL;
|
|
|
1f984a |
+ *count = 0;
|
|
|
1f984a |
+ }
|
|
|
1f984a |
+
|
|
|
1f984a |
+ rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type",
|
|
|
1f984a |
+ ve.what());
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
}
|
|
|
1f984a |
@@ -641,28 +740,38 @@ int lsmVolumeList(lsmConnect *c, lsmVolume **volumes[], uint32_t *count,
|
|
|
1f984a |
Value response;
|
|
|
1f984a |
|
|
|
1f984a |
int rc = rpc(c, "volumes", parameters, response);
|
|
|
1f984a |
- return get_volume_array(rc, response, volumes, count);
|
|
|
1f984a |
+ return get_volume_array(c, rc, response, volumes, count);
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
-static int get_disk_array(int rc, Value &response, lsmDisk **disks[],
|
|
|
1f984a |
- uint32_t *count)
|
|
|
1f984a |
+static int get_disk_array(lsmConnect *c, int rc, Value &response,
|
|
|
1f984a |
+ lsmDisk **disks[], uint32_t *count)
|
|
|
1f984a |
{
|
|
|
1f984a |
- if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) {
|
|
|
1f984a |
- std::vector<Value> d = response.asArray();
|
|
|
1f984a |
+ try {
|
|
|
1f984a |
+ if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) {
|
|
|
1f984a |
+ std::vector<Value> d = response.asArray();
|
|
|
1f984a |
|
|
|
1f984a |
- *count = d.size();
|
|
|
1f984a |
+ *count = d.size();
|
|
|
1f984a |
|
|
|
1f984a |
- if( d.size() ) {
|
|
|
1f984a |
- *disks = lsmDiskRecordAllocArray(d.size());
|
|
|
1f984a |
+ if( d.size() ) {
|
|
|
1f984a |
+ *disks = lsmDiskRecordAllocArray(d.size());
|
|
|
1f984a |
|
|
|
1f984a |
- if( *disks ){
|
|
|
1f984a |
- for( size_t i = 0; i < d.size(); ++i ) {
|
|
|
1f984a |
- (*disks)[i] = valueToDisk(d[i]);
|
|
|
1f984a |
+ if( *disks ){
|
|
|
1f984a |
+ for( size_t i = 0; i < d.size(); ++i ) {
|
|
|
1f984a |
+ (*disks)[i] = valueToDisk(d[i]);
|
|
|
1f984a |
+ }
|
|
|
1f984a |
+ } else {
|
|
|
1f984a |
+ rc = LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
}
|
|
|
1f984a |
- } else {
|
|
|
1f984a |
- rc = LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
}
|
|
|
1f984a |
}
|
|
|
1f984a |
+ } catch( const ValueException &ve ) {
|
|
|
1f984a |
+ rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type",
|
|
|
1f984a |
+ ve.what());
|
|
|
1f984a |
+ if( *disks && *count ) {
|
|
|
1f984a |
+ lsmDiskRecordFreeArray(*disks, *count);
|
|
|
1f984a |
+ *disks = NULL;
|
|
|
1f984a |
+ *count = 0;
|
|
|
1f984a |
+ }
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
|
|
|
1f984a |
@@ -684,30 +793,39 @@ int lsmDiskList(lsmConnect *c, lsmDisk **disks[],
|
|
|
1f984a |
Value response;
|
|
|
1f984a |
|
|
|
1f984a |
int rc = rpc(c, "disks", parameters, response);
|
|
|
1f984a |
- return get_disk_array(rc, response, disks, count);
|
|
|
1f984a |
+ return get_disk_array(c, rc, response, disks, count);
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
typedef void* (*convert)(Value &v);
|
|
|
1f984a |
|
|
|
1f984a |
-static void* parse_job_response(Value response, int &rc, char **job, convert conv)
|
|
|
1f984a |
+static void* parse_job_response(lsmConnect *c, Value response, int &rc,
|
|
|
1f984a |
+ char **job, convert conv)
|
|
|
1f984a |
{
|
|
|
1f984a |
void *val = NULL;
|
|
|
1f984a |
- //We get an array back. first value is job, second is data of interest.
|
|
|
1f984a |
- if( Value::array_t == response.valueType() ) {
|
|
|
1f984a |
- std::vector<Value> r = response.asArray();
|
|
|
1f984a |
- if( Value::string_t == r[0].valueType()) {
|
|
|
1f984a |
- *job = strdup((r[0].asString()).c_str());
|
|
|
1f984a |
- if( *job ) {
|
|
|
1f984a |
+
|
|
|
1f984a |
+ try {
|
|
|
1f984a |
+ //We get an array back. first value is job, second is data of interest.
|
|
|
1f984a |
+ if( Value::array_t == response.valueType() ) {
|
|
|
1f984a |
+ std::vector<Value> r = response.asArray();
|
|
|
1f984a |
+ if( Value::string_t == r[0].valueType()) {
|
|
|
1f984a |
+ *job = strdup((r[0].asString()).c_str());
|
|
|
1f984a |
+ if( *job ) {
|
|
|
1f984a |
+ rc = LSM_ERR_JOB_STARTED;
|
|
|
1f984a |
+ } else {
|
|
|
1f984a |
+ rc = LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
+ }
|
|
|
1f984a |
+
|
|
|
1f984a |
rc = LSM_ERR_JOB_STARTED;
|
|
|
1f984a |
- } else {
|
|
|
1f984a |
- rc = LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
}
|
|
|
1f984a |
-
|
|
|
1f984a |
- rc = LSM_ERR_JOB_STARTED;
|
|
|
1f984a |
- }
|
|
|
1f984a |
- if( Value::object_t == r[1].valueType() ) {
|
|
|
1f984a |
- val = conv(r[1]);
|
|
|
1f984a |
+ if( Value::object_t == r[1].valueType() ) {
|
|
|
1f984a |
+ val = conv(r[1]);
|
|
|
1f984a |
+ }
|
|
|
1f984a |
}
|
|
|
1f984a |
+ } catch( const ValueException &ve ) {
|
|
|
1f984a |
+ rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type",
|
|
|
1f984a |
+ ve.what());
|
|
|
1f984a |
+ free(*job);
|
|
|
1f984a |
+ *job = NULL;
|
|
|
1f984a |
}
|
|
|
1f984a |
return val;
|
|
|
1f984a |
}
|
|
|
1f984a |
@@ -739,7 +857,7 @@ int lsmVolumeCreate(lsmConnect *c, lsmPool *pool, const char *volumeName,
|
|
|
1f984a |
|
|
|
1f984a |
int rc = rpc(c, "volume_create", parameters, response);
|
|
|
1f984a |
if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
- *newVolume = (lsmVolume *)parse_job_response(response, rc, job,
|
|
|
1f984a |
+ *newVolume = (lsmVolume *)parse_job_response(c, response, rc, job,
|
|
|
1f984a |
(convert)valueToVolume);
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
@@ -775,7 +893,7 @@ int lsmVolumeResize(lsmConnect *c, lsmVolume *volume,
|
|
|
1f984a |
|
|
|
1f984a |
int rc = rpc(c, "volume_resize", parameters, response);
|
|
|
1f984a |
if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
- *resizedVolume = (lsmVolume *)parse_job_response(response, rc, job,
|
|
|
1f984a |
+ *resizedVolume = (lsmVolume *)parse_job_response(c, response, rc, job,
|
|
|
1f984a |
(convert)valueToVolume);
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
@@ -813,7 +931,7 @@ int lsmVolumeReplicate(lsmConnect *c, lsmPool *pool,
|
|
|
1f984a |
|
|
|
1f984a |
int rc = rpc(c, "volume_replicate", parameters, response);
|
|
|
1f984a |
if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
- *newReplicant = (lsmVolume *)parse_job_response(response, rc, job,
|
|
|
1f984a |
+ *newReplicant = (lsmVolume *)parse_job_response(c, response, rc, job,
|
|
|
1f984a |
(convert)valueToVolume);
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
@@ -823,6 +941,7 @@ int lsmVolumeReplicate(lsmConnect *c, lsmPool *pool,
|
|
|
1f984a |
int lsmVolumeReplicateRangeBlockSize(lsmConnect *c, lsmSystem *system,
|
|
|
1f984a |
uint32_t *bs, lsmFlag_t flags)
|
|
|
1f984a |
{
|
|
|
1f984a |
+ int rc = 0;
|
|
|
1f984a |
CONN_SETUP(c);
|
|
|
1f984a |
|
|
|
1f984a |
if( !bs || LSM_FLAG_UNUSED_CHECK(flags) ) {
|
|
|
1f984a |
@@ -833,17 +952,22 @@ int lsmVolumeReplicateRangeBlockSize(lsmConnect *c, lsmSystem *system,
|
|
|
1f984a |
return LSM_ERR_INVALID_SYSTEM;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
- std::map<std::string, Value> p;
|
|
|
1f984a |
- p["system"] = systemToValue(system);
|
|
|
1f984a |
- p["flags"] = Value(flags);
|
|
|
1f984a |
- Value parameters(p);
|
|
|
1f984a |
- Value response;
|
|
|
1f984a |
-
|
|
|
1f984a |
- int rc = rpc(c, "volume_replicate_range_block_size", parameters, response);
|
|
|
1f984a |
- if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
- if( Value::numeric_t == response.valueType() ) {
|
|
|
1f984a |
- *bs = response.asUint32_t();
|
|
|
1f984a |
+ try {
|
|
|
1f984a |
+ std::map<std::string, Value> p;
|
|
|
1f984a |
+ p["system"] = systemToValue(system);
|
|
|
1f984a |
+ p["flags"] = Value(flags);
|
|
|
1f984a |
+ Value parameters(p);
|
|
|
1f984a |
+ Value response;
|
|
|
1f984a |
+
|
|
|
1f984a |
+ rc = rpc(c, "volume_replicate_range_block_size", parameters, response);
|
|
|
1f984a |
+ if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
+ if( Value::numeric_t == response.valueType() ) {
|
|
|
1f984a |
+ *bs = response.asUint32_t();
|
|
|
1f984a |
+ }
|
|
|
1f984a |
}
|
|
|
1f984a |
+ } catch( const ValueException &ve ) {
|
|
|
1f984a |
+ rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type",
|
|
|
1f984a |
+ ve.what());
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
}
|
|
|
1f984a |
@@ -879,12 +1003,13 @@ int lsmVolumeReplicateRange(lsmConnect *c,
|
|
|
1f984a |
Value response;
|
|
|
1f984a |
|
|
|
1f984a |
int rc = rpc(c, "volume_replicate_range", parameters, response);
|
|
|
1f984a |
- return jobCheck(rc, response, job);
|
|
|
1f984a |
+ return jobCheck(c, rc, response, job);
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
int lsmVolumeDelete(lsmConnect *c, lsmVolume *volume, char **job,
|
|
|
1f984a |
lsmFlag_t flags)
|
|
|
1f984a |
{
|
|
|
1f984a |
+ int rc = 0;
|
|
|
1f984a |
CONN_SETUP(c);
|
|
|
1f984a |
|
|
|
1f984a |
if( !LSM_IS_VOL(volume) ) {
|
|
|
1f984a |
@@ -895,25 +1020,30 @@ int lsmVolumeDelete(lsmConnect *c, lsmVolume *volume, char **job,
|
|
|
1f984a |
return LSM_ERR_INVALID_ARGUMENT;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
- std::map<std::string, Value> p;
|
|
|
1f984a |
- p["volume"] = volumeToValue(volume);
|
|
|
1f984a |
- p["flags"] = Value(flags);
|
|
|
1f984a |
-
|
|
|
1f984a |
- Value parameters(p);
|
|
|
1f984a |
- Value response;
|
|
|
1f984a |
-
|
|
|
1f984a |
- int rc = rpc(c, "volume_delete", parameters, response);
|
|
|
1f984a |
- if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
- //We get a value back, either null or job id.
|
|
|
1f984a |
- if( Value::string_t == response.valueType() ) {
|
|
|
1f984a |
- *job = strdup(response.asString().c_str());
|
|
|
1f984a |
-
|
|
|
1f984a |
- if( *job ) {
|
|
|
1f984a |
- rc = LSM_ERR_JOB_STARTED;
|
|
|
1f984a |
- } else {
|
|
|
1f984a |
- rc = LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
+ try {
|
|
|
1f984a |
+ std::map<std::string, Value> p;
|
|
|
1f984a |
+ p["volume"] = volumeToValue(volume);
|
|
|
1f984a |
+ p["flags"] = Value(flags);
|
|
|
1f984a |
+
|
|
|
1f984a |
+ Value parameters(p);
|
|
|
1f984a |
+ Value response;
|
|
|
1f984a |
+
|
|
|
1f984a |
+ rc = rpc(c, "volume_delete", parameters, response);
|
|
|
1f984a |
+ if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
+ //We get a value back, either null or job id.
|
|
|
1f984a |
+ if( Value::string_t == response.valueType() ) {
|
|
|
1f984a |
+ *job = strdup(response.asString().c_str());
|
|
|
1f984a |
+
|
|
|
1f984a |
+ if( *job ) {
|
|
|
1f984a |
+ rc = LSM_ERR_JOB_STARTED;
|
|
|
1f984a |
+ } else {
|
|
|
1f984a |
+ rc = LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
+ }
|
|
|
1f984a |
}
|
|
|
1f984a |
}
|
|
|
1f984a |
+ } catch( const ValueException &ve ) {
|
|
|
1f984a |
+ rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type",
|
|
|
1f984a |
+ ve.what());
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
|
|
|
1f984a |
@@ -1026,7 +1156,7 @@ int lsmVolumesAccessibleByInitiator(lsmConnect *c,
|
|
|
1f984a |
Value response;
|
|
|
1f984a |
|
|
|
1f984a |
int rc = rpc(c, "volumes_accessible_by_initiator", parameters, response);
|
|
|
1f984a |
- return get_volume_array(rc, response, volumes, count);
|
|
|
1f984a |
+ return get_volume_array(c, rc, response, volumes, count);
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
int lsmInitiatorsGrantedToVolume(lsmConnect *c, lsmVolume *volume,
|
|
|
1f984a |
@@ -1050,7 +1180,7 @@ int lsmInitiatorsGrantedToVolume(lsmConnect *c, lsmVolume *volume,
|
|
|
1f984a |
Value response;
|
|
|
1f984a |
|
|
|
1f984a |
int rc = rpc(c, "initiators_granted_to_volume", parameters, response);
|
|
|
1f984a |
- return get_initiator_array(rc, response, initiators, count);
|
|
|
1f984a |
+ return get_initiator_array(c, rc, response, initiators, count);
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
|
|
|
1f984a |
@@ -1101,7 +1231,7 @@ int lsmAccessGroupList( lsmConnect *c, lsmAccessGroup **groups[],
|
|
|
1f984a |
Value response;
|
|
|
1f984a |
|
|
|
1f984a |
int rc = rpc(c, "access_group_list", parameters, response);
|
|
|
1f984a |
- return getAccessGroups(rc, response, groups, groupCount);
|
|
|
1f984a |
+ return getAccessGroups(c, rc, response, groups, groupCount);
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
int lsmAccessGroupCreate(lsmConnect *c, const char *name,
|
|
|
1f984a |
@@ -1279,6 +1409,7 @@ int lsmVolumesAccessibleByAccessGroup(lsmConnect *c,
|
|
|
1f984a |
lsmVolume **volumes[],
|
|
|
1f984a |
uint32_t *count, lsmFlag_t flags)
|
|
|
1f984a |
{
|
|
|
1f984a |
+ int rc = 0;
|
|
|
1f984a |
CONN_SETUP(c);
|
|
|
1f984a |
|
|
|
1f984a |
if( !LSM_IS_ACCESS_GROUP(group)) {
|
|
|
1f984a |
@@ -1289,26 +1420,36 @@ int lsmVolumesAccessibleByAccessGroup(lsmConnect *c,
|
|
|
1f984a |
return LSM_ERR_INVALID_ARGUMENT;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
- std::map<std::string, Value> p;
|
|
|
1f984a |
- p["group"] = accessGroupToValue(group);
|
|
|
1f984a |
- p["flags"] = Value(flags);
|
|
|
1f984a |
+ try {
|
|
|
1f984a |
+ std::map<std::string, Value> p;
|
|
|
1f984a |
+ p["group"] = accessGroupToValue(group);
|
|
|
1f984a |
+ p["flags"] = Value(flags);
|
|
|
1f984a |
|
|
|
1f984a |
- Value parameters(p);
|
|
|
1f984a |
- Value response;
|
|
|
1f984a |
+ Value parameters(p);
|
|
|
1f984a |
+ Value response;
|
|
|
1f984a |
|
|
|
1f984a |
- int rc = rpc(c, "volumes_accessible_by_access_group", parameters, response);
|
|
|
1f984a |
- if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) {
|
|
|
1f984a |
- std::vector<Value> vol = response.asArray();
|
|
|
1f984a |
+ rc = rpc(c, "volumes_accessible_by_access_group", parameters, response);
|
|
|
1f984a |
+ if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) {
|
|
|
1f984a |
+ std::vector<Value> vol = response.asArray();
|
|
|
1f984a |
|
|
|
1f984a |
- *count = vol.size();
|
|
|
1f984a |
+ *count = vol.size();
|
|
|
1f984a |
|
|
|
1f984a |
- if( vol.size() ) {
|
|
|
1f984a |
- *volumes = lsmVolumeRecordAllocArray(vol.size());
|
|
|
1f984a |
+ if( vol.size() ) {
|
|
|
1f984a |
+ *volumes = lsmVolumeRecordAllocArray(vol.size());
|
|
|
1f984a |
|
|
|
1f984a |
- for( size_t i = 0; i < vol.size(); ++i ) {
|
|
|
1f984a |
- (*volumes)[i] = valueToVolume(vol[i]);
|
|
|
1f984a |
+ for( size_t i = 0; i < vol.size(); ++i ) {
|
|
|
1f984a |
+ (*volumes)[i] = valueToVolume(vol[i]);
|
|
|
1f984a |
+ }
|
|
|
1f984a |
}
|
|
|
1f984a |
}
|
|
|
1f984a |
+ } catch( const ValueException &ve ) {
|
|
|
1f984a |
+ rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type",
|
|
|
1f984a |
+ ve.what());
|
|
|
1f984a |
+ if( *volumes && *count ) {
|
|
|
1f984a |
+ lsmVolumeRecordFreeArray(*volumes, *count);
|
|
|
1f984a |
+ *volumes = NULL;
|
|
|
1f984a |
+ *count = 0;
|
|
|
1f984a |
+ }
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
}
|
|
|
1f984a |
@@ -1336,12 +1477,13 @@ int lsmAccessGroupsGrantedToVolume(lsmConnect *c,
|
|
|
1f984a |
Value response;
|
|
|
1f984a |
|
|
|
1f984a |
int rc = rpc(c, "access_groups_granted_to_volume", parameters, response);
|
|
|
1f984a |
- return getAccessGroups(rc, response, groups, groupCount);
|
|
|
1f984a |
+ return getAccessGroups(c, rc, response, groups, groupCount);
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
int lsmVolumeChildDependency(lsmConnect *c, lsmVolume *volume,
|
|
|
1f984a |
uint8_t *yes, lsmFlag_t flags)
|
|
|
1f984a |
{
|
|
|
1f984a |
+ int rc = 0;
|
|
|
1f984a |
CONN_SETUP(c);
|
|
|
1f984a |
|
|
|
1f984a |
if( !LSM_IS_VOL(volume)) {
|
|
|
1f984a |
@@ -1352,25 +1494,30 @@ int lsmVolumeChildDependency(lsmConnect *c, lsmVolume *volume,
|
|
|
1f984a |
return LSM_ERR_INVALID_ARGUMENT;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
- std::map<std::string, Value> p;
|
|
|
1f984a |
- p["volume"] = volumeToValue(volume);
|
|
|
1f984a |
- p["flags"] = Value(flags);
|
|
|
1f984a |
+ try {
|
|
|
1f984a |
+ std::map<std::string, Value> p;
|
|
|
1f984a |
+ p["volume"] = volumeToValue(volume);
|
|
|
1f984a |
+ p["flags"] = Value(flags);
|
|
|
1f984a |
|
|
|
1f984a |
- Value parameters(p);
|
|
|
1f984a |
- Value response;
|
|
|
1f984a |
+ Value parameters(p);
|
|
|
1f984a |
+ Value response;
|
|
|
1f984a |
|
|
|
1f984a |
- *yes = 0;
|
|
|
1f984a |
+ *yes = 0;
|
|
|
1f984a |
|
|
|
1f984a |
- int rc = rpc(c, "volume_child_dependency", parameters, response);
|
|
|
1f984a |
- if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
- //We should be getting a boolean value back.
|
|
|
1f984a |
- if( Value::boolean_t == response.valueType() ) {
|
|
|
1f984a |
- if( response.asBool() ) {
|
|
|
1f984a |
- *yes = 1;
|
|
|
1f984a |
+ rc = rpc(c, "volume_child_dependency", parameters, response);
|
|
|
1f984a |
+ if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
+ //We should be getting a boolean value back.
|
|
|
1f984a |
+ if( Value::boolean_t == response.valueType() ) {
|
|
|
1f984a |
+ if( response.asBool() ) {
|
|
|
1f984a |
+ *yes = 1;
|
|
|
1f984a |
+ }
|
|
|
1f984a |
+ } else {
|
|
|
1f984a |
+ rc = LSM_ERR_INTERNAL_ERROR;
|
|
|
1f984a |
}
|
|
|
1f984a |
- } else {
|
|
|
1f984a |
- rc = LSM_ERR_INTERNAL_ERROR;
|
|
|
1f984a |
}
|
|
|
1f984a |
+ } catch( const ValueException &ve ) {
|
|
|
1f984a |
+ rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type",
|
|
|
1f984a |
+ ve.what());
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
}
|
|
|
1f984a |
@@ -1396,45 +1543,56 @@ int lsmVolumeChildDependencyRm(lsmConnect *c, lsmVolume *volume,
|
|
|
1f984a |
Value response;
|
|
|
1f984a |
|
|
|
1f984a |
int rc = rpc(c, "volume_child_dependency_rm", parameters, response);
|
|
|
1f984a |
- return jobCheck(rc, response, job);
|
|
|
1f984a |
+ return jobCheck(c, rc, response, job);
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
int lsmSystemList(lsmConnect *c, lsmSystem **systems[],
|
|
|
1f984a |
uint32_t *systemCount, lsmFlag_t flags)
|
|
|
1f984a |
{
|
|
|
1f984a |
+ int rc = 0;
|
|
|
1f984a |
CONN_SETUP(c);
|
|
|
1f984a |
|
|
|
1f984a |
if( !systems || ! systemCount || LSM_FLAG_UNUSED_CHECK(flags) ) {
|
|
|
1f984a |
return LSM_ERR_INVALID_ARGUMENT;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
- std::map<std::string, Value> p;
|
|
|
1f984a |
- p["flags"] = Value(flags);
|
|
|
1f984a |
- Value parameters(p);
|
|
|
1f984a |
- Value response;
|
|
|
1f984a |
-
|
|
|
1f984a |
- int rc = rpc(c, "systems", parameters, response);
|
|
|
1f984a |
- if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) {
|
|
|
1f984a |
- std::vector<Value> sys = response.asArray();
|
|
|
1f984a |
-
|
|
|
1f984a |
- *systemCount = sys.size();
|
|
|
1f984a |
-
|
|
|
1f984a |
- if( sys.size() ) {
|
|
|
1f984a |
- *systems = lsmSystemRecordAllocArray(sys.size());
|
|
|
1f984a |
-
|
|
|
1f984a |
- if( *systems ) {
|
|
|
1f984a |
- for( size_t i = 0; i < sys.size(); ++i ) {
|
|
|
1f984a |
- (*systems)[i] = valueToSystem(sys[i]);
|
|
|
1f984a |
- if( !(*systems)[i] ) {
|
|
|
1f984a |
- lsmSystemRecordFreeArray(*systems, i);
|
|
|
1f984a |
- rc = LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
- break;
|
|
|
1f984a |
+ try {
|
|
|
1f984a |
+ std::map<std::string, Value> p;
|
|
|
1f984a |
+ p["flags"] = Value(flags);
|
|
|
1f984a |
+ Value parameters(p);
|
|
|
1f984a |
+ Value response;
|
|
|
1f984a |
+
|
|
|
1f984a |
+ rc = rpc(c, "systems", parameters, response);
|
|
|
1f984a |
+ if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) {
|
|
|
1f984a |
+ std::vector<Value> sys = response.asArray();
|
|
|
1f984a |
+
|
|
|
1f984a |
+ *systemCount = sys.size();
|
|
|
1f984a |
+
|
|
|
1f984a |
+ if( sys.size() ) {
|
|
|
1f984a |
+ *systems = lsmSystemRecordAllocArray(sys.size());
|
|
|
1f984a |
+
|
|
|
1f984a |
+ if( *systems ) {
|
|
|
1f984a |
+ for( size_t i = 0; i < sys.size(); ++i ) {
|
|
|
1f984a |
+ (*systems)[i] = valueToSystem(sys[i]);
|
|
|
1f984a |
+ if( !(*systems)[i] ) {
|
|
|
1f984a |
+ lsmSystemRecordFreeArray(*systems, i);
|
|
|
1f984a |
+ rc = LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
+ break;
|
|
|
1f984a |
+ }
|
|
|
1f984a |
}
|
|
|
1f984a |
+ } else {
|
|
|
1f984a |
+ rc = LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
}
|
|
|
1f984a |
- } else {
|
|
|
1f984a |
- rc = LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
}
|
|
|
1f984a |
}
|
|
|
1f984a |
+ } catch( const ValueException &ve ) {
|
|
|
1f984a |
+ rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type",
|
|
|
1f984a |
+ ve.what());
|
|
|
1f984a |
+ if( *systems ) {
|
|
|
1f984a |
+ lsmSystemRecordFreeArray( *systems, *systemCount);
|
|
|
1f984a |
+ *systems = NULL;
|
|
|
1f984a |
+ *systemCount = 0;
|
|
|
1f984a |
+ }
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
}
|
|
|
1f984a |
@@ -1442,30 +1600,45 @@ int lsmSystemList(lsmConnect *c, lsmSystem **systems[],
|
|
|
1f984a |
int lsmFsList(lsmConnect *c, lsmFs **fs[], uint32_t *fsCount,
|
|
|
1f984a |
lsmFlag_t flags)
|
|
|
1f984a |
{
|
|
|
1f984a |
+ int rc = 0;
|
|
|
1f984a |
CONN_SETUP(c);
|
|
|
1f984a |
|
|
|
1f984a |
if( !fs || !fsCount || LSM_FLAG_UNUSED_CHECK(flags) ) {
|
|
|
1f984a |
return LSM_ERR_INVALID_ARGUMENT;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
- std::map<std::string, Value> p;
|
|
|
1f984a |
- p["flags"] = Value(flags);
|
|
|
1f984a |
- Value parameters(p);
|
|
|
1f984a |
- Value response;
|
|
|
1f984a |
+ try {
|
|
|
1f984a |
+ std::map<std::string, Value> p;
|
|
|
1f984a |
+ p["flags"] = Value(flags);
|
|
|
1f984a |
+ Value parameters(p);
|
|
|
1f984a |
+ Value response;
|
|
|
1f984a |
|
|
|
1f984a |
- int rc = rpc(c, "fs", parameters, response);
|
|
|
1f984a |
- if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) {
|
|
|
1f984a |
- std::vector<Value> sys = response.asArray();
|
|
|
1f984a |
+ rc = rpc(c, "fs", parameters, response);
|
|
|
1f984a |
+ if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) {
|
|
|
1f984a |
+ std::vector<Value> sys = response.asArray();
|
|
|
1f984a |
|
|
|
1f984a |
- *fsCount = sys.size();
|
|
|
1f984a |
+ *fsCount = sys.size();
|
|
|
1f984a |
|
|
|
1f984a |
- if( sys.size() ) {
|
|
|
1f984a |
- *fs = lsmFsRecordAllocArray(sys.size());
|
|
|
1f984a |
+ if( sys.size() ) {
|
|
|
1f984a |
+ *fs = lsmFsRecordAllocArray(sys.size());
|
|
|
1f984a |
|
|
|
1f984a |
- for( size_t i = 0; i < sys.size(); ++i ) {
|
|
|
1f984a |
- (*fs)[i] = valueToFs(sys[i]);
|
|
|
1f984a |
+ if( *fs ) {
|
|
|
1f984a |
+ for( size_t i = 0; i < sys.size(); ++i ) {
|
|
|
1f984a |
+ (*fs)[i] = valueToFs(sys[i]);
|
|
|
1f984a |
+ }
|
|
|
1f984a |
+ } else {
|
|
|
1f984a |
+ rc = LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
+ }
|
|
|
1f984a |
}
|
|
|
1f984a |
}
|
|
|
1f984a |
+ } catch( const ValueException &ve ) {
|
|
|
1f984a |
+ rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type",
|
|
|
1f984a |
+ ve.what());
|
|
|
1f984a |
+ if( *fs && *fsCount) {
|
|
|
1f984a |
+ lsmFsRecordFreeArray(*fs, *fsCount);
|
|
|
1f984a |
+ *fs = NULL;
|
|
|
1f984a |
+ *fsCount = 0;
|
|
|
1f984a |
+ }
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
|
|
|
1f984a |
@@ -1497,7 +1670,7 @@ int lsmFsCreate(lsmConnect *c, lsmPool *pool, const char *name,
|
|
|
1f984a |
|
|
|
1f984a |
int rc = rpc(c, "fs_create", parameters, response);
|
|
|
1f984a |
if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
- *fs = (lsmFs *)parse_job_response(response, rc, job,
|
|
|
1f984a |
+ *fs = (lsmFs *)parse_job_response(c, response, rc, job,
|
|
|
1f984a |
(convert)valueToFs);
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
@@ -1523,7 +1696,7 @@ int lsmFsDelete(lsmConnect *c, lsmFs *fs, char **job, lsmFlag_t flags)
|
|
|
1f984a |
Value response;
|
|
|
1f984a |
|
|
|
1f984a |
int rc = rpc(c, "fs_delete", parameters, response);
|
|
|
1f984a |
- return jobCheck(rc, response, job);
|
|
|
1f984a |
+ return jobCheck(c, rc, response, job);
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
|
|
|
1f984a |
@@ -1551,7 +1724,7 @@ int lsmFsResize(lsmConnect *c, lsmFs *fs,
|
|
|
1f984a |
|
|
|
1f984a |
int rc = rpc(c, "fs_resize", parameters, response);
|
|
|
1f984a |
if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
- *rfs = (lsmFs *)parse_job_response(response, rc, job,
|
|
|
1f984a |
+ *rfs = (lsmFs *)parse_job_response(c, response, rc, job,
|
|
|
1f984a |
(convert)valueToFs);
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
@@ -1583,7 +1756,7 @@ int lsmFsClone(lsmConnect *c, lsmFs *src_fs,
|
|
|
1f984a |
|
|
|
1f984a |
int rc = rpc(c, "fs_clone", parameters, response);
|
|
|
1f984a |
if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
- *cloned_fs = (lsmFs *)parse_job_response(response, rc, job,
|
|
|
1f984a |
+ *cloned_fs = (lsmFs *)parse_job_response(c, response, rc, job,
|
|
|
1f984a |
(convert)valueToFs);
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
@@ -1615,12 +1788,13 @@ int lsmFsFileClone(lsmConnect *c, lsmFs *fs, const char *src_file_name,
|
|
|
1f984a |
Value response;
|
|
|
1f984a |
|
|
|
1f984a |
int rc = rpc(c, "file_clone", parameters, response);
|
|
|
1f984a |
- return jobCheck(rc, response, job);
|
|
|
1f984a |
+ return jobCheck(c, rc, response, job);
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
int lsmFsChildDependency( lsmConnect *c, lsmFs *fs, lsmStringList *files,
|
|
|
1f984a |
uint8_t *yes, lsmFlag_t flags)
|
|
|
1f984a |
{
|
|
|
1f984a |
+ int rc = 0;
|
|
|
1f984a |
CONN_SETUP(c);
|
|
|
1f984a |
|
|
|
1f984a |
if( !LSM_IS_FS(fs) ) {
|
|
|
1f984a |
@@ -1637,26 +1811,31 @@ int lsmFsChildDependency( lsmConnect *c, lsmFs *fs, lsmStringList *files,
|
|
|
1f984a |
return LSM_ERR_INVALID_ARGUMENT;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
- std::map<std::string, Value> p;
|
|
|
1f984a |
- p["fs"] = fsToValue(fs);
|
|
|
1f984a |
- p["files"] = stringListToValue(files);
|
|
|
1f984a |
- p["flags"] = Value(flags);
|
|
|
1f984a |
-
|
|
|
1f984a |
- Value parameters(p);
|
|
|
1f984a |
- Value response;
|
|
|
1f984a |
-
|
|
|
1f984a |
- *yes = 0;
|
|
|
1f984a |
-
|
|
|
1f984a |
- int rc = rpc(c, "fs_child_dependency", parameters, response);
|
|
|
1f984a |
- if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
- //We should be getting a boolean value back.
|
|
|
1f984a |
- if( Value::boolean_t == response.valueType() ) {
|
|
|
1f984a |
- if( response.asBool() ) {
|
|
|
1f984a |
- *yes = 1;
|
|
|
1f984a |
+ try {
|
|
|
1f984a |
+ std::map<std::string, Value> p;
|
|
|
1f984a |
+ p["fs"] = fsToValue(fs);
|
|
|
1f984a |
+ p["files"] = stringListToValue(files);
|
|
|
1f984a |
+ p["flags"] = Value(flags);
|
|
|
1f984a |
+
|
|
|
1f984a |
+ Value parameters(p);
|
|
|
1f984a |
+ Value response;
|
|
|
1f984a |
+
|
|
|
1f984a |
+ *yes = 0;
|
|
|
1f984a |
+
|
|
|
1f984a |
+ rc = rpc(c, "fs_child_dependency", parameters, response);
|
|
|
1f984a |
+ if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
+ //We should be getting a boolean value back.
|
|
|
1f984a |
+ if( Value::boolean_t == response.valueType() ) {
|
|
|
1f984a |
+ if( response.asBool() ) {
|
|
|
1f984a |
+ *yes = 1;
|
|
|
1f984a |
+ }
|
|
|
1f984a |
+ } else {
|
|
|
1f984a |
+ rc = LSM_ERR_INTERNAL_ERROR;
|
|
|
1f984a |
}
|
|
|
1f984a |
- } else {
|
|
|
1f984a |
- rc = LSM_ERR_INTERNAL_ERROR;
|
|
|
1f984a |
}
|
|
|
1f984a |
+ } catch( const ValueException &ve ) {
|
|
|
1f984a |
+ rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type",
|
|
|
1f984a |
+ ve.what());
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
}
|
|
|
1f984a |
@@ -1689,12 +1868,13 @@ int lsmFsChildDependencyRm( lsmConnect *c, lsmFs *fs, lsmStringList *files,
|
|
|
1f984a |
Value response;
|
|
|
1f984a |
|
|
|
1f984a |
int rc = rpc(c, "fs_child_dependency_rm", parameters, response);
|
|
|
1f984a |
- return jobCheck(rc, response, job);
|
|
|
1f984a |
+ return jobCheck(c, rc, response, job);
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
int lsmFsSsList(lsmConnect *c, lsmFs *fs, lsmSs **ss[],
|
|
|
1f984a |
uint32_t *ssCount, lsmFlag_t flags )
|
|
|
1f984a |
{
|
|
|
1f984a |
+ int rc = 0;
|
|
|
1f984a |
CONN_SETUP(c);
|
|
|
1f984a |
|
|
|
1f984a |
if( !LSM_IS_FS(fs) ) {
|
|
|
1f984a |
@@ -1712,19 +1892,33 @@ int lsmFsSsList(lsmConnect *c, lsmFs *fs, lsmSs **ss[],
|
|
|
1f984a |
Value parameters(p);
|
|
|
1f984a |
Value response;
|
|
|
1f984a |
|
|
|
1f984a |
- int rc = rpc(c, "fs_snapshots", parameters, response);
|
|
|
1f984a |
- if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) {
|
|
|
1f984a |
- std::vector<Value> sys = response.asArray();
|
|
|
1f984a |
+ try {
|
|
|
1f984a |
+ rc = rpc(c, "fs_snapshots", parameters, response);
|
|
|
1f984a |
+ if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) {
|
|
|
1f984a |
+ std::vector<Value> sys = response.asArray();
|
|
|
1f984a |
|
|
|
1f984a |
- *ssCount = sys.size();
|
|
|
1f984a |
+ *ssCount = sys.size();
|
|
|
1f984a |
|
|
|
1f984a |
- if( sys.size() ) {
|
|
|
1f984a |
- *ss = lsmSsRecordAllocArray(sys.size());
|
|
|
1f984a |
+ if( sys.size() ) {
|
|
|
1f984a |
+ *ss = lsmSsRecordAllocArray(sys.size());
|
|
|
1f984a |
|
|
|
1f984a |
- for( size_t i = 0; i < sys.size(); ++i ) {
|
|
|
1f984a |
- (*ss)[i] = valueToSs(sys[i]);
|
|
|
1f984a |
+ if( *ss ) {
|
|
|
1f984a |
+ for( size_t i = 0; i < sys.size(); ++i ) {
|
|
|
1f984a |
+ (*ss)[i] = valueToSs(sys[i]);
|
|
|
1f984a |
+ }
|
|
|
1f984a |
+ } else {
|
|
|
1f984a |
+ rc = LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
+ }
|
|
|
1f984a |
}
|
|
|
1f984a |
}
|
|
|
1f984a |
+ } catch( const ValueException &ve ) {
|
|
|
1f984a |
+ rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type",
|
|
|
1f984a |
+ ve.what());
|
|
|
1f984a |
+ if( *ss && *ssCount ) {
|
|
|
1f984a |
+ lsmSsRecordFreeArray(*ss, *ssCount);
|
|
|
1f984a |
+ *ss = NULL;
|
|
|
1f984a |
+ *ssCount = 0;
|
|
|
1f984a |
+ }
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
|
|
|
1f984a |
@@ -1761,7 +1955,7 @@ int lsmFsSsCreate(lsmConnect *c, lsmFs *fs, const char *name,
|
|
|
1f984a |
|
|
|
1f984a |
int rc = rpc(c, "fs_snapshot_create", parameters, response);
|
|
|
1f984a |
if( LSM_ERR_OK == rc ) {
|
|
|
1f984a |
- *snapshot = (lsmSs *)parse_job_response(response, rc, job,
|
|
|
1f984a |
+ *snapshot = (lsmSs *)parse_job_response(c, response, rc, job,
|
|
|
1f984a |
(convert)valueToSs);
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
@@ -1793,7 +1987,7 @@ int lsmFsSsDelete(lsmConnect *c, lsmFs *fs, lsmSs *ss, char **job,
|
|
|
1f984a |
Value response;
|
|
|
1f984a |
|
|
|
1f984a |
int rc = rpc(c, "fs_snapshot_delete", parameters, response);
|
|
|
1f984a |
- return jobCheck(rc, response, job);
|
|
|
1f984a |
+ return jobCheck(c, rc, response, job);
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
int lsmFsSsRevert(lsmConnect *c, lsmFs *fs, lsmSs *ss,
|
|
|
1f984a |
@@ -1839,37 +2033,52 @@ int lsmFsSsRevert(lsmConnect *c, lsmFs *fs, lsmSs *ss,
|
|
|
1f984a |
Value response;
|
|
|
1f984a |
|
|
|
1f984a |
int rc = rpc(c, "fs_snapshot_revert", parameters, response);
|
|
|
1f984a |
- return jobCheck(rc, response, job);
|
|
|
1f984a |
+ return jobCheck(c, rc, response, job);
|
|
|
1f984a |
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
int lsmNfsList( lsmConnect *c, lsmNfsExport **exports[], uint32_t *count,
|
|
|
1f984a |
lsmFlag_t flags)
|
|
|
1f984a |
{
|
|
|
1f984a |
+ int rc = 0;
|
|
|
1f984a |
CONN_SETUP(c);
|
|
|
1f984a |
|
|
|
1f984a |
if( CHECK_RP(exports) || !count || LSM_FLAG_UNUSED_CHECK(flags) ) {
|
|
|
1f984a |
return LSM_ERR_INVALID_ARGUMENT;
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
- std::map<std::string, Value> p;
|
|
|
1f984a |
- p["flags"] = Value(flags);
|
|
|
1f984a |
- Value parameters(p);
|
|
|
1f984a |
- Value response;
|
|
|
1f984a |
+ try {
|
|
|
1f984a |
+ std::map<std::string, Value> p;
|
|
|
1f984a |
+ p["flags"] = Value(flags);
|
|
|
1f984a |
+ Value parameters(p);
|
|
|
1f984a |
+ Value response;
|
|
|
1f984a |
|
|
|
1f984a |
- int rc = rpc(c, "exports", parameters, response);
|
|
|
1f984a |
- if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) {
|
|
|
1f984a |
- std::vector<Value> exps = response.asArray();
|
|
|
1f984a |
+ rc = rpc(c, "exports", parameters, response);
|
|
|
1f984a |
+ if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) {
|
|
|
1f984a |
+ std::vector<Value> exps = response.asArray();
|
|
|
1f984a |
|
|
|
1f984a |
- *count = exps.size();
|
|
|
1f984a |
+ *count = exps.size();
|
|
|
1f984a |
|
|
|
1f984a |
- if( *count ) {
|
|
|
1f984a |
- *exports = lsmNfsExportRecordAllocArray(*count);
|
|
|
1f984a |
+ if( *count ) {
|
|
|
1f984a |
+ *exports = lsmNfsExportRecordAllocArray(*count);
|
|
|
1f984a |
|
|
|
1f984a |
- for( size_t i = 0; i < *count; ++i ) {
|
|
|
1f984a |
- (*exports)[i] = valueToNfsExport(exps[i]);
|
|
|
1f984a |
+ if( *exports ) {
|
|
|
1f984a |
+ for( size_t i = 0; i < *count; ++i ) {
|
|
|
1f984a |
+ (*exports)[i] = valueToNfsExport(exps[i]);
|
|
|
1f984a |
+ }
|
|
|
1f984a |
+ } else {
|
|
|
1f984a |
+ rc = LSM_ERR_NO_MEMORY;
|
|
|
1f984a |
+ }
|
|
|
1f984a |
}
|
|
|
1f984a |
}
|
|
|
1f984a |
+ } catch( const ValueException &ve ) {
|
|
|
1f984a |
+ rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type",
|
|
|
1f984a |
+ ve.what());
|
|
|
1f984a |
+ if( *exports && *count ) {
|
|
|
1f984a |
+ lsmNfsExportRecordFreeArray( *exports, *count );
|
|
|
1f984a |
+ *exports = NULL;
|
|
|
1f984a |
+ *count = 0;
|
|
|
1f984a |
+ }
|
|
|
1f984a |
}
|
|
|
1f984a |
return rc;
|
|
|
1f984a |
}
|
|
|
1f984a |
diff --git src/lsm_plugin_ipc.cpp src/lsm_plugin_ipc.cpp
|
|
|
1f984a |
index c23806c..c68a742 100644
|
|
|
1f984a |
--- src/lsm_plugin_ipc.cpp
|
|
|
1f984a |
+++ src/lsm_plugin_ipc.cpp
|
|
|
1f984a |
@@ -257,20 +257,20 @@ static int handle_startup(lsmPluginPtr p, Value ¶ms, Value &response)
|
|
|
1f984a |
{
|
|
|
1f984a |
int rc = LSM_ERR_NO_SUPPORT;
|
|
|
1f984a |
xmlURIPtr uri = NULL;
|
|
|
1f984a |
+ std::string uri_string = params["uri"].asString();
|
|
|
1f984a |
+ std::string password;
|
|
|
1f984a |
|
|
|
1f984a |
if( p ) {
|
|
|
1f984a |
- uri = xmlParseURI(params["uri"].asString().c_str());
|
|
|
1f984a |
+ uri = xmlParseURI(uri_string.c_str());
|
|
|
1f984a |
if( uri ) {
|
|
|
1f984a |
- const char *pass = NULL;
|
|
|
1f984a |
-
|
|
|
1f984a |
lsmFlag_t flags = LSM_FLAG_GET_VALUE(params);
|
|
|
1f984a |
|
|
|
1f984a |
if( Value::string_t == params["password"].valueType() ) {
|
|
|
1f984a |
- pass = params["password"].asString().c_str();
|
|
|
1f984a |
+ password = params["password"].asString();
|
|
|
1f984a |
}
|
|
|
1f984a |
|
|
|
1f984a |
//Let the plug-in initialize itself.
|
|
|
1f984a |
- rc = p->reg(p, uri, pass, params["timeout"].asUint32_t(),
|
|
|
1f984a |
+ rc = p->reg(p, uri, password.c_str(), params["timeout"].asUint32_t(),
|
|
|
1f984a |
flags);
|
|
|
1f984a |
xmlFreeURI(uri);
|
|
|
1f984a |
uri = NULL;
|
|
|
1f984a |
@@ -314,7 +314,7 @@ static int handle_get_time_out( lsmPluginPtr p, Value ¶ms, Value &response)
|
|
|
1f984a |
|
|
|
1f984a |
static int handle_job_status( lsmPluginPtr p, Value ¶ms, Value &response)
|
|
|
1f984a |
{
|
|
|
1f984a |
- const char *job_id = NULL;
|
|
|
1f984a |
+ std::string job_id;
|
|
|
1f984a |
lsmJobStatus status;
|
|
|
1f984a |
uint8_t percent;
|
|
|
1f984a |
lsmDataType t = LSM_DATA_TYPE_UNKNOWN;
|
|
|
1f984a |
@@ -328,9 +328,9 @@ static int handle_job_status( lsmPluginPtr p, Value ¶ms, Value &response)
|
|
|
1f984a |
rc = LSM_ERR_TRANSPORT_INVALID_ARG;
|
|
|
1f984a |
} else {
|
|
|
1f984a |
|
|
|
1f984a |
- job_id = params["job_id"].asString().c_str();
|
|
|
1f984a |
+ job_id = params["job_id"].asString();
|
|
|
1f984a |
|
|
|
1f984a |
- rc = p->mgmtOps->job_status(p, job_id, &status, &percent, &t,
|
|
|
1f984a |
+ rc = p->mgmtOps->job_status(p, job_id.c_str(), &status, &percent, &t,
|
|
|
1f984a |
&value, LSM_FLAG_GET_VALUE(params));
|
|
|
1f984a |
|
|
|
1f984a |
if( LSM_ERR_OK == rc) {
|