[NEW PATCH] Related to BZ#719516 vdsClient: Make list nicer. (via gerrit-bot)
David Naori
dnaori at redhat.com
Fri Jul 8 14:12:52 UTC 2011
New patch submitted by David Naori (dnaori at redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/676
commit 514f444578aebfe3174225cb331e82ae9b3728c2
Author: David Naori <dnaori at redhat.com>
Date: Thu Jul 7 16:21:15 2011 +0300
Related to BZ#719516 vdsClient: Make list nicer.
Change-Id: I0753685d3032e79cc3f5de888b8ee7e865954d9c
diff --git a/vdsm_cli/vdsClient.py b/vdsm_cli/vdsClient.py
index 38640cc..2a73785 100755
--- a/vdsm_cli/vdsClient.py
+++ b/vdsm_cli/vdsClient.py
@@ -173,34 +173,31 @@ class service:
return self.ExecAndExit(self.s.changeFloppy(vmId, file))
def do_list(self, args):
- table=False
- if len(args):
- if args[0] == 'table':
- table=True
+ table = {}
+ if args:
+ if args != ['table']:
+ raise ValueError
+ for s in self.s.getAllVmStats()['statsList']:
+ table[ s['vmId'] ] = s
+
response = self.s.list(True)
- if response['status']['code'] != 0:
- print response['status']['message']
- else:
+ for conf in response['vmList']:
if table:
- allStats = {}
- for s in self.s.getAllVmStats()['statsList']:
- allStats[s['vmId']] = s
- for conf in response['vmList']:
- if table:
- id = conf['vmId']
- if id not in allStats:
- continue
- status = conf['status']
- if allStats[id].get('monitorResponse') == '-1':
- status += '*'
- print "%-36s %6s %-20s %-20s %-20s" % (id,
- conf.get('pid', 'none'),
- conf.get('vmName', '<< NO NAME >>'),
- status, allStats[id].get('guestIPs', '') )
- else:
- if 'sysprepInf' in conf:
- conf['sysprepInf'] = '<<exists>>'
- printConf(conf)
+ vmId = conf['vmId']
+ if vmId not in table:
+ continue
+ status = conf['status']
+ if table[vmId].get('monitorResponse') == '-1':
+ status += '*'
+ print "%-36s %6s %-20s %-20s %-20s" % ( vmId,
+ conf.get('pid', 'none'),
+ conf.get('vmName', '<< NO NAME >>'),
+ status, table[vmId].get('guestIPs', '') )
+ else:
+ if 'sysprepInf' in conf:
+ conf['sysprepInf'] = '<<exists>>'
+ printConf(conf)
+
sys.exit(response['status']['code'])
def do_listNames(self, args):
More information about the vdsm-patches
mailing list