* Plugins update for search support of query methods.
* Some PEP8 clean up.
Signed-off-by: Gris Ge <***@redhat.com>
---
plugin/nstor/nstor.py | 30 ++++++++++----------
plugin/ontap/ontap.py | 44 +++++++++++++++++------------
plugin/sim/simulator.py | 50 +++++++++++++++++++++-----------
plugin/smispy/smis.py | 72 +++++++++++++++++++++++++----------------------
plugin/targetd/targetd.py | 22 +++++++--------
plugin/v7k/ibmv7k.py | 15 ++++++----
6 files changed, 134 insertions(+), 99 deletions(-)
diff --git a/plugin/nstor/nstor.py b/plugin/nstor/nstor.py
index c661090..06529c6 100644
--- a/plugin/nstor/nstor.py
+++ b/plugin/nstor/nstor.py
@@ -30,7 +30,7 @@ import time
from lsm import (AccessGroup, Capabilities, ErrorNumber, FileSystem, INfs,
IStorageAreaNetwork, Initiator, LsmError, NfsExport, Pool,
FsSnapshot, System, VERSION, Volume, md5,
- common_urllib2_error_handler)
+ common_urllib2_error_handler, search_property)
class NexentaStor(INfs, IStorageAreaNetwork):
@@ -104,7 +104,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
float(size[:-1]) * 1024 * 1024 * 1024 * 1024 * 1024 * 1024)
return size
- def pools(self, flags=0):
+ def pools(self, search_key=None, search_value=None, flags=0):
pools_list = self._request("get_all_names", "volume", [""])
pools = []
@@ -120,9 +120,9 @@ class NexentaStor(INfs, IStorageAreaNetwork):
Pool.STATUS_UNKNOWN, '',
self.system.id))
- return pools
+ return search_property(pools, search_key, search_value)
- def fs(self, flags=0):
+ def fs(self, search_key=None, search_value=None, flags=0):
fs_list = self._request("get_all_names", "folder", [""])
fss = []
@@ -143,7 +143,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
pool_name,
fs))
- return fss
+ return search_property(fss, search_key, search_value)
def fs_create(self, pool, name, size_bytes, flags=0):
"""
@@ -171,7 +171,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
snapshot_info = self._request("get_child_props", "snapshot",
[snapshot, "creation_seconds"])
snapshots.append(FsSnapshot(snapshot, snapshot,
- snapshot_info['creation_seconds']))
+ snapshot_info['creation_seconds']))
return snapshots
@@ -182,7 +182,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
snapshot_info = self._request("get_child_props", "snapshot",
[full_name, "creation_seconds"])
return None, FsSnapshot(full_name, full_name,
- snapshot_info['creation_seconds'])
+ snapshot_info['creation_seconds'])
def fs_snapshot_delete(self, fs, snapshot, flags=0):
self._request("destroy", "snapshot", [snapshot.name, ""])
@@ -302,11 +302,11 @@ class NexentaStor(INfs, IStorageAreaNetwork):
return None, fs
def fs_file_clone(self, fs, src_file_name, dest_file_name, snapshot=None,
- flags=0):
+ flags=0):
return
def fs_snapshot_restore(self, fs, snapshot, files, restore_files,
- all_files=False, flags=0):
+ all_files=False, flags=0):
self._request("rollback", "snapshot", [snapshot.name, '-r'])
return
@@ -350,7 +350,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
rc.append(m.split('=>')[0])
return rc
- def exports(self, flags=0):
+ def exports(self, search_key=None, search_value=None, flags=0):
"""
Get a list of all exported file systems on the controller.
"""
@@ -368,7 +368,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
'N/A', 'N/A',
opts['extra_options']))
- return exports
+ return search_property(exports, search_key, search_value)
def export_fs(self, fs_id, export_path, root_list, rw_list, ro_list,
anon_uid, anon_gid, auth_type, options, flags=0):
@@ -417,7 +417,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
def _calc_group(name):
return 'lsm_' + md5(name)[0:8]
- def volumes(self, flags=0):
+ def volumes(self, search_key=None, search_value=None, flags=0):
"""
Returns an array of volume objects
@@ -464,7 +464,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
'N/A',
NexentaStor._get_pool_id(lu)))
- return vol_list
+ return search_property(vol_list, search_key, search_value)
def initiators(self, flags=0):
"""
@@ -693,7 +693,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
[volume.name, view_number])
return
- def access_group(self, flags=0):
+ def access_groups(self, search_key=None, search_value=None, flags=0):
"""
Returns a list of access groups
"""
@@ -705,7 +705,7 @@ class NexentaStor(INfs, IStorageAreaNetwork):
[hg])
ag_list.append(AccessGroup(hg, hg, initiators, self.system.id))
- return ag_list
+ return search_property(ag_list, search_key, search_value)
def access_group_create(self, name, initiator_id, id_type, system_id,
flags=0):
diff --git a/plugin/ontap/ontap.py b/plugin/ontap/ontap.py
index 5e9aa12..9ddb39d 100644
--- a/plugin/ontap/ontap.py
+++ b/plugin/ontap/ontap.py
@@ -15,6 +15,7 @@
# USA
#
# Author: tasleson
+# Gris Ge <***@redhat.com>
import os
import traceback
@@ -25,7 +26,8 @@ import na
from lsm import (Volume, Initiator, FileSystem, FsSnapshot, NfsExport,
AccessGroup, System, Capabilities, Disk, Pool, OptionalData,
IStorageAreaNetwork, INfs, LsmError, ErrorNumber, JobStatus,
- md5, Error, VERSION, common_urllib2_error_handler)
+ md5, Error, VERSION, common_urllib2_error_handler,
+ search_property)
#Maps na to lsm, this is expected to expand over time.
e_map = {
@@ -202,7 +204,7 @@ class Ontap(IStorageAreaNetwork, INfs):
#If we use the newer API we can use the uuid instead of this fake
#md5 one
return FsSnapshot(md5(s['name'] + s['access-time']), s['name'],
- s['access-time'])
+ s['access-time'])
@staticmethod
def _disk_type(netapp_disk_type):
@@ -287,9 +289,10 @@ class Ontap(IStorageAreaNetwork, INfs):
self.sys_info.id, opt_data)
@handle_ontap_errors
- def volumes(self, flags=0):
+ def volumes(self, search_key=None, search_value=None, flags=0):
luns = self.f.luns_get_all()
- return [self._lun(l) for l in luns]
+ return search_property(
+ [self._lun(l) for l in luns], search_key, search_value)
@staticmethod
def _pool_id(na_xxx):
@@ -471,12 +474,13 @@ class Ontap(IStorageAreaNetwork, INfs):
return "NetApp Filer support", VERSION
@handle_ontap_errors
- def disks(self, flags=0):
+ def disks(self, search_key=None, search_value=None, flags=0):
disks = self.f.disks()
- return [self._disk(d, flags) for d in disks]
+ return search_property(
+ [self._disk(d, flags) for d in disks], search_key, search_value)
@handle_ontap_errors
- def pools(self, flags=0):
+ def pools(self, search_key=None, search_value=None, flags=0):
pools = []
na_aggrs = self.f.aggregates()
na_disks = []
@@ -489,7 +493,7 @@ class Ontap(IStorageAreaNetwork, INfs):
na_vols = self.f.volumes()
for na_vol in na_vols:
pools.extend([self._pool_from_na_vol(na_vol, na_aggrs, flags)])
- return pools
+ return search_property(pools, search_key, search_value)
@handle_ontap_errors
def systems(self, flags=0):
@@ -742,9 +746,10 @@ class Ontap(IStorageAreaNetwork, INfs):
self.sys_info.id)
@handle_ontap_errors
- def access_groups(self, flags=0):
+ def access_groups(self, search_key=None, search_value=None, flags=0):
groups = self.f.igroups()
- return [self._access_group(g) for g in groups]
+ return search_property(
+ [self._access_group(g) for g in groups], search_key, search_value)
@handle_ontap_errors
def access_group_create(self, name, initiator_id, id_type, system_id,
@@ -863,10 +868,11 @@ class Ontap(IStorageAreaNetwork, INfs):
return None
@handle_ontap_errors
- def fs(self, flags=0):
+ def fs(self, search_key=None, search_value=None, flags=0):
volumes = self.f.volumes()
pools = self.pools()
- return [self._vol(v, pools) for v in volumes]
+ return search_property(
+ [self._vol(v, pools) for v in volumes], search_key, search_value)
@handle_ontap_errors
def fs_delete(self, fs, flags=0):
@@ -896,7 +902,7 @@ class Ontap(IStorageAreaNetwork, INfs):
@handle_ontap_errors
def fs_file_clone(self, fs, src_file_name, dest_file_name, snapshot=None,
- flags=0):
+ flags=0):
full_src = Ontap.build_name(fs.name, src_file_name)
full_dest = Ontap.build_name(fs.name, dest_file_name)
@@ -923,7 +929,7 @@ class Ontap(IStorageAreaNetwork, INfs):
self.f.snapshot_delete(fs.name, snapshot.name)
def _ss_restore_files(self, volume_name, snapshot_name, files,
- restore_files):
+ restore_files):
for i in range(len(files)):
src = Ontap.build_name(volume_name, files[i])
dest = None
@@ -933,7 +939,7 @@ class Ontap(IStorageAreaNetwork, INfs):
@handle_ontap_errors
def fs_snapshot_restore(self, fs, snapshot, files, restore_files,
- all_files=False, flags=0):
+ all_files=False, flags=0):
"""
Restores a FS or files on a FS.
Note: Restoring an individual file is a O(n) operation, i.e. time it
@@ -949,7 +955,7 @@ class Ontap(IStorageAreaNetwork, INfs):
"num files != num restore_files")
self._ss_restore_files(fs.name, snapshot.name, files,
- restore_files)
+ restore_files)
return "%s@%d" % (Ontap.SS_JOB, len(files))
else:
raise LsmError(ErrorNumber.INVALID_ARGUMENT,
@@ -1019,11 +1025,13 @@ class Ontap(IStorageAreaNetwork, INfs):
None)
@handle_ontap_errors
- def exports(self, flags=0):
+ def exports(self, search_key=None, search_value=None, flags=0):
#Get the file systems once and pass to _export which needs to lookup
#the file system id by name.
v = self.fs()
- return [Ontap._export(v, e) for e in self.f.nfs_exports()]
+ return search_property(
+ [Ontap._export(v, e) for e in self.f.nfs_exports()],
+ search_key, search_value)
def _get_volume_from_id(self, fs_id):
fs = self.fs()
diff --git a/plugin/sim/simulator.py b/plugin/sim/simulator.py
index 22ddfe3..d8a80bc 100644
--- a/plugin/sim/simulator.py
+++ b/plugin/sim/simulator.py
@@ -16,11 +16,10 @@
# Author: tasleson
from lsm import (uri_parse, VERSION, Capabilities, Pool, INfs,
- IStorageAreaNetwork, Error)
+ IStorageAreaNetwork, Error, search_property)
from simarray import SimArray
-
class SimPlugin(INfs, IStorageAreaNetwork):
"""
Simple class that implements enough to allow the framework to be exercised.
@@ -76,6 +75,13 @@ class SimPlugin(INfs, IStorageAreaNetwork):
def capabilities(self, system, flags=0):
rc = Capabilities()
rc.enable_all()
+ rc.set(Capabilities.POOLS_QUICK_SEARCH, Capabilities.UNSUPPORTED)
+ rc.set(Capabilities.VOLUMES_QUICK_SEARCH, Capabilities.UNSUPPORTED)
+ rc.set(Capabilities.DISKS_QUICK_SEARCH, Capabilities.UNSUPPORTED)
+ rc.set(Capabilities.FS_QUICK_SEARCH, Capabilities.UNSUPPORTED)
+ rc.set(Capabilities.ACCESS_GROUPS_QUICK_SEARCH,
+ Capabilities.UNSUPPORTED)
+ rc.set(Capabilities.NFS_EXPORTS_QUICK_SEARCH, Capabilities.UNSUPPORTED)
return rc
def plugin_info(self, flags=0):
@@ -85,9 +91,11 @@ class SimPlugin(INfs, IStorageAreaNetwork):
sim_syss = self.sim_array.systems()
return [SimPlugin._sim_data_2_lsm(s) for s in sim_syss]
- def pools(self, flags=0):
+ def pools(self, search_key=None, search_value=None, flags=0):
sim_pools = self.sim_array.pools(flags)
- return [SimPlugin._sim_data_2_lsm(p) for p in sim_pools]
+ return search_property(
+ [SimPlugin._sim_data_2_lsm(p) for p in sim_pools],
+ search_key, search_value)
def pool_create(self, system, pool_name, size_bytes,
raid_type=Pool.RAID_TYPE_UNKNOWN,
@@ -115,13 +123,17 @@ class SimPlugin(INfs, IStorageAreaNetwork):
def pool_delete(self, pool, flags=0):
return self.sim_array.pool_delete(pool.id, flags)
- def volumes(self, flags=0):
+ def volumes(self, search_key=None, search_value=None, flags=0):
sim_vols = self.sim_array.volumes()
- return [SimPlugin._sim_data_2_lsm(v) for v in sim_vols]
+ return search_property(
+ [SimPlugin._sim_data_2_lsm(v) for v in sim_vols],
+ search_key, search_value)
- def disks(self, flags=0):
+ def disks(self, search_key=None, search_value=None, flags=0):
sim_disks = self.sim_array.disks()
- return [SimPlugin._sim_data_2_lsm(d) for d in sim_disks]
+ return search_property(
+ [SimPlugin._sim_data_2_lsm(d) for d in sim_disks],
+ search_key, search_value)
def volume_create(self, pool, volume_name, size_bytes, provisioning,
flags=0):
@@ -162,9 +174,11 @@ class SimPlugin(INfs, IStorageAreaNetwork):
def volume_offline(self, volume, flags=0):
return self.sim_array.volume_online(volume.id, flags)
- def access_groups(self, flags=0):
+ def access_groups(self, search_key=None, search_value=None, flags=0):
sim_ags = self.sim_array.ags()
- return [SimPlugin._sim_data_2_lsm(a) for a in sim_ags]
+ return search_property(
+ [SimPlugin._sim_data_2_lsm(a) for a in sim_ags],
+ search_key, search_value)
def access_group_create(self, name, initiator_id, id_type, system_id,
flags=0):
@@ -235,9 +249,11 @@ class SimPlugin(INfs, IStorageAreaNetwork):
def volume_child_dependency_rm(self, volume, flags=0):
return self.sim_array.volume_child_dependency_rm(volume.id, flags)
- def fs(self, flags=0):
+ def fs(self, search_key=None, search_value=None, flags=0):
sim_fss = self.sim_array.fs()
- return [SimPlugin._sim_data_2_lsm(f) for f in sim_fss]
+ return search_property(
+ [SimPlugin._sim_data_2_lsm(f) for f in sim_fss],
+ search_key, search_value)
def fs_create(self, pool, name, size_bytes, flags=0):
sim_fs = self.sim_array.fs_create(pool.id, name, size_bytes)
@@ -259,7 +275,7 @@ class SimPlugin(INfs, IStorageAreaNetwork):
src_fs.id, dest_fs_name, snapshot.id, flags)
def fs_file_clone(self, fs, src_file_name, dest_file_name, snapshot=None,
- flags=0):
+ flags=0):
if snapshot is None:
return self.sim_array.fs_file_clone(
fs.id, src_file_name, dest_file_name, None, flags)
@@ -280,7 +296,7 @@ class SimPlugin(INfs, IStorageAreaNetwork):
fs.id, snapshot.id, flags)
def fs_snapshot_restore(self, fs, snapshot, files, restore_files,
- all_files=False, flags=0):
+ all_files=False, flags=0):
return self.sim_array.fs_snapshot_restore(
fs.id, snapshot.id, files, restore_files, all_files, flags)
@@ -294,9 +310,11 @@ class SimPlugin(INfs, IStorageAreaNetwork):
# The API should change some day
return ["simple"]
- def exports(self, flags=0):
+ def exports(self, search_key=None, search_value=None, flags=0):
sim_exps = self.sim_array.exports(flags)
- return [SimPlugin._sim_data_2_lsm(e) for e in sim_exps]
+ return search_property(
+ [SimPlugin._sim_data_2_lsm(e) for e in sim_exps],
+ search_key, search_value)
def export_fs(self, fs_id, export_path, root_list, rw_list, ro_list,
anon_uid, anon_gid, auth_type, options, flags=0):
diff --git a/plugin/smispy/smis.py b/plugin/smispy/smis.py
index 8bcf6b3..44d2018 100644
--- a/plugin/smispy/smis.py
+++ b/plugin/smispy/smis.py
@@ -26,7 +26,8 @@ from pywbem import CIMError
from lsm import (IStorageAreaNetwork, Error, uri_parse, LsmError, ErrorNumber,
JobStatus, md5, Pool, Initiator, Volume, AccessGroup, System,
- Capabilities, Disk, OptionalData, txt_a, VERSION)
+ Capabilities, Disk, OptionalData, txt_a, VERSION,
+ search_property)
## Variable Naming scheme:
# cim_xxx CIMInstance
@@ -79,13 +80,14 @@ def handle_cim_errors(method):
traceback.format_exc())
return cim_wrapper
+
def _spec_ver_str_to_num(spec_ver_str):
"""
Convert version string stored in CIM_RegisteredProfile to a integer.
Example:
"1.5.1" -> 1,005,001
"""
- tmp_list = [0,0,0]
+ tmp_list = [0, 0, 0]
tmp_list = spec_ver_str.split(".")
if len(tmp_list) == 2:
tmp_list.extend([0])
@@ -95,14 +97,15 @@ def _spec_ver_str_to_num(spec_ver_str):
int(tmp_list[2]))
return None
+
class SNIA(object):
BLK_ROOT_PROFILE = 'Array'
BLK_SRVS_PROFILE = 'Block Services'
DISK_LITE_PROFILE = 'Disk Drive Lite'
MULTI_SYS_PROFILE = 'Multiple Computer System'
- SMIS_SPEC_VER_1_4 ='1.4'
- SMIS_SPEC_VER_1_5 ='1.5'
- SMIS_SPEC_VER_1_6 ='1.6'
+ SMIS_SPEC_VER_1_4 = '1.4'
+ SMIS_SPEC_VER_1_5 = '1.5'
+ SMIS_SPEC_VER_1_6 = '1.6'
REG_ORG_CODE = pywbem.Uint16(11)
@@ -577,13 +580,13 @@ class Smis(IStorageAreaNetwork):
if 'force_fallback_mode' in u['parameters'] and \
u['parameters']['force_fallback_mode'] == 'yes':
- return
+ return
# Checking profile registration support status unless
# force_fallback_mode is enabled in URI.
namespace_check_list = Smis.DMTF_INTEROP_NAMESPACES
if 'namespace' in u['parameters'] and \
- u['parameters']['namespace'] not in namespace_check_list:
+ u['parameters']['namespace'] not in namespace_check_list:
namespace_check_list.extend([u['parameters']['namespace']])
for interop_namespace in Smis.DMTF_INTEROP_NAMESPACES:
@@ -707,7 +710,7 @@ class Smis(IStorageAreaNetwork):
cap.set(Capabilities.VOLUME_REPLICATE_CLONE)
if self.RepSvc.RepTypes.SYNC_CLONE_LOCAL in s_rt or \
- self.RepSvc.RepTypes.ASYNC_CLONE_LOCAL in s_rt:
+ self.RepSvc.RepTypes.ASYNC_CLONE_LOCAL in s_rt:
cap.set(Capabilities.VOLUME_REPLICATE_COPY)
else:
# Try older storage configuration service
@@ -728,14 +731,14 @@ class Smis(IStorageAreaNetwork):
if len(sct):
cap.set(Capabilities.VOLUME_REPLICATE)
- # Mirror support is not working and is not supported at
- # this time.
+ # Mirror support is not working and is not supported at
+ # this time.
- # if Smis.CopyTypes.ASYNC in sct:
- # cap.set(Capabilities.VOLUME_REPLICATE_MIRROR_ASYNC)
+ # if Smis.CopyTypes.ASYNC in sct:
+ # cap.set(Capabilities.VOLUME_REPLICATE_MIRROR_ASYNC)
- # if Smis.CopyTypes.SYNC in sct:
- # cap.set(Capabilities.VOLUME_REPLICATE_MIRROR_SYNC)
+ # if Smis.CopyTypes.SYNC in sct:
+ # cap.set(Capabilities.VOLUME_REPLICATE_MIRROR_SYNC)
if Smis.CopyTypes.UNSYNCASSOC in sct:
cap.set(Capabilities.VOLUME_REPLICATE_CLONE)
@@ -1285,7 +1288,7 @@ class Smis(IStorageAreaNetwork):
return self._new_pool(cim_pools[0])
@handle_cim_errors
- def volumes(self, flags=0):
+ def volumes(self, search_key=None, search_value=None, flags=0):
"""
Return all volumes.
We are basing on "Block Services Package" profile version 1.4 or
@@ -1328,7 +1331,7 @@ class Smis(IStorageAreaNetwork):
else:
vol = self._new_vol(cim_vol, pool_id, sys_id)
rc.extend([vol])
- return rc
+ return search_property(rc, search_key, search_value)
def _systems(self, system_name=None):
"""
@@ -1413,7 +1416,7 @@ class Smis(IStorageAreaNetwork):
return pool_pros
@handle_cim_errors
- def pools(self, flags=0):
+ def pools(self, search_key=None, search_value=None, flags=0):
"""
We are basing on "Block Services Package" profile version 1.4 or
later:
@@ -1474,7 +1477,7 @@ class Smis(IStorageAreaNetwork):
raise LsmError(ErrorNumber.INTERNAL_ERROR,
"Failed to retrieve pool information " +
"from CIM_StoragePool: %s" % cim_pool.path)
- return rc
+ return search_property(rc, search_key, search_value)
def _sys_id_of_cim_pool(self, cim_pool):
"""
@@ -1526,9 +1529,10 @@ class Smis(IStorageAreaNetwork):
status |= System.STATUS_OK
elif os == Smis.SystemOperationalStatus.DEGRADED:
status |= System.STATUS_DEGRADED
- elif os == Smis.SystemOperationalStatus.ERROR or \
- os == Smis.SystemOperationalStatus.STRESSED or \
- os == Smis.SystemOperationalStatus.NON_RECOVERABLE_ERROR:
+ elif (os == Smis.SystemOperationalStatus.ERROR or
+ os == Smis.SystemOperationalStatus.STRESSED or
+ os ==
+ Smis.SystemOperationalStatus.NON_RECOVERABLE_ERROR):
status |= System.STATUS_ERROR
elif os == Smis.SystemOperationalStatus.PREDICTIVE_FAILURE:
status |= System.STATUS_PREDICTIVE_FAILURE
@@ -2141,10 +2145,12 @@ class Smis(IStorageAreaNetwork):
'Error: access group %s does not exist!' % volume.id)
@handle_cim_errors
- def access_groups(self, flags=0):
+ def access_groups(self, search_key=None, search_value=None, flags=0):
cim_spc_pros = self._new_access_group_cim_spc_pros()
cim_spcs = self._get_access_groups(property_list=cim_spc_pros)
- return [self._new_access_group(cim_spc) for cim_spc in cim_spcs]
+ return search_property(
+ [self._new_access_group(cim_spc) for cim_spc in cim_spcs],
+ search_key, search_value)
def _initiator_lookup(self, initiator_id):
"""
@@ -2194,7 +2200,6 @@ class Smis(IStorageAreaNetwork):
*(self._c.InvokeMethod('HidePaths', ccs.path,
**hide_params)))[0]
-
@handle_cim_errors
def job_free(self, job_id, flags=0):
"""
@@ -2210,7 +2215,7 @@ class Smis(IStorageAreaNetwork):
pass
@handle_cim_errors
- def disks(self, flags=0):
+ def disks(self, search_key=None, search_value=None, flags=0):
"""
return all object of data.Disk.
We are using "Disk Drive Lite Subprofile" v1.4 of SNIA SMI-S for these
@@ -2255,7 +2260,7 @@ class Smis(IStorageAreaNetwork):
cim_ext_pros)
rc.extend([self._new_disk(cim_disk, cim_ext, flags)])
- return rc
+ return search_property(rc, search_key, search_value)
@staticmethod
def _new_disk_cim_disk_pros(flag=0):
@@ -2922,8 +2927,8 @@ class Smis(IStorageAreaNetwork):
cim_sys_pros = self._property_list_of_id("System")
if not self.fallback_mode and \
self._profile_is_supported(SNIA.BLK_SRVS_PROFILE,
- SNIA.SMIS_SPEC_VER_1_4,
- strict=False) is None:
+ SNIA.SMIS_SPEC_VER_1_4,
+ strict=False) is None:
raise LsmError(ErrorNumber.NO_SUPPORT,
"SMI-S %s version %s is not supported" %
(SNIA.BLK_SRVS_PROFILE,
@@ -2953,8 +2958,8 @@ class Smis(IStorageAreaNetwork):
"""
if not self.fallback_mode and \
self._profile_is_supported(SNIA.BLK_SRVS_PROFILE,
- SNIA.SMIS_SPEC_VER_1_4,
- strict=False) is None:
+ SNIA.SMIS_SPEC_VER_1_4,
+ strict=False) is None:
raise LsmError(ErrorNumber.NO_SUPPORT,
"SMI-S %s version %s is not supported" %
(SNIA.BLK_SRVS_PROFILE,
@@ -3085,8 +3090,8 @@ class Smis(IStorageAreaNetwork):
possible_element_names = []
if raid_type == Pool.RAID_TYPE_JBOD:
possible_element_names = ['JBOD']
- elif raid_type == Pool.RAID_TYPE_RAID0 or \
- raid_type == Pool.RAID_TYPE_NOT_APPLICABLE:
+ elif (raid_type == Pool.RAID_TYPE_RAID0 or
+ raid_type == Pool.RAID_TYPE_NOT_APPLICABLE):
possible_element_names = ['RAID0']
elif raid_type == Pool.RAID_TYPE_RAID1:
possible_element_names = ['RAID1']
@@ -3376,7 +3381,7 @@ class Smis(IStorageAreaNetwork):
# we enumerate CIM_ComputerSystem.
try:
cim_scss_path = self._c.EnumerateInstanceNames(
- 'CIM_StorageConfigurationService')
+ 'CIM_StorageConfigurationService')
except CIMError as e:
# If array does not support CIM_StorageConfigurationService
# we use CIM_ComputerSystem which is mandatory.
@@ -3433,7 +3438,6 @@ class Smis(IStorageAreaNetwork):
else:
return cim_syss
-
def _cim_sys_of_id(self, system_id, property_list=None):
"""
Return a CIMInstance of CIM_ComputerSystem for given system id.
diff --git a/plugin/targetd/targetd.py b/plugin/targetd/targetd.py
index 0f82349..b4f4396 100644
--- a/plugin/targetd/targetd.py
+++ b/plugin/targetd/targetd.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
-# Copyright (C) 2011-2013 Red Hat, Inc.
+# Copyright (C) 2011-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
@@ -16,14 +16,14 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# Author: Andy Grover <agrover at redhat com>
+# Gris Ge <***@redhat.com>
import copy
from lsm import (Pool, Volume, System, Capabilities, Initiator,
IStorageAreaNetwork, INfs, FileSystem, FsSnapshot, NfsExport,
LsmError, ErrorNumber, uri_parse, md5, VERSION,
- common_urllib2_error_handler)
-
+ common_urllib2_error_handler, search_property)
import urllib2
import json
@@ -144,7 +144,7 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported")
@handle_errors
- def volumes(self, flags=0):
+ def volumes(self, search_key=None, search_value=None, flags=0):
volumes = []
for p_name in (p['name'] for p in self._jsonrequest("pool_list") if
p['type'] == 'block'):
@@ -154,16 +154,16 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
512, vol['size'] / 512,
Volume.STATUS_OK,
self.system.id, p_name))
- return volumes
+ return search_property(volumes, search_key, search_value)
@handle_errors
- def pools(self, flags=0):
+ def pools(self, search_key=None, search_value=None, flags=0):
pools = []
for pool in self._jsonrequest("pool_list"):
pools.append(Pool(pool['name'], pool['name'], pool['size'],
pool['free_size'], Pool.STATUS_UNKNOWN, '',
'targetd'))
- return pools
+ return search_property(pools, search_key, search_value)
@handle_errors
def initiators(self, flags=0):
@@ -307,14 +307,14 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
return inits
@handle_errors
- def fs(self, flags=0):
+ def fs(self, search_key=None, search_value=None, flags=0):
rc = []
for fs in self._jsonrequest("fs_list"):
#self, id, name, total_space, free_space, pool_id, system_id
rc.append(FileSystem(fs['uuid'], fs['name'], fs['total_space'],
fs['free_space'], fs['pool'],
self.system.id))
- return rc
+ return search_property(rc, search_key, search_value)
@handle_errors
def fs_delete(self, fs, flags=0):
@@ -397,7 +397,7 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
return md5(export_path + opts)
@handle_errors
- def exports(self, flags=0):
+ def exports(self, search_key=None, search_value=None, flags=0):
tmp_exports = {}
exports = []
fs_full_paths = {}
@@ -470,7 +470,7 @@ class TargetdStorage(IStorageAreaNetwork, INfs):
export['path'], sec, root, rw, ro, anonuid,
anongid, TargetdStorage._option_string(options)))
- return exports
+ return search_property(exports, search_key, search_value)
def _get_fs_path(self, fs_id):
for fs in self._jsonrequest("fs_list"):
diff --git a/plugin/v7k/ibmv7k.py b/plugin/v7k/ibmv7k.py
index f7ef393..077503b 100644
--- a/plugin/v7k/ibmv7k.py
+++ b/plugin/v7k/ibmv7k.py
@@ -18,7 +18,8 @@
import paramiko
from lsm import (Capabilities, ErrorNumber, IStorageAreaNetwork, Initiator,
- LsmError, Pool, System, VERSION, Volume, uri_parse)
+ LsmError, Pool, System, VERSION, Volume, uri_parse,
+ search_property)
def handle_ssh_errors(method):
@@ -423,16 +424,20 @@ class IbmV7k(IStorageAreaNetwork):
def plugin_info(self, flags=0):
return "IBM V7000 lsm plugin", VERSION
- def pools(self, flags=0):
+ def pools(self, search_key=None, search_value=None, flags=0):
gp = self._get_pools()
- return [self._pool(p) for p in gp.itervalues()]
+ return search_property(
+ [self._pool(p) for p in gp.itervalues()],
+ search_key, search_value)
def systems(self, flags=0):
return [self.sys_info]
- def volumes(self, flags=0):
+ def volumes(self, search_key=None, search_value=None, flags=0):
gv = self._get_volumes()
- return [self._volume(v) for v in gv.itervalues()]
+ return search_property(
+ [self._volume(v) for v in gv.itervalues()],
+ search_key, search_value)
def initiators(self, flags=0):
init_list = []
--
1.8.3.1