Change in vdsm[master]: hsm: Support GUID list param in GetDeviceList
frolland at redhat.com
frolland at redhat.com
Thu May 7 13:47:08 UTC 2015
Hello Fred Rolland,
I'd like you to do a code review. Please visit
https://gerrit.ovirt.org/40661
to review the following change.
Change subject: hsm: Support GUID list param in GetDeviceList
......................................................................
hsm: Support GUID list param in GetDeviceList
Add support for additional optional parameter of a list of GUIDs
to GetDeviceList.
Example of usage :
$ vdsClient -s 0 getDeviceList 3b4fa3ce90178,
360b20097ed8
Change-Id: Ic173d94a132e617ae97353d38520a86bede657d7
Bug-Url:https://bugzilla.redhat.com/609689
Signed-off-by: Fred Rolland <frolland at redhat.com>
---
M client/vdsClient.py
M vdsm/API.py
M vdsm/rpc/BindingXMLRPC.py
M vdsm/rpc/vdsmapi-schema.json
M vdsm/storage/hsm.py
M vdsm/storage/multipath.py
6 files changed, 40 insertions(+), 11 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/61/40661/1
diff --git a/client/vdsClient.py b/client/vdsClient.py
index 8a242c7..af21776 100755
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -31,6 +31,7 @@
import pprint as pp
from vdsm import utils, vdscli
+from storage import sd
try:
import vdsClientGluster as ge
_glusterEnabled = True
@@ -718,7 +719,29 @@
return 0, ''
def getDeviceList(self, args):
- devices = self.s.getDeviceList(*args)
+ storageType = sd.UNKNOWN_DOMAIN
+ devList = {}
+ if len(args) == 1:
+ try:
+ if sd.storageType(args[0]) == sd.type2name(sd.ISCSI_DOMAIN):
+ storageType = args[0]
+ elif sd.storageType(args[0]) == sd.type2name(sd.FCP_DOMAIN):
+ storageType = args[0]
+ except:
+ devList = args[0].split(',')
+
+ if len(args) == 2:
+ if sd.storageType(args[0]) == sd.type2name(sd.ISCSI_DOMAIN):
+ storageType = args[0]
+ elif sd.storageType(args[0]) == sd.type2name(sd.FCP_DOMAIN):
+ storageType = args[0]
+ else:
+ raise ValueError('Invalid argument "%s". Not a valid '
+ 'storage type' % args[0])
+ devList = args[1].split(',')
+
+ devices = self.s.getDeviceList(storageType, devList)
+
if devices['status']['code']:
return devices['status']['code'], devices['status']['message']
pp.pprint(devices['devList'])
@@ -2207,8 +2230,9 @@
)),
'getDeviceList': (serv.getDeviceList,
('[storageType]',
+ '[<devlist>]',
'List of all block devices (optionally - matching '
- 'storageType).'
+ 'storageType, optionally - of each device listed).'
)),
'getDevicesVisibility': (serv.getDevicesVisibility,
('<devlist>',
diff --git a/vdsm/API.py b/vdsm/API.py
index c66cf4c..8364cdb 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -1612,8 +1612,8 @@
def getLVMVolumeGroups(self, storageType=None):
return self._irs.getVGList(storageType)
- def getDeviceList(self, storageType=None):
- return self._irs.getDeviceList(storageType)
+ def getDeviceList(self, storageType=None, guidList=None):
+ return self._irs.getDeviceList(storageType, guidList)
def getDevicesVisibility(self, guidList):
return self._irs.getDevicesVisibility(guidList)
diff --git a/vdsm/rpc/BindingXMLRPC.py b/vdsm/rpc/BindingXMLRPC.py
index 62957bd..e8c8d7e 100644
--- a/vdsm/rpc/BindingXMLRPC.py
+++ b/vdsm/rpc/BindingXMLRPC.py
@@ -964,9 +964,9 @@
api = API.Global()
return api.getLVMVolumeGroups(storageType)
- def devicesGetList(self, storageType=None, options=None):
+ def devicesGetList(self, storageType=None, guids=None, options=None):
api = API.Global()
- return api.getDeviceList(storageType)
+ return api.getDeviceList(storageType, guids)
def devicesGetVisibility(self, guids, options=None):
api = API.Global()
diff --git a/vdsm/rpc/vdsmapi-schema.json b/vdsm/rpc/vdsmapi-schema.json
index 48ee624..4279b52 100644
--- a/vdsm/rpc/vdsmapi-schema.json
+++ b/vdsm/rpc/vdsmapi-schema.json
@@ -1473,13 +1473,16 @@
#
# @storageType: #optional Only return devices of this type
#
+# @guidList: #optional Only return info on specific list of block device GUIDs
+#
# Returns:
# An array of @BlockDeviceInfo
#
# Since: 4.10.0
##
{'command': {'class': 'Host', 'name': 'getDeviceList'},
- 'data': {'*storageType': 'BlockDeviceType'},
+ 'data': {'*storageType': 'BlockDeviceType',
+ '*guidList': ['UUID']},
'returns': ['BlockDeviceInfo']}
##
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 5201bb8..327f594 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -1998,12 +1998,14 @@
return logableDevs
@public(logger=logged(resPrinter=partial(_logResp_getDeviceList, None)))
- def getDeviceList(self, storageType=None, options={}):
+ def getDeviceList(self, storageType=None, guids=None, options={}):
"""
List all Block Devices.
:param storageType: Filter by storage type.
:type storageType: Some enum?
+ :param guids: List of device GUIDs to retrieve info.
+ :type guids: list
:param options: ?
:returns: Dict containing a list of all the devices of the storage
@@ -2011,7 +2013,7 @@
:rtype: dict
"""
vars.task.setDefaultException(se.BlockDeviceActionError())
- devices = self._getDeviceList(storageType)
+ devices = self._getDeviceList(storageType, guids)
return dict(devList=devices)
def _getDeviceList(self, storageType=None, guids=None):
@@ -2027,7 +2029,7 @@
devices = []
pvs = {}
- if guids is not None:
+ if guids is not None and len(guids) > 0:
for guid in guids:
try:
pv = lvm.getPV(guid)
diff --git a/vdsm/storage/multipath.py b/vdsm/storage/multipath.py
index 93540ea..d68da3b 100644
--- a/vdsm/storage/multipath.py
+++ b/vdsm/storage/multipath.py
@@ -189,7 +189,7 @@
def pathListIter(filterGuids=None):
- filteringOn = filterGuids is not None
+ filteringOn = filterGuids is not None and len(filterGuids) > 0
filterLen = len(filterGuids) if filteringOn else -1
devsFound = 0
--
To view, visit https://gerrit.ovirt.org/40661
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic173d94a132e617ae97353d38520a86bede657d7
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Freddy Rolland <frolland at redhat.com>
Gerrit-Reviewer: Fred Rolland <frolland at redhat.com>
More information about the vdsm-patches
mailing list