Hello Fred Rolland,
I'd like you to do a code review. Please visit
https://gerrit.ovirt.org/45093
to review the following change.
Change subject: hsm: Support testPvCreate param in getDeviceList
......................................................................
hsm: Support testPvCreate param in getDeviceList
Add optional 'testPvCreate' boolean parameter to getDeviceList.
By default it will be True to keep same behavior as before.
If specified as False, the PV create test will be skipped and the
'status' field will not be populated.
Examples:
getDeviceList
return all devices
getDeviceList FCP
return only FCP devices
getDeviceList FCP True
return only FCP devices and perform PV create test
getDeviceList ISCSI False guid1 guid2
return info for guid1 and guid2, assuming ISCSI type
without performing PV create test
Change-Id: Ic28954708f2fd7c7b721aa7f9a0fb6e1a6019597
Bug-Url:
https://bugzilla.redhat.com/1217401
Signed-off-by: Fred Rolland <frolland(a)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
5 files changed, 46 insertions(+), 27 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/93/45093/1
diff --git a/client/vdsClient.py b/client/vdsClient.py
index ce40974..c62321d 100755
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -732,8 +732,11 @@
def getDeviceList(self, args):
if len(args) == 0:
res = self.s.getDeviceList()
+ elif len(args) == 1:
+ res = self.s.getDeviceList(args[0])
else:
- res = self.s.getDeviceList(args[0], args[1:])
+ res = self.s.getDeviceList(args[0],
+ utils.tobool(args[1]), args[2:])
if res['status']['code']:
return res['status']['code'],
res['status']['message']
@@ -2277,16 +2280,22 @@
)),
'getDeviceList': (serv.getDeviceList,
('[storageType]',
+ '[testPvCreate]',
'[<devlist>]',
'List of all block devices (optionally - matching '
- 'storageType, optionally - of each device listed).',
+ 'storageType, optionally - perform PV create test '
+ 'optionally - of each device listed).',
' getDeviceList',
' return all devices',
' getDeviceList FCP',
' return only FCP devices',
- ' getDeviceList ISCSI guid1 guid2',
+ ' getDeviceList FCP True',
+ ' return only FCP devices and perform ',
+ ' PV creation test',
+ ' getDeviceList ISCSI False guid1 guid2',
' return info for guid1 and guid2',
- ' , assuming ISCSI type'
+ ' , assuming ISCSI type and skip PV ',
+ ' creation test'
)),
'getDevicesVisibility': (serv.getDevicesVisibility,
('<devlist>',
diff --git a/vdsm/API.py b/vdsm/API.py
index 66822a5..bbc3f03 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -1679,8 +1679,8 @@
def getLVMVolumeGroups(self, storageType=None):
return self._irs.getVGList(storageType)
- def getDeviceList(self, storageType=None, guids=()):
- return self._irs.getDeviceList(storageType, guids)
+ def getDeviceList(self, storageType=None, testPvCreate=True, guids=()):
+ return self._irs.getDeviceList(storageType, testPvCreate, guids)
def getDevicesVisibility(self, guidList):
return self._irs.getDevicesVisibility(guidList)
diff --git a/vdsm/rpc/bindingxmlrpc.py b/vdsm/rpc/bindingxmlrpc.py
index 7f1da4f..b23643b 100644
--- a/vdsm/rpc/bindingxmlrpc.py
+++ b/vdsm/rpc/bindingxmlrpc.py
@@ -1029,9 +1029,10 @@
api = API.Global()
return api.getLVMVolumeGroups(storageType)
- def devicesGetList(self, storageType=None, guids=(), options=None):
+ def devicesGetList(self, storageType=None, testPvCreate=True,
+ guids=(), options=None):
api = API.Global()
- res = api.getDeviceList(storageType, guids)
+ res = api.getDeviceList(storageType, testPvCreate, guids)
return unprotect_passwords(res)
def devicesGetVisibility(self, guids, options=None):
diff --git a/vdsm/rpc/vdsmapi-schema.json b/vdsm/rpc/vdsmapi-schema.json
index 4cac5ae..42b9c91 100644
--- a/vdsm/rpc/vdsmapi-schema.json
+++ b/vdsm/rpc/vdsmapi-schema.json
@@ -1477,6 +1477,9 @@
#
# @storageType: #optional Only return devices of this type
#
+# @testPvCreate: #optional Indicates if PV creation test should be performed
+# (new in version 4.17)
+#
# @guids: #optional Only return info on specific list of block device
# GUIDs (new in version 4.17)
#
@@ -1487,6 +1490,7 @@
##
{'command': {'class': 'Host', 'name':
'getDeviceList'},
'data': {'*storageType': 'BlockDeviceType',
+ '*testPvCreate': 'bool',
'*guids': ['str']},
'returns': ['BlockDeviceInfo']}
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 0806abb..b5e2b7f 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -1957,12 +1957,15 @@
masterVersion, leaseParams)
@public
- def getDeviceList(self, storageType=None, guids=(), options={}):
+ def getDeviceList(self, storageType=None, testPvCreate=True,
+ guids=(), options={}):
"""
List all Block Devices.
:param storageType: Filter by storage type.
:type storageType: Some enum?
+ :param testPvCreate: Test PV creation.
+ :type bool: if true PV creation will be tested for the given devices
:param guids: List of device GUIDs to retrieve info.
:type guids: list
:param options: ?
@@ -1972,10 +1975,11 @@
:rtype: dict
"""
vars.task.setDefaultException(se.BlockDeviceActionError())
- devices = self._getDeviceList(storageType=storageType, guids=guids)
+ devices = self._getDeviceList(storageType=storageType,
+ testPvCreate=testPvCreate, guids=guids)
return dict(devList=devices)
- def _getDeviceList(self, storageType=None, guids=()):
+ def _getDeviceList(self, storageType=None, testPvCreate=True, guids=()):
sdCache.refreshStorage()
typeFilter = lambda dev: True
if storageType:
@@ -2030,22 +2034,23 @@
'physicalblocksize':
dev.get("physicalblocksize", "")}
devices.append(devInfo)
- # Look for devices that will probably fail if pvcreated.
- devNamesToPVTest = tuple(dev["GUID"] for dev in devices)
- unusedDevs, usedDevs = lvm.testPVCreate(
- devNamesToPVTest, metadataSize=blockSD.VG_METADATASIZE)
- # Assuming that unusables v unusables = None
- free = tuple(os.path.basename(d) for d in unusedDevs)
- used = tuple(os.path.basename(d) for d in usedDevs)
- for dev in devices:
- guid = dev['GUID']
- if guid in free:
- dev['status'] = "free"
- elif guid in used:
- dev['status'] = "used"
- else:
- raise KeyError("pvcreate response foresight is "
- "can not be determined for %s", dev)
+ if testPvCreate:
+ # Look for devices that will probably fail if pvcreated.
+ devNamesToPVTest = tuple(dev["GUID"] for dev in devices)
+ unusedDevs, usedDevs = lvm.testPVCreate(
+ devNamesToPVTest, metadataSize=blockSD.VG_METADATASIZE)
+ # Assuming that unusables v unusables = None
+ free = tuple(os.path.basename(d) for d in unusedDevs)
+ used = tuple(os.path.basename(d) for d in usedDevs)
+ for dev in devices:
+ guid = dev['GUID']
+ if guid in free:
+ dev['status'] = "free"
+ elif guid in used:
+ dev['status'] = "used"
+ else:
+ raise KeyError("pvcreate response foresight is "
+ "can not be determined for %s", dev)
return devices
--
To view, visit
https://gerrit.ovirt.org/45093
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic28954708f2fd7c7b721aa7f9a0fb6e1a6019597
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Freddy Rolland <frolland(a)redhat.com>
Gerrit-Reviewer: Fred Rolland <frolland(a)redhat.com>