Francesco Romani has uploaded a new change for review.
Change subject: client: add option to make quiet
......................................................................
client: add option to make quiet
When used for (quite brutal) benchmarking, the output
from vdsClient can add noise and can cause a (little)
slowdown.
Add an option to make it quiet.
Change-Id: Icbb9654b47fd993aee34b2292a1d94d1e4019b6a
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M client/vdsClient.py
1 file changed, 25 insertions(+), 12 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/40/35340/1
diff --git a/client/vdsClient.py b/client/vdsClient.py
index 583a0a2..d675228 100644
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -183,11 +183,12 @@
self.useSSL = False
self.truststore = None
self.pretty = True
+ self.quiet = False
def do_connect(self, hostPort):
self.s = vdscli.connect(hostPort, self.useSSL, self.truststore)
- def ExecAndExit(self, response, parameterName='none'):
+ def printResponse(self, response, parameterName='none'):
if response['status']['code'] != 0:
print response['status']['message']
else:
@@ -202,6 +203,10 @@
printDict(response['info'], self.pretty)
else:
printDict(response['status'], self.pretty)
+
+ def ExecAndExit(self, response, parameterName='none'):
+ if not self.quiet:
+ self.printResponse(response, parameterName)
sys.exit(response['status']['code'])
def do_create(self, args):
@@ -309,7 +314,8 @@
if view == 'long':
if 'sysprepInf' in conf:
conf['sysprepInf'] = '<<exists>>'
- printConf(conf)
+ if not self.quiet:
+ printConf(conf)
elif view == 'table':
vmId = conf['vmId']
@@ -318,20 +324,23 @@
status = conf['status']
if allStats[vmId].get('monitorResponse') == '-1':
status += '*'
- print("%-36s %6s %-20s %-20s %-20s" %
- (vmId, conf.get('pid', 'none'),
- conf.get('vmName', '<< NO NAME >>'),
- status, allStats[vmId].get('guestIPs', '')))
+ if not self.quiet:
+ print("%-36s %6s %-20s %-20s %-20s" %
+ (vmId, conf.get('pid', 'none'),
+ conf.get('vmName', '<< NO NAME
>>'),
+ status, allStats[vmId].get('guestIPs', '')))
elif view == 'ids':
- print conf['vmId']
+ if not self.quiet:
+ print conf['vmId']
sys.exit(response['status']['code'])
def do_destroy(self, args):
vmId = args[0]
response = self.s.destroy(vmId)
- print response['status']['message']
+ if not self.quiet:
+ print response['status']['message']
sys.exit(response['status']['code'])
def do_pause(self, args):
@@ -356,7 +365,8 @@
response = self.s.shutdown(vmId, delay, message, reboot)
else:
response = self.s.shutdown(vmId, delay, message)
- print response['status']['message']
+ if not self.quiet:
+ print response['status']['message']
sys.exit(response['status']['code'])
def do_setVmTicket(self, args):
@@ -2765,9 +2775,10 @@
commands.update(ge.getGlusterCmdDict(serv))
try:
- opts, args = getopt.getopt(sys.argv[1:], "hmso", ["help",
"methods",
- "SSL",
"truststore=",
- "oneliner"])
+ opts, args = getopt.getopt(sys.argv[1:],
+ "hmsoq",
+ ["help", "methods",
"SSL", "truststore=",
+ "oneliner", "quiet"])
for o, v in opts:
if o == "-h" or o == "--help":
@@ -2782,6 +2793,8 @@
serv.truststore = v
if o == '-o' or o == '--oneliner':
serv.pretty = False
+ if o == '-q' or o == '--quiet':
+ serv.quiet = True
if len(args) < 2:
raise Exception("Need at least two arguments")
server, command = args[0:2]
--
To view, visit
http://gerrit.ovirt.org/35340
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icbb9654b47fd993aee34b2292a1d94d1e4019b6a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>