Martin Polednik has uploaded a new change for review.
Change subject: vdsm: expose hostdev via vdsClient
......................................................................
vdsm: expose hostdev via vdsClient
Exposes current API verb hostdevListByCaps by vdsClient,
using pretty tree graphical structure.
Change-Id: I1e4dd1a1ee9af0d1873a081c115289ad2e52204f
Signed-off-by: Martin Polednik <mpolednik(a)redhat.com>
---
M client/vdsClient.py
1 file changed, 31 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/16/32316/1
diff --git a/client/vdsClient.py b/client/vdsClient.py
index 35f4ca5..18776cb 100644
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -117,16 +117,33 @@
print "\t%s = %s" % (element, conf[element])
-def printDict(dict, pretty=True):
+def printDict(dict, pretty=True, depth=0):
keys = dict.keys()
keys.sort()
for element in keys:
if pretty:
representation = pp.pformat(dict[element]).replace(
- '\n', '\n\t' + ' ' * len(element + ' =
'))
+ '\n', '\n\t' + ' ' * len(element + ' = ')
+ '\t' * depth)
else:
representation = dict[element]
- print "\t%s = %s" % (element, representation)
+ print '\t' * depth + '\t%s = %s' % (element, representation)
+
+
+def printDevices(devices, pretty=True):
+ roots = [device for device in devices if
+ devices[device]['params'].get('parent', None) not in
devices]
+
+ _printChildDevices(devices, roots, pretty)
+
+
+def _printChildDevices(devices, roots, pretty=True, depth=1):
+ for root in roots:
+ printDict({root: devices[root]}, pretty, depth)
+
+ _printChildDevices(
+ devices, [device for device in devices if
+ devices[device]['params'].get('parent', None) ==
root],
+ pretty, depth + 1)
def printStats(list):
@@ -199,6 +216,8 @@
printStats(response['statsList'])
elif 'info' in response:
printDict(response['info'], self.pretty)
+ elif 'deviceList' in response:
+ printDevices(response['deviceList'], self.pretty)
else:
printDict(response['status'], self.pretty)
sys.exit(response['status']['code'])
@@ -520,6 +539,9 @@
def do_getAllVmStats(self, args):
return self.ExecAndExit(self.s.getAllVmStats())
+
+ def do_hostdevListByCaps(self, args):
+ return self.ExecAndExit(self.s.hostdevListByCaps(args))
def desktopLogin(self, args):
vmId, domain, user, password = tuple(args[:4])
@@ -2138,6 +2160,12 @@
('',
'Get Statistics info for all existing VMs'
)),
+ 'hostdevListByCaps': (serv.do_hostdevListByCaps,
+ ('[<caps>]',
+ 'Get available devices on host with given '
+ 'capability. Leave caps empty to list all '
+ 'devices.'
+ )),
'getVGList': (serv.getVGList,
('storageType',
'List of all VGs.'
--
To view, visit
http://gerrit.ovirt.org/32316
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1e4dd1a1ee9af0d1873a081c115289ad2e52204f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpolednik(a)redhat.com>