Discussion:
[Libstoragemgmt-devel] [PATCH 3/4] rename time out methods
Tony Asleson
2014-05-14 22:41:49 UTC
Permalink
Python & JSON rpc changed from:

set_time_out -> time_out_set
get_time_out -> get_time_out

They now conform to noun-verb expectation we have
established in library.

Signed-off-by: Tony Asleson <***@redhat.com>
---
c_binding/lsm_mgmt.cpp | 4 ++--
c_binding/lsm_plugin_ipc.cpp | 4 ++--
plugin/nstor/nstor.py | 4 ++--
plugin/ontap/ontap.py | 12 ++++++------
plugin/sim/simarray.py | 4 ++--
plugin/sim/simulator.py | 8 ++++----
plugin/smispy/smis.py | 4 ++--
plugin/targetd/targetd.py | 4 ++--
plugin/v7k/ibmv7k.py | 4 ++--
python_binding/lsm/_client.py | 12 ++++++------
python_binding/lsm/_iplugin.py | 4 ++--
test/plugin_test.py | 4 ++--
12 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/c_binding/lsm_mgmt.cpp b/c_binding/lsm_mgmt.cpp
index 8d59137..b92a44b 100644
--- a/c_binding/lsm_mgmt.cpp
+++ b/c_binding/lsm_mgmt.cpp
@@ -366,7 +366,7 @@ int lsm_connect_timeout_set(lsm_connect *c, uint32_t timeout, lsm_flag flags)
Value response;

//No response data needed on set time out.
- return rpc(c, "set_time_out", parameters, response);
+ return rpc(c, "time_out_set", parameters, response);
}

int lsm_connect_timeout_get(lsm_connect *c, uint32_t *timeout, lsm_flag flags)
@@ -384,7 +384,7 @@ int lsm_connect_timeout_get(lsm_connect *c, uint32_t *timeout, lsm_flag flags)
Value parameters(p);
Value response;

- rc = rpc(c, "get_time_out", parameters, response);
+ rc = rpc(c, "time_out_get", parameters, response);
if( rc == LSM_ERR_OK ) {
*timeout = response.asUint32_t();
}
diff --git a/c_binding/lsm_plugin_ipc.cpp b/c_binding/lsm_plugin_ipc.cpp
index 97a2c2b..cca61a6 100644
--- a/c_binding/lsm_plugin_ipc.cpp
+++ b/c_binding/lsm_plugin_ipc.cpp
@@ -2384,7 +2384,7 @@ static std::map<std::string,handler> dispatch = static_map<std::string,handler>
("fs_snapshot_delete", ss_delete)
("fs_snapshot_revert", ss_revert)
("fs_snapshots", ss_list)
- ("get_time_out", handle_get_time_out)
+ ("time_out_get", handle_get_time_out)
("initiators", handle_initiators)
("initiator_grant", initiator_grant)
("initiators_granted_to_volume", init_granted_to_volume)
@@ -2399,7 +2399,7 @@ static std::map<std::string,handler> dispatch = static_map<std::string,handler>
("pool_create_from_volumes", handle_pool_create_from_volumes)
("pool_create_from_pool", handle_pool_create_from_pool)
("pool_delete", handle_pool_delete)
- ("set_time_out", handle_set_time_out)
+ ("time_out_set", handle_set_time_out)
("shutdown", handle_shutdown)
("startup", handle_startup)
("systems", handle_system_list)
diff --git a/plugin/nstor/nstor.py b/plugin/nstor/nstor.py
index 3e47cb1..8254ab5 100644
--- a/plugin/nstor/nstor.py
+++ b/plugin/nstor/nstor.py
@@ -188,11 +188,11 @@ class NexentaStor(INfs, IStorageAreaNetwork):
self._request("destroy", "snapshot", [snapshot.name, ""])
return

- def set_time_out(self, ms, flags=0):
+ def time_out_set(self, ms, flags=0):
self.timeout = ms
return

- def get_time_out(self, flags=0):
+ def time_out_get(self, flags=0):
return self.timeout

def shutdown(self, flags=0):
diff --git a/plugin/ontap/ontap.py b/plugin/ontap/ontap.py
index b26d91d..3f87ecd 100644
--- a/plugin/ontap/ontap.py
+++ b/plugin/ontap/ontap.py
@@ -159,10 +159,10 @@ class Ontap(IStorageAreaNetwork, INfs):
System.STATUS_OK, '')
return self.f.validate()

- def set_time_out(self, ms, flags=0):
+ def time_out_set(self, ms, flags=0):
self.f.timeout = ms / Ontap.TMO_CONV

- def get_time_out(self, flags=0):
+ def time_out_get(self, flags=0):
return self.f.timeout * Ontap.TMO_CONV

def shutdown(self, flags=0):
@@ -532,15 +532,15 @@ class Ontap(IStorageAreaNetwork, INfs):
double if it's reasonable to try and get this operation to happen
"""

- current_tmo = self.get_time_out()
+ current_tmo = self.time_out_get()
try:
#If the user selects a short timeout we may not be able
#to restore the array back, so lets give the array
#a chance to recover.
if current_tmo < 30000:
- self.set_time_out(60000)
+ self.time_out_set(60000)
else:
- self.set_time_out(current_tmo * 2)
+ self.time_out_set(current_tmo * 2)

self.f.volume_resize(vol, size_diff_kb)
except:
@@ -551,7 +551,7 @@ class Ontap(IStorageAreaNetwork, INfs):
+ traceback.format_exc())
finally:
#Restore timeout.
- self.set_time_out(current_tmo)
+ self.time_out_set(current_tmo)

def _na_volume_resize_restore(self, vol, size_diff):
try:
diff --git a/plugin/sim/simarray.py b/plugin/sim/simarray.py
index 7cb6493..29268ad 100644
--- a/plugin/sim/simarray.py
+++ b/plugin/sim/simarray.py
@@ -128,10 +128,10 @@ class SimArray(object):
def job_free(self, job_id, flags=0):
return self.data.job_free(job_id, flags=0)

- def set_time_out(self, ms, flags=0):
+ def time_out_set(self, ms, flags=0):
return self.data.set_time_out(ms, flags)

- def get_time_out(self, flags=0):
+ def time_out_get(self, flags=0):
return self.data.get_time_out(flags)

def systems(self):
diff --git a/plugin/sim/simulator.py b/plugin/sim/simulator.py
index 1ea1a45..b489cb5 100644
--- a/plugin/sim/simulator.py
+++ b/plugin/sim/simulator.py
@@ -66,12 +66,12 @@ class SimPlugin(INfs, IStorageAreaNetwork):
"""
return sim_data

- def set_time_out(self, ms, flags=0):
- self.sim_array.set_time_out(ms, flags)
+ def time_out_set(self, ms, flags=0):
+ self.sim_array.time_out_set(ms, flags)
return None

- def get_time_out(self, flags=0):
- return self.sim_array.get_time_out(flags)
+ def time_out_get(self, flags=0):
+ return self.sim_array.time_out_get(flags)

def capabilities(self, system, flags=0):
rc = Capabilities()
diff --git a/plugin/smispy/smis.py b/plugin/smispy/smis.py
index 0cf0038..c63d8cd 100644
--- a/plugin/smispy/smis.py
+++ b/plugin/smispy/smis.py
@@ -587,10 +587,10 @@ class Smis(IStorageAreaNetwork):
else:
raise e

- def set_time_out(self, ms, flags=0):
+ def time_out_set(self, ms, flags=0):
self.tmo = ms

- def get_time_out(self, flags=0):
+ def time_out_get(self, flags=0):
return self.tmo

def shutdown(self, flags=0):
diff --git a/plugin/targetd/targetd.py b/plugin/targetd/targetd.py
index d93665c..b437ce5 100644
--- a/plugin/targetd/targetd.py
+++ b/plugin/targetd/targetd.py
@@ -83,11 +83,11 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
'Authorization': 'Basic %s' % (auth,)}

@handle_errors
- def set_time_out(self, ms, flags=0):
+ def time_out_set(self, ms, flags=0):
self.tmo = ms

@handle_errors
- def get_time_out(self, flags=0):
+ def time_out_get(self, flags=0):
return self.tmo

@handle_errors
diff --git a/plugin/v7k/ibmv7k.py b/plugin/v7k/ibmv7k.py
index 16750d0..130e28d 100644
--- a/plugin/v7k/ibmv7k.py
+++ b/plugin/v7k/ibmv7k.py
@@ -384,13 +384,13 @@ class IbmV7k(IStorageAreaNetwork):
si = self._get_system_info()
self.sys_info = System(si['id'], si['name'], System.STATUS_OK, '')

- def set_time_out(self, ms, flags=0):
+ def time_out_set(self, ms, flags=0):
self.tmo = ms
self.ssh.close()
self.ssh = SSHClient(self.up['host'], self.up['username'],
self.password, self.tmo)

- def get_time_out(self, flags=0):
+ def time_out_get(self, flags=0):
return self.tmo

def shutdown(self, flags=0):
diff --git a/python_binding/lsm/_client.py b/python_binding/lsm/_client.py
index ec7d87e..f34c87c 100644
--- a/python_binding/lsm/_client.py
+++ b/python_binding/lsm/_client.py
@@ -200,26 +200,26 @@ class Client(INetworkAttachedStorage):
# @param ms Time-out in ms
# @param flags Reserved for future use, must be zero.
@_return_requires(None)
- def set_time_out(self, ms, flags=0):
+ def time_out_set(self, ms, flags=0):
"""
Sets any time-outs for the plug-in (ms)

Return None on success, else LsmError exception
"""
- return self._tp.rpc('set_time_out', _del_self(locals()))
+ return self._tp.rpc('time_out_set', _del_self(locals()))

## Retrieves the current time-out value.
# @param self The this pointer
# @param flags Reserved for future use, must be zero.
# @returns Time-out value
@_return_requires(int)
- def get_time_out(self, flags=0):
+ def time_out_get(self, flags=0):
"""
Retrieves the current time-out

Return time-out in ms, else raise LsmError
"""
- return self._tp.rpc('get_time_out', _del_self(locals()))
+ return self._tp.rpc('time_out_get', _del_self(locals()))

## Retrieves the status of the specified job id.
# @param self The this pointer
@@ -1143,8 +1143,8 @@ class _TestClient(unittest.TestCase):
def test_tmo(self):
expected = 40000

- self.c.set_time_out(expected)
- tmo = self.c.get_time_out()
+ self.c.time_out_set(expected)
+ tmo = self.c.time_out_get()
self.assertTrue(tmo == expected)

def test_job_errors(self):
diff --git a/python_binding/lsm/_iplugin.py b/python_binding/lsm/_iplugin.py
index b1ff58f..493a093 100644
--- a/python_binding/lsm/_iplugin.py
+++ b/python_binding/lsm/_iplugin.py
@@ -39,7 +39,7 @@ class IPlugin(object):
pass

@_abstractmethod
- def set_time_out(self, ms, flags=0):
+ def time_out_set(self, ms, flags=0):
"""
Sets any time-outs for the plug-in (ms)

@@ -48,7 +48,7 @@ class IPlugin(object):
pass

@_abstractmethod
- def get_time_out(self, flags=0):
+ def time_out_get(self, flags=0):
"""
Retrieves the current time-out

diff --git a/test/plugin_test.py b/test/plugin_test.py
index c7a20d0..0cdf99e 100755
--- a/test/plugin_test.py
+++ b/test/plugin_test.py
@@ -260,8 +260,8 @@ class TestPlugin(unittest.TestCase):

def test_timeout(self):
tmo = 40000
- self.c.set_time_out(tmo)
- self.assertEquals(self.c.get_time_out(), tmo)
+ self.c.time_out_set(tmo)
+ self.assertEquals(self.c.time_out_get(), tmo)

def test_systems_list(self):
arrays = self.c.systems()
--
1.8.2.1
Tony Asleson
2014-05-14 22:41:50 UTC
Permalink
Reduce the possible values for capabilities to two. However,
to future proof I have introduced a new function/method called
'supported' which returns boolean for Python and Zero/Non-zero for
C. This way if we add more states later existing code will not
break. The existing get functionality remains which returns an
enumerated value.

Signed-off-by: Tony Asleson <***@redhat.com>
---
.../libstoragemgmt/libstoragemgmt_capabilities.h | 14 ++-
c_binding/lsm_datatypes.cpp | 11 +-
python_binding/lsm/_cmdline.py | 121 ++++++++++-----------
python_binding/lsm/_data.py | 14 ++-
test/plugin_test.py | 4 +-
test/tester.c | 2 +
6 files changed, 89 insertions(+), 77 deletions(-)

diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_capabilities.h b/c_binding/include/libstoragemgmt/libstoragemgmt_capabilities.h
index a02baa6..5a3bc86 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_capabilities.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_capabilities.h
@@ -32,10 +32,7 @@ extern "C" {
/** \enum lsm_capability_value_type Possible values for supported feature*/
typedef enum {
LSM_CAPABILITY_UNSUPPORTED = 0, /**< Feature is not supported */
- LSM_CAPABILITY_SUPPORTED = 1, /**< Feature is supported */
- LSM_CAPABILITY_SUPPORTED_OFFLINE = 2, /**< Feature is supported when offlined */
- LSM_CAPABILITY_NO_IMPLEMENTED = 3, /**< Feature is not implemented */
- LSM_CAPABILITY_UNKNOWN = 4 /**< Feature status unknown */
+ LSM_CAPABILITY_SUPPORTED = 1 /**< Feature is supported */
} lsm_capability_value_type;

/** \enum lsm_capability_value_type Capabilities supported by array */
@@ -165,6 +162,15 @@ lsm_capability_value_type LSM_DLL_EXPORT lsm_capability_get(
lsm_storage_capabilities *cap,
lsm_capability_type t);

+/**
+ * Boolean version of capability support
+ * @param cap
+ * @param t
+ * @return Non-zero if supported, 0 if not supported
+ */
+int LSM_DLL_EXPORT lsm_capability_supported(lsm_storage_capabilities *cap,
+ lsm_capability_type t);
+

#ifdef __cplusplus
}
diff --git a/c_binding/lsm_datatypes.cpp b/c_binding/lsm_datatypes.cpp
index ff39dc1..44ba0c3 100644
--- a/c_binding/lsm_datatypes.cpp
+++ b/c_binding/lsm_datatypes.cpp
@@ -1527,7 +1527,7 @@ int lsm_nfs_export_options_set( lsm_nfs_export *exp, const char *value )
lsm_capability_value_type lsm_capability_get(lsm_storage_capabilities *cap,
lsm_capability_type t)
{
- lsm_capability_value_type rc = LSM_CAPABILITY_UNKNOWN;
+ lsm_capability_value_type rc = LSM_CAPABILITY_UNSUPPORTED;

if( LSM_IS_CAPABILITIY(cap) && (uint32_t)t < cap->len ) {
rc = (lsm_capability_value_type)cap->cap[t];
@@ -1535,6 +1535,15 @@ lsm_capability_value_type lsm_capability_get(lsm_storage_capabilities *cap,
return rc;
}

+int LSM_DLL_EXPORT lsm_capability_supported(lsm_storage_capabilities *cap,
+ lsm_capability_type t)
+{
+ if( lsm_capability_get(cap, t) == LSM_CAPABILITY_SUPPORTED ) {
+ return 1;
+ }
+ return 0;
+}
+
int lsm_capability_set(lsm_storage_capabilities *cap, lsm_capability_type t,
lsm_capability_value_type v)
{
diff --git a/python_binding/lsm/_cmdline.py b/python_binding/lsm/_cmdline.py
index 1845e82..3d31e1d 100644
--- a/python_binding/lsm/_cmdline.py
+++ b/python_binding/lsm/_cmdline.py
@@ -1264,16 +1264,10 @@ class CmdLine:
else:
s = ':'

- if val == Capabilities.SUPPORTED:
+ if val:
v = "SUPPORTED"
- elif val == Capabilities.UNSUPPORTED:
- v = "UNSUPPORTED"
- elif val == Capabilities.SUPPORTED_OFFLINE:
- v = "SUPPORTED_OFFLINE"
- elif val == Capabilities.NOT_IMPLEMENTED:
- v = "NOT_IMPLEMENTED"
else:
- v = "UNKNOWN"
+ v = "UNSUPPORTED"

out("%s%s%s" % (cap, s, v))

@@ -1281,96 +1275,97 @@ class CmdLine:
s = _get_item(self.c.systems(), args.sys, "system id")

cap = self.c.capabilities(s)
- self._cp("BLOCK_SUPPORT", cap.get(Capabilities.BLOCK_SUPPORT))
- self._cp("FS_SUPPORT", cap.get(Capabilities.FS_SUPPORT))
- self._cp("INITIATORS", cap.get(Capabilities.INITIATORS))
+ self._cp("BLOCK_SUPPORT", cap.supported(Capabilities.BLOCK_SUPPORT))
+ self._cp("FS_SUPPORT", cap.supported(Capabilities.FS_SUPPORT))
+ self._cp("INITIATORS", cap.supported(Capabilities.INITIATORS))
self._cp("INITIATORS_GRANTED_TO_VOLUME",
- cap.get(Capabilities.INITIATORS_GRANTED_TO_VOLUME))
- self._cp("VOLUMES", cap.get(Capabilities.VOLUMES))
- self._cp("VOLUME_CREATE", cap.get(Capabilities.VOLUME_CREATE))
- self._cp("VOLUME_RESIZE", cap.get(Capabilities.VOLUME_RESIZE))
+ cap.supported(Capabilities.INITIATORS_GRANTED_TO_VOLUME))
+ self._cp("VOLUMES", cap.supported(Capabilities.VOLUMES))
+ self._cp("VOLUME_CREATE", cap.supported(Capabilities.VOLUME_CREATE))
+ self._cp("VOLUME_RESIZE", cap.supported(Capabilities.VOLUME_RESIZE))
self._cp("VOLUME_REPLICATE",
- cap.get(Capabilities.VOLUME_REPLICATE))
+ cap.supported(Capabilities.VOLUME_REPLICATE))
self._cp("VOLUME_REPLICATE_CLONE",
- cap.get(Capabilities.VOLUME_REPLICATE_CLONE))
+ cap.supported(Capabilities.VOLUME_REPLICATE_CLONE))
self._cp("VOLUME_REPLICATE_COPY",
- cap.get(Capabilities.VOLUME_REPLICATE_COPY))
+ cap.supported(Capabilities.VOLUME_REPLICATE_COPY))
self._cp("VOLUME_REPLICATE_MIRROR_ASYNC",
- cap.get(Capabilities.VOLUME_REPLICATE_MIRROR_ASYNC))
+ cap.supported(Capabilities.VOLUME_REPLICATE_MIRROR_ASYNC))
self._cp("VOLUME_REPLICATE_MIRROR_SYNC",
- cap.get(Capabilities.VOLUME_REPLICATE_MIRROR_SYNC))
+ cap.supported(Capabilities.VOLUME_REPLICATE_MIRROR_SYNC))
self._cp("VOLUME_COPY_RANGE_BLOCK_SIZE",
- cap.get(Capabilities.VOLUME_COPY_RANGE_BLOCK_SIZE))
+ cap.supported(Capabilities.VOLUME_COPY_RANGE_BLOCK_SIZE))
self._cp("VOLUME_COPY_RANGE",
- cap.get(Capabilities.VOLUME_COPY_RANGE))
+ cap.supported(Capabilities.VOLUME_COPY_RANGE))
self._cp("VOLUME_COPY_RANGE_CLONE",
- cap.get(Capabilities.VOLUME_COPY_RANGE_CLONE))
+ cap.supported(Capabilities.VOLUME_COPY_RANGE_CLONE))
self._cp("VOLUME_COPY_RANGE_COPY",
- cap.get(Capabilities.VOLUME_COPY_RANGE_COPY))
- self._cp("VOLUME_DELETE", cap.get(Capabilities.VOLUME_DELETE))
- self._cp("VOLUME_ONLINE", cap.get(Capabilities.VOLUME_ONLINE))
- self._cp("VOLUME_OFFLINE", cap.get(Capabilities.VOLUME_OFFLINE))
+ cap.supported(Capabilities.VOLUME_COPY_RANGE_COPY))
+ self._cp("VOLUME_DELETE", cap.supported(Capabilities.VOLUME_DELETE))
+ self._cp("VOLUME_ONLINE", cap.supported(Capabilities.VOLUME_ONLINE))
+ self._cp("VOLUME_OFFLINE", cap.supported(Capabilities.VOLUME_OFFLINE))
self._cp("VOLUME_INITIATOR_GRANT",
- cap.get(Capabilities.VOLUME_INITIATOR_GRANT))
+ cap.supported(Capabilities.VOLUME_INITIATOR_GRANT))
self._cp("VOLUME_INITIATOR_REVOKE",
- cap.get(Capabilities.VOLUME_INITIATOR_REVOKE))
+ cap.supported(Capabilities.VOLUME_INITIATOR_REVOKE))
self._cp("VOLUME_THIN",
- cap.get(Capabilities.VOLUME_THIN))
+ cap.supported(Capabilities.VOLUME_THIN))
self._cp("VOLUME_ISCSI_CHAP_AUTHENTICATION",
- cap.get(Capabilities.VOLUME_ISCSI_CHAP_AUTHENTICATION))
+ cap.supported(Capabilities.VOLUME_ISCSI_CHAP_AUTHENTICATION))
self._cp("ACCESS_GROUP_GRANT",
- cap.get(Capabilities.ACCESS_GROUP_GRANT))
+ cap.supported(Capabilities.ACCESS_GROUP_GRANT))
self._cp("ACCESS_GROUP_REVOKE",
- cap.get(Capabilities.ACCESS_GROUP_REVOKE))
+ cap.supported(Capabilities.ACCESS_GROUP_REVOKE))
self._cp("ACCESS_GROUP_LIST",
- cap.get(Capabilities.ACCESS_GROUP_LIST))
+ cap.supported(Capabilities.ACCESS_GROUP_LIST))
self._cp("ACCESS_GROUP_CREATE",
- cap.get(Capabilities.ACCESS_GROUP_CREATE))
+ cap.supported(Capabilities.ACCESS_GROUP_CREATE))
self._cp("ACCESS_GROUP_DELETE",
- cap.get(Capabilities.ACCESS_GROUP_DELETE))
+ cap.supported(Capabilities.ACCESS_GROUP_DELETE))
self._cp("ACCESS_GROUP_ADD_INITIATOR",
- cap.get(Capabilities.ACCESS_GROUP_ADD_INITIATOR))
+ cap.supported(Capabilities.ACCESS_GROUP_ADD_INITIATOR))
self._cp("ACCESS_GROUP_DEL_INITIATOR",
- cap.get(Capabilities.ACCESS_GROUP_DEL_INITIATOR))
+ cap.supported(Capabilities.ACCESS_GROUP_DEL_INITIATOR))
self._cp("VOLUMES_ACCESSIBLE_BY_ACCESS_GROUP",
- cap.get(Capabilities.VOLUMES_ACCESSIBLE_BY_ACCESS_GROUP))
+ cap.supported(
+ Capabilities.VOLUMES_ACCESSIBLE_BY_ACCESS_GROUP))
self._cp("VOLUME_ACCESSIBLE_BY_INITIATOR",
- cap.get(Capabilities.VOLUME_ACCESSIBLE_BY_INITIATOR))
+ cap.supported(Capabilities.VOLUME_ACCESSIBLE_BY_INITIATOR))
self._cp("ACCESS_GROUPS_GRANTED_TO_VOLUME",
- cap.get(Capabilities.ACCESS_GROUPS_GRANTED_TO_VOLUME))
+ cap.supported(Capabilities.ACCESS_GROUPS_GRANTED_TO_VOLUME))
self._cp("VOLUME_CHILD_DEPENDENCY",
- cap.get(Capabilities.VOLUME_CHILD_DEPENDENCY))
+ cap.supported(Capabilities.VOLUME_CHILD_DEPENDENCY))
self._cp("VOLUME_CHILD_DEPENDENCY_RM",
- cap.get(Capabilities.VOLUME_CHILD_DEPENDENCY_RM))
- self._cp("FS", cap.get(Capabilities.FS))
- self._cp("FS_DELETE", cap.get(Capabilities.FS_DELETE))
- self._cp("FS_RESIZE", cap.get(Capabilities.FS_RESIZE))
- self._cp("FS_CREATE", cap.get(Capabilities.FS_CREATE))
- self._cp("FS_CLONE", cap.get(Capabilities.FS_CLONE))
- self._cp("FILE_CLONE", cap.get(Capabilities.FILE_CLONE))
- self._cp("FS_SNAPSHOTS", cap.get(Capabilities.FS_SNAPSHOTS))
+ cap.supported(Capabilities.VOLUME_CHILD_DEPENDENCY_RM))
+ self._cp("FS", cap.supported(Capabilities.FS))
+ self._cp("FS_DELETE", cap.supported(Capabilities.FS_DELETE))
+ self._cp("FS_RESIZE", cap.supported(Capabilities.FS_RESIZE))
+ self._cp("FS_CREATE", cap.supported(Capabilities.FS_CREATE))
+ self._cp("FS_CLONE", cap.supported(Capabilities.FS_CLONE))
+ self._cp("FILE_CLONE", cap.supported(Capabilities.FILE_CLONE))
+ self._cp("FS_SNAPSHOTS", cap.supported(Capabilities.FS_SNAPSHOTS))
self._cp("FS_SNAPSHOT_CREATE",
- cap.get(Capabilities.FS_SNAPSHOT_CREATE))
+ cap.supported(Capabilities.FS_SNAPSHOT_CREATE))
self._cp("FS_SNAPSHOT_CREATE_SPECIFIC_FILES",
- cap.get(Capabilities.FS_SNAPSHOT_CREATE_SPECIFIC_FILES))
+ cap.supported(Capabilities.FS_SNAPSHOT_CREATE_SPECIFIC_FILES))
self._cp("FS_SNAPSHOT_DELETE",
- cap.get(Capabilities.FS_SNAPSHOT_DELETE))
+ cap.supported(Capabilities.FS_SNAPSHOT_DELETE))
self._cp("FS_SNAPSHOT_REVERT",
- cap.get(Capabilities.FS_SNAPSHOT_REVERT))
+ cap.supported(Capabilities.FS_SNAPSHOT_REVERT))
self._cp("FS_SNAPSHOT_REVERT_SPECIFIC_FILES",
- cap.get(Capabilities.FS_SNAPSHOT_REVERT_SPECIFIC_FILES))
+ cap.supported(Capabilities.FS_SNAPSHOT_REVERT_SPECIFIC_FILES))
self._cp("FS_CHILD_DEPENDENCY",
- cap.get(Capabilities.FS_CHILD_DEPENDENCY))
+ cap.supported(Capabilities.FS_CHILD_DEPENDENCY))
self._cp("FS_CHILD_DEPENDENCY_RM",
- cap.get(Capabilities.FS_CHILD_DEPENDENCY_RM))
- self._cp("FS_CHILD_DEPENDENCY_RM_SPECIFIC_FILES", cap.get(
+ cap.supported(Capabilities.FS_CHILD_DEPENDENCY_RM))
+ self._cp("FS_CHILD_DEPENDENCY_RM_SPECIFIC_FILES", cap.supported(
Capabilities.FS_CHILD_DEPENDENCY_RM_SPECIFIC_FILES))
- self._cp("EXPORT_AUTH", cap.get(Capabilities.EXPORT_AUTH))
- self._cp("EXPORTS", cap.get(Capabilities.EXPORTS))
- self._cp("EXPORT_FS", cap.get(Capabilities.EXPORT_FS))
- self._cp("EXPORT_REMOVE", cap.get(Capabilities.EXPORT_REMOVE))
+ self._cp("EXPORT_AUTH", cap.supported(Capabilities.EXPORT_AUTH))
+ self._cp("EXPORTS", cap.supported(Capabilities.EXPORTS))
+ self._cp("EXPORT_FS", cap.supported(Capabilities.EXPORT_FS))
+ self._cp("EXPORT_REMOVE", cap.supported(Capabilities.EXPORT_REMOVE))
self._cp("EXPORT_CUSTOM_PATH",
- cap.get(Capabilities.EXPORT_CUSTOM_PATH))
+ cap.supported(Capabilities.EXPORT_CUSTOM_PATH))

def plugin_info(self, args):
desc, version = self.c.plugin_info()
diff --git a/python_binding/lsm/_data.py b/python_binding/lsm/_data.py
index 603bf16..7d78039 100644
--- a/python_binding/lsm/_data.py
+++ b/python_binding/lsm/_data.py
@@ -1459,11 +1459,8 @@ class OptionalData(IData):
class Capabilities(IData):
(
UNSUPPORTED, # Not supported
- SUPPORTED, # Supported
- SUPPORTED_OFFLINE, # Supported, but only when item is in offline state
- NOT_IMPLEMENTED, # Not implemented
- UNKNOWN # Capability not known
- ) = (0, 1, 2, 3, 4)
+ SUPPORTED # Supported
+ ) = (0, 1)

_NUM = 512

@@ -1591,9 +1588,14 @@ class Capabilities(IData):
else:
self._cap = bytearray(Capabilities._NUM)

+ def supported(self, capability):
+ if self.get(capability) == Capabilities.SUPPORTED:
+ return True
+ return False
+
def get(self, capability):
if capability > len(self._cap):
- return Capabilities.UNKNOWN
+ return Capabilities.UNSUPPORTED
return self._cap[capability]

def set(self, capability, value=SUPPORTED):
diff --git a/test/plugin_test.py b/test/plugin_test.py
index 0cdf99e..50c79a4 100755
--- a/test/plugin_test.py
+++ b/test/plugin_test.py
@@ -14,8 +14,6 @@
# 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 AT redhat DOT com

import lsm
import functools
@@ -90,7 +88,7 @@ class Duration(object):

def supported(cap, capability):
for c in capability:
- if cap.get(c) != lsm.Capabilities.SUPPORTED:
+ if not cap.supported(c):
return False
return True

diff --git a/test/tester.c b/test/tester.c
index 40ef059..4a20b88 100644
--- a/test/tester.c
+++ b/test/tester.c
@@ -1815,6 +1815,8 @@ static void cap_test( lsm_storage_capabilities *cap, lsm_capability_type t)
lsm_capability_value_type supported;
supported = lsm_capability_get(cap, t);

+ fail_unless ( lsm_capability_supported(cap, t) != 0,
+ "lsm_capability_supported returned unsupported");
fail_unless( supported == LSM_CAPABILITY_SUPPORTED,
"supported = %d for %d", supported, t);
}
--
1.8.2.1
Tony Asleson
2014-05-14 22:41:48 UTC
Permalink
na.py, un-used functions
- clear_all_clone_errors
- igroup_exists
- nfs_export_fs

ontap.py, un-used
- error_message
- import urllib2

Signed-off-by: Tony Asleson <***@redhat.com>
---
plugin/ontap/na.py | 50 --------------------------------------------------
plugin/ontap/ontap.py | 2 --
2 files changed, 52 deletions(-)

diff --git a/plugin/ontap/na.py b/plugin/ontap/na.py
index 174b33a..668ce30 100644
--- a/plugin/ontap/na.py
+++ b/plugin/ontap/na.py
@@ -401,18 +401,6 @@ class Filer(object):
vols = self.volumes()
return [v['name'] for v in vols]

- def clear_all_clone_errors(self):
- """
- Clears all the clone errors.
- """
- errors = self._invoke('clone-list-status')['status']
-
- if errors is not None:
- errors = to_list(errors['ops-info'])
- for e in errors:
- self._invoke('clone-clear', {'clone-id': e['clone-id']})
- return None
-
def clone(self, source_path, dest_path, backing_snapshot=None,
ranges=None):
"""
@@ -481,13 +469,6 @@ class Filer(object):
rc = to_list(g['initiator-groups']['initiator-group-info'])
return rc

- def igroup_exists(self, name):
- g = self.igroups()
- for ig in g:
- if ig['initiator-group-name'] == name:
- return True
- return False
-
def igroup_create(self, name, igroup_type):
params = {'initiator-group-name': name,
'initiator-group-type': igroup_type}
@@ -642,37 +623,6 @@ class Filer(object):
else:
return Filer._build_list(hosts, 'exports-hostname-info', 'name')

- def nfs_export_fs(self, volume_path, export_path, ro_list, rw_list,
- root_list, anonuid=None, sec_flavor=None):
- """
- Export a fs, deprecated (Will remove soon)
- """
- rule = {'pathname': volume_path}
- if volume_path != export_path:
- #Try creating the directory needed
- rule['actual-pathname'] = volume_path
- rule['pathname'] = export_path
-
- if len(ro_list):
- rule['read-only'] = Filer._build_export_fs_list(ro_list)
-
- if len(rw_list):
- rule['read-write'] = Filer._build_export_fs_list(rw_list)
-
- if len(root_list):
- rule['root'] = Filer._build_export_fs_list(root_list)
-
- if anonuid:
- rule['anon'] = anonuid
-
- if sec_flavor:
- rule['sec-flavor'] = Filer._build_list([sec_flavor],
- 'sec-flavor-info', 'flavor')
-
- params = {'persistent': 'true', 'rules': {'exports-rule-info': [rule]},
- 'verbose': 'true'}
- self._invoke('nfs-exportfs-append-rules', params)
-
def _build_export_rules(self, volume_path, export_path, ro_list, rw_list,
root_list, anonuid=None, sec_flavor=None):
"""
diff --git a/plugin/ontap/ontap.py b/plugin/ontap/ontap.py
index c59f6d9..b26d91d 100644
--- a/plugin/ontap/ontap.py
+++ b/plugin/ontap/ontap.py
@@ -18,7 +18,6 @@

import os
import traceback
-import urllib2
import urlparse
import sys

@@ -271,7 +270,6 @@ class Ontap(IStorageAreaNetwork, INfs):
return status_info

def _disk(self, d, flag):
- error_message = ""
opt_data = OptionalData()
status = Ontap._status_of_na_disk(d)
if flag == Disk.RETRIEVE_FULL_INFO:
--
1.8.2.1
Loading...