Discussion:
[Libstoragemgmt-devel] [PATCH 00/15] To be committed
Tony Asleson
2014-04-15 21:46:54 UTC
Permalink
This is the uncommitted patches that I have. Please
review and see if all looks good. If I get no feedback I'm
going to push as too much is getting outstanding.

This set includes some patches from Gris which I edited to
include the C bits and have them pass tests. Gris, please
let me know if you're OK with these changes. Otherwise
submit your changes and I will rebase mine.

Thanks,
Tony


Gris Ge (2):
expose size_bytes_2_size_human() out
update Python lsm.System class base on Python API wiki V2

Tony Asleson (13):
plugin_test.py: Add more test coverage
_iplugin.py: Remove abstract base class from some classes
Move plugin/util to src/util
C API: Add function lsm_uri_parse
Misc. fixes for system status changes & display changes
PY & C API: Change snapshots to refer to fs snapshots
python: Rename access_group_list to access_groups
PY & C API: Make pool status_info mandatory
PY & C API: Remove Pool STATUS_OFFLINE
PY & C API: pool_create* take system instead of system_id
PY & C API: pool_create_from_pool use pool obj.
PY & C API: pool_create_from_[disks|volumes] to use objs.
tester.c: Rename camel case functions

include/libstoragemgmt/libstoragemgmt.h | 49 +--
.../libstoragemgmt/libstoragemgmt_plug_interface.h | 103 +++---
include/libstoragemgmt/libstoragemgmt_pool.h | 7 +
include/libstoragemgmt/libstoragemgmt_snapshot.h | 24 +-
include/libstoragemgmt/libstoragemgmt_types.h | 20 +-
libstoragemgmt.spec.in | 1 +
lsm/Makefile.am | 1 +
lsm/lsm/__init__.py | 4 +-
lsm/lsm/_client.py | 24 +-
lsm/lsm/_cmdline.py | 75 +++--
lsm/lsm/_data.py | 137 +++++---
lsm/lsm/_iplugin.py | 171 +++++-----
lsm/lsm/ibmv7k.py | 4 +-
lsm/lsm/lsmcli_data_display.py | 347 +++++++++++++++++++++
lsm/lsm/nstor.py | 41 +--
lsm/lsm/ontap.py | 29 +-
lsm/lsm/simarray.py | 24 +-
lsm/lsm/simulator.py | 20 +-
lsm/lsm/smis.py | 57 +---
lsm/lsm/targetd.py | 89 +-----
plugin/simc_lsmplugin.c | 82 +++--
plugin/util/misc.cpp | 48 ---
plugin/util/misc.h | 109 -------
plugin/util/qparams.c | 242 --------------
plugin/util/qparams.h | 104 ------
src/Makefile.am | 3 +-
src/lsm_convert.cpp | 87 +++++-
src/lsm_convert.hpp | 16 +-
src/lsm_datatypes.cpp | 62 ++--
src/lsm_datatypes.hpp | 4 +-
src/lsm_mgmt.cpp | 118 ++++---
src/lsm_plugin_ipc.cpp | 259 ++++++++++-----
src/util/misc.cpp | 48 +++
src/util/misc.h | 108 +++++++
src/util/qparams.c | 242 ++++++++++++++
src/util/qparams.h | 88 ++++++
test/cmdtest.py | 2 +-
test/plugin_test.py | 246 +++++++++++++--
test/tester.c | 244 +++++++++------
39 files changed, 2081 insertions(+), 1258 deletions(-)
create mode 100644 lsm/lsm/lsmcli_data_display.py
delete mode 100644 plugin/util/misc.cpp
delete mode 100644 plugin/util/misc.h
delete mode 100644 plugin/util/qparams.c
delete mode 100644 plugin/util/qparams.h
create mode 100644 src/util/misc.cpp
create mode 100644 src/util/misc.h
create mode 100644 src/util/qparams.c
create mode 100644 src/util/qparams.h
--
1.8.2.1
Tony Asleson
2014-04-15 21:46:57 UTC
Permalink
Signed-off-by: Tony Asleson <***@redhat.com>
---
plugin/util/misc.cpp | 48 ----------
plugin/util/misc.h | 109 -----------------------
plugin/util/qparams.c | 242 --------------------------------------------------
plugin/util/qparams.h | 104 ----------------------
src/util/misc.cpp | 48 ++++++++++
src/util/misc.h | 108 ++++++++++++++++++++++
src/util/qparams.c | 242 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/util/qparams.h | 102 +++++++++++++++++++++
8 files changed, 500 insertions(+), 503 deletions(-)
delete mode 100644 plugin/util/misc.cpp
delete mode 100644 plugin/util/misc.h
delete mode 100644 plugin/util/qparams.c
delete mode 100644 plugin/util/qparams.h
create mode 100644 src/util/misc.cpp
create mode 100644 src/util/misc.h
create mode 100644 src/util/qparams.c
create mode 100644 src/util/qparams.h

diff --git a/plugin/util/misc.cpp b/plugin/util/misc.cpp
deleted file mode 100644
index e5e13c5..0000000
--- a/plugin/util/misc.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2011-2013 Red Hat, Inc.
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Author: tasleson
- */
-
-#include "misc.h"
-#include "qparams.h"
-#include <string>
-#include <string.h>
-
-namespace LSM {
-
-std::string getValue(std::string uri, std::string key)
-{
- int i;
- std::string rc;
- struct qparam_set *queryParamSet = NULL;
-
- queryParamSet = qparam_query_parse(uri.c_str());
- if( NULL == queryParamSet ) {
- return rc;
- } else {
- for( i = 0; i < queryParamSet->n; ++i ) {
- if(strcmp(queryParamSet->p[i].name, key.c_str()) == 0 ) {
- rc = queryParamSet->p[i].value;
- break;
- }
- }
- free_qparam_set(queryParamSet);
- }
- return rc;
-}
-
-}
\ No newline at end of file
diff --git a/plugin/util/misc.h b/plugin/util/misc.h
deleted file mode 100644
index 678d826..0000000
--- a/plugin/util/misc.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2011-2013 Red Hat, Inc.
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Author: tasleson
- */
-
-#ifndef MISC_H
-#define MISC_H
-#include <string>
-#include <map>
-#include <stdint.h>
-
-#include <libstoragemgmt/libstoragemgmt_common.h>
-
-namespace LSM {
-
-/**
- * Retrieve the first value that matches key from a query string
- * @param query_string Query String to parse.
- * @param key Key to look for
- * @return empty string if key not found, else returns value.
- */
-LSM_DLL_LOCAL std::string getValue(std::string query_string, std::string key);
-
-/**
- * Simple class used to store jobs in an associative array.
- * @param t Type you want to associate with an integer.
- * @return
- */
-template <class Type>
-class LSM_DLL_LOCAL JobControl {
-
-public:
-
- /**
- * Ctor
- */
- JobControl():ticket(0)
- {
- }
-
- /**
- * Adds an item to the collection.
- * @param t Type to add.
- * @return Index it was inserted at.
- */
- int insert( Type t )
- {
- jobs[++ticket] = t;
- return ticket;
- }
-
- /**
- * Returns item at index num.
- * @param num Key
- * @return Item
- */
- Type get(uint32_t num)
- {
- return getInt(num)->second;
- }
-
- /**
- * Checks to see if an item is present.
- * @param num Key
- * @return true if key exists, else false.
- */
- bool present(uint32_t num)
- {
- return ( getInt(num) != jobs.end());
- }
-
- /**
- * Removes an item.
- * @param num Key
- */
- void remove(uint32_t num)
- {
- jobs.erase(getInt(num));
- }
-
-private:
- typename std::map<uint32_t, Type>::iterator getInt(uint32_t num )
- {
- typename std::map<uint32_t, Type>::iterator i = jobs.find(num);
- return i;
- }
- uint32_t ticket;
- std::map<uint32_t , Type> jobs;
-};
-
-} //End namespace
-
-
-#endif /* MISC_H */
-
diff --git a/plugin/util/qparams.c b/plugin/util/qparams.c
deleted file mode 100644
index dc42dae..0000000
--- a/plugin/util/qparams.c
+++ /dev/null
@@ -1,242 +0,0 @@
-/* Copyright (C) 2007, 2009-2011 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Authors:
- * Richard W.M. Jones <***@redhat.com>
- *
- * Utility functions to help parse and assemble query strings.
- *
- *
- *
- * !!!NOTE!!!: Taken from libvirt and modified to remove libvirt coupling.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-#include <libxml/uri.h>
-#include "qparams.h"
-#include <string.h>
-
-struct qparam_set *
-new_qparam_set (int init_alloc, ...)
-{
- va_list args;
- struct qparam_set *ps;
- const char *pname, *pvalue;
-
- if (init_alloc <= 0) init_alloc = 1;
-
-
- ps = (struct qparam_set *)calloc( 1, sizeof(*(ps)));
- if( !ps ) {
- return NULL;
- }
-
- ps->n = 0;
- ps->alloc = init_alloc;
-
- ps->p = (struct qparam *) calloc( ps->alloc, sizeof(*(ps->p)));
-
- if (!ps->p) {
- free(ps);
- return NULL;
- }
-
- va_start (args, init_alloc);
- while ((pname = va_arg (args, char *)) != NULL) {
- pvalue = va_arg (args, char *);
-
- if (append_qparam (ps, pname, pvalue) == -1) {
- free_qparam_set (ps);
- ps = NULL;
- break;
- }
- }
- va_end (args);
-
- return ps;
-}
-
-int
-append_qparams (struct qparam_set *ps, ...)
-{
- va_list args;
- const char *pname, *pvalue;
- int ret = 0;
-
- va_start (args, ps);
- while ((pname = va_arg (args, char *)) != NULL) {
- pvalue = va_arg (args, char *);
-
- if (append_qparam (ps, pname, pvalue) == -1) {
- ret = -1;
- break;
- }
- }
- va_end (args);
-
- return ret;
-}
-
-/* Ensure there is space to store at least one more parameter
- * at the end of the set.
- */
-static int
-grow_qparam_set (struct qparam_set *ps)
-{
- if (ps->n >= ps->alloc) {
-
- void *tmp = realloc( ps->p, ps->alloc * 2);
- if( !tmp ) {
- return -1;
- }
- ps->p = (struct qparam *)tmp;
- ps->alloc *= 2;
- }
-
- return 0;
-}
-
-int
-append_qparam (struct qparam_set *ps,
- const char *name, const char *value)
-{
- char *pname, *pvalue;
-
- pname = strdup (name);
- if (!pname) {
- return -1;
- }
-
- pvalue = strdup (value);
- if (!pvalue) {
- free(pname);
- return -1;
- }
-
- if (grow_qparam_set (ps) == -1) {
- free(pname);
- free(pvalue);
- return -1;
- }
-
- ps->p[ps->n].name = pname;
- ps->p[ps->n].value = pvalue;
- ps->p[ps->n].ignore = 0;
- ps->n++;
-
- return 0;
-}
-
-void
-free_qparam_set (struct qparam_set *ps)
-{
- int i;
-
- for (i = 0; i < ps->n; ++i) {
- free(ps->p[i].name);
- free(ps->p[i].value);
- }
- free(ps->p);
- ps->p = NULL;
- free(ps);
-}
-
-struct qparam_set *
-qparam_query_parse (const char *query)
-{
- struct qparam_set *ps;
- const char *end, *eq;
-
- ps = new_qparam_set (0, NULL);
- if (!ps) {
- return NULL;
- }
-
- if (!query || query[0] == '\0') return ps;
-
- while (*query) {
- char *name = NULL, *value = NULL;
-
- /* Find the next separator, or end of the string. */
- end = strchr (query, '&');
- if (!end)
- end = strchr (query, ';');
- if (!end)
- end = query + strlen (query);
-
- /* Find the first '=' character between here and end. */
- eq = strchr (query, '=');
- if (eq && eq >= end) eq = NULL;
-
- /* Empty section (eg. "&&"). */
- if (end == query)
- goto next;
-
- /* If there is no '=' character, then we have just "name"
- * and consistent with CGI.pm we assume value is "".
- */
- else if (!eq) {
- name = xmlURIUnescapeString (query, end - query, NULL);
- if (!name) goto out_of_memory;
- }
- /* Or if we have "name=" here (works around annoying
- * problem when calling xmlURIUnescapeString with len = 0).
- */
- else if (eq+1 == end) {
- name = xmlURIUnescapeString (query, eq - query, NULL);
- if (!name) goto out_of_memory;
- }
- /* If the '=' character is at the beginning then we have
- * "=value" and consistent with CGI.pm we _ignore_ this.
- */
- else if (query == eq)
- goto next;
-
- /* Otherwise it's "name=value". */
- else {
- name = xmlURIUnescapeString (query, eq - query, NULL);
- if (!name)
- goto out_of_memory;
- value = xmlURIUnescapeString (eq+1, end - (eq+1), NULL);
- if (!value) {
- free(name);
- goto out_of_memory;
- }
- }
-
- /* Append to the parameter set. */
- if (append_qparam (ps, name, value ? value : "") == -1) {
- free(name);
- free(value);
- goto out_of_memory;
- }
- free(name);
- free(value);
-
- next:
- query = end;
- if (*query) query ++; /* skip '&' separator */
- }
-
- return ps;
-
- out_of_memory:
- free_qparam_set (ps);
- return NULL;
-}
diff --git a/plugin/util/qparams.h b/plugin/util/qparams.h
deleted file mode 100644
index 187fa0a..0000000
--- a/plugin/util/qparams.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2010-2011 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Authors:
- * Richard W.M. Jones <***@redhat.com>
- *
- * Utility functions to help parse and assemble query strings.
- *
- *
- * !!!NOTE!!!: Taken from libvirt and modified to remove libvirt coupling.
- */
-
-#ifndef _QPARAMS_H_
-# define _QPARAMS_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if defined _WIN32 || defined __CYGWIN__
- #define QPARAM_DLL_IMPORT __declspec(dllimport)
- #define QPARAM_DLL_EXPORT __declspec(dllexport)
- #define QPARAM_DLL_LOCAL
-#else
- #if __GNUC__ >= 4
- #define QPARAM_DLL_IMPORT __attribute__ ((visibility ("default")))
- #define QPARAM_DLL_EXPORT __attribute__ ((visibility ("default")))
- #define QPARAM_DLL_LOCAL __attribute__ ((visibility ("hidden")))
- #else
- #define QPARAM_DLL_IMPORT
- #define QPARAM_DLL_EXPORT
- #define QPARAM_DLL_LOCAL
- #endif
-#endif
-
-/**
- * * ATTRIBUTE_SENTINEL:
- * *
- * * Macro to check for NULL-terminated varargs lists
- * */
-# ifndef ATTRIBUTE_SENTINEL
-# if __GNUC_PREREQ (4, 0)
-# define ATTRIBUTE_SENTINEL __attribute__((__sentinel__))
-# else
-# define ATTRIBUTE_SENTINEL
-# endif
-# endif
-
-
-/**
- * Single web service query parameter 'name=value'.
- */
-struct qparam {
- char *name; /**< Name (unescaped). */
- char *value; /**< Value (unescaped). */
- int ignore; /**< Ignore this field in qparam_get_query */
-};
-
-/**
- * Set of parameters.
- */
-struct qparam_set {
- int n; /**< number of parameters used */
- int alloc; /**< allocated space */
- struct qparam *p; /**< array of parameters */
-};
-
-/* New parameter set. */
-QPARAM_DLL_LOCAL struct qparam_set *new_qparam_set (int init_alloc, ...)
- ATTRIBUTE_SENTINEL;
-
-/* Appending parameters. */
-QPARAM_DLL_LOCAL int append_qparams (struct qparam_set *ps, ...)
- ATTRIBUTE_SENTINEL;
-QPARAM_DLL_LOCAL int append_qparam (struct qparam_set *ps,
- const char *name, const char *value);
-
-
-/* Parse a query string into a parameter set. */
-QPARAM_DLL_LOCAL struct qparam_set *qparam_query_parse (const char *query);
-
-QPARAM_DLL_LOCAL void free_qparam_set (struct qparam_set *ps);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _QPARAMS_H_ */
-
-
diff --git a/src/util/misc.cpp b/src/util/misc.cpp
new file mode 100644
index 0000000..e5e13c5
--- /dev/null
+++ b/src/util/misc.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2011-2013 Red Hat, Inc.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author: tasleson
+ */
+
+#include "misc.h"
+#include "qparams.h"
+#include <string>
+#include <string.h>
+
+namespace LSM {
+
+std::string getValue(std::string uri, std::string key)
+{
+ int i;
+ std::string rc;
+ struct qparam_set *queryParamSet = NULL;
+
+ queryParamSet = qparam_query_parse(uri.c_str());
+ if( NULL == queryParamSet ) {
+ return rc;
+ } else {
+ for( i = 0; i < queryParamSet->n; ++i ) {
+ if(strcmp(queryParamSet->p[i].name, key.c_str()) == 0 ) {
+ rc = queryParamSet->p[i].value;
+ break;
+ }
+ }
+ free_qparam_set(queryParamSet);
+ }
+ return rc;
+}
+
+}
\ No newline at end of file
diff --git a/src/util/misc.h b/src/util/misc.h
new file mode 100644
index 0000000..43f37f3
--- /dev/null
+++ b/src/util/misc.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2011-2013 Red Hat, Inc.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author: tasleson
+ */
+
+#ifndef MISC_H
+#define MISC_H
+#include <string>
+#include <map>
+#include <stdint.h>
+
+#include <libstoragemgmt/libstoragemgmt_common.h>
+
+namespace LSM {
+
+/**
+ * Retrieve the first value that matches key from a query string
+ * @param query_string Query String to parse.
+ * @param key Key to look for
+ * @return empty string if key not found, else returns value.
+ */
+LSM_DLL_LOCAL std::string getValue(std::string query_string, std::string key);
+
+/**
+ * Simple class used to store jobs in an associative array.
+ * @param t Type you want to associate with an integer.
+ * @return
+ */
+template <class Type>
+class LSM_DLL_LOCAL JobControl {
+
+public:
+
+ /**
+ * Ctor
+ */
+ JobControl():ticket(0)
+ {
+ }
+
+ /**
+ * Adds an item to the collection.
+ * @param t Type to add.
+ * @return Index it was inserted at.
+ */
+ int insert( Type t )
+ {
+ jobs[++ticket] = t;
+ return ticket;
+ }
+
+ /**
+ * Returns item at index num.
+ * @param num Key
+ * @return Item
+ */
+ Type get(uint32_t num)
+ {
+ return getInt(num)->second;
+ }
+
+ /**
+ * Checks to see if an item is present.
+ * @param num Key
+ * @return true if key exists, else false.
+ */
+ bool present(uint32_t num)
+ {
+ return ( getInt(num) != jobs.end());
+ }
+
+ /**
+ * Removes an item.
+ * @param num Key
+ */
+ void remove(uint32_t num)
+ {
+ jobs.erase(getInt(num));
+ }
+
+private:
+ typename std::map<uint32_t, Type>::iterator getInt(uint32_t num )
+ {
+ typename std::map<uint32_t, Type>::iterator i = jobs.find(num);
+ return i;
+ }
+ uint32_t ticket;
+ std::map<uint32_t , Type> jobs;
+};
+
+} //End namespace
+
+
+#endif /* MISC_H */
diff --git a/src/util/qparams.c b/src/util/qparams.c
new file mode 100644
index 0000000..dc42dae
--- /dev/null
+++ b/src/util/qparams.c
@@ -0,0 +1,242 @@
+/* Copyright (C) 2007, 2009-2011 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Authors:
+ * Richard W.M. Jones <***@redhat.com>
+ *
+ * Utility functions to help parse and assemble query strings.
+ *
+ *
+ *
+ * !!!NOTE!!!: Taken from libvirt and modified to remove libvirt coupling.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include <libxml/uri.h>
+#include "qparams.h"
+#include <string.h>
+
+struct qparam_set *
+new_qparam_set (int init_alloc, ...)
+{
+ va_list args;
+ struct qparam_set *ps;
+ const char *pname, *pvalue;
+
+ if (init_alloc <= 0) init_alloc = 1;
+
+
+ ps = (struct qparam_set *)calloc( 1, sizeof(*(ps)));
+ if( !ps ) {
+ return NULL;
+ }
+
+ ps->n = 0;
+ ps->alloc = init_alloc;
+
+ ps->p = (struct qparam *) calloc( ps->alloc, sizeof(*(ps->p)));
+
+ if (!ps->p) {
+ free(ps);
+ return NULL;
+ }
+
+ va_start (args, init_alloc);
+ while ((pname = va_arg (args, char *)) != NULL) {
+ pvalue = va_arg (args, char *);
+
+ if (append_qparam (ps, pname, pvalue) == -1) {
+ free_qparam_set (ps);
+ ps = NULL;
+ break;
+ }
+ }
+ va_end (args);
+
+ return ps;
+}
+
+int
+append_qparams (struct qparam_set *ps, ...)
+{
+ va_list args;
+ const char *pname, *pvalue;
+ int ret = 0;
+
+ va_start (args, ps);
+ while ((pname = va_arg (args, char *)) != NULL) {
+ pvalue = va_arg (args, char *);
+
+ if (append_qparam (ps, pname, pvalue) == -1) {
+ ret = -1;
+ break;
+ }
+ }
+ va_end (args);
+
+ return ret;
+}
+
+/* Ensure there is space to store at least one more parameter
+ * at the end of the set.
+ */
+static int
+grow_qparam_set (struct qparam_set *ps)
+{
+ if (ps->n >= ps->alloc) {
+
+ void *tmp = realloc( ps->p, ps->alloc * 2);
+ if( !tmp ) {
+ return -1;
+ }
+ ps->p = (struct qparam *)tmp;
+ ps->alloc *= 2;
+ }
+
+ return 0;
+}
+
+int
+append_qparam (struct qparam_set *ps,
+ const char *name, const char *value)
+{
+ char *pname, *pvalue;
+
+ pname = strdup (name);
+ if (!pname) {
+ return -1;
+ }
+
+ pvalue = strdup (value);
+ if (!pvalue) {
+ free(pname);
+ return -1;
+ }
+
+ if (grow_qparam_set (ps) == -1) {
+ free(pname);
+ free(pvalue);
+ return -1;
+ }
+
+ ps->p[ps->n].name = pname;
+ ps->p[ps->n].value = pvalue;
+ ps->p[ps->n].ignore = 0;
+ ps->n++;
+
+ return 0;
+}
+
+void
+free_qparam_set (struct qparam_set *ps)
+{
+ int i;
+
+ for (i = 0; i < ps->n; ++i) {
+ free(ps->p[i].name);
+ free(ps->p[i].value);
+ }
+ free(ps->p);
+ ps->p = NULL;
+ free(ps);
+}
+
+struct qparam_set *
+qparam_query_parse (const char *query)
+{
+ struct qparam_set *ps;
+ const char *end, *eq;
+
+ ps = new_qparam_set (0, NULL);
+ if (!ps) {
+ return NULL;
+ }
+
+ if (!query || query[0] == '\0') return ps;
+
+ while (*query) {
+ char *name = NULL, *value = NULL;
+
+ /* Find the next separator, or end of the string. */
+ end = strchr (query, '&');
+ if (!end)
+ end = strchr (query, ';');
+ if (!end)
+ end = query + strlen (query);
+
+ /* Find the first '=' character between here and end. */
+ eq = strchr (query, '=');
+ if (eq && eq >= end) eq = NULL;
+
+ /* Empty section (eg. "&&"). */
+ if (end == query)
+ goto next;
+
+ /* If there is no '=' character, then we have just "name"
+ * and consistent with CGI.pm we assume value is "".
+ */
+ else if (!eq) {
+ name = xmlURIUnescapeString (query, end - query, NULL);
+ if (!name) goto out_of_memory;
+ }
+ /* Or if we have "name=" here (works around annoying
+ * problem when calling xmlURIUnescapeString with len = 0).
+ */
+ else if (eq+1 == end) {
+ name = xmlURIUnescapeString (query, eq - query, NULL);
+ if (!name) goto out_of_memory;
+ }
+ /* If the '=' character is at the beginning then we have
+ * "=value" and consistent with CGI.pm we _ignore_ this.
+ */
+ else if (query == eq)
+ goto next;
+
+ /* Otherwise it's "name=value". */
+ else {
+ name = xmlURIUnescapeString (query, eq - query, NULL);
+ if (!name)
+ goto out_of_memory;
+ value = xmlURIUnescapeString (eq+1, end - (eq+1), NULL);
+ if (!value) {
+ free(name);
+ goto out_of_memory;
+ }
+ }
+
+ /* Append to the parameter set. */
+ if (append_qparam (ps, name, value ? value : "") == -1) {
+ free(name);
+ free(value);
+ goto out_of_memory;
+ }
+ free(name);
+ free(value);
+
+ next:
+ query = end;
+ if (*query) query ++; /* skip '&' separator */
+ }
+
+ return ps;
+
+ out_of_memory:
+ free_qparam_set (ps);
+ return NULL;
+}
diff --git a/src/util/qparams.h b/src/util/qparams.h
new file mode 100644
index 0000000..9009560
--- /dev/null
+++ b/src/util/qparams.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2010-2011 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Authors:
+ * Richard W.M. Jones <***@redhat.com>
+ *
+ * Utility functions to help parse and assemble query strings.
+ *
+ *
+ * !!!NOTE!!!: Taken from libvirt and modified to remove libvirt coupling.
+ */
+
+#ifndef _QPARAMS_H_
+# define _QPARAMS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined _WIN32 || defined __CYGWIN__
+ #define QPARAM_DLL_IMPORT __declspec(dllimport)
+ #define QPARAM_DLL_EXPORT __declspec(dllexport)
+ #define QPARAM_DLL_LOCAL
+#else
+ #if __GNUC__ >= 4
+ #define QPARAM_DLL_IMPORT __attribute__ ((visibility ("default")))
+ #define QPARAM_DLL_EXPORT __attribute__ ((visibility ("default")))
+ #define QPARAM_DLL_LOCAL __attribute__ ((visibility ("hidden")))
+ #else
+ #define QPARAM_DLL_IMPORT
+ #define QPARAM_DLL_EXPORT
+ #define QPARAM_DLL_LOCAL
+ #endif
+#endif
+
+/**
+ * * ATTRIBUTE_SENTINEL:
+ * *
+ * * Macro to check for NULL-terminated varargs lists
+ * */
+# ifndef ATTRIBUTE_SENTINEL
+# if __GNUC_PREREQ (4, 0)
+# define ATTRIBUTE_SENTINEL __attribute__((__sentinel__))
+# else
+# define ATTRIBUTE_SENTINEL
+# endif
+# endif
+
+
+/**
+ * Single web service query parameter 'name=value'.
+ */
+struct qparam {
+ char *name; /**< Name (unescaped). */
+ char *value; /**< Value (unescaped). */
+ int ignore; /**< Ignore this field in qparam_get_query */
+};
+
+/**
+ * Set of parameters.
+ */
+struct qparam_set {
+ int n; /**< number of parameters used */
+ int alloc; /**< allocated space */
+ struct qparam *p; /**< array of parameters */
+};
+
+/* New parameter set. */
+QPARAM_DLL_LOCAL struct qparam_set *new_qparam_set (int init_alloc, ...)
+ ATTRIBUTE_SENTINEL;
+
+/* Appending parameters. */
+QPARAM_DLL_LOCAL int append_qparams (struct qparam_set *ps, ...)
+ ATTRIBUTE_SENTINEL;
+QPARAM_DLL_LOCAL int append_qparam (struct qparam_set *ps,
+ const char *name, const char *value);
+
+
+/* Parse a query string into a parameter set. */
+QPARAM_DLL_LOCAL struct qparam_set *qparam_query_parse (const char *query);
+
+QPARAM_DLL_LOCAL void free_qparam_set (struct qparam_set *ps);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _QPARAMS_H_ */
--
1.8.2.1
Tony Asleson
2014-04-15 21:46:58 UTC
Permalink
Will be useful to C plug-in writers.

Signed-off-by: Tony Asleson <***@redhat.com>
---
.../libstoragemgmt/libstoragemgmt_plug_interface.h | 16 ++++
src/Makefile.am | 3 +-
src/lsm_plugin_ipc.cpp | 89 +++++++++++++++++++++-
src/util/qparams.h | 26 ++-----
test/tester.c | 37 +++++++++
5 files changed, 146 insertions(+), 25 deletions(-)

diff --git a/include/libstoragemgmt/libstoragemgmt_plug_interface.h b/include/libstoragemgmt/libstoragemgmt_plug_interface.h
index 28ae176..af212d2 100644
--- a/include/libstoragemgmt/libstoragemgmt_plug_interface.h
+++ b/include/libstoragemgmt/libstoragemgmt_plug_interface.h
@@ -1251,6 +1251,22 @@ lsm_storage_capabilities LSM_DLL_EXPORT *lsm_capability_record_alloc(char const
*/
lsm_optional_data LSM_DLL_EXPORT *lsm_optional_data_record_alloc(void);

+
+/**
+ * Convenience function for plug-in writer.
+ * Note: Make sure to free returned items to prevent memory leaks.
+ * @param[in] uri
+ * @param[out] scheme
+ * @param[out] user
+ * @param[out] server
+ * @param[out] port
+ * @param[out] query_params
+ * @return LSM_ERR_OK on successful parse, else error reason.
+ */
+int LSM_DLL_EXPORT lsm_uri_parse(const char *uri, char **scheme, char **user,
+ char **server, int *port, char **path,
+ lsm_optional_data **query_params);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/Makefile.am b/src/Makefile.am
index 0cb17a2..0c10a68 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -8,7 +8,8 @@ libstoragemgmt_la_LIBADD=$(LIBXML_LIBS) $(YAJL_LIBS) $(LIBGLIB_LIBS)
libstoragemgmt_la_LDFLAGS=
libstoragemgmt_la_SOURCES=lsm_mgmt.cpp lsm_datatypes.hpp lsm_datatypes.cpp \
lsm_convert.hpp lsm_convert.cpp lsm_ipc.hpp lsm_ipc.cpp \
- lsm_plugin_ipc.hpp lsm_plugin_ipc.cpp
+ lsm_plugin_ipc.hpp lsm_plugin_ipc.cpp util/qparams.c \
+ util/qparams.h

DEPS = $(top_builddir)/src/libstoragemgmt.la

diff --git a/src/lsm_plugin_ipc.cpp b/src/lsm_plugin_ipc.cpp
index 9dd2359..86cb7f8 100644
--- a/src/lsm_plugin_ipc.cpp
+++ b/src/lsm_plugin_ipc.cpp
@@ -28,13 +28,14 @@
#include "libstoragemgmt/libstoragemgmt_fs.h"
#include "libstoragemgmt/libstoragemgmt_snapshot.h"
#include "libstoragemgmt/libstoragemgmt_nfsexport.h"
-#include <libstoragemgmt/libstoragemgmt_plug_interface.h>
-#include <libstoragemgmt/libstoragemgmt_volumes.h>
-#include <libstoragemgmt/libstoragemgmt_pool.h>
-#include <libstoragemgmt/libstoragemgmt_initiators.h>
+#include "libstoragemgmt/libstoragemgmt_plug_interface.h"
+#include "libstoragemgmt/libstoragemgmt_volumes.h"
+#include "libstoragemgmt/libstoragemgmt_pool.h"
+#include "libstoragemgmt/libstoragemgmt_initiators.h"
#include <errno.h>
#include <string.h>
#include <libxml/uri.h>
+#include "util/qparams.h"
#include <syslog.h>

//Forward decl.
@@ -2505,3 +2506,83 @@ int lsm_plugin_error_log( lsm_plugin_ptr plug, lsm_error_ptr error)

return LSM_ERR_OK;
}
+
+
+#define STR_D(c, s) \
+do { \
+ if(s) { \
+ (c) = strdup(s); \
+ if( !c ) {\
+ rc = LSM_ERR_NO_MEMORY; \
+ goto bail; \
+ } \
+ } \
+} while(0)\
+
+int LSM_DLL_EXPORT lsm_uri_parse(const char *uri, char **scheme, char **user,
+ char **server, int *port, char **path,
+ lsm_optional_data **query_params)
+{
+ int rc = LSM_ERR_INVALID_URI;
+ xmlURIPtr u = NULL;
+
+ if( uri && strlen(uri) > 0 ) {
+ *scheme = NULL;
+ *user = NULL;
+ *server = NULL;
+ *port = -1;
+ *path = NULL;
+ *query_params = NULL;
+
+ u = xmlParseURI(uri);
+ if( u ) {
+ STR_D(*scheme, u->scheme);
+ STR_D(*user, u->user);
+ STR_D(*server, u->server);
+ STR_D(*path, u->path);
+ *port = u->port;
+
+ *query_params = lsm_optional_data_record_alloc();
+ if( *query_params ) {
+ int i;
+ struct qparam_set *qp = NULL;
+ qp = qparam_query_parse(u->query_raw);
+
+ for( i = 0; i < qp->n; ++i ) {
+ rc = lsm_optional_data_string_set(*query_params,
+ qp->p[i].name,
+ qp->p[i].value);
+ if( LSM_ERR_OK != rc ) {
+ goto bail;
+ }
+ }
+ } else {
+ rc = LSM_ERR_NO_MEMORY;
+ goto bail;
+ }
+
+ rc = LSM_ERR_OK;
+ }
+
+ bail:
+ if( rc != LSM_ERR_OK ){
+ free(*scheme);
+ *scheme = NULL;
+ free(*user);
+ *user = NULL;
+ free(*server);
+ *server = NULL;
+ *port = -1;
+ free(*path);
+ *path = NULL;
+ lsm_optional_data_record_free(*query_params);
+ *query_params = NULL;
+ }
+
+ if( u ) {
+ xmlFreeURI(u);
+ u = NULL;
+ }
+ }
+ return rc;
+}
\ No newline at end of file
diff --git a/src/util/qparams.h b/src/util/qparams.h
index 9009560..ca5ddb4 100644
--- a/src/util/qparams.h
+++ b/src/util/qparams.h
@@ -31,21 +31,7 @@
extern "C" {
#endif

-#if defined _WIN32 || defined __CYGWIN__
- #define QPARAM_DLL_IMPORT __declspec(dllimport)
- #define QPARAM_DLL_EXPORT __declspec(dllexport)
- #define QPARAM_DLL_LOCAL
-#else
- #if __GNUC__ >= 4
- #define QPARAM_DLL_IMPORT __attribute__ ((visibility ("default")))
- #define QPARAM_DLL_EXPORT __attribute__ ((visibility ("default")))
- #define QPARAM_DLL_LOCAL __attribute__ ((visibility ("hidden")))
- #else
- #define QPARAM_DLL_IMPORT
- #define QPARAM_DLL_EXPORT
- #define QPARAM_DLL_LOCAL
- #endif
-#endif
+#include "libstoragemgmt/libstoragemgmt_common.h"

/**
* * ATTRIBUTE_SENTINEL:
@@ -80,20 +66,20 @@ struct qparam_set {
};

/* New parameter set. */
-QPARAM_DLL_LOCAL struct qparam_set *new_qparam_set (int init_alloc, ...)
+LSM_DLL_LOCAL struct qparam_set *new_qparam_set (int init_alloc, ...)
ATTRIBUTE_SENTINEL;

/* Appending parameters. */
-QPARAM_DLL_LOCAL int append_qparams (struct qparam_set *ps, ...)
+LSM_DLL_LOCAL int append_qparams (struct qparam_set *ps, ...)
ATTRIBUTE_SENTINEL;
-QPARAM_DLL_LOCAL int append_qparam (struct qparam_set *ps,
+LSM_DLL_LOCAL int append_qparam (struct qparam_set *ps,
const char *name, const char *value);


/* Parse a query string into a parameter set. */
-QPARAM_DLL_LOCAL struct qparam_set *qparam_query_parse (const char *query);
+LSM_DLL_LOCAL struct qparam_set *qparam_query_parse (const char *query);

-QPARAM_DLL_LOCAL void free_qparam_set (struct qparam_set *ps);
+LSM_DLL_LOCAL void free_qparam_set (struct qparam_set *ps);

#ifdef __cplusplus
}
diff --git a/test/tester.c b/test/tester.c
index b577b23..f1288c3 100644
--- a/test/tester.c
+++ b/test/tester.c
@@ -2610,6 +2610,42 @@ START_TEST(test_pool_create)
}
END_TEST

+START_TEST(test_uri_parse)
+{
+ const char uri_g[] = "sim://***@host:123/path/?namespace=root/uber";
+ char *scheme = NULL;
+ char *user = NULL;
+ char *server = NULL;
+ char *path = NULL;
+ int port = 0;
+ lsm_optional_data *qp = NULL;
+ int rc = lsm_uri_parse(uri_g, &scheme, &user, &server, &port, &path, &qp);
+
+ fail_unless(LSM_ERR_OK == rc, "lsm_uri_parse %d", rc);
+
+ if( LSM_ERR_OK == rc ) {
+ fail_unless(strcmp(scheme, "sim") == 0, "%s", scheme);
+ fail_unless(strcmp(user, "user") == 0, "%s", user);
+ fail_unless(strcmp(server, "host") == 0, "%s", server);
+ fail_unless(strcmp(path, "/path/") == 0, "%s", path);
+ fail_unless(port == 123, "%d", port);
+
+ fail_unless(qp != NULL);
+ if( qp ) {
+ fail_unless(strcmp("root/uber",
+ lsm_optional_data_string_get(qp, "namespace")) == 0,
+ "%s", lsm_optional_data_string_get(qp, "namespace"));
+ }
+
+ free(scheme);
+ free(user);
+ free(server);
+ free(path);
+ lsm_optional_data_record_free(qp);
+ }
+}
+END_TEST
+
Suite * lsm_suite(void)
{
Suite *s = suite_create("libStorageMgmt");
@@ -2620,6 +2656,7 @@ Suite * lsm_suite(void)

tcase_add_test(basic, test_pool_delete);
tcase_add_test(basic, test_pool_create);
+ tcase_add_test(basic, test_uri_parse);

tcase_add_test(basic, test_error_reporting);
tcase_add_test(basic, test_capability);
--
1.8.2.1
Tony Asleson
2014-04-15 21:47:03 UTC
Permalink
Make consistent with other listing methods.

Signed-off-by: Tony Asleson <***@redhat.com>
---
lsm/lsm/_client.py | 2 +-
lsm/lsm/_cmdline.py | 10 +++++-----
2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/lsm/lsm/_client.py b/lsm/lsm/_client.py
index 8bb5949..8dc7693 100644
--- a/lsm/lsm/_client.py
+++ b/lsm/lsm/_client.py
@@ -704,7 +704,7 @@ class Client(INetworkAttachedStorage):
# @param flags Reserved for future use, must be zero.
# @returns List of access groups
@_return_requires([AccessGroup])
- def access_group_list(self, flags=0):
+ def access_groups(self, flags=0):
"""
Returns a list of access groups
"""
diff --git a/lsm/lsm/_cmdline.py b/lsm/lsm/_cmdline.py
index ecc1e92..0f5e3de 100644
--- a/lsm/lsm/_cmdline.py
+++ b/lsm/lsm/_cmdline.py
@@ -1101,7 +1101,7 @@ class CmdLine:
elif args.type == 'NFS_CLIENT_AUTH':
self.display_nfs_client_authentication()
elif args.type == 'ACCESS_GROUPS':
- self.display_data(self.c.access_group_list())
+ self.display_data(self.c.access_groups())
elif args.type == 'SYSTEMS':
self.display_data(self.c.systems())
elif args.type == 'DISKS':
@@ -1142,7 +1142,7 @@ class CmdLine:
self.display_data([access_group])

def _add_rm_access_grp_init(self, args, op):
- agl = self.c.access_group_list()
+ agl = self.c.access_groups()
group = _get_item(agl, args.ag, "access group id")

if op:
@@ -1162,7 +1162,7 @@ class CmdLine:
self._add_rm_access_grp_init(args, False)

def access_group_volumes(self, args):
- agl = self.c.access_group_list()
+ agl = self.c.access_groups()
group = _get_item(agl, args.ag, "access group id")
vols = self.c.volumes_accessible_by_access_group(group)
self.display_data(vols)
@@ -1191,7 +1191,7 @@ class CmdLine:

## Used to delete access group
def access_group_delete(self, args):
- agl = self.c.access_group_list()
+ agl = self.c.access_groups()
group = _get_item(agl, args.ag, "access group id")
return self.c.access_group_del(group)

@@ -1563,7 +1563,7 @@ class CmdLine:
return self._access(False, args)

def _access_group(self, args, grant=True):
- agl = self.c.access_group_list()
+ agl = self.c.access_groups()
group = _get_item(agl, args.ag, "access group id")
v = _get_item(self.c.volumes(), args.vol, "volume id")
--
1.8.2.1
Tony Asleson
2014-04-15 21:47:04 UTC
Permalink
Signed-off-by: Tony Asleson <***@redhat.com>
---
.../libstoragemgmt/libstoragemgmt_plug_interface.h | 3 +-
include/libstoragemgmt/libstoragemgmt_pool.h | 7 ++
lsm/lsm/_data.py | 20 +++---
lsm/lsm/ibmv7k.py | 2 +-
lsm/lsm/nstor.py | 2 +-
lsm/lsm/simarray.py | 14 +++-
lsm/lsm/smis.py | 3 +-
lsm/lsm/targetd.py | 2 +-
plugin/simc_lsmplugin.c | 6 +-
src/lsm_convert.cpp | 5 +-
src/lsm_datatypes.cpp | 22 ++++++-
src/lsm_datatypes.hpp | 1 +
test/tester.c | 76 ++++++++++++----------
13 files changed, 104 insertions(+), 59 deletions(-)

diff --git a/include/libstoragemgmt/libstoragemgmt_plug_interface.h b/include/libstoragemgmt/libstoragemgmt_plug_interface.h
index 887cf89..7f6a962 100644
--- a/include/libstoragemgmt/libstoragemgmt_plug_interface.h
+++ b/include/libstoragemgmt/libstoragemgmt_plug_interface.h
@@ -1049,13 +1049,14 @@ void LSM_DLL_EXPORT lsm_pool_free_space_set(lsm_pool *p, uint64_t free_space);
* @param total_space Total space
* @param free_space Space available
* @param status Pool status, bit field (See LSM_POOL_STATUS_XXXX constants)
+ * @param status_info Additional textual information on status
* @param system_id System id
* @return LSM_ERR_OK on success, else error reason.
*/
lsm_pool LSM_DLL_EXPORT *lsm_pool_record_alloc(const char *id, const char *name,
uint64_t total_space,
uint64_t free_space,
- uint64_t status,
+ uint64_t status, const char* status_info,
const char *system_id);

/**
diff --git a/include/libstoragemgmt/libstoragemgmt_pool.h b/include/libstoragemgmt/libstoragemgmt_pool.h
index e631594..d809561 100644
--- a/include/libstoragemgmt/libstoragemgmt_pool.h
+++ b/include/libstoragemgmt/libstoragemgmt_pool.h
@@ -87,6 +87,13 @@ uint64_t LSM_DLL_EXPORT lsm_pool_free_space_get( lsm_pool *p );
uint64_t LSM_DLL_EXPORT lsm_pool_status_get( lsm_pool *s );

/**
+ * Retrieve the status info for the Pool.
+ * @param s Pool to retrieve status for
+ * @return Pool status info which is a character string.
+ */
+const char LSM_DLL_EXPORT *lsm_pool_status_info_get( lsm_pool *s );
+
+/**
* Retrieve the system id for the specified pool.
* @param p Pool pointer
* @return System ID
diff --git a/lsm/lsm/_data.py b/lsm/lsm/_data.py
index 72c2629..6de540e 100644
--- a/lsm/lsm/_data.py
+++ b/lsm/lsm/_data.py
@@ -785,6 +785,7 @@ The lsm.System class does not have class methods.
@default_property('total_space', doc="Total space in bytes")
@default_property('free_space', doc="Free space in bytes")
@default_property('status', doc="Enumerated status")
+@default_property('status_info', doc="Text explaining status")
@default_property('system_id', doc="System identifier")
@default_property("optional_data", doc="Optional data")
class Pool(IData):
@@ -1165,13 +1166,17 @@ class Pool(IData):
# total_space: All spaces in bytes could be allocated to user.
'free_space': 'Free Space',
# free_space: Free spaces in bytes could be allocated to user.
- 'status': 'Status',
+ 'status': 'Status',
# status: Indicate the status of Pool.
+ 'status_info': 'Status Info',
+ # status_info: A string explaining the detail of current status.
+ # Check comments above about Pool.STATUS_XXX for
+ # what info you should save in it.
'system_id': 'System ID',
# system_id: Identifier of belonging system.
}
_MAN_PROPERTIES_SEQUENCE = ['id', 'name', 'total_space', 'free_space',
- 'status', 'system_id']
+ 'status', 'status_info', 'system_id']

_OPT_PROPERTIES_2_HEADER = {
'raid_type': 'RAID Type',
@@ -1191,12 +1196,6 @@ class Pool(IData):
# not implemented at current pool level.
# If we really need to identify the under algorithm some
# day, we will expand to THINP_TYPE_THIN_ALLOCATED and etc
- 'status': 'Status',
- # status: The status of this pool, OK, Data Lose, or etc.
- 'status_info': 'Status Info',
- # status_info: A string explaining the detail of current status.
- # Check comments above about Pool.STATUS_XXX for
- # what info you should save in it.
'element_type': 'Element Type',
# element_type: That kind of items can this pool create:
# ELEMENT_TYPE_VOLUME
@@ -1211,7 +1210,7 @@ class Pool(IData):
}

_OPT_PROPERTIES_SEQUENCE = ['raid_type', 'member_type', 'member_ids',
- 'element_type', 'thinp_type', 'status_info']
+ 'element_type', 'thinp_type']

def _value_convert(self, key_name, value, human, enum_as_number,
list_convert):
@@ -1236,12 +1235,13 @@ class Pool(IData):
return value

def __init__(self, _id, _name, _total_space, _free_space, _status,
- _system_id, _optional_data=None):
+ _status_info, _system_id, _optional_data=None):
self._id = _id # Identifier
self._name = _name # Human recognisable name
self._total_space = _total_space # Total size
self._free_space = _free_space # Free space available
self._status = _status # Status of pool.
+ self._status_info = _status_info # Additional status text of pool
self._system_id = _system_id # System id this pool belongs

if _optional_data is None:
diff --git a/lsm/lsm/ibmv7k.py b/lsm/lsm/ibmv7k.py
index 846034f..16750d0 100644
--- a/lsm/lsm/ibmv7k.py
+++ b/lsm/lsm/ibmv7k.py
@@ -192,7 +192,7 @@ class IbmV7k(IStorageAreaNetwork):

def _pool(self, p):
return Pool(p['id'], p['name'], int(p['capacity']),
- int(p['free_capacity']), Pool.STATUS_UNKNOWN,
+ int(p['free_capacity']), Pool.STATUS_UNKNOWN, '',
self.sys_info.id)

def _get_volumes(self):
diff --git a/lsm/lsm/nstor.py b/lsm/lsm/nstor.py
index b0cca76..cf6f276 100644
--- a/lsm/lsm/nstor.py
+++ b/lsm/lsm/nstor.py
@@ -115,7 +115,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
pools.append(Pool(pool_info['name'], pool_info['name'],
NexentaStor._to_bytes(pool_info['size']),
NexentaStor._to_bytes(pool_info['free']),
- Pool.STATUS_UNKNOWN,
+ Pool.STATUS_UNKNOWN, '',
self.system.id))

return pools
diff --git a/lsm/lsm/simarray.py b/lsm/lsm/simarray.py
index e6043fa..d8c375c 100644
--- a/lsm/lsm/simarray.py
+++ b/lsm/lsm/simarray.py
@@ -156,6 +156,7 @@ class SimArray(object):
total_space = self.data.pool_total_space(pool_id)
free_space = self.data.pool_free_space(pool_id)
status = sim_pool['status']
+ status_info = sim_pool['status_info']
sys_id = sim_pool['sys_id']
opt_data = OptionalData()
if flags == Pool.RETRIEVE_FULL_INFO:
@@ -163,11 +164,10 @@ class SimArray(object):
opt_data.set('member_type', sim_pool['member_type'])
opt_data.set('member_ids', sim_pool['member_ids'])
opt_data.set('thinp_type', Pool.THINP_TYPE_THIN)
- opt_data.set('status_info', '')
opt_data.set('element_type', sim_pool['element_type'])

- return Pool(pool_id, name, total_space, free_space, status, sys_id,
- opt_data)
+ return Pool(pool_id, name, total_space, free_space, status,
+ status_info, sys_id, opt_data)

def pools(self, flags=0):
rc = []
@@ -539,6 +539,7 @@ class SimData(object):
SIM_DATA_INIT_NAME = 'NULL'
SIM_DATA_TMO = 30000 # ms
SIM_DATA_POOL_STATUS = Pool.STATUS_OK
+ SIM_DATA_POOL_STATUS_INFO = ''
SIM_DATA_DISK_DEFAULT_RAID = Pool.RAID_TYPE_RAID0
SIM_DATA_VOLUME_DEFAULT_RAID = Pool.RAID_TYPE_RAID0
SIM_DATA_POOL_ELEMENT_TYPE = Pool.ELEMENT_TYPE_FS \
@@ -607,6 +608,7 @@ class SimData(object):
'member_ids': [SimData._disk_id(0), SimData._disk_id(1)],
'raid_type': Pool.RAID_TYPE_RAID1,
'status': SimData.SIM_DATA_POOL_STATUS,
+ 'status_info': SimData.SIM_DATA_POOL_STATUS_INFO,
'sys_id': SimData.SIM_DATA_SYS_ID,
'element_type': SimData.SIM_DATA_SYS_POOL_ELEMENT_TYPE,
},
@@ -618,6 +620,7 @@ class SimData(object):
'member_size': pool_size_200g,
'raid_type': Pool.RAID_TYPE_NOT_APPLICABLE,
'status': Pool.STATUS_OK,
+ 'status_info': SimData.SIM_DATA_POOL_STATUS_INFO,
'sys_id': SimData.SIM_DATA_SYS_ID,
'element_type': SimData.SIM_DATA_POOL_ELEMENT_TYPE,
},
@@ -629,6 +632,7 @@ class SimData(object):
'member_ids': [SimData._disk_id(2), SimData._disk_id(3)],
'raid_type': Pool.RAID_TYPE_RAID0,
'status': Pool.STATUS_OK,
+ 'status_info': SimData.SIM_DATA_POOL_STATUS_INFO,
'sys_id': SimData.SIM_DATA_SYS_ID,
'element_type': SimData.SIM_DATA_POOL_ELEMENT_TYPE,
},
@@ -690,6 +694,7 @@ class SimData(object):
],
'raid_type': Pool.RAID_TYPE_RAID1,
'status': Pool.STATUS_OK,
+ 'status_info': SimData.SIM_DATA_POOL_STATUS_INFO,
'sys_id': SimData.SIM_DATA_SYS_ID,
'element_type': SimData.SIM_DATA_POOL_ELEMENT_TYPE,
}
@@ -1652,6 +1657,7 @@ class SimData(object):
sim_pool['sys_id'] = SimData.SIM_DATA_SYS_ID
sim_pool['element_type'] = SimData.SIM_DATA_POOL_ELEMENT_TYPE
sim_pool['status'] = SimData.SIM_DATA_POOL_STATUS
+ sim_pool['status_info'] = SimData.SIM_DATA_POOL_STATUS_INFO
self.pool_dict[pool_id] = sim_pool
return sim_pool

@@ -1749,6 +1755,7 @@ class SimData(object):
sim_pool['sys_id'] = SimData.SIM_DATA_SYS_ID
sim_pool['element_type'] = SimData.SIM_DATA_POOL_ELEMENT_TYPE
sim_pool['status'] = SimData.SIM_DATA_POOL_STATUS
+ sim_pool['status_info'] = SimData.SIM_DATA_POOL_STATUS_INFO
self.pool_dict[pool_id] = sim_pool
return sim_pool

@@ -1794,6 +1801,7 @@ class SimData(object):
sim_pool['sys_id'] = SimData.SIM_DATA_SYS_ID
sim_pool['element_type'] = SimData.SIM_DATA_POOL_ELEMENT_TYPE
sim_pool['status'] = SimData.SIM_DATA_POOL_STATUS
+ sim_pool['status_info'] = SimData.SIM_DATA_POOL_STATUS_INFO
self.pool_dict[pool_id] = sim_pool
return sim_pool

diff --git a/lsm/lsm/smis.py b/lsm/lsm/smis.py
index d2d137c..5516883 100644
--- a/lsm/lsm/smis.py
+++ b/lsm/lsm/smis.py
@@ -1471,7 +1471,8 @@ class Smis(IStorageAreaNetwork):
if 'OperationalStatus' in cim_pool:
status = Smis._pool_status_of(cim_pool)[0]

- return Pool(pool_id, name, total_space, free_space, status, system_id)
+ return Pool(pool_id, name, total_space, free_space, status, '',
+ system_id)

@staticmethod
def _cim_sys_2_lsm_sys(cim_sys):
diff --git a/lsm/lsm/targetd.py b/lsm/lsm/targetd.py
index 132d91c..5bbb4ae 100644
--- a/lsm/lsm/targetd.py
+++ b/lsm/lsm/targetd.py
@@ -165,7 +165,7 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
pools = []
for pool in self._jsonrequest("pool_list"):
pools.append(Pool(pool['name'], pool['name'], pool['size'],
- pool['free_size'], Pool.STATUS_UNKNOWN,
+ pool['free_size'], Pool.STATUS_UNKNOWN, '',
'targetd'))
return pools

diff --git a/plugin/simc_lsmplugin.c b/plugin/simc_lsmplugin.c
index 6f65eb1..bcdcd50 100644
--- a/plugin/simc_lsmplugin.c
+++ b/plugin/simc_lsmplugin.c
@@ -990,7 +990,7 @@ static int _pool_create(lsm_plugin_ptr c, const char *system_id,
if( !new_pool ) {
/* Create the pool */
new_pool = lsm_pool_record_alloc(md5(pool_name), pool_name, size_bytes,
- size_bytes, LSM_POOL_STATUS_OK,
+ size_bytes, LSM_POOL_STATUS_OK, "",
system_id);

pool_to_store = lsm_pool_record_copy(new_pool);
@@ -2485,7 +2485,7 @@ int load( lsm_plugin_ptr c, const char *uri, const char *password,

p = lsm_pool_record_alloc("POOL_3", "lsm_test_aggr",
UINT64_MAX, UINT64_MAX,
- LSM_POOL_STATUS_OK,
+ LSM_POOL_STATUS_OK, "",
sys_id);
if( p ) {
pd->pools = g_hash_table_new_full(g_str_hash, g_str_equal, free,
@@ -2498,7 +2498,7 @@ int load( lsm_plugin_ptr c, const char *uri, const char *password,
snprintf(name, sizeof(name), "POOL_%d", i);

p = lsm_pool_record_alloc(name, name, UINT64_MAX,
- UINT64_MAX, LSM_POOL_STATUS_OK,
+ UINT64_MAX, LSM_POOL_STATUS_OK, "",
sys_id);

if( p ) {
diff --git a/src/lsm_convert.cpp b/src/lsm_convert.cpp
index 7be6dce..82c4663 100644
--- a/src/lsm_convert.cpp
+++ b/src/lsm_convert.cpp
@@ -160,12 +160,12 @@ lsm_pool *value_to_pool(Value &pool)

if (is_expected_object(pool, "Pool")) {
std::map<std::string, Value> i = pool.asObject();
- rc = lsm_pool_record_alloc(
- i["id"].asString().c_str(),
+ rc = lsm_pool_record_alloc(i["id"].asString().c_str(),
i["name"].asString().c_str(),
i["total_space"].asUint64_t(),
i["free_space"].asUint64_t(),
i["status"].asUint64_t(),
+ i["status_info"].asString().c_str(),
i["system_id"].asString().c_str());
}
return rc;
@@ -181,6 +181,7 @@ Value pool_to_value(lsm_pool *pool)
p["total_space"] = Value(pool->total_space);
p["free_space"] = Value(pool->free_space);
p["status"] = Value(pool->status);
+ p["status_info"] = Value(pool->status_info);
p["system_id"] = Value(pool->system_id);
return Value(p);
}
diff --git a/src/lsm_datatypes.cpp b/src/lsm_datatypes.cpp
index b5e68e0..e374fbf 100644
--- a/src/lsm_datatypes.cpp
+++ b/src/lsm_datatypes.cpp
@@ -468,6 +468,9 @@ rtype *name(uint32_t size) \
if (size > 0) { \
size_t s = sizeof(rtype) * size; \
rc = (rtype *) malloc(s); \
+ if( rc ) { \
+ memset(rc, 0, s); \
+ } \
} \
return rc; \
}
@@ -498,7 +501,7 @@ int name( record_type pa[], uint32_t size) \
CREATE_ALLOC_ARRAY_FUNC(lsm_pool_record_array_alloc, lsm_pool *)

lsm_pool *lsm_pool_record_alloc(const char *id, const char *name,
- uint64_t totalSpace, uint64_t freeSpace, uint64_t status,
+ uint64_t totalSpace, uint64_t freeSpace, uint64_t status, const char* status_info,
const char *system_id)
{
lsm_pool *rc = (lsm_pool *)malloc(sizeof(lsm_pool));
@@ -510,9 +513,10 @@ lsm_pool *lsm_pool_record_alloc(const char *id, const char *name,
rc->total_space = totalSpace;
rc->free_space = freeSpace;
rc->status = status;
+ rc->status_info = strdup(status_info);
rc->system_id = strdup(system_id);

- if( !rc->id || !rc->name || !rc->system_id ) {
+ if( !rc->id || !rc->name || !rc->system_id || !rc->status_info ) {
lsm_pool_record_free(rc);
rc = NULL;
}
@@ -534,6 +538,7 @@ lsm_pool * lsm_pool_record_copy( lsm_pool *toBeCopied)
toBeCopied->total_space,
toBeCopied->free_space,
toBeCopied->status,
+ toBeCopied->status_info,
toBeCopied->system_id);
}
return NULL;
@@ -548,6 +553,11 @@ int lsm_pool_record_free(lsm_pool *p)
p->name = NULL;
}

+ if( p->status_info ) {
+ free(p->status_info);
+ p->status_info = NULL;
+ }
+
if (p->id) {
free(p->id);
p->id = NULL;
@@ -606,6 +616,14 @@ uint64_t lsm_pool_status_get( lsm_pool *p )
return UINT64_MAX;
}

+const char LSM_DLL_EXPORT *lsm_pool_status_info_get( lsm_pool *p )
+{
+ if (LSM_IS_POOL(p)) {
+ return p->status_info;
+ }
+ return NULL;
+}
+
char *lsm_pool_system_id_get( lsm_pool *p )
{
if (LSM_IS_POOL(p)) {
diff --git a/src/lsm_datatypes.hpp b/src/lsm_datatypes.hpp
index a0b3574..552daf1 100644
--- a/src/lsm_datatypes.hpp
+++ b/src/lsm_datatypes.hpp
@@ -70,6 +70,7 @@ struct LSM_DLL_LOCAL _lsm_pool {
uint64_t total_space; /**< Total size */
uint64_t free_space; /**< Free space available */
uint64_t status; /**< Status of pool */
+ char *status_info; /**< Status info for pool */
char *system_id; /**< system id */
};

diff --git a/test/tester.c b/test/tester.c
index 25de3c1..eeefa7b 100644
--- a/test/tester.c
+++ b/test/tester.c
@@ -1107,55 +1107,63 @@ START_TEST(test_nfs_exports)

fail_unless(NULL != test_pool);

- rc = lsm_fs_create(c, test_pool, "C_unit_test_nfs_export", 50000000, &nfs, &job, LSM_FLAG_RSVD);
+ if( test_pool ) {
+ rc = lsm_fs_create(c, test_pool, "C_unit_test_nfs_export", 50000000, &nfs, &job, LSM_FLAG_RSVD);

- if( LSM_ERR_JOB_STARTED == rc ) {
- nfs = wait_for_job_fs(c, &job);
- } else {
- fail_unless(LSM_ERR_OK == rc, "RC = %d", rc);
- }
+ if( LSM_ERR_JOB_STARTED == rc ) {
+ nfs = wait_for_job_fs(c, &job);
+ } else {
+ fail_unless(LSM_ERR_OK == rc, "RC = %d", rc);
+ }

- fail_unless(nfs != NULL);
- lsm_nfs_export **exports = NULL;
- uint32_t count = 0;
+ fail_unless(nfs != NULL);
+ lsm_nfs_export **exports = NULL;
+ uint32_t count = 0;

- rc = lsm_nfs_list(c, &exports, &count, LSM_FLAG_RSVD);
+ if( nfs ) {
+ rc = lsm_nfs_list(c, &exports, &count, LSM_FLAG_RSVD);

- fail_unless(LSM_ERR_OK == rc, "lsmNfsList rc= %d\n", rc);
- fail_unless(count == 0);
- fail_unless(NULL == exports);
+ fail_unless(LSM_ERR_OK == rc, "lsmNfsList rc= %d\n", rc);
+ fail_unless(count == 0);
+ fail_unless(NULL == exports);


- lsm_string_list *access = lsm_string_list_alloc(1);
- fail_unless(NULL != access);
+ lsm_string_list *access = lsm_string_list_alloc(1);
+ fail_unless(NULL != access);

- lsm_string_list_elem_set(access, 0, "192.168.2.29");
+ lsm_string_list_elem_set(access, 0, "192.168.2.29");

- lsm_nfs_export *e = NULL;
+ lsm_nfs_export *e = NULL;

- rc = lsm_nfs_export_fs(c, lsm_fs_id_get(nfs), NULL, access, access, NULL,
- ANON_UID_GID_NA, ANON_UID_GID_NA, NULL, NULL, &e, LSM_FLAG_RSVD);
- fail_unless(LSM_ERR_OK == rc, "lsmNfsExportFs %d\n", rc);
+ rc = lsm_nfs_export_fs(c, lsm_fs_id_get(nfs), NULL, access,
+ access, NULL, ANON_UID_GID_NA,
+ ANON_UID_GID_NA, NULL, NULL, &e,
+ LSM_FLAG_RSVD);
+ fail_unless(LSM_ERR_OK == rc, "lsmNfsExportFs %d\n", rc);

- lsm_nfs_export_record_free(e);
- e=NULL;
+ lsm_nfs_export_record_free(e);
+ e=NULL;

- rc = lsm_nfs_list(c, &exports, &count, LSM_FLAG_RSVD);
- fail_unless( LSM_ERR_OK == rc);
- fail_unless( exports != NULL);
- fail_unless( count == 1 );
+ rc = lsm_nfs_list(c, &exports, &count, LSM_FLAG_RSVD);
+ fail_unless( LSM_ERR_OK == rc);
+ fail_unless( exports != NULL);
+ fail_unless( count == 1 );

- rc = lsm_nfs_export_delete(c, exports[0], LSM_FLAG_RSVD);
- fail_unless( LSM_ERR_OK == rc, "lsmNfsExportRemove %d\n", rc );
- lsm_nfs_export_record_array_free(exports, count);
+ if( count ) {
+ rc = lsm_nfs_export_delete(c, exports[0], LSM_FLAG_RSVD);
+ fail_unless( LSM_ERR_OK == rc, "lsmNfsExportRemove %d\n", rc );
+ lsm_nfs_export_record_array_free(exports, count);

- exports = NULL;
+ exports = NULL;

- rc = lsm_nfs_list(c, &exports, &count, LSM_FLAG_RSVD);
+ rc = lsm_nfs_list(c, &exports, &count, LSM_FLAG_RSVD);

- fail_unless(LSM_ERR_OK == rc, "lsmNfsList rc= %d\n", rc);
- fail_unless(count == 0);
- fail_unless(NULL == exports);
+ fail_unless(LSM_ERR_OK == rc, "lsmNfsList rc= %d\n", rc);
+ fail_unless(count == 0);
+ fail_unless(NULL == exports);
+ }
+ }
+ }
}
END_TEST
--
1.8.2.1
Tony Asleson
2014-04-15 21:46:59 UTC
Permalink
From: Gris Ge <***@redhat.com>

* Expose size_bytes_2_size_human() as lsm.size_bytes_2_size_human()

Signed-off-by: Gris Ge <***@redhat.com>
---
lsm/lsm/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lsm/lsm/__init__.py b/lsm/lsm/__init__.py
index 3bc51f9..22bf7c4 100644
--- a/lsm/lsm/__init__.py
+++ b/lsm/lsm/__init__.py
@@ -3,7 +3,7 @@ __all__ = []
from version import VERSION

from _common import Error, Info, LsmError, ErrorLevel, ErrorNumber, \
- JobStatus, uri_parse, md5, Proxy
+ JobStatus, uri_parse, md5, Proxy, size_bytes_2_size_human
from _data import Initiator, Disk, \
Volume, Pool, System, FileSystem, Snapshot, NfsExport, BlockRange, \
AccessGroup, OptionalData, Capabilities, txt_a
--
1.8.2.1
Tony Asleson
2014-04-15 21:47:01 UTC
Permalink
Signed-off-by: Tony Asleson <***@redhat.com>
---
libstoragemgmt.spec.in | 1 +
lsm/Makefile.am | 1 +
lsm/lsm/_cmdline.py | 11 ++++---
lsm/lsm/lsmcli_data_display.py | 71 ++++++++++++++++++++++--------------------
test/cmdtest.py | 2 +-
5 files changed, 47 insertions(+), 39 deletions(-)

diff --git a/libstoragemgmt.spec.in b/libstoragemgmt.spec.in
index ff02f92..57ee743 100644
--- a/libstoragemgmt.spec.in
+++ b/libstoragemgmt.spec.in
@@ -326,6 +326,7 @@ fi
%{python_sitelib}/lsm/_common.*
%{python_sitelib}/lsm/_data.*
%{python_sitelib}/lsm/_iplugin.*
+%{python_sitelib}/lsm/lsmcli_data_display.*
%{python_sitelib}/lsm/_pluginrunner.*
%{python_sitelib}/lsm/simulator.*
%{python_sitelib}/lsm/simarray.*
diff --git a/lsm/Makefile.am b/lsm/Makefile.am
index 2006c4d..029e87b 100644
--- a/lsm/Makefile.am
+++ b/lsm/Makefile.am
@@ -19,6 +19,7 @@ lsm_PYTHON = lsm/__init__.py \
lsm/_data.py \
lsm/eseries.py \
lsm/_iplugin.py \
+ lsm/lsmcli_data_display.py \
lsm/na.py \
lsm/nstor.py \
lsm/ontap.py \
diff --git a/lsm/lsm/_cmdline.py b/lsm/lsm/_cmdline.py
index 93a928f..ecc1e92 100644
--- a/lsm/lsm/_cmdline.py
+++ b/lsm/lsm/_cmdline.py
@@ -166,9 +166,10 @@ cmds = (
],
optional=[
dict(name=('-a', '--all'),
- help='Retrieve and display in scrit friendly way with ' +
+ help='Retrieve and display in script friendly way with ' +
'all information including optional data if available',
default=False,
+ dest='all',
action='store_true'),
dict(fs_id_opt),
],
@@ -811,11 +812,13 @@ class CmdLine:
# plug-in to plug-in.
# @param objects Data, first row is header all other data.
def display_data(self, objects, extra_properties=None):
+ display_all = False
+
if len(objects) == 0:
return

if hasattr(self.args, 'all') and self.args.all:
- self.args.script = True
+ display_all = True

flag_with_header = True
if self.args.sep:
@@ -830,8 +833,8 @@ class CmdLine:
flag_new_way_works = DisplayData.display_data(
objects, display_way=display_way, flag_human=self.args.human,
flag_enum=self.args.enum, extra_properties=extra_properties,
- spliter=self.args.sep, flag_with_header=flag_with_header,
- flag_dsp_all_data=self.args.all)
+ splitter=self.args.sep, flag_with_header=flag_with_header,
+ flag_dsp_all_data=display_all)

if flag_new_way_works:
return
diff --git a/lsm/lsm/lsmcli_data_display.py b/lsm/lsm/lsmcli_data_display.py
index 09b1a24..810f590 100644
--- a/lsm/lsm/lsmcli_data_display.py
+++ b/lsm/lsm/lsmcli_data_display.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012 Red Hat, Inc.
+# Copyright (C) 2014 Red Hat, Inc.
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
@@ -20,13 +20,14 @@ from collections import OrderedDict

from lsm import System, size_bytes_2_size_human

-class EnumConvert:
- BIT_MAP_STRING_SPLITER = ','
+
+class EnumConvert(object):
+ BIT_MAP_STRING_SPLITTER = ','

@staticmethod
def _txt_a(txt, append):
if len(txt):
- return txt + EnumConvert.BIT_MAP_STRING_SPLITER + append
+ return txt + EnumConvert.BIT_MAP_STRING_SPLITTER + append
else:
return append

@@ -54,9 +55,10 @@ class EnumConvert:
return EnumConvert.SYSTEM_STATUS_CONV[System.STATUS_UNKNOWN]
return rc

-class DisplayData:

- def __init__():
+class DisplayData(object):
+
+ def __init__(self):
pass

@staticmethod
@@ -68,12 +70,12 @@ class DisplayData:
except IOError:
sys.exit(1)

- DISPLAY_WAY_COLUME = 0
+ DISPLAY_WAY_COLUMN = 0
DISPLAY_WAY_SCRIPT = 1

- DISPLAY_WAY_DEFAULT = DISPLAY_WAY_COLUME
+ DISPLAY_WAY_DEFAULT = DISPLAY_WAY_COLUMN

- DEFAULT_SPLITER=' | '
+ DEFAULT_SPLITTER = ' | '

SYSTEM_MAN_HEADER = OrderedDict()
SYSTEM_MAN_HEADER['id'] = 'ID'
@@ -148,7 +150,7 @@ class DisplayData:

for key in display_headers.keys():
key_str = display_headers[key]
- value = DisplayData._get_man_pro_value(
+ value = DisplayData._get_man_pro_value(
obj, key, value_conv_enum, value_conv_human, flag_human,
flag_enum)
data_dict[key_str] = value
@@ -158,7 +160,7 @@ class DisplayData:
if key in display_headers.keys():
continue
key_str = mandatory_headers[key]
- value = DisplayData._get_man_pro_value(
+ value = DisplayData._get_man_pro_value(
obj, key, value_conv_enum, value_conv_human, flag_human,
flag_enum)
data_dict[key_str] = value
@@ -176,7 +178,7 @@ class DisplayData:
if key in display_headers.keys():
continue
key_str = mandatory_headers[key]
- value = DisplayData._get_man_pro_value(
+ value = DisplayData._get_man_pro_value(
obj, key, value_conv_enum, value_conv_human,
flag_human, flag_enum)
data_dict[key_str] = value
@@ -193,7 +195,7 @@ class DisplayData:
def display_data(objs, display_way=None,
flag_human=True, flag_enum=False,
extra_properties=None,
- spliter=None,
+ splitter=None,
flag_with_header=True,
flag_dsp_all_data=False):
if len(objs) == 0:
@@ -202,8 +204,8 @@ class DisplayData:
if display_way is None:
display_way = DisplayData.DISPLAY_WAY_DEFAULT

- if spliter is None:
- spliter = DisplayData.DEFAULT_SPLITER
+ if splitter is None:
+ splitter = DisplayData.DEFAULT_SPLITTER

data_dict_list = []
if type(objs[0]) in DisplayData.VALUE_CONVERT.keys():
@@ -215,14 +217,14 @@ class DisplayData:
else:
return None
if display_way == DisplayData.DISPLAY_WAY_SCRIPT:
- DisplayData._display_data_script_way(data_dict_list, spliter)
- elif display_way == DisplayData.DISPLAY_WAY_COLUME:
- DisplayData._display_data_colume_way(
- data_dict_list, spliter, flag_with_header)
+ DisplayData._display_data_script_way(data_dict_list, splitter)
+ elif display_way == DisplayData.DISPLAY_WAY_COLUMN:
+ DisplayData._display_data_column_way(
+ data_dict_list, splitter, flag_with_header)
return True

@staticmethod
- def _display_data_script_way(data_dict_list, spliter):
+ def _display_data_script_way(data_dict_list, splitter):
key_column_width = 1
value_column_width = 1

@@ -245,40 +247,41 @@ class DisplayData:
value_column_width = cur_value_width

row_format = '%%-%ds%s%%-%ds' % (key_column_width,
- spliter,
+ splitter,
value_column_width)
sub_row_format = '%s%s%%-%ds' % (' ' * key_column_width,
- spliter,
+ splitter,
value_column_width)
- obj_spliter = '%s%s%s' % ('-' * key_column_width,
- '-' * len(spliter),
+ obj_splitter = '%s%s%s' % ('-' * key_column_width,
+ '-' * len(splitter),
'-' * value_column_width)

for data_dict in data_dict_list:
- DisplayData._out(obj_spliter)
+ DisplayData._out(obj_splitter)
for key_name in data_dict:
value = data_dict[key_name]
if isinstance(value, list):
flag_first_data = True
for sub_value in value:
if flag_first_data:
- out(row_format % (key_name, str(sub_value)))
+ DisplayData._out(row_format %
+ (key_name, str(sub_value)))
flag_first_data = False
else:
DisplayData._out(sub_row_format % str(sub_value))
else:
DisplayData._out(row_format % (key_name, str(value)))
- DisplayData._out(obj_spliter)
+ DisplayData._out(obj_splitter)

@staticmethod
- def _display_data_colume_way(data_dict_list, spliter, flag_with_header):
+ def _display_data_column_way(data_dict_list, splitter, flag_with_header):
if len(data_dict_list) == 0:
return
two_d_list = []

item_count = len(data_dict_list[0].keys())

- # detemin how many lines we will print
+ # determine how many lines we will print
row_width = 0
for data_dict in data_dict_list:
cur_max_wd = 0
@@ -329,16 +332,16 @@ class DisplayData:

# display two_list
row_formats = []
- header_spliter = ''
+ header_splitter = ''
for column_index in range(0, len(two_d_list[0])):
max_width = DisplayData._find_max_width(two_d_list, column_index)
row_formats.extend(['%%-%ds' % max_width])
- header_spliter += '-' * max_width
+ header_splitter += '-' * max_width
if column_index != (len(two_d_list[0]) - 1):
- header_spliter += '-' * len(spliter)
+ header_splitter += '-' * len(splitter)

- row_format = spliter.join(row_formats)
+ row_format = splitter.join(row_formats)
for row_index in range(0, len(two_d_list)):
DisplayData._out(row_format % tuple(two_d_list[row_index]))
if row_index == 0 and flag_with_header:
- DisplayData._out(header_spliter)
+ DisplayData._out(header_splitter)
diff --git a/test/cmdtest.py b/test/cmdtest.py
index 89f8862..9a9edd1 100755
--- a/test/cmdtest.py
+++ b/test/cmdtest.py
@@ -431,7 +431,7 @@ def display_check(display_list, system_id):
call([cmd, 'list', '--type', 'SNAPSHOTS', '--fs', fs_id])

if 'POOLS' in display_list:
- call([cmd, '-H', '-t' + sep, 'list', '--type', 'POOLS', '-o'])
+ call([cmd, '-H', '-t' + sep, 'list', '--type', 'POOLS', '-a'])


def test_display(cap, system_id):
--
1.8.2.1
Tony Asleson
2014-04-15 21:47:05 UTC
Permalink
This has been replaced with STATUS_DORMANT

Signed-off-by: Tony Asleson <***@redhat.com>
---
include/libstoragemgmt/libstoragemgmt_types.h | 2 +-
lsm/lsm/_data.py | 7 -------
lsm/lsm/ontap.py | 6 +++---
3 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/include/libstoragemgmt/libstoragemgmt_types.h b/include/libstoragemgmt/libstoragemgmt_types.h
index 98d123a..a54e2dd 100644
--- a/include/libstoragemgmt/libstoragemgmt_types.h
+++ b/include/libstoragemgmt/libstoragemgmt_types.h
@@ -229,7 +229,7 @@ typedef enum {
#define LSM_POOL_STATUS_STRESSED 0x0000000000000008
#define LSM_POOL_STATUS_DEGRADED 0x0000000000000010
#define LSM_POOL_STATUS_ERROR 0x0000000000000020
-#define LSM_POOL_STATUS_OFFLINE 0x0000000000000040
+/*#define LSM_POOL_AVAILABLE 0x0000000000000040 */
#define LSM_POOL_STATUS_STARTING 0x0000000000000080
#define LSM_POOL_STATUS_STOPPING 0x0000000000000100
#define LSM_POOL_STATUS_STOPPED 0x0000000000000200
diff --git a/lsm/lsm/_data.py b/lsm/lsm/_data.py
index 6de540e..603bf16 100644
--- a/lsm/lsm/_data.py
+++ b/lsm/lsm/_data.py
@@ -1066,12 +1066,6 @@ class Pool(IData):
# Example:
# * Pool.status = 'Disk 0_0_1 offline'
STATUS_ERROR = 1 << 5
- # ERROR:
- # Pool data is not accessible due to RAID members offline.
- # Example:
- # * RAID 5 pool lost access to 2 disks.
- # * RAID 0 pool lost access to 1 disks.
- STATUS_OFFLINE = 1 << 6
# OFFLINE:
# Pool is not accessible for internal issue.
# Should explain in Pool.status_info for reason.
@@ -1128,7 +1122,6 @@ class Pool(IData):
STATUS_STRESSED: 'STRESSED',
STATUS_DEGRADED: 'DEGRADED',
STATUS_ERROR: 'ERROR',
- STATUS_OFFLINE: 'OFFLINE',
STATUS_STARTING: 'STARTING',
STATUS_STOPPING: 'STOPPING',
STATUS_STOPPED: 'STOPPED',
diff --git a/lsm/lsm/ontap.py b/lsm/lsm/ontap.py
index 5166880..88bf5ca 100644
--- a/lsm/lsm/ontap.py
+++ b/lsm/lsm/ontap.py
@@ -98,9 +98,9 @@ class Ontap(IStorageAreaNetwork, INfs):
'offline': Pool.STATUS_STOPPED,
'online': Pool.STATUS_OK,
'partial': Pool.STATUS_ERROR,
- 'quiesced': Pool.STATUS_OFFLINE,
- 'quiescing': Pool.STATUS_OFFLINE,
- 'restricted': Pool.STATUS_OFFLINE,
+ 'quiesced': Pool.STATUS_DORMANT,
+ 'quiescing': Pool.STATUS_DORMANT,
+ 'restricted': Pool.STATUS_DORMANT,
'reverted': Pool.STATUS_OTHER,
'unknown': Pool.STATUS_UNKNOWN,
'unmounted': Pool.STATUS_STOPPED,
--
1.8.2.1
Tony Asleson
2014-04-15 21:47:06 UTC
Permalink
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 7f6a962..6d8dfe9 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 bcdcd50..c6034ea 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 &params, 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 &params, 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 &params, 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 &params,
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 &params,
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 &params, 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 &params, 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
Tony Asleson
2014-04-15 21:46:56 UTC
Permalink
In _iplugin.py my original intention was that we specify the interface and then
plug-in writers provide the implementation. However, in those cases where the
plug-in doesn't support one or more operations the plug-in writer was required
to provide an implementation which just raised an exception stating that the
operation wasn't supported. Instead of requiring every plug-in to do this I
changed the classes so that the classes that have an interface that isn't
mandatory to provide this default not implemented implementation.

This allows for a reduction in the overall code base without loss of
functionality. The base IPlugin class is still abstract thus the class that
derives from it will still need to implement all the methods contained in it.

Signed-off-by: Tony Asleson <***@redhat.com>
---
lsm/lsm/_iplugin.py | 171 +++++++++++++++++++++++++++-------------------------
lsm/lsm/nstor.py | 31 ----------
lsm/lsm/ontap.py | 17 ------
lsm/lsm/smis.py | 52 ----------------
lsm/lsm/targetd.py | 81 -------------------------
5 files changed, 88 insertions(+), 264 deletions(-)

diff --git a/lsm/lsm/_iplugin.py b/lsm/lsm/_iplugin.py
index 5326d4b..b1ff58f 100644
--- a/lsm/lsm/_iplugin.py
+++ b/lsm/lsm/_iplugin.py
@@ -17,6 +17,7 @@

from abc import ABCMeta as _ABCMeta
from abc import abstractmethod as _abstractmethod
+from lsm import LsmError, ErrorNumber, Pool


class IPlugin(object):
@@ -126,25 +127,68 @@ class IPlugin(object):


class IStorageAreaNetwork(IPlugin):
- @_abstractmethod
+
+ def pool_create(self, system_id, pool_name, size_bytes,
+ raid_type=Pool.RAID_TYPE_UNKNOWN,
+ member_type=Pool.MEMBER_TYPE_UNKNOWN, flags=0):
+ """
+ Creates a pool letting the array pick the specifics
+
+ Returns a tuple (job_id, re-sized_volume)
+ Note: Tuple return values are mutually exclusive, when one
+ is None the other must be valid.
+ """
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
+
+ def pool_create_from_disks(self, system_id, pool_name, member_ids,
+ raid_type, flags=0):
+ """
+ Creates a pool letting the user select the disks
+
+ Returns a tuple (job_id, re-sized_volume)
+ Note: Tuple return values are mutually exclusive, when one
+ is None the other must be valid.
+ """
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
+
+ def pool_create_from_volumes(self, system_id, pool_name, member_ids,
+ raid_type, flags=0):
+ """
+ Creates a pool from existing volumes
+
+ Returns a tuple (job_id, re-sized_volume)
+ Note: Tuple return values are mutually exclusive, when one
+ is None the other must be valid.
+ """
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
+
+ def pool_create_from_pool(self, system_id, pool_name, member_id,
+ size_bytes, flags=0):
+ """
+ Creates a pool from existing volumes
+
+ Returns a tuple (job_id, re-sized_volume)
+ Note: Tuple return values are mutually exclusive, when one
+ is None the other must be valid.
+ """
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
+
def volumes(self, flags=0):
"""
Returns an array of volume objects

Raises LsmError on error
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def initiators(self, flags=0):
"""
Return an array of initiator objects

Raises LsmError on error
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def volume_create(self, pool, volume_name, size_bytes, provisioning,
flags=0):
"""
@@ -154,18 +198,16 @@ class IStorageAreaNetwork(IPlugin):
Note: Tuple return values are mutually exclusive, when one
is None the other must be valid.
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def volume_delete(self, volume, flags=0):
"""
Deletes a volume.

Returns Job id or None if completed, else raises LsmError on errors.
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def volume_resize(self, volume, new_size_bytes, flags=0):
"""
Re-sizes a volume.
@@ -174,10 +216,8 @@ class IStorageAreaNetwork(IPlugin):
Note: Tuple return values are mutually exclusive, when one
is None the other must be valid.
"""
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- pass
-
- @_abstractmethod
def volume_replicate(self, pool, rep_type, volume_src, name, flags=0):
"""
Replicates a volume from the specified pool. In this library, to
@@ -187,9 +227,8 @@ class IStorageAreaNetwork(IPlugin):
Note: Tuple return values are mutually exclusive, when one
is None the other must be valid.
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def volume_replicate_range_block_size(self, system, flags=0):
"""
Returns the number of bytes per block for volume_replicate_range
@@ -200,9 +239,8 @@ class IStorageAreaNetwork(IPlugin):

Returns bytes per block, Raises LsmError on error
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def volume_replicate_range(self, rep_type, volume_src, volume_dest, ranges,
flags=0):
"""
@@ -212,27 +250,24 @@ class IStorageAreaNetwork(IPlugin):

Returns Job id or None if completed, else raises LsmError on errors.
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def volume_online(self, volume, flags=0):
"""
Makes a volume available to the host

Returns None on success, else raises LsmError on errors.
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def volume_offline(self, volume, flags=0):
"""
Makes a volume unavailable to the host

Returns None on success, else raises LsmError on errors.
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def iscsi_chap_auth(self, initiator, in_user, in_password, out_user,
out_password, flags):
"""
@@ -245,9 +280,8 @@ class IStorageAreaNetwork(IPlugin):

Raises LsmError on error
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def initiator_grant(self, initiator_id, initiator_type, volume, access,
flags=0):
"""
@@ -255,16 +289,15 @@ class IStorageAreaNetwork(IPlugin):

Returns None on success, else raises LsmError on errors.
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def initiator_revoke(self, initiator, volume, flags=0):
"""
Revokes access to a volume for the specified initiator

Returns None on success, else raises LsmError on errors.
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

def access_group_grant(self, group, volume, access, flags=0):
"""
@@ -272,7 +305,7 @@ class IStorageAreaNetwork(IPlugin):

Returns None on success, else raises LsmError on errors.
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

def access_group_revoke(self, group, volume, flags=0):
"""
@@ -280,71 +313,62 @@ class IStorageAreaNetwork(IPlugin):

Returns None on success, else raises LsmError on errors.
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def access_group_list(self, flags=0):
"""
Returns a list of access groups, raises LsmError on errors.
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def access_group_create(self, name, initiator_id, id_type, system_id,
flags=0):
"""
Returns a list of access groups, raises LsmError on errors.
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def access_group_del(self, group, flags=0):
"""
Deletes an access group, Raises LsmError on error
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def access_group_add_initiator(self, group, initiator_id, id_type,
flags=0):
"""
Adds an initiator to an access group, Raises LsmError on error
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def access_group_del_initiator(self, group, initiator_id, flags=0):
"""
Deletes an initiator from an access group, Raises LsmError on error
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def volumes_accessible_by_access_group(self, group, flags=0):
"""
Returns the list of volumes that access group has access to.
Raises LsmError on error
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def access_groups_granted_to_volume(self, volume, flags=0):
"""
Returns the list of access groups that have access to the specified,
Raises LsmError on error
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def volume_child_dependency(self, volume, flags=0):
"""
Returns True if this volume has other volumes which are dependant on
it. Implies that this volume cannot be deleted or possibly modified
because it would affect its children.
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def volume_child_dependency_rm(self, volume, flags=0):
"""
If this volume has child dependency, this method call will fully
@@ -357,31 +381,27 @@ class IStorageAreaNetwork(IPlugin):

Returns None if complete else job id, raises LsmError on errors.
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def volumes_accessible_by_initiator(self, initiator, flags=0):
"""
Returns a list of volumes that the initiator has access to,
Raises LsmError on errors.
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def initiators_granted_to_volume(self, volume, flags=0):
"""
Returns a list of initiators that have access to the specified volume,
Raises LsmError on errors.
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")


class INetworkAttachedStorage(IPlugin):
"""
Class the represents Network attached storage (Common NFS/CIFS operations)
"""
-
- @_abstractmethod
def fs(self, flags=0):
"""
Returns a list of file systems on the controller. Raises LsmError on
@@ -389,7 +409,6 @@ class INetworkAttachedStorage(IPlugin):
"""
pass

- @_abstractmethod
def fs_delete(self, fs, flags=0):
"""
WARNING: Destructive
@@ -397,9 +416,8 @@ class INetworkAttachedStorage(IPlugin):
Deletes a file system and everything it contains
Returns None on success, else job id
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def fs_resize(self, fs, new_size_bytes, flags=0):
"""
Re-size a file system
@@ -408,9 +426,8 @@ class INetworkAttachedStorage(IPlugin):
Note: Tuple return values are mutually exclusive, when one
is None the other must be valid.
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def fs_create(self, pool, name, size_bytes, flags=0):
"""
Creates a file system given a pool, name and size.
@@ -421,9 +438,8 @@ class INetworkAttachedStorage(IPlugin):
Note: Tuple return values are mutually exclusive, when one
is None the other must be valid.
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def fs_clone(self, src_fs, dest_fs_name, snapshot=None, flags=0):
"""
Creates a thin, point in time read/writable copy of src to dest.
@@ -433,9 +449,8 @@ class INetworkAttachedStorage(IPlugin):
Note: Tuple return values are mutually exclusive, when one
is None the other must be valid.
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def file_clone(self, fs, src_file_name, dest_file_name, snapshot=None,
flags=0):
"""
@@ -444,17 +459,15 @@ class INetworkAttachedStorage(IPlugin):

Returns Job id or None if completed, else raises LsmError on errors.
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def fs_snapshots(self, fs, flags=0):
"""
Returns a list of snapshots for the supplied file system,
Raises LsmError on error
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def fs_snapshot_create(self, fs, snapshot_name, files, flags=0):
"""
Snapshot is a point in time read-only copy
@@ -474,18 +487,16 @@ class INetworkAttachedStorage(IPlugin):
Note: Snapshot name may not match
what was passed in (depends on array implementation)
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def fs_snapshot_delete(self, fs, snapshot, flags=0):
"""
Frees the re-sources for the given snapshot on the supplied filesystem.

Returns Job id or None if completed, else raises LsmError on errors.
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def fs_snapshot_revert(self, fs, snapshot, files, restore_files,
all_files=False, flags=0):
"""
@@ -502,9 +513,8 @@ class INetworkAttachedStorage(IPlugin):

Returns None on success, else job id, LsmError exception on error
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def fs_child_dependency(self, fs, files, flags=0):
"""
Returns True if the specified filesystem or specified file on this
@@ -512,9 +522,8 @@ class INetworkAttachedStorage(IPlugin):
or specified file on this file system cannot be deleted or possibly
modified because it would affect its children.
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def fs_child_dependency_rm(self, fs, files, flags=0):
"""
If this filesystem or specified file on this filesystem has child
@@ -527,35 +536,31 @@ class INetworkAttachedStorage(IPlugin):

Returns Job id or None if completed, else raises LsmError on errors.
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")


class INfs(INetworkAttachedStorage):
- @_abstractmethod
def export_auth(self, flags=0):
"""
Returns the types of authentication that are available for NFS
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def exports(self, flags=0):
"""
Get a list of all exported file systems on the controller.
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def export_fs(self, fs_id, export_path, root_list, rw_list, ro_list,
anon_uid, anon_gid, auth_type, options, flags=0):
"""
Exports a filesystem as specified in the export
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

- @_abstractmethod
def export_remove(self, export, flags=0):
"""
Removes the specified export
"""
- pass
+ raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
diff --git a/lsm/lsm/nstor.py b/lsm/lsm/nstor.py
index 172fe43..10f5525 100644
--- a/lsm/lsm/nstor.py
+++ b/lsm/lsm/nstor.py
@@ -590,37 +590,6 @@ class NexentaStor(INfs, IStorageAreaNetwork):

# return

- def volume_replicate_range_block_size(self, system, flags=0):
- """
- Returns the number of bytes per block for volume_replicate_range
- call. Callers of volume_replicate_range need to use this when
- calculating start and block lengths.
-
- Note: bytes per block may not match volume blocksize.
-
- Returns bytes per block.
- """
- raise LsmError(ErrorNumber.NO_SUPPORT, "This operation is not "
- "supported")
-
- def volume_replicate_range(self, rep_type, volume_src, volume_dest, ranges,
- flags=0):
- """
- Replicates a portion of a volume to itself or another volume. The src,
- dest and number of blocks values change with vendor, call
- volume_replicate_range_block_size to get block unit size.
-
- Returns Job id or None if completed, else raises LsmError on errors.
- """
- raise LsmError(ErrorNumber.NO_SUPPORT, "Replicate range operation is"
- " not supported")
-
- def volume_online(self, volume, flags=0):
- return
-
- def volume_offline(self, volume, flags=0):
- return
-
def iscsi_chap_auth(self, initiator, in_user, in_password, out_user,
out_password, flags=0):
"""
diff --git a/lsm/lsm/ontap.py b/lsm/lsm/ontap.py
index d52b3e4..5321c95 100644
--- a/lsm/lsm/ontap.py
+++ b/lsm/lsm/ontap.py
@@ -818,23 +818,6 @@ class Ontap(IStorageAreaNetwork, INfs):
self.f.iscsi_initiator_add_auth(initiator.id, in_user, in_password,
out_user, out_password)

- @handle_ontap_errors
- def initiator_grant(self, initiator_id, initiator_type, volume, access,
- flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_ontap_errors
- def initiator_revoke(self, initiator, volume, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_ontap_errors
- def volumes_accessible_by_initiator(self, initiator, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_ontap_errors
- def initiators_granted_to_volume(self, volume, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
@staticmethod
def _rpercent(total, current):
p = 1 - (current / float(total))
diff --git a/lsm/lsm/smis.py b/lsm/lsm/smis.py
index 4164381..2050fe7 100644
--- a/lsm/lsm/smis.py
+++ b/lsm/lsm/smis.py
@@ -1844,14 +1844,6 @@ class Smis(IStorageAreaNetwork):
raise LsmError(ErrorNumber.NO_SUPPORT,
"volume-replicate not supported")

- def volume_replicate_range_block_size(self, system, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- def volume_replicate_range(self, rep_type, volume_src, volume_dest,
- ranges,
- flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
@handle_cim_errors
def volume_online(self, volume, flags=0):
return None
@@ -2117,23 +2109,6 @@ class Smis(IStorageAreaNetwork):
cim_spcs = self._get_access_groups(property_list=cim_spc_pros)
return [self._new_access_group(cim_spc) for cim_spc in cim_spcs]

- @handle_cim_errors
- def access_group_create(self, name, initiator_id, id_type, system_id,
- flags=0):
- # page 880 1.5 spec. CreateMaskingView
- #
- # No access to a provider that implements this at this time,
- # so unable to develop and test.
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_cim_errors
- def access_group_del(self, group, flags=0):
- # page 880 1.5 spec. DeleteMaskingView
- #
- # No access to a provider that implements this at this time,
- # so unable to develop and test.
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
def _initiator_lookup(self, initiator_id):
"""
Looks up an initiator by initiator id
@@ -2182,27 +2157,6 @@ class Smis(IStorageAreaNetwork):
*(self._c.InvokeMethod('HidePaths', ccs.path,
**hide_params)))[0]

- @handle_cim_errors
- def iscsi_chap_auth(self, initiator, in_user, in_password, out_user,
- out_password, flags):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_cim_errors
- def initiator_grant(self, initiator_id, initiator_type, volume, access,
- flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_cim_errors
- def initiator_revoke(self, initiator, volume, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_cim_errors
- def volumes_accessible_by_initiator(self, initiator, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_cim_errors
- def initiators_granted_to_volume(self, volume, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")

@handle_cim_errors
def job_free(self, job_id, flags=0):
@@ -2218,12 +2172,6 @@ class Smis(IStorageAreaNetwork):
except CIMError:
pass

- def volume_child_dependency(self, volume, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- def volume_child_dependency_rm(self, volume, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
@handle_cim_errors
def disks(self, flags=0):
"""
diff --git a/lsm/lsm/targetd.py b/lsm/lsm/targetd.py
index 3f0a5cf..8b5c235 100644
--- a/lsm/lsm/targetd.py
+++ b/lsm/lsm/targetd.py
@@ -235,15 +235,6 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
return None, self._get_volume(pool_id, name)

@handle_errors
- def volume_replicate_range_block_size(self, system, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_errors
- def volume_replicate_range(self, rep_type, volume_src, volume_dest,
- ranges, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_errors
def volume_online(self, volume, flags=0):
vol_list = self._jsonrequest("vol_list", dict(pool=volume.pool_id))

@@ -254,48 +245,6 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
return not self.volume_online(volume)

@handle_errors
- def volume_resize(self, volume, new_size_bytes, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_errors
- def access_group_grant(self, group, volume, access, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_errors
- def access_group_revoke(self, group, volume, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_errors
- def access_group_list(self, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_errors
- def access_group_create(self, name, initiator_id, id_type, system_id,
- flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_errors
- def access_group_del(self, group, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_errors
- def access_group_add_initiator(self, group, initiator_id, id_type,
- flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_errors
- def access_group_del_initiator(self, group, initiator, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_errors
- def volumes_accessible_by_access_group(self, group, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_errors
- def access_groups_granted_to_volume(self, volume, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_errors
def iscsi_chap_auth(self, initiator, in_user, in_password, out_user,
out_password, flags=0):
self._jsonrequest("initiator_set_auth",
@@ -362,14 +311,6 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
return inits

@handle_errors
- def volume_child_dependency(self, volume, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_errors
- def volume_child_dependency_rm(self, volume, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_errors
def fs(self, flags=0):
rc = []
for fs in self._jsonrequest("fs_list"):
@@ -384,10 +325,6 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
self._jsonrequest("fs_destroy", dict(uuid=fs.id))

@handle_errors
- def fs_resize(self, fs, new_size_bytes, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_errors
def fs_create(self, pool, name, size_bytes, flags=0):
self._jsonrequest("fs_create", dict(pool_name=pool.id, name=name,
size_bytes=size_bytes))
@@ -408,11 +345,6 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
return None, self._get_fs(src_fs.pool_id, dest_fs_name)

@handle_errors
- def file_clone(self, fs, src_file_name, dest_file_name, snapshot=None,
- flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_errors
def fs_snapshots(self, fs, flags=0):
rc = []
for ss in self._jsonrequest("ss_list", dict(fs_uuid=fs.id)):
@@ -434,19 +366,6 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
ss_uuid=snapshot.id))

@handle_errors
- def fs_snapshot_revert(self, fs, snapshot, files, restore_files,
- all_files=False, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_errors
- def fs_child_dependency(self, fs, files, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_errors
- def fs_child_dependency_rm(self, fs, files, flags=0):
- raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
-
- @handle_errors
def export_auth(self, flags=0):
exports = self._jsonrequest("nfs_export_auth_list")
return exports
--
1.8.2.1
Tony Asleson
2014-04-15 21:47:02 UTC
Permalink
The snapshot functionality we have pertains to fs, so renamed
classes and C functions to reflect that.

Signed-off-by: Tony Asleson <***@redhat.com>
---
include/libstoragemgmt/libstoragemgmt.h | 14 +++----
.../libstoragemgmt/libstoragemgmt_plug_interface.h | 36 ++++++++--------
include/libstoragemgmt/libstoragemgmt_snapshot.h | 24 +++++------
include/libstoragemgmt/libstoragemgmt_types.h | 2 +-
lsm/lsm/__init__.py | 2 +-
lsm/lsm/_client.py | 6 +--
lsm/lsm/_data.py | 2 +-
lsm/lsm/nstor.py | 6 +--
lsm/lsm/ontap.py | 4 +-
lsm/lsm/simarray.py | 4 +-
lsm/lsm/targetd.py | 4 +-
plugin/simc_lsmplugin.c | 36 ++++++++--------
src/lsm_convert.cpp | 12 +++---
src/lsm_convert.hpp | 4 +-
src/lsm_datatypes.cpp | 28 ++++++-------
src/lsm_datatypes.hpp | 2 +-
src/lsm_mgmt.cpp | 20 ++++-----
src/lsm_plugin_ipc.cpp | 48 +++++++++++-----------
test/plugin_test.py | 2 +-
test/tester.c | 14 +++----
20 files changed, 136 insertions(+), 134 deletions(-)

diff --git a/include/libstoragemgmt/libstoragemgmt.h b/include/libstoragemgmt/libstoragemgmt.h
index c37cfe1..109b511 100644
--- a/include/libstoragemgmt/libstoragemgmt.h
+++ b/include/libstoragemgmt/libstoragemgmt.h
@@ -195,7 +195,7 @@ extern "C" {
*/
int LSM_DLL_EXPORT lsm_job_status_ss_get(lsm_connect *c, const char *job,
lsm_job_status *status, uint8_t *percent_complete,
- lsm_ss **ss, lsm_flag flags);
+ lsm_fs_ss **ss, lsm_flag flags);

/**
* Frees the resources used by a job.
@@ -789,7 +789,7 @@ extern "C" {
* error code.
*/
int LSM_DLL_EXPORT lsm_fs_clone(lsm_connect *conn, lsm_fs *src_fs,
- const char *name, lsm_ss *optional_ss,
+ const char *name, lsm_fs_ss *optional_ss,
lsm_fs **cloned_fs,
char **job, lsm_flag flags);

@@ -851,7 +851,7 @@ extern "C" {
int LSM_DLL_EXPORT lsm_fs_file_clone(lsm_connect *conn, lsm_fs *fs,
const char *src_file_name,
const char *dest_file_name,
- lsm_ss *snapshot, char **job,
+ lsm_fs_ss *snapshot, char **job,
lsm_flag flags);

/**
@@ -864,7 +864,7 @@ extern "C" {
* @return LSM_ERR_OK on success, else error reason
*/
int LSM_DLL_EXPORT lsm_fs_ss_list(lsm_connect *conn, lsm_fs *fs,
- lsm_ss **ss[], uint32_t *ss_count,
+ lsm_fs_ss **ss[], uint32_t *ss_count,
lsm_flag flags);

/**
@@ -881,7 +881,7 @@ extern "C" {
*/
int LSM_DLL_EXPORT lsm_fs_ss_create(lsm_connect *c, lsm_fs *fs,
const char *name, lsm_string_list *files,
- lsm_ss **snapshot, char **job,
+ lsm_fs_ss **snapshot, char **job,
lsm_flag flags);

/**
@@ -894,7 +894,7 @@ extern "C" {
* @return LSM_ERR_OK on success, LSM_ERR_JOB_STARTED if async., else error
* code.
*/
- int LSM_DLL_EXPORT lsm_fs_ss_delete(lsm_connect *c, lsm_fs *fs, lsm_ss *ss,
+ int LSM_DLL_EXPORT lsm_fs_ss_delete(lsm_connect *c, lsm_fs *fs, lsm_fs_ss *ss,
char **job, lsm_flag flags);

/**
@@ -911,7 +911,7 @@ extern "C" {
* @return LSM_ERR_OK on success, LSM_ERR_JOB_STARTED if async.,
* else error code
*/
- int LSM_DLL_EXPORT lsm_fs_ss_revert(lsm_connect *c, lsm_fs *fs, lsm_ss *ss,
+ int LSM_DLL_EXPORT lsm_fs_ss_revert(lsm_connect *c, lsm_fs *fs, lsm_fs_ss *ss,
lsm_string_list *files,
lsm_string_list *restore_files,
int all_files, char **job, lsm_flag flags);
diff --git a/include/libstoragemgmt/libstoragemgmt_plug_interface.h b/include/libstoragemgmt/libstoragemgmt_plug_interface.h
index 0a719c6..887cf89 100644
--- a/include/libstoragemgmt/libstoragemgmt_plug_interface.h
+++ b/include/libstoragemgmt/libstoragemgmt_plug_interface.h
@@ -697,7 +697,7 @@ typedef int (*lsm_plug_fs_delete)(lsm_plugin_ptr c, lsm_fs *fs, char **job, lsm_
typedef int (*lsm_plug_fs_clone)(lsm_plugin_ptr c, lsm_fs *src_fs,
const char *dest_fs_name,
lsm_fs **cloned_fs,
- lsm_ss *optional_snapshot,
+ lsm_fs_ss *optional_snapshot,
char **job, lsm_flag flags);
/**
* Determine if a file system has child dependencies, callback function signature
@@ -750,10 +750,11 @@ typedef int (*lsm_plug_fs_resize)(lsm_plugin_ptr c, lsm_fs *fs,
typedef int (*lsm_plug_fs_file_clone)(lsm_plugin_ptr c, lsm_fs *fs,
const char *src_file_name,
const char *dest_file_name,
- lsm_ss *snapshot, char **job, lsm_flag flags);
+ lsm_fs_ss *snapshot, char **job, lsm_flag flags);

/**
- * Retrieve a list of snapshots for a file system, callback function signature
+ * Retrieve a list of fs snapshots for a file system, callback function
+ * signature
* @param[in] c Valid lsm plug-in pointer
* @param[in] fs File system
* @param[out] ss Array of snap shots
@@ -761,12 +762,12 @@ typedef int (*lsm_plug_fs_file_clone)(lsm_plugin_ptr c, lsm_fs *fs,
* @param[in] flags Reserved
* @return LSM_ERR_OK, else error reason
*/
-typedef int (*lsm_plug_ss_list)(lsm_plugin_ptr c, lsm_fs *fs, lsm_ss **ss[],
+typedef int (*lsm_plug_fs_ss_list)(lsm_plugin_ptr c, lsm_fs *fs, lsm_fs_ss **ss[],
uint32_t *ss_count, lsm_flag flags);

/**
- * Create a snapshot of the specified file system and optionally constrain it to
- * a list of files, callback function signature
+ * Create a fs snapshot of the specified file system and optionally constrain
+ * it to a list of files, callback function signature
* @param[in] c Valid lsm plug-in pointer
* @param[in] fs File system to create snapshot for
* @param[in] name Snap shot name
@@ -775,11 +776,12 @@ typedef int (*lsm_plug_ss_list)(lsm_plugin_ptr c, lsm_fs *fs, lsm_ss **ss[],
* @param[out] job Job ID
* @return LSM_ERR_OK, else error reason
*/
-typedef int (*lsm_plug_ss_create)(lsm_plugin_ptr c, lsm_fs *fs,
+typedef int (*lsm_plug_fs_ss_create)(lsm_plugin_ptr c, lsm_fs *fs,
const char *name, lsm_string_list *files,
- lsm_ss **snapshot, char **job, lsm_flag flags);
+ lsm_fs_ss **snapshot, char **job, lsm_flag flags);
/**
- * Delete a snapshot, callback function signature, callback function signature
+ * Delete a fs snapshot, callback function signature, callback function
+ * signature
* @param[in] c Valid lsm plug-in pointer
* @param[in] fs File system to delete snapshot for
* @param[in] ss Snapshot to delete
@@ -787,7 +789,7 @@ typedef int (*lsm_plug_ss_create)(lsm_plugin_ptr c, lsm_fs *fs,
* @param[in] flags Reserved
* @return LSM_ERR_OK, else error reason
*/
-typedef int (*lsm_plug_ss_delete)(lsm_plugin_ptr c, lsm_fs *fs, lsm_ss *ss,
+typedef int (*lsm_plug_fs_ss_delete)(lsm_plugin_ptr c, lsm_fs *fs, lsm_fs_ss *ss,
char **job, lsm_flag flags);

/**
@@ -801,7 +803,7 @@ typedef int (*lsm_plug_ss_delete)(lsm_plugin_ptr c, lsm_fs *fs, lsm_ss *ss,
* @param[out] job Job ID
* @return LSM_ERR_OK, else error reason
*/
-typedef int (*lsm_plug_ss_revert)(lsm_plugin_ptr c, lsm_fs *fs, lsm_ss *ss,
+typedef int (*lsm_plug_fs_ss_revert)(lsm_plugin_ptr c, lsm_fs *fs, lsm_fs_ss *ss,
lsm_string_list *files,
lsm_string_list *restore_files,
int all_files, char **job, lsm_flag flags);
@@ -916,10 +918,10 @@ struct lsm_fs_ops_v1 {
lsm_plug_fs_file_clone fs_file_clone; /**< clone files on a file system */
lsm_plug_fs_child_dependency fs_child_dependency; /**< check file system child dependencies */
lsm_plug_fs_child_dependency_delete fs_child_dependency_rm; /**< remove file system child dependencies */
- lsm_plug_ss_list ss_list; /**< list snapshots */
- lsm_plug_ss_create ss_create; /**< create a snapshot */
- lsm_plug_ss_delete ss_delete; /**< delete a snapshot */
- lsm_plug_ss_revert ss_revert; /**< revert a snapshot */
+ lsm_plug_fs_ss_list fs_ss_list; /**< list snapshots */
+ lsm_plug_fs_ss_create fs_ss_create; /**< create a snapshot */
+ lsm_plug_fs_ss_delete fs_ss_delete; /**< delete a snapshot */
+ lsm_plug_fs_ss_revert fs_ss_revert; /**< revert a snapshot */
};

/** \struct lsm_nas_ops_v1
@@ -1207,7 +1209,7 @@ lsm_fs LSM_DLL_EXPORT **lsm_fs_record_array_alloc( uint32_t size );
* @param ts Epoch time stamp when snapshot was created
* @return Allocated memory, NULL on error
*/
-lsm_ss LSM_DLL_EXPORT *lsm_ss_record_alloc( const char *id, const char *name,
+lsm_fs_ss LSM_DLL_EXPORT *lsm_fs_ss_record_alloc( const char *id, const char *name,
uint64_t ts);

/**
@@ -1215,7 +1217,7 @@ lsm_ss LSM_DLL_EXPORT *lsm_ss_record_alloc( const char *id, const char *name,
* @param size Number of elements
* @return Allocated memory, NULL on error
*/
-lsm_ss LSM_DLL_EXPORT **lsm_ss_record_array_alloc( uint32_t size );
+lsm_fs_ss LSM_DLL_EXPORT **lsm_fs_ss_record_array_alloc( uint32_t size );

/**
* Set a capability
diff --git a/include/libstoragemgmt/libstoragemgmt_snapshot.h b/include/libstoragemgmt/libstoragemgmt_snapshot.h
index 8baec40..393596b 100644
--- a/include/libstoragemgmt/libstoragemgmt_snapshot.h
+++ b/include/libstoragemgmt/libstoragemgmt_snapshot.h
@@ -27,18 +27,18 @@ extern "C" {
#endif

/**
- * Frees a snapshot record.
+ * Frees a file system snapshot record.
* @param ss Snapshot record
* @return LSM_ERR_OK on success, else error reason.
*/
-int LSM_DLL_EXPORT lsm_ss_record_free(lsm_ss *ss);
+int LSM_DLL_EXPORT lsm_fs_ss_record_free(lsm_fs_ss *ss);

/**
- * Copies a snapshot record.
+ * Copies a file system snapshot record.
* @param source Source to copy
* @return Copy of source record snapshot
*/
-lsm_ss LSM_DLL_EXPORT *lsm_ss_record_copy(lsm_ss *source);
+lsm_fs_ss LSM_DLL_EXPORT *lsm_fs_ss_record_copy(lsm_fs_ss *source);

/**
* Frees an array of snapshot record.
@@ -46,28 +46,28 @@ lsm_ss LSM_DLL_EXPORT *lsm_ss_record_copy(lsm_ss *source);
* @param size Number of snapshot records.
* @return LSM_ERR_OK on success, else error reason.
*/
-int LSM_DLL_EXPORT lsm_ss_record_array_free(lsm_ss *ss[], uint32_t size);
+int LSM_DLL_EXPORT lsm_fs_ss_record_array_free(lsm_fs_ss *ss[], uint32_t size);

/**
- * Returns the snapshot id.
+ * Returns the file system snapshot id.
* @param ss The snapshot record
* @return Pointer to id.
*/
-const char LSM_DLL_EXPORT *lsm_ss_id_get(lsm_ss *ss);
+const char LSM_DLL_EXPORT *lsm_fs_ss_id_get(lsm_fs_ss *ss);

/**
* Returns the name.
- * @param ss The snapshot record
+ * @param ss The file system snapshot record
* @return The Name
*/
-const char LSM_DLL_EXPORT *lsm_ss_name_get(lsm_ss *ss);
+const char LSM_DLL_EXPORT *lsm_fs_ss_name_get(lsm_fs_ss *ss);

/**
* Returns the timestamp
- * @param ss The snapshot record.
- * @return The timestamp the snapshot was taken
+ * @param ss The file system snapshot record.
+ * @return The timestamp the file system snapshot was taken
*/
-uint64_t LSM_DLL_EXPORT lsm_ss_time_stamp_get(lsm_ss *ss);
+uint64_t LSM_DLL_EXPORT lsm_fs_ss_time_stamp_get(lsm_fs_ss *ss);

#ifdef __cplusplus
}
diff --git a/include/libstoragemgmt/libstoragemgmt_types.h b/include/libstoragemgmt/libstoragemgmt_types.h
index 5e2389d..98d123a 100644
--- a/include/libstoragemgmt/libstoragemgmt_types.h
+++ b/include/libstoragemgmt/libstoragemgmt_types.h
@@ -103,7 +103,7 @@ typedef struct _lsm_fs lsm_fs;
/**
* Opaque data type for snapshot
*/
-typedef struct _lsm_ss lsm_ss;
+typedef struct _lsm_fs_ss lsm_fs_ss;

/**
* Opaque data type for disk
diff --git a/lsm/lsm/__init__.py b/lsm/lsm/__init__.py
index 22bf7c4..0635b7e 100644
--- a/lsm/lsm/__init__.py
+++ b/lsm/lsm/__init__.py
@@ -5,7 +5,7 @@ from version import VERSION
from _common import Error, Info, LsmError, ErrorLevel, ErrorNumber, \
JobStatus, uri_parse, md5, Proxy, size_bytes_2_size_human
from _data import Initiator, Disk, \
- Volume, Pool, System, FileSystem, Snapshot, NfsExport, BlockRange, \
+ Volume, Pool, System, FileSystem, FsSnapshot, NfsExport, BlockRange, \
AccessGroup, OptionalData, Capabilities, txt_a
from _iplugin import IPlugin, IStorageAreaNetwork, INetworkAttachedStorage, \
INfs
diff --git a/lsm/lsm/_client.py b/lsm/lsm/_client.py
index 197a7e9..8bb5949 100644
--- a/lsm/lsm/_client.py
+++ b/lsm/lsm/_client.py
@@ -19,7 +19,7 @@ import time
import os
import unittest
from lsm import (Volume, NfsExport, Capabilities, Pool, System,
- Initiator, Disk, AccessGroup, FileSystem, Snapshot,
+ Initiator, Disk, AccessGroup, FileSystem, FsSnapshot,
uri_parse, LsmError, JobStatus, ErrorNumber,
INetworkAttachedStorage)

@@ -938,7 +938,7 @@ class Client(INetworkAttachedStorage):
# @param fs The file system
# @param flags Reserved for future use, must be zero.
# @returns a list of snapshot objects.
- @_return_requires([Snapshot])
+ @_return_requires([FsSnapshot])
def fs_snapshots(self, fs, flags=0):
"""
Returns a list of snapshot names for the supplied file system
@@ -952,7 +952,7 @@ class Client(INetworkAttachedStorage):
# @param files The list of specific files to snapshot.
# @param flags Reserved for future use, must be zero.
# @returns tuple (job_id, snapshot)
- @_return_requires(unicode, Snapshot)
+ @_return_requires(unicode, FsSnapshot)
def fs_snapshot_create(self, fs, snapshot_name, files, flags=0):
"""
Snapshot is a point in time read-only copy
diff --git a/lsm/lsm/_data.py b/lsm/lsm/_data.py
index f950be0..72c2629 100644
--- a/lsm/lsm/_data.py
+++ b/lsm/lsm/_data.py
@@ -1328,7 +1328,7 @@ class FileSystem(IData):
@default_property('id', doc="Unique identifier")
@default_property('name', doc="Snapshot name")
@default_property('ts', doc="Time stamp the snapshot was created")
-class Snapshot(IData):
+class FsSnapshot(IData):
def __init__(self, _id, _name, _ts):
self._id = _id
self._name = _name
diff --git a/lsm/lsm/nstor.py b/lsm/lsm/nstor.py
index 6fc6232..b0cca76 100644
--- a/lsm/lsm/nstor.py
+++ b/lsm/lsm/nstor.py
@@ -29,7 +29,7 @@ import time

from lsm import (AccessGroup, Capabilities, ErrorNumber, FileSystem, INfs,
IStorageAreaNetwork, Initiator, LsmError, NfsExport, Pool,
- Snapshot, System, VERSION, Volume, md5)
+ FsSnapshot, System, VERSION, Volume, md5)


class NexentaStor(INfs, IStorageAreaNetwork):
@@ -168,7 +168,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
for snapshot in snapshot_list:
snapshot_info = self._request("get_child_props", "snapshot",
[snapshot, "creation_seconds"])
- snapshots.append(Snapshot(snapshot, snapshot,
+ snapshots.append(FsSnapshot(snapshot, snapshot,
snapshot_info['creation_seconds']))

return snapshots
@@ -179,7 +179,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
self._request("create", "snapshot", [full_name, "0"])
snapshot_info = self._request("get_child_props", "snapshot",
[full_name, "creation_seconds"])
- return None, Snapshot(full_name, full_name,
+ return None, FsSnapshot(full_name, full_name,
snapshot_info['creation_seconds'])

def fs_snapshot_delete(self, fs, snapshot, flags=0):
diff --git a/lsm/lsm/ontap.py b/lsm/lsm/ontap.py
index 5cb20b8..5166880 100644
--- a/lsm/lsm/ontap.py
+++ b/lsm/lsm/ontap.py
@@ -23,7 +23,7 @@ import urlparse
import sys

import na
-from lsm import (Volume, Initiator, FileSystem, Snapshot, NfsExport,
+from lsm import (Volume, Initiator, FileSystem, FsSnapshot, NfsExport,
AccessGroup, System, Capabilities, Disk, Pool, OptionalData,
IStorageAreaNetwork, INfs, LsmError, ErrorNumber, JobStatus,
md5, Error, VERSION)
@@ -207,7 +207,7 @@ class Ontap(IStorageAreaNetwork, INfs):
def _ss(s):
#If we use the newer API we can use the uuid instead of this fake
#md5 one
- return Snapshot(md5(s['name'] + s['access-time']), s['name'],
+ return FsSnapshot(md5(s['name'] + s['access-time']), s['name'],
s['access-time'])

@staticmethod
diff --git a/lsm/lsm/simarray.py b/lsm/lsm/simarray.py
index ce615b6..e6043fa 100644
--- a/lsm/lsm/simarray.py
+++ b/lsm/lsm/simarray.py
@@ -27,7 +27,7 @@ import time

from _common import (size_human_2_size_bytes, size_bytes_2_size_human)
from lsm import (System, Volume, Disk, Pool, FileSystem, AccessGroup,
- Initiator, Snapshot, NfsExport, OptionalData, md5,
+ Initiator, FsSnapshot, NfsExport, OptionalData, md5,
LsmError, ErrorNumber, JobStatus)

# Used for format width for disks
@@ -295,7 +295,7 @@ class SimArray(object):

@staticmethod
def _sim_snap_2_lsm(sim_snap):
- return Snapshot(sim_snap['snap_id'], sim_snap['name'],
+ return FsSnapshot(sim_snap['snap_id'], sim_snap['name'],
sim_snap['timestamp'])

def fs_snapshots(self, fs_id, flags=0):
diff --git a/lsm/lsm/targetd.py b/lsm/lsm/targetd.py
index 8a94d22..132d91c 100644
--- a/lsm/lsm/targetd.py
+++ b/lsm/lsm/targetd.py
@@ -20,7 +20,7 @@
import copy

from lsm import (Pool, Volume, System, Capabilities, Initiator,
- IStorageAreaNetwork, INfs, FileSystem, Snapshot, NfsExport,
+ IStorageAreaNetwork, INfs, FileSystem, FsSnapshot, NfsExport,
LsmError, ErrorNumber, uri_parse, md5, Error, VERSION)

import traceback
@@ -349,7 +349,7 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
rc = []
for ss in self._jsonrequest("ss_list", dict(fs_uuid=fs.id)):
#id, name, timestamp
- rc.append(Snapshot(ss['uuid'], ss['name'], ss['timestamp']))
+ rc.append(FsSnapshot(ss['uuid'], ss['name'], ss['timestamp']))
return rc

@handle_errors
diff --git a/plugin/simc_lsmplugin.c b/plugin/simc_lsmplugin.c
index d889109..6f65eb1 100644
--- a/plugin/simc_lsmplugin.c
+++ b/plugin/simc_lsmplugin.c
@@ -170,7 +170,7 @@ void free_allocated_job(void *j)
lsm_pool_record_free((lsm_pool *)job->return_data);
break;
case(LSM_DATA_TYPE_SS):
- lsm_ss_record_free((lsm_ss *)job->return_data);
+ lsm_fs_ss_record_free((lsm_fs_ss *)job->return_data);
break;
case(LSM_DATA_TYPE_STRING_LIST):
lsm_string_list_free((lsm_string_list *)job->return_data);
@@ -230,7 +230,7 @@ void free_fs_record(struct allocated_fs *fs)

static void free_ss(void *s)
{
- lsm_ss_record_free((lsm_ss *)s);
+ lsm_fs_ss_record_free((lsm_fs_ss *)s);
}

static void free_export(void *exp)
@@ -2024,7 +2024,7 @@ static int fs_resize(lsm_plugin_ptr c, lsm_fs *fs,
}

static int fs_clone(lsm_plugin_ptr c, lsm_fs *src_fs, const char *dest_fs_name,
- lsm_fs **cloned_fs, lsm_ss *optional_snapshot,
+ lsm_fs **cloned_fs, lsm_fs_ss *optional_snapshot,
char **job, lsm_flag flags)
{
int rc = LSM_ERR_OK;
@@ -2045,7 +2045,7 @@ static int fs_clone(lsm_plugin_ptr c, lsm_fs *src_fs, const char *dest_fs_name,
static int fs_file_clone(lsm_plugin_ptr c, lsm_fs *fs,
const char *src_file_name,
const char *dest_file_name,
- lsm_ss *snapshot, char **job,
+ lsm_fs_ss *snapshot, char **job,
lsm_flag flags)
{
int rc = LSM_ERR_OK;
@@ -2089,7 +2089,7 @@ static int fs_child_dependency_rm( lsm_plugin_ptr c, lsm_fs *fs,
return rc;
}

-static int ss_list(lsm_plugin_ptr c, lsm_fs * fs, lsm_ss **ss[],
+static int ss_list(lsm_plugin_ptr c, lsm_fs * fs, lsm_fs_ss **ss[],
uint32_t *count, lsm_flag flags)
{
int rc = LSM_ERR_OK;
@@ -2100,24 +2100,24 @@ static int ss_list(lsm_plugin_ptr c, lsm_fs * fs, lsm_ss **ss[],

if( find ) {
char *k = NULL;
- lsm_ss *v = NULL;
+ lsm_fs_ss *v = NULL;
GHashTableIter iter;

*ss = NULL;
*count = g_hash_table_size(find->ss);

if( *count ) {
- *ss = lsm_ss_record_array_alloc(*count);
+ *ss = lsm_fs_ss_record_array_alloc(*count);
if( *ss ) {
int i = 0;
g_hash_table_iter_init(&iter, find->ss);

while(g_hash_table_iter_next(&iter,
(gpointer) &k,(gpointer)&v)) {
- (*ss)[i] = lsm_ss_record_copy(v);
+ (*ss)[i] = lsm_fs_ss_record_copy(v);
if( !(*ss)[i] ) {
rc = lsm_log_error_basic(c, LSM_ERR_NO_MEMORY, "ENOMEM");
- lsm_ss_record_array_free(*ss, i);
+ lsm_fs_ss_record_array_free(*ss, i);
*ss = NULL;
*count = 0;
break;
@@ -2138,7 +2138,7 @@ static int ss_list(lsm_plugin_ptr c, lsm_fs * fs, lsm_ss **ss[],

static int ss_create(lsm_plugin_ptr c, lsm_fs *fs,
const char *name, lsm_string_list *files,
- lsm_ss **snapshot, char **job,
+ lsm_fs_ss **snapshot, char **job,
lsm_flag flags)
{
int rc = LSM_ERR_NO_MEMORY;
@@ -2151,16 +2151,16 @@ static int ss_create(lsm_plugin_ptr c, lsm_fs *fs,
if( !g_hash_table_lookup(find->ss, md5(name)) ) {
char *id = strdup(md5(name));
if( id ) {
- lsm_ss *ss = lsm_ss_record_alloc(id, name, time(NULL));
- lsm_ss *new_shot = lsm_ss_record_copy(ss);
+ lsm_fs_ss *ss = lsm_fs_ss_record_alloc(id, name, time(NULL));
+ lsm_fs_ss *new_shot = lsm_fs_ss_record_copy(ss);
if( ss && new_shot ) {
g_hash_table_insert(find->ss, (gpointer)id, (gpointer)ss);
rc = create_job(pd, job, LSM_DATA_TYPE_SS, new_shot,
(void**)snapshot);
} else {
- lsm_ss_record_free(ss);
+ lsm_fs_ss_record_free(ss);
ss = NULL;
- lsm_ss_record_free(new_shot);
+ lsm_fs_ss_record_free(new_shot);
*snapshot = NULL;
free(id);
id = NULL;
@@ -2176,7 +2176,7 @@ static int ss_create(lsm_plugin_ptr c, lsm_fs *fs,
return rc;
}

-static int ss_delete(lsm_plugin_ptr c, lsm_fs *fs, lsm_ss *ss,
+static int ss_delete(lsm_plugin_ptr c, lsm_fs *fs, lsm_fs_ss *ss,
char **job, lsm_flag flags)
{
int rc = LSM_ERR_OK;
@@ -2186,7 +2186,7 @@ static int ss_delete(lsm_plugin_ptr c, lsm_fs *fs, lsm_ss *ss,
pd->fs, lsm_fs_id_get(fs));

if( find ) {
- if( !g_hash_table_remove(find->ss, lsm_ss_id_get(ss)) ) {
+ if( !g_hash_table_remove(find->ss, lsm_fs_ss_id_get(ss)) ) {
rc = lsm_log_error_basic(c, LSM_ERR_NOT_FOUND_SS,
"snapshot not found");
} else {
@@ -2198,7 +2198,7 @@ static int ss_delete(lsm_plugin_ptr c, lsm_fs *fs, lsm_ss *ss,
return rc;
}

-static int ss_revert(lsm_plugin_ptr c, lsm_fs *fs, lsm_ss *ss,
+static int ss_revert(lsm_plugin_ptr c, lsm_fs *fs, lsm_fs_ss *ss,
lsm_string_list *files,
lsm_string_list *restore_files,
int all_files, char **job, lsm_flag flags)
@@ -2210,7 +2210,7 @@ static int ss_revert(lsm_plugin_ptr c, lsm_fs *fs, lsm_ss *ss,
pd->fs, lsm_fs_id_get(fs));

if( find ) {
- if(!g_hash_table_lookup(find->ss, lsm_ss_id_get(ss))) {
+ if(!g_hash_table_lookup(find->ss, lsm_fs_ss_id_get(ss))) {
rc = lsm_log_error_basic(c, LSM_ERR_NOT_FOUND_SS,
"snapshot not found");
} else {
diff --git a/src/lsm_convert.cpp b/src/lsm_convert.cpp
index a2d2805..7be6dce 100644
--- a/src/lsm_convert.cpp
+++ b/src/lsm_convert.cpp
@@ -414,23 +414,23 @@ Value fs_to_value(lsm_fs *fs)
}


-lsm_ss *value_to_ss(Value &ss)
+lsm_fs_ss *value_to_ss(Value &ss)
{
- lsm_ss *rc = NULL;
- if( is_expected_object(ss, "Snapshot") ) {
+ lsm_fs_ss *rc = NULL;
+ if( is_expected_object(ss, "FsSnapshot") ) {
std::map<std::string, Value> f = ss.asObject();
- rc = lsm_ss_record_alloc(f["id"].asString().c_str(),
+ rc = lsm_fs_ss_record_alloc(f["id"].asString().c_str(),
f["name"].asString().c_str(),
f["ts"].asUint64_t());
}
return rc;
}

-Value ss_to_value(lsm_ss *ss)
+Value ss_to_value(lsm_fs_ss *ss)
{
if( LSM_IS_SS(ss) ) {
std::map<std::string, Value> f;
- f["class"] = Value("Snapshot");
+ f["class"] = Value("FsSnapshot");
f["id"] = Value(ss->id);
f["name"] = Value(ss->name);
f["ts"] = Value(ss->ts);
diff --git a/src/lsm_convert.hpp b/src/lsm_convert.hpp
index 580c13c..366234d 100644
--- a/src/lsm_convert.hpp
+++ b/src/lsm_convert.hpp
@@ -187,14 +187,14 @@ Value fs_to_value(lsm_fs *fs);
* @param ss Value representing a snapshot to be converted
* @return lsm_ss pointer or NULL on error.
*/
-lsm_ss *value_to_ss(Value &ss);
+lsm_fs_ss *value_to_ss(Value &ss);

/**
* Converts a lsm_ss pointer to a Value
* @param ss Snapshot pointer to convert
* @return Value
*/
-Value ss_to_value(lsm_ss *ss);
+Value ss_to_value(lsm_fs_ss *ss);

/**
* Converts a value to a lsm_nfs_export *
diff --git a/src/lsm_datatypes.cpp b/src/lsm_datatypes.cpp
index add7467..b5e68e0 100644
--- a/src/lsm_datatypes.cpp
+++ b/src/lsm_datatypes.cpp
@@ -1270,10 +1270,10 @@ uint64_t lsm_fs_free_space_get(lsm_fs *fs)
MEMBER_GET(fs, LSM_IS_FS, free_space, 0);
}

-lsm_ss * lsm_ss_record_alloc( const char *id, const char *name,
+lsm_fs_ss * lsm_fs_ss_record_alloc( const char *id, const char *name,
uint64_t ts)
{
- lsm_ss *rc = (lsm_ss *) malloc(sizeof(lsm_ss));
+ lsm_fs_ss *rc = (lsm_fs_ss *) malloc(sizeof(lsm_fs_ss));
if( rc ) {
rc->magic = LSM_SS_MAGIC;
rc->id = strdup(id);
@@ -1281,25 +1281,25 @@ lsm_ss * lsm_ss_record_alloc( const char *id, const char *name,
rc->ts = ts;

if( !rc->id || ! rc->name ) {
- lsm_ss_record_free(rc);
+ lsm_fs_ss_record_free(rc);
rc = NULL;
}
}
return rc;
}

-lsm_ss *lsm_ss_record_copy(lsm_ss *source)
+lsm_fs_ss *lsm_fs_ss_record_copy(lsm_fs_ss *source)
{
- lsm_ss *rc = NULL;
+ lsm_fs_ss *rc = NULL;
if( LSM_IS_SS(source) ) {
- rc = lsm_ss_record_alloc( lsm_ss_id_get(source),
- lsm_ss_name_get(source),
- lsm_ss_time_stamp_get(source));
+ rc = lsm_fs_ss_record_alloc( lsm_fs_ss_id_get(source),
+ lsm_fs_ss_name_get(source),
+ lsm_fs_ss_time_stamp_get(source));
}
return rc;
}

-int lsm_ss_record_free( lsm_ss *ss)
+int lsm_fs_ss_record_free( lsm_fs_ss *ss)
{
if( LSM_IS_SS(ss) ) {
ss->magic = LSM_DEL_MAGIC(LSM_SS_MAGIC);
@@ -1311,21 +1311,21 @@ int lsm_ss_record_free( lsm_ss *ss)
return LSM_ERR_INVALID_SS;
}

-CREATE_ALLOC_ARRAY_FUNC(lsm_ss_record_array_alloc, lsm_ss *)
-CREATE_FREE_ARRAY_FUNC(lsm_ss_record_array_free, lsm_ss_record_free, lsm_ss *,
+CREATE_ALLOC_ARRAY_FUNC(lsm_fs_ss_record_array_alloc, lsm_fs_ss *)
+CREATE_FREE_ARRAY_FUNC(lsm_fs_ss_record_array_free, lsm_fs_ss_record_free, lsm_fs_ss *,
LSM_ERR_INVALID_SS)

-const char *lsm_ss_id_get(lsm_ss *ss)
+const char *lsm_fs_ss_id_get(lsm_fs_ss *ss)
{
MEMBER_GET(ss, LSM_IS_SS, id, NULL);
}

-const char *lsm_ss_name_get(lsm_ss *ss)
+const char *lsm_fs_ss_name_get(lsm_fs_ss *ss)
{
MEMBER_GET(ss, LSM_IS_SS, name, NULL);
}

-uint64_t lsm_ss_time_stamp_get(lsm_ss *ss)
+uint64_t lsm_fs_ss_time_stamp_get(lsm_fs_ss *ss)
{
MEMBER_GET(ss, LSM_IS_SS, ts, 0);
}
diff --git a/src/lsm_datatypes.hpp b/src/lsm_datatypes.hpp
index fceeea7..a0b3574 100644
--- a/src/lsm_datatypes.hpp
+++ b/src/lsm_datatypes.hpp
@@ -273,7 +273,7 @@ struct LSM_DLL_LOCAL _lsm_fs {

#define LSM_SS_MAGIC 0xAA7A000F
#define LSM_IS_SS(obj) MAGIC_CHECK(obj, LSM_SS_MAGIC)
-struct LSM_DLL_LOCAL _lsm_ss {
+struct LSM_DLL_LOCAL _lsm_fs_ss {
uint32_t magic;
char *id;
char *name;
diff --git a/src/lsm_mgmt.cpp b/src/lsm_mgmt.cpp
index bba5bb9..ca3ccba 100644
--- a/src/lsm_mgmt.cpp
+++ b/src/lsm_mgmt.cpp
@@ -538,7 +538,7 @@ int lsm_job_status_fs_get(lsm_connect *c, const char *job,

int lsm_job_status_ss_get(lsm_connect *c, const char *job,
lsm_job_status *status, uint8_t *percentComplete,
- lsm_ss **ss, lsm_flag flags)
+ lsm_fs_ss **ss, lsm_flag flags)
{
int rc = LSM_ERR_OK;
Value rv;
@@ -1978,7 +1978,7 @@ int lsm_fs_resize(lsm_connect *c, lsm_fs *fs,
}

int lsm_fs_clone(lsm_connect *c, lsm_fs *src_fs,
- const char *name, lsm_ss *optional_ss,
+ const char *name, lsm_fs_ss *optional_ss,
lsm_fs **cloned_fs,
char **job, lsm_flag flags)
{
@@ -2010,7 +2010,7 @@ int lsm_fs_clone(lsm_connect *c, lsm_fs *src_fs,
}

int lsm_fs_file_clone(lsm_connect *c, lsm_fs *fs, const char *src_file_name,
- const char *dest_file_name, lsm_ss *snapshot, char **job,
+ const char *dest_file_name, lsm_fs_ss *snapshot, char **job,
lsm_flag flags)
{
CONN_SETUP(c);
@@ -2118,7 +2118,7 @@ int lsm_fs_child_dependency_delete( lsm_connect *c, lsm_fs *fs, lsm_string_list
return jobCheck(c, rc, response, job);
}

-int lsm_fs_ss_list(lsm_connect *c, lsm_fs *fs, lsm_ss **ss[],
+int lsm_fs_ss_list(lsm_connect *c, lsm_fs *fs, lsm_fs_ss **ss[],
uint32_t *ssCount, lsm_flag flags )
{
int rc = LSM_ERR_OK;
@@ -2147,7 +2147,7 @@ int lsm_fs_ss_list(lsm_connect *c, lsm_fs *fs, lsm_ss **ss[],
*ssCount = sys.size();

if( sys.size() ) {
- *ss = lsm_ss_record_array_alloc(sys.size());
+ *ss = lsm_fs_ss_record_array_alloc(sys.size());

if( *ss ) {
for( size_t i = 0; i < sys.size(); ++i ) {
@@ -2162,7 +2162,7 @@ int lsm_fs_ss_list(lsm_connect *c, lsm_fs *fs, lsm_ss **ss[],
rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type",
ve.what());
if( *ss && *ssCount ) {
- lsm_ss_record_array_free(*ss, *ssCount);
+ lsm_fs_ss_record_array_free(*ss, *ssCount);
*ss = NULL;
*ssCount = 0;
}
@@ -2172,7 +2172,7 @@ int lsm_fs_ss_list(lsm_connect *c, lsm_fs *fs, lsm_ss **ss[],
}

int lsm_fs_ss_create(lsm_connect *c, lsm_fs *fs, const char *name,
- lsm_string_list *files, lsm_ss **snapshot, char **job,
+ lsm_string_list *files, lsm_fs_ss **snapshot, char **job,
lsm_flag flags)
{
CONN_SETUP(c);
@@ -2202,13 +2202,13 @@ int lsm_fs_ss_create(lsm_connect *c, lsm_fs *fs, const char *name,

int rc = rpc(c, "fs_snapshot_create", parameters, response);
if( LSM_ERR_OK == rc ) {
- *snapshot = (lsm_ss *)parse_job_response(c, response, rc, job,
+ *snapshot = (lsm_fs_ss *)parse_job_response(c, response, rc, job,
(convert)value_to_ss);
}
return rc;
}

-int lsm_fs_ss_delete(lsm_connect *c, lsm_fs *fs, lsm_ss *ss, char **job,
+int lsm_fs_ss_delete(lsm_connect *c, lsm_fs *fs, lsm_fs_ss *ss, char **job,
lsm_flag flags)
{
CONN_SETUP(c);
@@ -2237,7 +2237,7 @@ int lsm_fs_ss_delete(lsm_connect *c, lsm_fs *fs, lsm_ss *ss, char **job,
return jobCheck(c, rc, response, job);
}

-int lsm_fs_ss_revert(lsm_connect *c, lsm_fs *fs, lsm_ss *ss,
+int lsm_fs_ss_revert(lsm_connect *c, lsm_fs *fs, lsm_fs_ss *ss,
lsm_string_list *files,
lsm_string_list *restore_files,
int all_files, char **job, lsm_flag flags)
diff --git a/src/lsm_plugin_ipc.cpp b/src/lsm_plugin_ipc.cpp
index 86cb7f8..c7d7f73 100644
--- a/src/lsm_plugin_ipc.cpp
+++ b/src/lsm_plugin_ipc.cpp
@@ -79,7 +79,7 @@ void * lsm_data_type_copy(lsm_data_type t, void *item)
rc = lsm_pool_record_copy((lsm_pool *)item);
break;
case(LSM_DATA_TYPE_SS):
- rc = lsm_ss_record_copy((lsm_ss *)item);
+ rc = lsm_fs_ss_record_copy((lsm_fs_ss *)item);
break;
case(LSM_DATA_TYPE_STRING_LIST):
rc = lsm_string_list_copy((lsm_string_list *)item);
@@ -371,9 +371,9 @@ static int handle_job_status( lsm_plugin_ptr p, Value &params, Value &response)
result.push_back(fs_to_value((lsm_fs *)value));
lsm_fs_record_free((lsm_fs *)value);
} else if( LSM_DATA_TYPE_SS == t &&
- LSM_IS_SS((lsm_ss *)value)) {
- result.push_back(ss_to_value((lsm_ss *)value));
- lsm_ss_record_free((lsm_ss *)value);
+ LSM_IS_SS((lsm_fs_ss *)value)) {
+ result.push_back(ss_to_value((lsm_fs_ss *)value));
+ lsm_fs_ss_record_free((lsm_fs_ss *)value);
} else if( LSM_DATA_TYPE_POOL == t &&
LSM_IS_POOL((lsm_pool *)value)) {
result.push_back(pool_to_value((lsm_pool *)value));
@@ -1658,7 +1658,7 @@ static int fs_clone(lsm_plugin_ptr p, Value &params, Value &response)
char *job = NULL;
lsm_fs *fs = value_to_fs(v_src_fs);
const char* name = v_name.asC_str();
- lsm_ss *ss = value_to_ss(v_ss);
+ lsm_fs_ss *ss = value_to_ss(v_ss);

if( fs &&
(( ss && v_ss.valueType() == Value::object_t) ||
@@ -1685,7 +1685,7 @@ static int fs_clone(lsm_plugin_ptr p, Value &params, Value &response)
}

lsm_fs_record_free(fs);
- lsm_ss_record_free(ss);
+ lsm_fs_ss_record_free(ss);

} else {
rc = LSM_ERR_TRANSPORT_INVALID_ARG;
@@ -1713,7 +1713,7 @@ static int file_clone(lsm_plugin_ptr p, Value &params, Value &response)


lsm_fs *fs = value_to_fs(v_fs);
- lsm_ss *ss = value_to_ss(v_ss);
+ lsm_fs_ss *ss = value_to_ss(v_ss);

if( fs &&
(( ss && v_ss.valueType() == Value::object_t) ||
@@ -1737,7 +1737,7 @@ static int file_clone(lsm_plugin_ptr p, Value &params, Value &response)
}

lsm_fs_record_free(fs);
- lsm_ss_record_free(ss);
+ lsm_fs_ss_record_free(ss);

} else {
rc = LSM_ERR_TRANSPORT_INVALID_ARG;
@@ -1823,7 +1823,7 @@ static int fs_child_dependency_rm(lsm_plugin_ptr p, Value &params, Value &respon
static int ss_list(lsm_plugin_ptr p, Value &params, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->fs_ops->ss_list ) {
+ if( p && p->san_ops && p->fs_ops->fs_ss_list ) {

Value v_fs = params["fs"];

@@ -1833,10 +1833,10 @@ static int ss_list(lsm_plugin_ptr p, Value &params, Value &response)
lsm_fs *fs = value_to_fs(v_fs);

if( fs ) {
- lsm_ss **ss = NULL;
+ lsm_fs_ss **ss = NULL;
uint32_t count = 0;

- rc = p->fs_ops->ss_list(p, fs, &ss, &count,
+ rc = p->fs_ops->fs_ss_list(p, fs, &ss, &count,
LSM_FLAG_GET_VALUE(params));

if( LSM_ERR_OK == rc ) {
@@ -1849,7 +1849,7 @@ static int ss_list(lsm_plugin_ptr p, Value &params, Value &response)

lsm_fs_record_free(fs);
fs = NULL;
- lsm_ss_record_array_free(ss, count);
+ lsm_fs_ss_record_array_free(ss, count);
ss = NULL;
}
}
@@ -1864,7 +1864,7 @@ static int ss_list(lsm_plugin_ptr p, Value &params, Value &response)
static int ss_create(lsm_plugin_ptr p, Value &params, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->fs_ops->ss_create ) {
+ if( p && p->san_ops && p->fs_ops->fs_ss_create ) {

Value v_fs = params["fs"];
Value v_ss_name = params["snapshot_name"];
@@ -1879,12 +1879,12 @@ static int ss_create(lsm_plugin_ptr p, Value &params, Value &response)
lsm_string_list *files = value_to_string_list(v_files);

if( fs && files ) {
- lsm_ss *ss = NULL;
+ lsm_fs_ss *ss = NULL;
char *job = NULL;

const char *name = v_ss_name.asC_str();

- rc = p->fs_ops->ss_create(p, fs, name, files, &ss, &job,
+ rc = p->fs_ops->fs_ss_create(p, fs, name, files, &ss, &job,
LSM_FLAG_GET_VALUE(params));

std::vector<Value> r;
@@ -1892,7 +1892,7 @@ static int ss_create(lsm_plugin_ptr p, Value &params, Value &response)
r.push_back(Value());
r.push_back(ss_to_value(ss));
response = Value(r);
- lsm_ss_record_free(ss);
+ lsm_fs_ss_record_free(ss);
} else if (LSM_ERR_JOB_STARTED == rc ) {
r.push_back(Value(job));
r.push_back(Value());
@@ -1917,7 +1917,7 @@ static int ss_create(lsm_plugin_ptr p, Value &params, Value &response)
static int ss_delete(lsm_plugin_ptr p, Value &params, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->fs_ops->ss_delete ) {
+ if( p && p->san_ops && p->fs_ops->fs_ss_delete ) {

Value v_fs = params["fs"];
Value v_ss = params["snapshot"];
@@ -1927,11 +1927,11 @@ static int ss_delete(lsm_plugin_ptr p, Value &params, Value &response)
LSM_FLAG_EXPECTED_TYPE(params)) {

lsm_fs *fs = value_to_fs(v_fs);
- lsm_ss *ss = value_to_ss(v_ss);
+ lsm_fs_ss *ss = value_to_ss(v_ss);

if( fs && ss ) {
char *job = NULL;
- rc = p->fs_ops->ss_delete(p, fs, ss, &job,
+ rc = p->fs_ops->fs_ss_delete(p, fs, ss, &job,
LSM_FLAG_GET_VALUE(params));

if( LSM_ERR_JOB_STARTED == rc ) {
@@ -1943,7 +1943,7 @@ static int ss_delete(lsm_plugin_ptr p, Value &params, Value &response)
}

lsm_fs_record_free(fs);
- lsm_ss_record_free(ss);
+ lsm_fs_ss_record_free(ss);
} else {
rc = LSM_ERR_TRANSPORT_INVALID_ARG;
}
@@ -1954,7 +1954,7 @@ static int ss_delete(lsm_plugin_ptr p, Value &params, Value &response)
static int ss_revert(lsm_plugin_ptr p, Value &params, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->fs_ops->ss_revert ) {
+ if( p && p->san_ops && p->fs_ops->fs_ss_revert ) {

Value v_fs = params["fs"];
Value v_ss = params["snapshot"];
@@ -1971,14 +1971,14 @@ static int ss_revert(lsm_plugin_ptr p, Value &params, Value &response)

char *job = NULL;
lsm_fs *fs = value_to_fs(v_fs);
- lsm_ss *ss = value_to_ss(v_ss);
+ lsm_fs_ss *ss = value_to_ss(v_ss);
lsm_string_list *files = value_to_string_list(v_files);
lsm_string_list *restore_files =
value_to_string_list(v_restore_files);
int all_files = (v_all_files.asBool()) ? 1 : 0;

if( fs && ss && files && restore_files ) {
- rc = p->fs_ops->ss_revert(p, fs, ss, files, restore_files,
+ rc = p->fs_ops->fs_ss_revert(p, fs, ss, files, restore_files,
all_files, &job,
LSM_FLAG_GET_VALUE(params));

@@ -1991,7 +1991,7 @@ static int ss_revert(lsm_plugin_ptr p, Value &params, Value &response)
}

lsm_fs_record_free(fs);
- lsm_ss_record_free(ss);
+ lsm_fs_ss_record_free(ss);
lsm_string_list_free(files);
lsm_string_list_free(restore_files);
} else {
diff --git a/test/plugin_test.py b/test/plugin_test.py
index 3b3759b..e00cc5f 100755
--- a/test/plugin_test.py
+++ b/test/plugin_test.py
@@ -106,7 +106,7 @@ class TestProxy(object):
'fs_create': (unicode, lsm.FileSystem),
'fs_clone': (unicode, lsm.FileSystem),
'file_clone': (unicode,),
- 'fs_snapshot_create': (unicode, lsm.Snapshot),
+ 'fs_snapshot_create': (unicode, lsm.FsSnapshot),
'fs_snapshot_delete': (unicode,),
'fs_snapshot_revert': (unicode,),
'fs_child_dependency_rm': (unicode,)}
diff --git a/test/tester.c b/test/tester.c
index f1288c3..25de3c1 100644
--- a/test/tester.c
+++ b/test/tester.c
@@ -265,10 +265,10 @@ lsm_fs *wait_for_job_fs(lsm_connect *c, char **job_id)
return fs;
}

-lsm_ss *wait_for_job_ss(lsm_connect *c, char **job_id)
+lsm_fs_ss *wait_for_job_ss(lsm_connect *c, char **job_id)
{
lsm_job_status status;
- lsm_ss *ss = NULL;
+ lsm_fs_ss *ss = NULL;
uint8_t pc = 0;
int rc = 0;

@@ -889,11 +889,11 @@ END_TEST
START_TEST(test_ss)
{
fail_unless(c != NULL);
- lsm_ss **ss_list = NULL;
+ lsm_fs_ss **ss_list = NULL;
uint32_t ss_count = 0;
char *job = NULL;
lsm_fs *fs = NULL;
- lsm_ss *ss = NULL;
+ lsm_fs_ss *ss = NULL;

printf("Testing snapshots\n");

@@ -956,7 +956,7 @@ START_TEST(test_ss)
wait_for_job(c, &job);
}

- lsm_ss_record_array_free(ss_list, ss_count);
+ lsm_fs_ss_record_array_free(ss_list, ss_count);
lsm_fs_record_free(fs);

printf("Testing snapshots done!\n");
@@ -1290,7 +1290,7 @@ START_TEST(test_invalid_input)
fail_unless(LSM_ERR_NOT_FOUND_JOB == rc, "rc %d", rc);

/* lsmJobStatusFsGet */
- lsm_ss *ss = (lsm_ss *)&bad;
+ lsm_fs_ss *ss = (lsm_fs_ss *)&bad;

rc = lsm_job_status_ss_get(c, NULL, NULL, NULL, NULL, LSM_FLAG_RSVD);
fail_unless(LSM_ERR_INVALID_ARGUMENT == rc, "rc %d", rc);
@@ -1685,7 +1685,7 @@ START_TEST(test_invalid_input)
rc = lsm_fs_ss_create(c, arg_fs, NULL, NULL, NULL, NULL, LSM_FLAG_RSVD);
fail_unless(rc == LSM_ERR_INVALID_ARGUMENT, "rc = %d", rc);

- lsm_ss *arg_ss = NULL;
+ lsm_fs_ss *arg_ss = NULL;
rc = lsm_fs_ss_create(c, arg_fs, "arg_snapshot", badf, &arg_ss, &job,
LSM_FLAG_RSVD);
fail_unless(rc == LSM_ERR_INVALID_SL, "rc = %d", rc);
--
1.8.2.1
Tony Asleson
2014-04-15 21:46:55 UTC
Permalink
Signed-off-by: Tony Asleson <***@redhat.com>
---
test/plugin_test.py | 244 ++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 227 insertions(+), 17 deletions(-)

diff --git a/test/plugin_test.py b/test/plugin_test.py
index cacf657..3b3759b 100755
--- a/test/plugin_test.py
+++ b/test/plugin_test.py
@@ -102,9 +102,9 @@ class TestProxy(object):
'volume_delete': (unicode,),
'volume_child_dependency_rm': (unicode),
'fs_delete': (unicode,),
- 'fs_resize': (unicode,),
- 'fs_create': (unicode,),
- 'fs_clone': (unicode,),
+ 'fs_resize': (unicode, lsm.FileSystem),
+ 'fs_create': (unicode, lsm.FileSystem),
+ 'fs_clone': (unicode, lsm.FileSystem),
'file_clone': (unicode,),
'fs_snapshot_create': (unicode, lsm.Snapshot),
'fs_snapshot_delete': (unicode,),
@@ -227,6 +227,11 @@ class TestPlugin(unittest.TestCase):

def setUp(self):
self.c = TestProxy(lsm.Client(TestPlugin.URI, TestPlugin.PASSWORD))
+
+ self.systems = self.c.systems()
+ self.pools = self.c.pools()
+
+ self.pool_by_sys_id = dict((p.system_id, p) for p in self.pools)
# TODO Store what exists, so that we don't remove it

def tearDown(self):
@@ -235,6 +240,11 @@ class TestPlugin(unittest.TestCase):
# the corresponding remove?
self.c.close()

+ def test_plugin_info(self):
+ (desc, version) = self.c.plugin_info()
+ self.assertTrue(desc is not None and len(desc) > 0)
+ self.assertTrue(version is not None and len(version) > 0)
+
def test_timeout(self):
tmo = 40000
self.c.set_time_out(tmo)
@@ -247,33 +257,233 @@ class TestPlugin(unittest.TestCase):
def test_pools_list(self):
pools_list = self.c.pools()

+ def test_volume_list(self):
+ volumes = self.c.volumes()
+
def test_disks_list(self):
disks = self.c.disks()

def test_pool_create(self):
pass

- def test_volume_create_delete(self):
- systems = self.c.systems()
- pools = self.c.pools()
+ def _volume_create(self, system_id):
+ if system_id in self.pool_by_sys_id:
+ p = self.pool_by_sys_id[system_id]
+
+ vol_size = min(p.free_space / 10, mb_in_bytes(512))
+
+ vol = self.c.volume_create(p, rs('volume'), vol_size,
+ lsm.Volume.PROVISION_DEFAULT)[1]
+
+ self.assertTrue(self._volume_exists(vol.id))
+ return vol, p
+
+ def _fs_create(self, system_id):
+ if system_id in self.pool_by_sys_id:
+ p = self.pool_by_sys_id[system_id]
+
+ fs_size = min(p.free_space / 10, mb_in_bytes(512))
+ fs = self.c.fs_create(p, rs('fs'), fs_size)[1]
+
+ self.assertTrue(self._fs_exists(fs.id))
+ return fs, p
+
+ def _volume_delete(self, volume):
+ self.c.volume_delete(volume)
+ self.assertFalse(self._volume_exists(volume.id))
+
+ def _fs_delete(self, fs):
+ self.c.fs_delete(fs)
+ self.assertFalse(self._fs_exists(fs.id))
+
+ def _fs_snapshot_delete(self, fs, ss):
+ self.c.fs_snapshot_delete(fs, ss)
+ self.assertFalse(self._fs_snapshot_exists(fs, ss.id))
+
+ def _volume_exists(self, volume_id):
+ volumes = self.c.volumes()
+
+ for v in volumes:
+ if v.id == volume_id:
+ return True
+
+ return False

- p_dict = dict((p.system_id, p) for p in pools)
+ def _fs_exists(self, fs_id):
+ fs = self.c.fs()

- for s in systems:
+ for f in fs:
+ if f.id == fs_id:
+ return True
+
+ return False
+
+ def _fs_snapshot_exists(self, fs, ss_id):
+ snapshots = self.c.fs_snapshots(fs)
+
+ for s in snapshots:
+ if s.id == ss_id:
+ return True
+
+ return False
+
+ def test_volume_create_delete(self):
+ for s in self.systems:
vol = None
cap = self.c.capabilities(s)
if cap.get(lsm.Capabilities.VOLUME_CREATE):
+ vol = self._volume_create(s.id)[0]
+ self.assertTrue(vol is not None)

- if s.id in p_dict:
- pool = p_dict[s.id]
+ if vol is not None and cap.get(lsm.Capabilities.VOLUME_DELETE):
+ self._volume_delete(vol)

- vol_size = min(pool.free_space / 10, mb_in_bytes(512))
+ def test_volume_resize(self):
+ for s in self.systems:
+ cap = self.c.capabilities(s)
+
+ if cap.get(lsm.Capabilities.VOLUME_CREATE) and \
+ cap.get(lsm.Capabilities.VOLUME_DELETE) and \
+ cap.get(lsm.Capabilities.VOLUME_RESIZE):
+ vol = self._volume_create(s.id)[0]
+ vol_resize = self.c.volume_resize(vol,
+ vol.size_bytes * 1.10)[1]
+ self.assertTrue(vol.size_bytes < vol_resize.size_bytes)
+ self._volume_delete(vol_resize)
+
+ def _replicate_test(self, capability, replication_type):
+ for s in self.systems:
+ cap = self.c.capabilities(s)
+
+ if cap.get(lsm.Capabilities.VOLUME_CREATE) and \
+ cap.get(lsm.Capabilities.VOLUME_DELETE):
+
+ vol, pool = self._volume_create(s.id)
+
+ if cap.get(capability):
+ volume_clone = self.c.volume_replicate(
+ pool, replication_type, vol,
+ rs('volume_clone'))[1]
+
+ self.assertTrue(volume_clone is not None)
+ self.assertTrue(self._volume_exists(volume_clone.id))
+ self._volume_delete(volume_clone)
+
+ self._volume_delete(vol)
+
+ def test_volume_replication(self):
+ self._replicate_test(lsm.Capabilities.VOLUME_REPLICATE_CLONE,
+ lsm.Volume.REPLICATE_CLONE)
+
+ self._replicate_test(lsm.Capabilities.VOLUME_REPLICATE_COPY,
+ lsm.Volume.REPLICATE_COPY)
+
+ self._replicate_test(lsm.Capabilities.VOLUME_REPLICATE_MIRROR_ASYNC,
+ lsm.Volume.REPLICATE_MIRROR_ASYNC)
+
+ self._replicate_test(lsm.Capabilities.VOLUME_REPLICATE_MIRROR_SYNC,
+ lsm.Volume.REPLICATE_MIRROR_SYNC)
+
+ def test_volume_replicate_range_block_size(self):
+ for s in self.systems:
+ cap = self.c.capabilities(s)
+
+ if cap.get(lsm.Capabilities.VOLUME_COPY_RANGE_BLOCK_SIZE):
+ size = self.c.volume_replicate_range_block_size(s)
+ self.assertTrue(size > 0)
+ else:
+ self.assertRaises(lsm.LsmError,
+ self.c.volume_replicate_range_block_size, s)
+
+ def test_replication_range(self):
+ for s in self.systems:
+ cap = self.c.capabilities(s)
+
+ if cap.get(lsm.Capabilities.VOLUME_CREATE) and \
+ cap.get(lsm.Capabilities.VOLUME_DELETE) and \
+ cap.get(lsm.Capabilities.VOLUME_COPY_RANGE):
+
+ vol, pool = self._volume_create(s.id)
+
+ br = lsm.BlockRange(0, 100, 10)
+
+ if cap.get(lsm.Capabilities.VOLUME_COPY_RANGE_CLONE):
+ self.c.volume_replicate_range(lsm.Volume.REPLICATE_CLONE,
+ vol, vol, [br])
+ else:
+ self.assertRaises(
+ lsm.LsmError,
+ self.c.volume_replicate_range,
+ lsm.Volume.REPLICATE_CLONE, vol, vol, [br])
+
+ br = lsm.BlockRange(200, 400, 50)
+
+ if cap.get(lsm.Capabilities.VOLUME_COPY_RANGE_COPY):
+ self.c.volume_replicate_range(lsm.Volume.REPLICATE_COPY,
+ vol, vol, [br])
+ else:
+ self.assertRaises(
+ lsm.LsmError,
+ self.c.volume_replicate_range,
+ lsm.Volume.REPLICATE_COPY, vol, vol, [br])
+
+ self._volume_delete(vol)
+
+ def test_fs_creation_deletion(self):
+ for s in self.systems:
+ cap = self.c.capabilities(s)
+
+ if cap.get(lsm.Capabilities.FS_CREATE):
+ fs = self._fs_create(s.id)[0]
+
+ if cap.get(lsm.Capabilities.FS_DELETE):
+ self._fs_delete(fs)
+
+ def test_fs_resize(self):
+ for s in self.systems:
+ cap = self.c.capabilities(s)
+
+ if cap.get(lsm.Capabilities.FS_CREATE):
+ fs = self._fs_create(s.id)[0]
+
+ if cap.get(lsm.Capabilities.FS_RESIZE):
+ fs_size = fs.total_space * 1.10
+ fs_resized = self.c.fs_resize(fs, fs_size)[1]
+ self.assertTrue(fs_resized.total_space)
+
+ if cap.get(lsm.Capabilities.FS_DELETE):
+ self._fs_delete(fs)
+
+ def test_fs_clone(self):
+ for s in self.systems:
+ cap = self.c.capabilities(s)
+
+ if cap.get(lsm.Capabilities.FS_CREATE) and \
+ cap.get(lsm.Capabilities.FS_CLONE):
+ fs = self._fs_create(s.id)[0]
+ fs_clone = self.c.fs_clone(fs, rs('fs_clone'))[1]
+
+ if cap.get(lsm.Capabilities.FS_DELETE):
+ self._fs_delete(fs_clone)
+ self._fs_delete(fs)
+
+ def test_fs_snapshot(self):
+ for s in self.systems:
+ cap = self.c.capabilities(s)
+
+ if cap.get(lsm.Capabilities.FS_CREATE) and \
+ cap.get(lsm.Capabilities.FS_SNAPSHOT_CREATE):
+
+ fs = self._fs_create(s.id)[0]
+
+ ss = self.c.fs_snapshot_create(fs, rs('fs_snapshot'), None)[1]
+ self.assertTrue(self._fs_snapshot_exists(fs, ss.id))
+
+ # Delete snapshot
+ if cap.get(lsm.Capabilities.FS_SNAPSHOT_DELETE):
+ self._fs_snapshot_delete(fs, ss)

- vol = self.c.volume_create(pool, rs('volume'), vol_size,
- lsm.Volume.PROVISION_DEFAULT)[1]

- if cap.get(lsm.Capabilities.VOLUME_DELETE):
- self.c.volume_delete(vol)


def dump_results():
@@ -282,9 +492,9 @@ def dump_results():
get our results out.

output details (yaml) results of what we called, how it finished and how
- long it tool.
+ long it took.
"""
- sys.stderr.write(yaml.dump(dict(methods_called=results, stats=stats)))
+ sys.stdout.write(yaml.dump(dict(methods_called=results, stats=stats)))


def add_our_params():
--
1.8.2.1
Tony Asleson
2014-04-15 21:47:07 UTC
Permalink
Change to use pool object instead of pool id as
source of creating pool from pool (sub pool).

Signed-off-by: Tony Asleson <***@redhat.com>
---
include/libstoragemgmt/libstoragemgmt.h | 8 ++++----
include/libstoragemgmt/libstoragemgmt_plug_interface.h | 8 ++++----
lsm/lsm/_client.py | 4 ++--
lsm/lsm/_cmdline.py | 9 ++-------
lsm/lsm/simulator.py | 4 ++--
plugin/simc_lsmplugin.c | 8 ++++----
src/lsm_mgmt.cpp | 16 ++++++++++------
src/lsm_plugin_ipc.cpp | 13 +++++++------
test/tester.c | 9 +++++++--
9 files changed, 42 insertions(+), 37 deletions(-)

diff --git a/include/libstoragemgmt/libstoragemgmt.h b/include/libstoragemgmt/libstoragemgmt.h
index 34fb781..5b43575 100644
--- a/include/libstoragemgmt/libstoragemgmt.h
+++ b/include/libstoragemgmt/libstoragemgmt.h
@@ -316,9 +316,9 @@ extern "C" {
* @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
+ * @param [in] pool The pool to create new pool from
* @param [in] size_bytes Desired size of new pool
- * @param [out] pool Newly created pool
+ * @param [out] created_pool Newly created pool
* @param [out] job Job ID of aysnc.
* @param [in] flags Reserved for future use, must be zero
* @return LSM_ERR_OK on success, LSM_ERR_JOB_STARTED if async.,
@@ -326,8 +326,8 @@ extern "C" {
*/
int LSM_DLL_EXPORT lsm_pool_create_from_pool(lsm_connect *conn,
lsm_system *system, const char *pool_name,
- const char *member_id, uint64_t size_bytes,
- lsm_pool** pool, char **job, lsm_flag flags);
+ lsm_pool *pool, uint64_t size_bytes,
+ lsm_pool** created_pool, char **job, lsm_flag flags);

/**
* Deletes a pool
diff --git a/include/libstoragemgmt/libstoragemgmt_plug_interface.h b/include/libstoragemgmt/libstoragemgmt_plug_interface.h
index 6d8dfe9..d6a941f 100644
--- a/include/libstoragemgmt/libstoragemgmt_plug_interface.h
+++ b/include/libstoragemgmt/libstoragemgmt_plug_interface.h
@@ -271,16 +271,16 @@ typedef int (*lsm_plug_pool_create_from_volumes)( lsm_plugin_ptr c,
* @param[in] c Valid lsm plug-in pointer
* @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] pool Pool to create pool from
* @param[in] size_bytes Size of pool
- * @param[out] pool Newly create pool if done sync.
+ * @param[out] created_pool Newly create pool if done sync.
* @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,
lsm_system *system,
- const char *pool_name, const char *member_id,
- uint64_t size_bytes, lsm_pool **pool, char **job,
+ const char *pool_name, lsm_pool *pool,
+ uint64_t size_bytes, lsm_pool **created_pool, char **job,
lsm_flag flags );


diff --git a/lsm/lsm/_client.py b/lsm/lsm/_client.py
index 9d86994..a769412 100644
--- a/lsm/lsm/_client.py
+++ b/lsm/lsm/_client.py
@@ -388,13 +388,13 @@ class Client(INetworkAttachedStorage):
# @param system_id The id of 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 member_id The id of pool to allocate space from for new pool.
+ # @param pool The pool to allocate space from for new pool.
# @param size_bytes The size of the new pool.
# @param flags Reserved for future use.
# @returns A tuple (job_id, new_pool), when one is None the other is
# valid.
@_return_requires(unicode, Pool)
- def pool_create_from_pool(self, system_id, pool_name, member_id,
+ def pool_create_from_pool(self, system_id, pool_name, pool,
size_bytes, flags=0):
"""
Creates pool from volumes.
diff --git a/lsm/lsm/_cmdline.py b/lsm/lsm/_cmdline.py
index a679583..7408292 100644
--- a/lsm/lsm/_cmdline.py
+++ b/lsm/lsm/_cmdline.py
@@ -1746,12 +1746,7 @@ class CmdLine:
"from pool only allow one member pool")

member_id = member_ids[0]
-
- pools = self.c.pools()
- pool_ids = [p.id for p in pools]
- if member_id not in pool_ids:
- raise ArgError("Invalid pools ID specified in " +
- "--member-id %s " % member_id)
+ pool = _get_item(self.c.pools(), member_id, "pool id")

size_bytes = self._size(self.args.size)

@@ -1759,7 +1754,7 @@ class CmdLine:
pool = self._wait_for_it(
"pool-create-from-pool",
*self.c.pool_create_from_pool(
- system, pool_name, member_id, size_bytes, 0))
+ system, pool_name, pool, size_bytes, 0))
self.display_data([pool])

def _read_configfile(self):
diff --git a/lsm/lsm/simulator.py b/lsm/lsm/simulator.py
index e5a3630..05bb21e 100644
--- a/lsm/lsm/simulator.py
+++ b/lsm/lsm/simulator.py
@@ -105,10 +105,10 @@ class SimPlugin(INfs, IStorageAreaNetwork):
return self.sim_array.pool_create_from_volumes(
system.id, pool_name, member_ids, raid_type, flags)

- def pool_create_from_pool(self, system, pool_name, member_id,
+ def pool_create_from_pool(self, system, pool_name, pool,
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, pool.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 c6034ea..ce6c25e 100644
--- a/plugin/simc_lsmplugin.c
+++ b/plugin/simc_lsmplugin.c
@@ -1095,17 +1095,17 @@ bail:
}

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,
+ const char *pool_name, lsm_pool *pool,
+ uint64_t size_bytes, lsm_pool **created_pool, char **job,
lsm_flag flags )
{
/* Check that the disks are valid, then call common routine */
int rc = LSM_ERR_OK;
struct plugin_data *pd = (struct plugin_data*)lsm_private_data_get(c);
- lsm_pool *p = find_pool(pd, member_id);
+ lsm_pool *p = find_pool(pd, lsm_pool_id_get(pool));

if( p ) {
- rc = _pool_create(c, system, pool_name, size_bytes, pool, job);
+ rc = _pool_create(c, system, pool_name, size_bytes, created_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 09497f1..bad3a1b 100644
--- a/src/lsm_mgmt.cpp
+++ b/src/lsm_mgmt.cpp
@@ -1013,8 +1013,8 @@ int LSM_DLL_EXPORT lsm_pool_create_from_volumes(lsm_connect *c,


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,
+ const char *pool_name, lsm_pool *pool,
+ uint64_t size_bytes, lsm_pool **created_pool, char **job,
lsm_flag flags)
{
CONN_SETUP(c);
@@ -1023,8 +1023,12 @@ int LSM_DLL_EXPORT lsm_pool_create_from_volumes(lsm_connect *c,
return LSM_ERR_INVALID_SYSTEM;
}

- if( CHECK_STR(pool_name) || CHECK_STR(member_id) ||
- !size_bytes || CHECK_RP(pool)|| CHECK_RP(job) ||
+ if( !LSM_IS_POOL(pool) ) {
+ return LSM_ERR_INVALID_POOL;
+ }
+
+ if( CHECK_STR(pool_name) ||
+ !size_bytes || CHECK_RP(created_pool)|| CHECK_RP(job) ||
LSM_FLAG_UNUSED_CHECK(flags) ) {
return LSM_ERR_INVALID_ARGUMENT;
}
@@ -1033,7 +1037,7 @@ int LSM_DLL_EXPORT lsm_pool_create_from_volumes(lsm_connect *c,
p["system"] = system_to_value(system);
p["pool_name"] = Value(pool_name);
p["size_bytes"] = Value(size_bytes);
- p["member_id"] = Value(member_id);
+ p["pool"] = pool_to_value(pool);
p["flags"] = Value(flags);

Value parameters(p);
@@ -1041,7 +1045,7 @@ int LSM_DLL_EXPORT lsm_pool_create_from_volumes(lsm_connect *c,

int rc = rpc(c, "pool_create_from_pool", parameters, response);
if( LSM_ERR_OK == rc ) {
- *pool = (lsm_pool *)parse_job_response(c, response, rc, job,
+ *created_pool = (lsm_pool *)parse_job_response(c, response, rc, job,
(convert)value_to_pool);
}
return rc;
diff --git a/src/lsm_plugin_ipc.cpp b/src/lsm_plugin_ipc.cpp
index 7e8b676..c71f752 100644
--- a/src/lsm_plugin_ipc.cpp
+++ b/src/lsm_plugin_ipc.cpp
@@ -598,29 +598,30 @@ static int handle_pool_create_from_pool(lsm_plugin_ptr p, Value &params, Value &

Value v_sys = params["system"];
Value v_pool_name = params["pool_name"];
- Value v_member_id = params["member_id"];
+ Value v_pool = params["pool"];
Value v_size = params["size_bytes"];

if( Value::object_t == v_sys.valueType() &&
Value::string_t == v_pool_name.valueType() &&
- Value::string_t == v_member_id.valueType() &&
+ Value::object_t == v_pool.valueType() &&
Value::numeric_t == v_size.valueType() &&
LSM_FLAG_EXPECTED_TYPE(params)) {

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();
+ lsm_pool *pool = value_to_pool(v_pool);
uint64_t size = v_size.asUint64_t();

- lsm_pool *pool = NULL;
+ lsm_pool *created_pool = NULL;
char *job = NULL;

rc = p->san_ops->pool_create_from_pool(p, sys, pool_name,
- member_id, size, &pool, &job,
+ pool, size, &created_pool, &job,
LSM_FLAG_GET_VALUE(params));

- Value p = pool_to_value(pool);
+ Value p = pool_to_value(created_pool);
response = job_handle(p, job);
+ lsm_pool_record_free(created_pool);
lsm_pool_record_free(pool);
lsm_system_record_free(sys);
free(job);
diff --git a/test/tester.c b/test/tester.c
index b7742b6..6da6461 100644
--- a/test/tester.c
+++ b/test/tester.c
@@ -2457,7 +2457,7 @@ START_TEST(test_pool_create)
lsm_disk **disks = NULL;
uint32_t num_disks = 0;
lsm_string_list *member_ids = lsm_string_list_alloc(0);
- char *pool_one = NULL;
+ lsm_pool *pool_one = NULL;
lsm_system *system = get_system(c);

/*
@@ -2533,7 +2533,7 @@ START_TEST(test_pool_create)

if( LSM_ERR_OK == rc ) {

- pool_one = strdup(lsm_pool_id_get(pools[0]));
+ pool_one = lsm_pool_record_copy(pools[0]);

for( i = 0; i < num_pools; ++i ) {
job = NULL;
@@ -2618,6 +2618,11 @@ START_TEST(test_pool_create)
}
}

+ if( pool_one ) {
+ lsm_pool_record_free(pool_one);
+ pool_one = NULL;
+ }
+
if( system ) {
lsm_system_record_free(system);
system = NULL;
--
1.8.2.1
Tony Asleson
2014-04-15 21:47:09 UTC
Permalink
Signed-off-by: Tony Asleson <***@redhat.com>
---
test/tester.c | 40 ++++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/test/tester.c b/test/tester.c
index bbd785c..71eb2d1 100644
--- a/test/tester.c
+++ b/test/tester.c
@@ -45,7 +45,7 @@ lsm_connect *c = NULL;
* @param buff Buffer to write the random string to
* @param len Length of the random string
*/
-void generateRandom(char *buff, uint32_t len)
+void generate_random(char *buff, uint32_t len)
{
uint32_t i = 0;
static int seed = 0;
@@ -81,7 +81,7 @@ char *plugin_to_use()
int rdir = atoi(rundir);
static char fn[128];
static char name[32];
- generateRandom(name, sizeof(name));
+ generate_random(name, sizeof(name));
snprintf(fn, sizeof(fn), uri, rdir, name);
printf("URI = %s\n", fn);
return fn;
@@ -92,7 +92,7 @@ char *plugin_to_use()
}
}

-lsm_pool *getTestPool(lsm_connect *c)
+lsm_pool *get_test_pool(lsm_connect *c)
{
lsm_pool **pools = NULL;
uint32_t count = 0;
@@ -725,7 +725,7 @@ START_TEST(test_access_groups_grant_revoke)
fail_unless(c!=NULL);
lsm_access_group *group = NULL;
int rc = 0;
- lsm_pool *pool = getTestPool(c);
+ lsm_pool *pool = get_test_pool(c);
char *job = NULL;
lsm_volume *n = NULL;

@@ -807,7 +807,7 @@ START_TEST(test_fs)
char *job = NULL;
uint64_t fs_free_space = 0;

- lsm_pool *test_pool = getTestPool(c);
+ lsm_pool *test_pool = get_test_pool(c);

rc = lsm_fs_list(c, &fs_list, &fs_count, LSM_FLAG_RSVD);

@@ -897,7 +897,7 @@ START_TEST(test_ss)

printf("Testing snapshots\n");

- lsm_pool *test_pool = getTestPool(c);
+ lsm_pool *test_pool = get_test_pool(c);

int rc = lsm_fs_create(c, test_pool, "test_fs", 100000000, &fs, &job, LSM_FLAG_RSVD);

@@ -1101,7 +1101,7 @@ START_TEST(test_nfs_exports)
fail_unless(c != NULL);
int rc = 0;

- lsm_pool *test_pool = getTestPool(c);
+ lsm_pool *test_pool = get_test_pool(c);
lsm_fs *nfs = NULL;
char *job = NULL;

@@ -1183,7 +1183,7 @@ START_TEST(test_volume_methods)

fail_unless(c != NULL);

- test_pool = getTestPool(c);
+ test_pool = get_test_pool(c);

if( test_pool ) {
rc = lsm_volume_create(c, test_pool, "lsm_volume_method_test",
@@ -1224,7 +1224,7 @@ START_TEST(test_invalid_input)

printf("Testing arguments\n");

- lsm_pool *test_pool = getTestPool(c);
+ lsm_pool *test_pool = get_test_pool(c);

lsm_connect *test_connect = NULL;
lsm_error_ptr test_error = NULL;
@@ -1914,7 +1914,7 @@ START_TEST(test_initiator_methods)
{
fail_unless(c != NULL);

- lsm_pool *test_pool = getTestPool(c);
+ lsm_pool *test_pool = get_test_pool(c);
lsm_volume *nv = NULL;
char *job = NULL;
int rc = 0;
@@ -2338,23 +2338,23 @@ START_TEST(test_nfs_export_funcs)
lsm_nfs_export_record_free(copy);


- generateRandom(rstring, sizeof(rstring));
+ generate_random(rstring, sizeof(rstring));
lsm_nfs_export_id_set(export, rstring);
fail_unless( strcmp(lsm_nfs_export_id_get(export), rstring) == 0 );

- generateRandom(rstring, sizeof(rstring));
+ generate_random(rstring, sizeof(rstring));
lsm_nfs_export_fs_id_set(export, rstring);
fail_unless( strcmp(lsm_nfs_export_fs_id_get(export), rstring) == 0 );

- generateRandom(rstring, sizeof(rstring));
+ generate_random(rstring, sizeof(rstring));
lsm_nfs_export_export_path_set(export, rstring);
fail_unless( strcmp(lsm_nfs_export_export_path_get(export), rstring) == 0 );

- generateRandom(rstring, sizeof(rstring));
+ generate_random(rstring, sizeof(rstring));
lsm_nfs_export_auth_type_set(export, rstring);
fail_unless( strcmp(lsm_nfs_export_auth_type_get(export), rstring) == 0 );

- generateRandom(rstring, sizeof(rstring));
+ generate_random(rstring, sizeof(rstring));
lsm_nfs_export_options_set(export, rstring);
fail_unless( strcmp(lsm_nfs_export_options_get(export), rstring) == 0 );

@@ -2368,17 +2368,17 @@ START_TEST(test_nfs_export_funcs)
fail_unless(lsm_nfs_export_anon_gid_get(export) == anongid);


- generateRandom(rstring, sizeof(rstring));
+ generate_random(rstring, sizeof(rstring));
lsm_string_list_append(rand, rstring);
lsm_nfs_export_root_set(export, rand);
fail_unless(compare_string_lists(lsm_nfs_export_root_get(export), rand) == 0);

- generateRandom(rstring, sizeof(rstring));
+ generate_random(rstring, sizeof(rstring));
lsm_string_list_append(rand, rstring);
lsm_nfs_export_read_write_set(export, rand);
fail_unless(compare_string_lists(lsm_nfs_export_read_write_get(export), rand) == 0);

- generateRandom(rstring, sizeof(rstring));
+ generate_random(rstring, sizeof(rstring));
lsm_string_list_append(rand, rstring);
lsm_nfs_export_read_only_set(export, rand);
fail_unless(compare_string_lists(lsm_nfs_export_read_only_get(export), rand) == 0);
@@ -2400,7 +2400,7 @@ START_TEST(test_pool_delete)

printf("Testing pool delete!\n");

- lsm_pool *test_pool = getTestPool(c);
+ lsm_pool *test_pool = get_test_pool(c);

fail_unless( test_pool != NULL );

@@ -2549,7 +2549,7 @@ START_TEST(test_pool_create)
job = NULL;
vol = NULL;

- generateRandom(r_name, sizeof(r_name));
+ generate_random(r_name, sizeof(r_name));

rc = lsm_volume_create(c, pools[i], r_name,
1024*1024*1024, LSM_PROVISION_DEFAULT,
--
1.8.2.1
Tony Asleson
2014-04-15 21:47:08 UTC
Permalink
Convert these two methods to use object instead of
object ids.

Signed-off-by: Tony Asleson <***@redhat.com>
---
include/libstoragemgmt/libstoragemgmt.h | 10 ++-
.../libstoragemgmt/libstoragemgmt_plug_interface.h | 11 +--
lsm/lsm/_client.py | 8 +--
lsm/lsm/_cmdline.py | 10 +--
lsm/lsm/simarray.py | 4 +-
lsm/lsm/simulator.py | 8 ++-
plugin/simc_lsmplugin.c | 10 ++-
src/lsm_convert.cpp | 66 +++++++++++++++++
src/lsm_convert.hpp | 12 ++++
src/lsm_mgmt.cpp | 50 +++++++++----
src/lsm_plugin_ipc.cpp | 84 ++++++++++++++--------
test/tester.c | 33 ++++++---
12 files changed, 227 insertions(+), 79 deletions(-)

diff --git a/include/libstoragemgmt/libstoragemgmt.h b/include/libstoragemgmt/libstoragemgmt.h
index 5b43575..b18adff 100644
--- a/include/libstoragemgmt/libstoragemgmt.h
+++ b/include/libstoragemgmt/libstoragemgmt.h
@@ -269,11 +269,13 @@ extern "C" {
* @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
+ * @param [in] disks An array of disk pointers to create new
+ * pool from.
* The new pool could contain more disks
* than requested due to internal needs,
* but if possible should only contain
* requested disks.
+ * @param [in] num_disks Number of disks in disks array
* @param [in] raid_type The RAID type for new pool
* @param [out] pool Newly created pool
* @param [out] job Job ID of aysnc.
@@ -283,7 +285,8 @@ extern "C" {
*/
int LSM_DLL_EXPORT lsm_pool_create_from_disks(lsm_connect *conn,
lsm_system *system, const char *pool_name,
- lsm_string_list *member_ids, lsm_pool_raid_type raid_type,
+ lsm_disk *disks[], uint32_t num_disks,
+ lsm_pool_raid_type raid_type,
lsm_pool** pool, char **job, lsm_flag flags);

/**
@@ -307,7 +310,8 @@ extern "C" {
*/
int LSM_DLL_EXPORT lsm_pool_create_from_volumes(lsm_connect *conn,
lsm_system *system, const char *pool_name,
- lsm_string_list *member_ids, lsm_pool_raid_type raid_type,
+ lsm_volume *volumes[], uint32_t num_volumes,
+ lsm_pool_raid_type raid_type,
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 d6a941f..1a506d0 100644
--- a/include/libstoragemgmt/libstoragemgmt_plug_interface.h
+++ b/include/libstoragemgmt/libstoragemgmt_plug_interface.h
@@ -237,7 +237,8 @@ typedef int (*lsm_plug_pool_create)( lsm_plugin_ptr c, lsm_system* system,
* @param[in] c Valid lsm plug-in pointer
* @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] disks Array of disk pointers to create pool from
+ * @param[in] num_disks Number of disks
* @param[in] raid_type Raid type for pool
* @param[out] pool Newly create pool if done sync.
* @param[out] job Job id if execution is async.
@@ -245,7 +246,7 @@ typedef int (*lsm_plug_pool_create)( lsm_plugin_ptr c, lsm_system* system,
*/
typedef int (*lsm_plug_pool_create_from_disks)( lsm_plugin_ptr c,
lsm_system *system,
- const char *pool_name, lsm_string_list *member_ids,
+ const char *pool_name, lsm_disk *disks[], uint32_t num_disks,
lsm_pool_raid_type raid_type, lsm_pool **pool, char **job,
lsm_flag flags);

@@ -254,7 +255,8 @@ typedef int (*lsm_plug_pool_create_from_disks)( lsm_plugin_ptr c,
* @param[in] c Valid lsm plug-in pointer
* @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] volumes Array of volume pointers
+ * @param[in] num_volumes Number of volumes
* @param[in] raid_type Raid type for pool
* @param[out] pool Newly create pool if done sync.
* @param[out] job Job id if execution is async.
@@ -262,7 +264,8 @@ typedef int (*lsm_plug_pool_create_from_disks)( lsm_plugin_ptr c,
*/
typedef int (*lsm_plug_pool_create_from_volumes)( lsm_plugin_ptr c,
lsm_system *system,
- const char *pool_name, lsm_string_list *member_ids,
+ const char *pool_name, lsm_volume *volumes[],
+ uint32_t num_volumes,
lsm_pool_raid_type raid_type, lsm_pool** pool, char **job,
lsm_flag flags);

diff --git a/lsm/lsm/_client.py b/lsm/lsm/_client.py
index a769412..a8a30c2 100644
--- a/lsm/lsm/_client.py
+++ b/lsm/lsm/_client.py
@@ -334,7 +334,7 @@ class Client(INetworkAttachedStorage):
# @param system_id The id of 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 member_ids The ids of disks to create new pool.
+ # @param Disks The disks (list) to create new pool from.
# The new pool could contain more disks than
# requested due to internal needs, but if possible,
# new pool should only contain requested disks.
@@ -345,7 +345,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_from_disks(self, system_id, pool_name, member_ids,
+ def pool_create_from_disks(self, system_id, pool_name, disks,
raid_type, flags=0):
"""
Creates pool from disks.
@@ -361,7 +361,7 @@ class Client(INetworkAttachedStorage):
# @param system_id The id of 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 member_ids The ids of volumes to create new pool.
+ # @param volumes The volumes to create new pool from.
# The new pool could contain more volumes than
# requested due to internal needs, but if possible,
# new pool should only contain requested volumes.
@@ -372,7 +372,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_from_volumes(self, system_id, pool_name, member_ids,
+ def pool_create_from_volumes(self, system_id, pool_name, volumes,
raid_type, flags=0):
"""
Creates pool from volumes.
diff --git a/lsm/lsm/_cmdline.py b/lsm/lsm/_cmdline.py
index 7408292..778647e 100644
--- a/lsm/lsm/_cmdline.py
+++ b/lsm/lsm/_cmdline.py
@@ -1689,15 +1689,17 @@ class CmdLine:
raise ArgError("No disk ID was provided for new pool")

member_ids = args.member_id
+ disks_to_use = []
disks = self.c.disks()
- disk_ids = [d.id for d in disks]
+ disk_ids = dict((x.id, x) for x in disks)
for member_id in member_ids:
if member_id not in disk_ids:
raise ArgError("Invalid Disk ID specified in " +
"--member-id %s " % member_id)
+ else:
+ disks_to_use.append(disk_ids[member_id])

- raid_type = Pool._raid_type_str_to_type(
- self.args.raid_type)
+ raid_type = Pool._raid_type_str_to_type(self.args.raid_type)
if raid_type == Pool.RAID_TYPE_UNKNOWN:
raise ArgError("Unknown RAID type specified: %s" %
self.args.raid_type)
@@ -1706,7 +1708,7 @@ class CmdLine:
pool = self._wait_for_it(
"pool-create-from-disks",
*self.c.pool_create_from_disks(
- system, pool_name, member_ids, raid_type, 0))
+ system, pool_name, disks_to_use, raid_type, 0))
self.display_data([pool])

def pool_create_from_volumes(self, args):
diff --git a/lsm/lsm/simarray.py b/lsm/lsm/simarray.py
index d8c375c..29cab42 100644
--- a/lsm/lsm/simarray.py
+++ b/lsm/lsm/simarray.py
@@ -184,10 +184,10 @@ class SimArray(object):
return self.data.job_create(
self._sim_pool_2_lsm(sim_pool, Pool.RETRIEVE_FULL_INFO))

- def pool_create_from_disks(self, sys_id, pool_name, member_ids, raid_type,
+ def pool_create_from_disks(self, sys_id, pool_name, disks_ids, raid_type,
flags=0):
sim_pool = self.data.pool_create_from_disks(
- sys_id, pool_name, member_ids, raid_type, flags)
+ sys_id, pool_name, disks_ids, raid_type, flags)
return self.data.job_create(
self._sim_pool_2_lsm(sim_pool, Pool.RETRIEVE_FULL_INFO))

diff --git a/lsm/lsm/simulator.py b/lsm/lsm/simulator.py
index 05bb21e..1ea1a45 100644
--- a/lsm/lsm/simulator.py
+++ b/lsm/lsm/simulator.py
@@ -16,7 +16,7 @@
# Author: tasleson

from lsm import (uri_parse, VERSION, Capabilities, Pool, INfs,
- IStorageAreaNetwork)
+ IStorageAreaNetwork, Error)

from simarray import SimArray

@@ -95,13 +95,15 @@ class SimPlugin(INfs, IStorageAreaNetwork):
return self.sim_array.pool_create(
system.id, pool_name, size_bytes, raid_type, member_type, flags)

- def pool_create_from_disks(self, system, pool_name, member_ids,
+ def pool_create_from_disks(self, system, pool_name, disks,
raid_type, flags=0):
+ member_ids = [x.id for x in disks]
return self.sim_array.pool_create_from_disks(
system.id, pool_name, member_ids, raid_type, flags)

- def pool_create_from_volumes(self, system, pool_name, member_ids,
+ def pool_create_from_volumes(self, system, pool_name, volumes,
raid_type, flags=0):
+ member_ids = [x.id for x in volumes]
return self.sim_array.pool_create_from_volumes(
system.id, pool_name, member_ids, raid_type, flags)

diff --git a/plugin/simc_lsmplugin.c b/plugin/simc_lsmplugin.c
index ce6c25e..d84b279 100644
--- a/plugin/simc_lsmplugin.c
+++ b/plugin/simc_lsmplugin.c
@@ -1029,7 +1029,7 @@ static int pool_create(lsm_plugin_ptr c, lsm_system *system,
}

static int pool_create_from_disks( lsm_plugin_ptr c, lsm_system *system,
- const char *pool_name, lsm_string_list *member_ids,
+ const char *pool_name, lsm_disk *disks[], uint32_t num_disks,
lsm_pool_raid_type raid_type, lsm_pool **pool, char **job,
lsm_flag flags)
{
@@ -1037,12 +1037,11 @@ static int pool_create_from_disks( lsm_plugin_ptr c, lsm_system *system,
uint64_t size = 0;
int rc = LSM_ERR_OK;
int i = 0;
- int num_disks = lsm_string_list_size(member_ids);
struct plugin_data *pd = (struct plugin_data*)lsm_private_data_get(c);

if( num_disks ) {
for( i = 0; i < num_disks; ++i ) {
- lsm_disk *d = find_disk(pd, lsm_string_list_elem_get(member_ids, i));
+ lsm_disk *d = find_disk(pd, lsm_disk_id_get(disks[i]));
if( d ) {
size += (lsm_disk_number_of_blocks_get(d) * lsm_disk_block_size_get(d));
} else {
@@ -1061,7 +1060,7 @@ bail:
}

static int pool_create_from_volumes( lsm_plugin_ptr c, lsm_system *system,
- const char *pool_name, lsm_string_list *member_ids,
+ const char *pool_name, lsm_volume *volumes[], uint32_t num_volumes,
lsm_pool_raid_type raid_type, lsm_pool **pool, char **job,
lsm_flag flags)
{
@@ -1069,13 +1068,12 @@ static int pool_create_from_volumes( lsm_plugin_ptr c, lsm_system *system,
uint64_t size = 0;
int rc = LSM_ERR_OK;
int i = 0;
- int num_volumes = lsm_string_list_size(member_ids);
struct plugin_data *pd = (struct plugin_data*)lsm_private_data_get(c);

if( num_volumes ) {
for( i = 0; i < num_volumes; ++i ) {
struct allocated_volume *v =
- find_volume(pd, lsm_string_list_elem_get(member_ids, i));
+ find_volume(pd, lsm_volume_id_get(volumes[i]));
if( v ) {
size += (lsm_volume_number_of_blocks_get(v->v) *
lsm_volume_number_of_blocks_get(v->v));
diff --git a/src/lsm_convert.cpp b/src/lsm_convert.cpp
index 82c4663..9785d5b 100644
--- a/src/lsm_convert.cpp
+++ b/src/lsm_convert.cpp
@@ -73,6 +73,40 @@ Value volume_to_value(lsm_volume *vol)
return Value();
}

+int value_array_to_volumes(Value &volume_values, lsm_volume **volumes[],
+ uint32_t *count)
+{
+ int rc = LSM_ERR_OK;
+ try {
+ if( Value::array_t == volume_values.valueType()) {
+ std::vector<Value> vol = volume_values.asArray();
+
+ *count = vol.size();
+
+ if( vol.size() ) {
+ *volumes = lsm_volume_record_array_alloc(vol.size());
+
+ if( *volumes ){
+ for( size_t i = 0; i < vol.size(); ++i ) {
+ (*volumes)[i] = value_to_volume(vol[i]);
+ }
+ } else {
+ rc = LSM_ERR_NO_MEMORY;
+ }
+ }
+ }
+ } catch( const ValueException &ve) {
+ if( *volumes && *count ) {
+ lsm_volume_record_array_free(*volumes, *count);
+ *volumes = NULL;
+ *count = 0;
+ }
+
+ rc = LSM_ERR_INTERNAL_ERROR;
+ }
+ return rc;
+}
+
lsm_disk *value_to_disk(Value &disk)
{
lsm_disk *rc = NULL;
@@ -125,6 +159,38 @@ Value disk_to_value(lsm_disk *disk)
return Value();
}

+int value_array_to_disks(Value &disk_values, lsm_disk **disks[], uint32_t *count)
+{
+ int rc = LSM_ERR_OK;
+ try {
+ if( Value::array_t == disk_values.valueType()) {
+ std::vector<Value> d = disk_values.asArray();
+
+ *count = d.size();
+
+ if( d.size() ) {
+ *disks = lsm_disk_record_array_alloc(d.size());
+
+ if( *disks ){
+ for( size_t i = 0; i < d.size(); ++i ) {
+ (*disks)[i] = value_to_disk(d[i]);
+ }
+ } else {
+ rc = LSM_ERR_NO_MEMORY;
+ }
+ }
+ }
+ } catch( const ValueException &ve ) {
+ rc = LSM_ERR_INTERNAL_ERROR;
+ if( *disks && *count ) {
+ lsm_disk_record_array_free(*disks, *count);
+ *disks = NULL;
+ *count = 0;
+ }
+ }
+ return rc;
+}
+
lsm_initiator *value_to_initiator(Value &init)
{
lsm_initiator *rc = NULL;
diff --git a/src/lsm_convert.hpp b/src/lsm_convert.hpp
index 366234d..988fa6c 100644
--- a/src/lsm_convert.hpp
+++ b/src/lsm_convert.hpp
@@ -51,6 +51,9 @@ lsm_volume * value_to_volume(Value &vol);
*/
Value volume_to_value(lsm_volume *vol);

+int value_array_to_volumes(Value &volume_values, lsm_volume **volumes[],
+ uint32_t *count);
+
/**
* Converts a Value to a lsm_disk
* @param disk Value representing a disk
@@ -66,6 +69,15 @@ lsm_disk *value_to_disk(Value &disk);
Value disk_to_value(lsm_disk *disk);

/**
+ * Converts a vector of disk values to an array.
+ * @param disks Vector of values that represents disks
+ * @param disks An array of disk pointers
+ * @param count Number of disks
+ * @return LSM_ERR_OK on success, else error reason.
+ */
+int value_array_to_disks(Value &disk_values, lsm_disk **disks[], uint32_t *count);
+
+/**
* Converts a value to lsm_initiator *
* @param init to convert
* @return lsm_initiator *, else NULL on error.
diff --git a/src/lsm_mgmt.cpp b/src/lsm_mgmt.cpp
index bad3a1b..6a87522 100644
--- a/src/lsm_mgmt.cpp
+++ b/src/lsm_mgmt.cpp
@@ -954,9 +954,9 @@ int lsm_pool_create(lsm_connect *c, lsm_system *system,

static int lsm_pool_create_from(lsm_connect *c,
lsm_system *system, const char *pool_name,
- lsm_string_list *member_ids, lsm_pool_raid_type raid_type,
+ std::vector<Value> &member_ids, lsm_pool_raid_type raid_type,
lsm_pool** pool, char **job, lsm_flag flags,
- const char *method)
+ const char *member_id, const char *method)
{
CONN_SETUP(c);

@@ -970,14 +970,11 @@ static int lsm_pool_create_from(lsm_connect *c,
return LSM_ERR_INVALID_ARGUMENT;
}

- if( !LSM_IS_STRING_LIST(member_ids) ) {
- return LSM_ERR_INVALID_SL;
- }

std::map<std::string, Value> p;
p["system"] = system_to_value(system);
p["pool_name"] = Value(pool_name);
- p["member_ids"] = string_list_to_value(member_ids);
+ p[member_id] = Value(member_ids);
p["raid_type"] = Value((int32_t)raid_type);
p["flags"] = Value(flags);

@@ -994,20 +991,49 @@ static int lsm_pool_create_from(lsm_connect *c,

int LSM_DLL_EXPORT lsm_pool_create_from_disks(lsm_connect *c,
lsm_system *system, const char *pool_name,
- lsm_string_list *member_ids, lsm_pool_raid_type raid_type,
+ lsm_disk *disks[], uint32_t num_disks,
+ lsm_pool_raid_type raid_type,
lsm_pool** pool, char **job, lsm_flag flags)
{
- return lsm_pool_create_from(c, system, pool_name, member_ids, raid_type,
- pool, job, flags, "pool_create_from_disks");
+ uint32_t i;
+
+ CONN_SETUP(c);
+
+ if( !disks || !num_disks ) {
+ return LSM_ERR_INVALID_ARGUMENT;
+ }
+
+ /* Create disks container */
+ std::vector<Value> d;
+ for( i = 0; i < num_disks; ++i ) {
+ d.push_back(disk_to_value(disks[i]));
+ }
+
+ return lsm_pool_create_from(c, system, pool_name, d, raid_type, pool, job,
+ flags, "disks", "pool_create_from_disks");
+
}

int LSM_DLL_EXPORT lsm_pool_create_from_volumes(lsm_connect *c,
lsm_system *system, const char *pool_name,
- lsm_string_list *member_ids, lsm_pool_raid_type raid_type,
+ lsm_volume *volumes[], uint32_t num_volumes,
+ lsm_pool_raid_type raid_type,
lsm_pool** pool, char **job, lsm_flag flags)
{
- return lsm_pool_create_from(c, system, pool_name, member_ids, raid_type,
- pool, job, flags,
+ uint32_t i;
+
+ if( !volumes || !num_volumes ) {
+ return LSM_ERR_INVALID_ARGUMENT;
+ }
+
+ /* Create disks container */
+ std::vector<Value> vols;
+ for( i = 0; i < num_volumes; ++i ) {
+ vols.push_back(volume_to_value(volumes[i]));
+ }
+
+ return lsm_pool_create_from(c, system, pool_name, vols, raid_type,
+ pool, job, flags, "volumes",
"pool_create_from_volumes");
}

diff --git a/src/lsm_plugin_ipc.cpp b/src/lsm_plugin_ipc.cpp
index c71f752..dde2d65 100644
--- a/src/lsm_plugin_ipc.cpp
+++ b/src/lsm_plugin_ipc.cpp
@@ -519,34 +519,28 @@ static int handle_pool_create(lsm_plugin_ptr p, Value &params, Value &response)
return rc;
}

-typedef int (*lsmPlugPoolCreateFrom)( 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);
-
-
-static int handle_pool_create_from( lsm_plugin_ptr p, Value &params,
- Value &response,
- lsmPlugPoolCreate
Tony Asleson
2014-04-15 21:47:00 UTC
Permalink
From: Gris Ge <***@redhat.com>

* Storing wiki Markdown documents in docstring. I will create a tool to
extract docstring and assemble out the identical Markdown string of our
wiki page. The docstring could be viewed via help(lsm.System) in python
interactive mode.
* Recoded lsm.System.status constants.
* Added lsm.System.status_info property.

V2: Changes to not use default value of status_info for class
system as this was hiding the missing C bits which I added
to support the status_info field being added. -Tony

Signed-off-by: Gris Ge <***@redhat.com>
Signed-off-by: Tony Asleson <***@redhat.com>
---
.../libstoragemgmt/libstoragemgmt_plug_interface.h | 10 +-
include/libstoragemgmt/libstoragemgmt_types.h | 16 +-
lsm/lsm/_cmdline.py | 33 +-
lsm/lsm/_data.py | 108 +++++--
lsm/lsm/ibmv7k.py | 2 +-
lsm/lsm/lsmcli_data_display.py | 344 +++++++++++++++++++++
lsm/lsm/nstor.py | 2 +-
lsm/lsm/ontap.py | 2 +-
lsm/lsm/simarray.py | 2 +-
lsm/lsm/smis.py | 2 +-
lsm/lsm/targetd.py | 2 +-
plugin/simc_lsmplugin.c | 2 +-
src/lsm_convert.cpp | 4 +-
src/lsm_datatypes.cpp | 12 +-
src/lsm_datatypes.hpp | 1 +
15 files changed, 491 insertions(+), 51 deletions(-)
create mode 100644 lsm/lsm/lsmcli_data_display.py

diff --git a/include/libstoragemgmt/libstoragemgmt_plug_interface.h b/include/libstoragemgmt/libstoragemgmt_plug_interface.h
index af212d2..0a719c6 100644
--- a/include/libstoragemgmt/libstoragemgmt_plug_interface.h
+++ b/include/libstoragemgmt/libstoragemgmt_plug_interface.h
@@ -1136,14 +1136,16 @@ lsm_system LSM_DLL_EXPORT **lsm_system_record_array_alloc( uint32_t size );

/**
* Allocates the storage for one system record.
- * @param[in] id Id
- * @param[in] name System name (human readable)
- * @param[in] status Status of the system
+ * @param[in] id Id
+ * @param[in] name System name (human readable)
+ * @param[in] status Status of the system
+ * @oaram[in] status_info Additional text for status
* @return Allocated memory or NULL on error.
*/
lsm_system LSM_DLL_EXPORT *lsm_system_record_alloc( const char *id,
const char *name,
- uint32_t status );
+ uint32_t status,
+ const char *status_info);

/**
* Allocates storage for Access_group array
diff --git a/include/libstoragemgmt/libstoragemgmt_types.h b/include/libstoragemgmt/libstoragemgmt_types.h
index 4a77dca..5e2389d 100644
--- a/include/libstoragemgmt/libstoragemgmt_types.h
+++ b/include/libstoragemgmt/libstoragemgmt_types.h
@@ -161,12 +161,16 @@ typedef enum {
* Different states a system status can be in.
* Bit field, can be in multiple states at the same time.
*/
-#define LSM_SYSTEM_STATUS_UNKNOWN 0x00000000 /**< System status unknown */
-#define LSM_SYSTEM_STATUS_OK 0x00000001 /**< System status OK */
-#define LSM_SYSTEM_STATUS_DEGRADED 0x00000002 /**< System is degraded */
-#define LSM_SYSTEM_STATUS_ERROR 0x00000004 /**< System has error(s) */
-#define LSM_SYSTEM_STATUS_PREDICTIVE_FAILURE 0x00000008 /**< System has predictive failure(s) */
-#define LSM_SYSTEM_STATUS_VENDOR_SPECIFIC 0x00000010 /**< Vendor specific status code */
+#define LSM_SYSTEM_STATUS_UNKNOWN 0x00000001 /**< Unknown */
+#define LSM_SYSTEM_STATUS_OK 0x00000002 /**< OK */
+#define LSM_SYSTEM_STATUS_ERROR 0x00000004 /**< Error(s) exist */
+#define LSM_SYSTEM_STATUS_DEGRADED 0x00000008 /**< Degraded */
+#define LSM_SYSTEM_STATUS_PREDICTIVE_FAILURE 0x00000010 /**< System has predictive failure(s) */
+#define LSM_SYSTEM_STATUS_STRESSED 0x00000020 /**< Temp or excessive IO */
+#define LSM_SYSTEM_STATUS_STARTING 0x00000040 /**< Booting */
+#define LSM_SYSTEM_STATUS_STOPPING 0x00000080 /**< Shutting down */
+#define LSM_SYSTEM_STATUS_STOPPED 0x00000100 /**< Stopped by admin */
+#define LSM_SYSTEM_STATUS_OTHER 0x00000200 /**< Vendor specific */

/**< \enum lsm_initiator_type Different types of initiator IDs */
typedef enum {
diff --git a/lsm/lsm/_cmdline.py b/lsm/lsm/_cmdline.py
index 49e736e..93a928f 100644
--- a/lsm/lsm/_cmdline.py
+++ b/lsm/lsm/_cmdline.py
@@ -28,6 +28,7 @@ from lsm import (Client, Pool, VERSION, LsmError, Capabilities, Disk,

from _data import PlugData
from _common import getch, size_human_2_size_bytes, Proxy
+from lsmcli_data_display import DisplayData

##@package lsm.cmdline

@@ -164,8 +165,9 @@ cmds = (
type=str.upper),
],
optional=[
- dict(name=('-o', '--optional'),
- help='Retrieve additional optional info if available',
+ dict(name=('-a', '--all'),
+ help='Retrieve and display in scrit friendly way with ' +
+ 'all information including optional data if available',
default=False,
action='store_true'),
dict(fs_id_opt),
@@ -808,13 +810,32 @@ class CmdLine:
# Tries to make the output better when it varies considerably from
# plug-in to plug-in.
# @param objects Data, first row is header all other data.
- def display_data(self, objects):
+ def display_data(self, objects, extra_properties=None):
if len(objects) == 0:
return

- if hasattr(self.args, 'optional') and self.args.optional:
+ if hasattr(self.args, 'all') and self.args.all:
self.args.script = True

+ flag_with_header = True
+ if self.args.sep:
+ flag_with_header = False
+ if self.args.header:
+ flag_with_header = True
+
+ display_way = DisplayData.DISPLAY_WAY_DEFAULT
+ if self.args.script:
+ display_way = DisplayData.DISPLAY_WAY_SCRIPT
+
+ flag_new_way_works = DisplayData.display_data(
+ objects, display_way=display_way, flag_human=self.args.human,
+ flag_enum=self.args.enum, extra_properties=extra_properties,
+ spliter=self.args.sep, flag_with_header=flag_with_header,
+ flag_dsp_all_data=self.args.all)
+
+ if flag_new_way_works:
+ return
+
# Assuming all objects are from the same class.
key_2_str = objects[0]._str_of_key()
key_seq = objects[0]._key_display_sequence()
@@ -1057,7 +1078,7 @@ class CmdLine:
if args.type == 'VOLUMES':
self.display_data(self.c.volumes())
elif args.type == 'POOLS':
- if args.optional is True:
+ if args.all:
self.display_data(
self.c.pools(Pool.RETRIEVE_FULL_INFO))
else:
@@ -1081,7 +1102,7 @@ class CmdLine:
elif args.type == 'SYSTEMS':
self.display_data(self.c.systems())
elif args.type == 'DISKS':
- if args.optional:
+ if args.all:
self.display_data(
self.c.disks(Disk.RETRIEVE_FULL_INFO))
else:
diff --git a/lsm/lsm/_data.py b/lsm/lsm/_data.py
index 6e314ba..f950be0 100644
--- a/lsm/lsm/_data.py
+++ b/lsm/lsm/_data.py
@@ -672,10 +672,86 @@ class Volume(IData):
@default_property('id', doc="Unique identifier")
@default_property('name', doc="User defined system name")
@default_property('status', doc="Enumerated status of system")
+@default_property('status_info', doc="Detail status information of system")
class System(IData):
- (STATUS_UNKNOWN, STATUS_OK, STATUS_DEGRADED, STATUS_ERROR,
- STATUS_PREDICTIVE_FAILURE, STATUS_VENDOR_SPECIFIC) = \
- (0x0, 0x1, 0x2, 0x4, 0x8, 0x10)
+ """
+### 11.3 System -- lsm.System
+
+#### 11.3.1 System Properties
+ * id
+ String. Free form string used to identify certain system at plugin level.
+ Plugin can use this property for performance improvement
+ when concerting between LSM object to internal object. When displaying this
+ property to user, use the ID hashed string(like md5) is suggested.
+ * name
+ String. Human friendly name for this system.
+ * status
+ Integer. Byte Map(Check Appendix.D). The health status of system.
+ Could be any combination of these values:
+ * **lsm.System.STATUS_UNKNOWN**
+ Plugin failed to determine the status.
+ * **lsm.System.STATUS_OK**
+ Everything is OK.
+ * **lsm.System.STATUS_ERROR**
+ System is having errors which causing 'Data Unavailable' or 'Data Lose'.
+ Example:
+ * A RAID5 pool lose two disks.
+ * All controllers down.
+ * Internal hardware(like, memory) down and no redundant part.
+ The 'status_info' property will explain the detail.
+ * **lsm.System.STATUS_DEGRADED**
+ System is still functional but lose protection of redundant parts,
+ Example:
+ * One or more controller offline, but existing controller is taking
+ over all works.
+ * A RAID 5 pool lose 1 disk, no spare disk or spare disk is rebuilding.
+ * One or more battery changed from online to offline.
+ The 'status_info' property will explain the detail.
+ * **lsm.System.STATUS_PREDICTIVE_FAILURE**
+ System is still functional and protected by redundant parts, but
+ certain parts will soon be unfunctional.
+ * One or more battery voltage low.
+ * SMART information indicate some disk is dieing.
+ The 'status_info' property will explain the detail.
+ * **lsm.System.STATUS_STRESSED**
+ System is having too much I/O in progress or temperature exceeded the
+ limit. The 'status_info' property will explain the detail.
+ * **lsm.System.STATUS_STARTING**
+ System is booting up.
+ * **lsm.System.STATUS_STOPPING**
+ System is shutting down.
+ * **lsm.System.STATUS_STOPPED**
+ System is stopped by administrator.
+ * **lsm.System.STATUS_OTHER**
+ Vendor specifice status. The 'status_info' property will explain the
+ detail.
+ * status_info
+ String. Free form string used for explaining system status. For example:
+ "Disk <disk_id> is in Offline state. Battery X is near end of life"
+
+##### 11.3.2 System Optional Properties
+
+The lsm.System class does not have any optional properties yet.
+
+##### 11.3.3 System Extra Constants
+
+The lsm.System class does not have any extra constants.
+
+##### 11.3.4 System Class Methods
+
+The lsm.System class does not have class methods.
+ """
+
+ STATUS_UNKNOWN = 1 << 0
+ STATUS_OK = 1 << 1
+ STATUS_ERROR = 1 << 2
+ STATUS_DEGRADED = 1 << 3
+ STATUS_PREDICTIVE_FAILURE = 1 << 4
+ STATUS_STRESSED = 1 << 5
+ STATUS_STARTING = 1 << 6
+ STATUS_STOPPING = 1 << 7
+ STATUS_STOPPED = 1 << 8
+ STATUS_OTHER = 1 << 9

@staticmethod
def _status_to_str(status):
@@ -698,27 +774,11 @@ class System(IData):

return rc

- def __init__(self, _id, _name, _status):
- self._id = _id # For SMI-S this is the CIM_ComputerSystem->Name
- self._name = _name # For SMI-S , CIM_ComputerSystem->ElementName
- self._status = _status # OperationalStatus
-
- _MAN_PROPERTIES_2_HEADER = {
- 'id': 'ID',
- 'name': 'Name',
- 'status': 'Status',
- }
-
- _MAN_PROPERTIES_SEQUENCE = ['id', 'name', 'status']
-
- def _value_convert(self, key_name, value, human, enum_as_number,
- list_convert):
-
- if enum_as_number is False:
- if key_name == 'status':
- value = System._status_to_str(value)
- return value
-
+ def __init__(self, _id, _name, _status, _status_info):
+ self._id = _id
+ self._name = _name
+ self._status = _status
+ self._status_info = _status_info

@default_property('id', doc="Unique identifier")
@default_property('name', doc="User supplied name")
diff --git a/lsm/lsm/ibmv7k.py b/lsm/lsm/ibmv7k.py
index 37c3243..846034f 100644
--- a/lsm/lsm/ibmv7k.py
+++ b/lsm/lsm/ibmv7k.py
@@ -382,7 +382,7 @@ class IbmV7k(IStorageAreaNetwork):
self.password, self.tmo)

si = self._get_system_info()
- self.sys_info = System(si['id'], si['name'], System.STATUS_OK)
+ self.sys_info = System(si['id'], si['name'], System.STATUS_OK, '')

def set_time_out(self, ms, flags=0):
self.tmo = ms
diff --git a/lsm/lsm/lsmcli_data_display.py b/lsm/lsm/lsmcli_data_display.py
new file mode 100644
index 0000000..09b1a24
--- /dev/null
+++ b/lsm/lsm/lsmcli_data_display.py
@@ -0,0 +1,344 @@
+# Copyright (C) 2012 Red Hat, Inc.
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+# USA
+#
+# Author: Gris Ge <***@redhat.com>
+import sys
+from collections import OrderedDict
+
+from lsm import System, size_bytes_2_size_human
+
+class EnumConvert:
+ BIT_MAP_STRING_SPLITER = ','
+
+ @staticmethod
+ def _txt_a(txt, append):
+ if len(txt):
+ return txt + EnumConvert.BIT_MAP_STRING_SPLITER + append
+ else:
+ return append
+
+ SYSTEM_STATUS_CONV = {
+ System.STATUS_UNKNOWN: 'Unknown',
+ System.STATUS_OK: 'OK',
+ System.STATUS_ERROR: 'Error',
+ System.STATUS_DEGRADED: 'Degraded',
+ System.STATUS_PREDICTIVE_FAILURE: 'Predictive failure',
+ System.STATUS_STRESSED: 'Stressed',
+ System.STATUS_STARTING: 'Starting',
+ System.STATUS_STOPPING: 'Stopping',
+ System.STATUS_STOPPED: 'Stopped',
+ System.STATUS_OTHER: 'Other',
+ }
+
+ @staticmethod
+ def system_status_to_str(system_status):
+ rc = ''
+ for cur_sys_status in EnumConvert.SYSTEM_STATUS_CONV.keys():
+ if system_status & cur_sys_status:
+ rc = EnumConvert._txt_a(rc,
+ EnumConvert.SYSTEM_STATUS_CONV[cur_sys_status])
+ if rc == '':
+ return EnumConvert.SYSTEM_STATUS_CONV[System.STATUS_UNKNOWN]
+ return rc
+
+class DisplayData:
+
+ def __init__():
+ pass
+
+ @staticmethod
+ def _out(msg):
+ try:
+ sys.stdout.write(str(msg))
+ sys.stdout.write("\n")
+ sys.stdout.flush()
+ except IOError:
+ sys.exit(1)
+
+ DISPLAY_WAY_COLUME = 0
+ DISPLAY_WAY_SCRIPT = 1
+
+ DISPLAY_WAY_DEFAULT = DISPLAY_WAY_COLUME
+
+ DEFAULT_SPLITER=' | '
+
+ SYSTEM_MAN_HEADER = OrderedDict()
+ SYSTEM_MAN_HEADER['id'] = 'ID'
+ SYSTEM_MAN_HEADER['name'] = 'Name'
+ SYSTEM_MAN_HEADER['status'] = 'Status'
+ SYSTEM_MAN_HEADER['status_info'] = 'Status Info'
+
+ SYSTEM_OPT_HEADER = OrderedDict()
+
+ SYSTEM_DSP_HEADER = SYSTEM_MAN_HEADER # SYSTEM_DSP_HEADER should be
+ # subset of SYSTEM_MAN_HEADER
+
+ SYSTEM_VALUE_CONV_ENUM = {
+ 'status': EnumConvert.system_status_to_str,
+ }
+
+ SYSTEM_VALUE_CONV_HUMAN = []
+
+ VALUE_CONVERT = {
+ System: {
+ 'mandatory_headers': SYSTEM_MAN_HEADER,
+ 'display_headers': SYSTEM_DSP_HEADER,
+ 'optional_headers': SYSTEM_OPT_HEADER,
+ 'value_conv_enum': SYSTEM_VALUE_CONV_ENUM,
+ 'value_conv_human': SYSTEM_VALUE_CONV_HUMAN,
+ }
+ }
+
+ @staticmethod
+ def _get_man_pro_value(obj, key, value_conv_enum, value_conv_human,
+ flag_human, flag_enum):
+ value = getattr(obj, key)
+ if not flag_enum:
+ if key in value_conv_enum.keys():
+ value = value_conv_enum[key](value)
+ if flag_human:
+ if key in value_conv_human:
+ value = size_bytes_2_size_human(value)
+ return value
+
+ @staticmethod
+ def _get_opt_pro_value(obj, key, value_conv_enum, value_conv_human,
+ flag_human, flag_enum):
+ value = obj.optional_data.get(key)
+ if not flag_enum:
+ if key in value_conv_enum.keys():
+ value = value_conv_enum[key](value)
+ if flag_human:
+ if key in value_conv_human:
+ value = size_bytes_2_size_human(value)
+ return value
+
+ @staticmethod
+ def _find_max_width(two_d_list, column_index):
+ max_width = 1
+ for row_index in range(0, len(two_d_list)):
+ row_data = two_d_list[row_index]
+ if len(row_data[column_index]) > max_width:
+ max_width = len(row_data[column_index])
+ return max_width
+
+ @staticmethod
+ def _data_dict_gen(obj, flag_human, flag_enum, extra_properties=None,
+ flag_dsp_all_data=False):
+ data_dict = OrderedDict()
+ value_convert = DisplayData.VALUE_CONVERT[type(obj)]
+ mandatory_headers = value_convert['mandatory_headers']
+ display_headers = value_convert['display_headers']
+ optional_headers = value_convert['optional_headers']
+ value_conv_enum = value_convert['value_conv_enum']
+ value_conv_human = value_convert['value_conv_human']
+
+ for key in display_headers.keys():
+ key_str = display_headers[key]
+ value = DisplayData._get_man_pro_value(
+ obj, key, value_conv_enum, value_conv_human, flag_human,
+ flag_enum)
+ data_dict[key_str] = value
+
+ if flag_dsp_all_data:
+ for key in mandatory_headers.keys():
+ if key in display_headers.keys():
+ continue
+ key_str = mandatory_headers[key]
+ value = DisplayData._get_man_pro_value(
+ obj, key, value_conv_enum, value_conv_human, flag_human,
+ flag_enum)
+ data_dict[key_str] = value
+
+ for key in optional_headers.keys():
+ key_str = optional_headers[key]
+ value = DisplayData._get_opt_pro_value(
+ obj, key, value_conv_enum, value_conv_human, flag_human,
+ flag_enum)
+ data_dict[key_str] = value
+
+ elif extra_properties:
+ for key in extra_properties:
+ if key in mandatory_headers.keys():
+ if key in display_headers.keys():
+ continue
+ key_str = mandatory_headers[key]
+ value = DisplayData._get_man_pro_value(
+ obj, key, value_conv_enum, value_conv_human,
+ flag_human, flag_enum)
+ data_dict[key_str] = value
+ elif key in optional_headers.keys():
+ key_str = optional_headers[key]
+ value = DisplayData._get_opt_pro_value(
+ obj, key, value_conv_enum, value_conv_human,
+ flag_human, flag_enum)
+ data_dict[key_str] = value
+
+ return data_dict
+
+ @staticmethod
+ def display_data(objs, display_way=None,
+ flag_human=True, flag_enum=False,
+ extra_properties=None,
+ spliter=None,
+ flag_with_header=True,
+ flag_dsp_all_data=False):
+ if len(objs) == 0:
+ return None
+
+ if display_way is None:
+ display_way = DisplayData.DISPLAY_WAY_DEFAULT
+
+ if spliter is None:
+ spliter = DisplayData.DEFAULT_SPLITER
+
+ data_dict_list = []
+ if type(objs[0]) in DisplayData.VALUE_CONVERT.keys():
+ for obj in objs:
+ data_dict = DisplayData._data_dict_gen(
+ obj, flag_human, flag_enum, extra_properties,
+ flag_dsp_all_data)
+ data_dict_list.extend([data_dict])
+ else:
+ return None
+ if display_way == DisplayData.DISPLAY_WAY_SCRIPT:
+ DisplayData._display_data_script_way(data_dict_list, spliter)
+ elif display_way == DisplayData.DISPLAY_WAY_COLUME:
+ DisplayData._display_data_colume_way(
+ data_dict_list, spliter, flag_with_header)
+ return True
+
+ @staticmethod
+ def _display_data_script_way(data_dict_list, spliter):
+ key_column_width = 1
+ value_column_width = 1
+
+ for data_dict in data_dict_list:
+ for key_name in data_dict.keys():
+ # find the max column width of key
+ cur_key_width = len(key_name)
+ if cur_key_width > key_column_width:
+ key_column_width = cur_key_width
+ # find the max column width of value
+ cur_value = data_dict[key_name]
+ cur_value_width = 0
+ if isinstance(cur_value, list):
+ if len(cur_value) == 0:
+ continue
+ cur_value_width = len(str(cur_value[0]))
+ else:
+ cur_value_width = len(str(cur_value))
+ if cur_value_width > value_column_width:
+ value_column_width = cur_value_width
+
+ row_format = '%%-%ds%s%%-%ds' % (key_column_width,
+ spliter,
+ value_column_width)
+ sub_row_format = '%s%s%%-%ds' % (' ' * key_column_width,
+ spliter,
+ value_column_width)
+ obj_spliter = '%s%s%s' % ('-' * key_column_width,
+ '-' * len(spliter),
+ '-' * value_column_width)
+
+ for data_dict in data_dict_list:
+ DisplayData._out(obj_spliter)
+ for key_name in data_dict:
+ value = data_dict[key_name]
+ if isinstance(value, list):
+ flag_first_data = True
+ for sub_value in value:
+ if flag_first_data:
+ out(row_format % (key_name, str(sub_value)))
+ flag_first_data = False
+ else:
+ DisplayData._out(sub_row_format % str(sub_value))
+ else:
+ DisplayData._out(row_format % (key_name, str(value)))
+ DisplayData._out(obj_spliter)
+
+ @staticmethod
+ def _display_data_colume_way(data_dict_list, spliter, flag_with_header):
+ if len(data_dict_list) == 0:
+ return
+ two_d_list = []
+
+ item_count = len(data_dict_list[0].keys())
+
+ # detemin how many lines we will print
+ row_width = 0
+ for data_dict in data_dict_list:
+ cur_max_wd = 0
+ for key_name in data_dict.keys():
+ if isinstance(data_dict[key_name], list):
+ cur_row_width = len(data_dict[key_name])
+ if cur_row_width > cur_max_wd:
+ cur_max_wd = cur_row_width
+ else:
+ pass
+ if cur_max_wd == 0:
+ cur_max_wd = 1
+ row_width += cur_max_wd
+
+ if flag_with_header:
+ # first line for header
+ row_width += 1
+
+ # init 2D list
+ for raw in range(0, row_width):
+ new = []
+ for column in range(0, item_count):
+ new.append([''])
+ two_d_list.append(new)
+
+ # header
+ current_row_num = -1
+ if flag_with_header:
+ two_d_list[0] = data_dict_list[0].keys()
+ current_row_num = 0
+
+ # Fill the 2D list with data_dict_list
+ for data_dict in data_dict_list:
+ current_row_num += 1
+ save_row_num = current_row_num
+ values = data_dict.values()
+ for index in range(0, len(values)):
+ value = values[index]
+ if isinstance(value, list):
+ for sub_index in range(0, len(value)):
+ tmp_row_num = save_row_num + sub_index
+ two_d_list[tmp_row_num][index] = str(value[sub_index])
+
+ if save_row_num + len(value) > current_row_num:
+ current_row_num = save_row_num + len(value) - 1
+ else:
+ two_d_list[save_row_num][index] = str(value)
+
+ # display two_list
+ row_formats = []
+ header_spliter = ''
+ for column_index in range(0, len(two_d_list[0])):
+ max_width = DisplayData._find_max_width(two_d_list, column_index)
+ row_formats.extend(['%%-%ds' % max_width])
+ header_spliter += '-' * max_width
+ if column_index != (len(two_d_list[0]) - 1):
+ header_spliter += '-' * len(spliter)
+
+ row_format = spliter.join(row_formats)
+ for row_index in range(0, len(two_d_list)):
+ DisplayData._out(row_format % tuple(two_d_list[row_index]))
+ if row_index == 0 and flag_with_header:
+ DisplayData._out(header_spliter)
diff --git a/lsm/lsm/nstor.py b/lsm/lsm/nstor.py
index 10f5525..6fc6232 100644
--- a/lsm/lsm/nstor.py
+++ b/lsm/lsm/nstor.py
@@ -77,7 +77,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
license_info = self._request("get_license_info", "appliance", [""])
fqdn = self._request("get_fqdn", "appliance", [""])
self._system = System(license_info['machine_sig'], fqdn,
- System.STATUS_OK)
+ System.STATUS_OK, '')
return self._system

def startup(self, uri, password, timeout, flags=0):
diff --git a/lsm/lsm/ontap.py b/lsm/lsm/ontap.py
index 5321c95..5cb20b8 100644
--- a/lsm/lsm/ontap.py
+++ b/lsm/lsm/ontap.py
@@ -162,7 +162,7 @@ class Ontap(IStorageAreaNetwork, INfs):
i = self.f.system_info()
#TODO Get real filer status
self.sys_info = System(i['system-id'], i['system-name'],
- System.STATUS_OK)
+ System.STATUS_OK, '')
return self.f.validate()

def set_time_out(self, ms, flags=0):
diff --git a/lsm/lsm/simarray.py b/lsm/lsm/simarray.py
index e5fe45f..ce615b6 100644
--- a/lsm/lsm/simarray.py
+++ b/lsm/lsm/simarray.py
@@ -597,7 +597,7 @@ class SimData(object):
}
self.syss = [System(SimData.SIM_DATA_SYS_ID,
'LSM simulated storage plug-in',
- System.STATUS_OK)]
+ System.STATUS_OK, '')]
pool_size_200g = size_human_2_size_bytes('200GiB')
self.pool_dict = {
'POO1': {
diff --git a/lsm/lsm/smis.py b/lsm/lsm/smis.py
index 2050fe7..d2d137c 100644
--- a/lsm/lsm/smis.py
+++ b/lsm/lsm/smis.py
@@ -1492,7 +1492,7 @@ class Smis(IStorageAreaNetwork):
elif os == Smis.SystemOperationalStatus.PREDICTIVE_FAILURE:
status |= System.STATUS_PREDICTIVE_FAILURE

- return System(cim_sys['Name'], cim_sys['ElementName'], status)
+ return System(cim_sys['Name'], cim_sys['ElementName'], status, '')

def _cim_sys_pros(self):
"""
diff --git a/lsm/lsm/targetd.py b/lsm/lsm/targetd.py
index 8b5c235..8a94d22 100644
--- a/lsm/lsm/targetd.py
+++ b/lsm/lsm/targetd.py
@@ -62,7 +62,7 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
self.url = None
self.headers = None
self.system = System("targetd", "targetd storage appliance",
- System.STATUS_UNKNOWN)
+ System.STATUS_UNKNOWN, '')

@handle_errors
def startup(self, uri, password, timeout, flags=0):
diff --git a/plugin/simc_lsmplugin.c b/plugin/simc_lsmplugin.c
index f4f422a..d889109 100644
--- a/plugin/simc_lsmplugin.c
+++ b/plugin/simc_lsmplugin.c
@@ -2481,7 +2481,7 @@ int load( lsm_plugin_ptr c, const char *uri, const char *password,
pd->num_systems = 1;
pd->system[0] = lsm_system_record_alloc(sys_id,
"LSM simulated storage plug-in",
- LSM_SYSTEM_STATUS_OK);
+ LSM_SYSTEM_STATUS_OK, "");

p = lsm_pool_record_alloc("POOL_3", "lsm_test_aggr",
UINT64_MAX, UINT64_MAX,
diff --git a/src/lsm_convert.cpp b/src/lsm_convert.cpp
index b3f48c4..a2d2805 100644
--- a/src/lsm_convert.cpp
+++ b/src/lsm_convert.cpp
@@ -194,7 +194,8 @@ lsm_system *value_to_system(Value &system)
std::map<std::string, Value> i = system.asObject();
rc = lsm_system_record_alloc( i["id"].asString().c_str(),
i["name"].asString().c_str(),
- i["status"].asUint32_t());
+ i["status"].asUint32_t(),
+ i["status_info"].asString().c_str());
}
return rc;
}
@@ -207,6 +208,7 @@ Value system_to_value(lsm_system *system)
s["id"] = Value(system->id);
s["name"] = Value(system->name);
s["status"] = Value(system->status);
+ s["status_info"] = Value(system->status_info);
return Value(s);
}
return Value();
diff --git a/src/lsm_datatypes.cpp b/src/lsm_datatypes.cpp
index b0b2427..add7467 100644
--- a/src/lsm_datatypes.cpp
+++ b/src/lsm_datatypes.cpp
@@ -743,7 +743,7 @@ lsm_disk *lsm_disk_record_alloc(const char *id, const char *name,
CREATE_ALLOC_ARRAY_FUNC(lsm_system_record_array_alloc, lsm_system *)

lsm_system *lsm_system_record_alloc( const char *id, const char *name,
- uint32_t status)
+ uint32_t status, const char *status_info)
{
lsm_system *rc = (lsm_system *)malloc(sizeof(lsm_system));
if (rc) {
@@ -751,7 +751,8 @@ lsm_system *lsm_system_record_alloc( const char *id, const char *name,
rc->id = strdup(id);
rc->name = strdup(name);
rc->status = status;
- if( !rc->name || !rc->id ) {
+ rc->status_info = strdup(status_info);
+ if( !rc->name || !rc->id || !rc->status_info ) {
lsm_system_record_free(rc);
rc = NULL;
}
@@ -774,6 +775,11 @@ int lsm_system_record_free(lsm_system *s)
s->name = NULL;
}

+ if (s->status_info) {
+ free(s->status_info);
+ s->status_info = NULL;
+ }
+
free(s);
return LSM_ERR_OK;
}
@@ -787,7 +793,7 @@ lsm_system *lsm_system_record_copy(lsm_system *s)
{
lsm_system *rc = NULL;
if( LSM_IS_SYSTEM(s) ) {
- rc = lsm_system_record_alloc(s->id, s->name, s->status);
+ rc = lsm_system_record_alloc(s->id, s->name, s->status, s->status_info);
}
return rc;
}
diff --git a/src/lsm_datatypes.hpp b/src/lsm_datatypes.hpp
index 34340ff..fceeea7 100644
--- a/src/lsm_datatypes.hpp
+++ b/src/lsm_datatypes.hpp
@@ -187,6 +187,7 @@ struct _lsm_system {
char *id; /**< Id */
char *name; /**< Name */
uint32_t status; /**< Enumerated status value */
+ char *status_info; /**< System status text */
};

#define LSM_CONNECT_MAGIC 0xAA7A000A
--
1.8.2.1
Loading...