On 06/07/2012 11:40 PM, guyanhua wrote: > > Modify the virsh_cmd function by adding a param ignore_status with False > default > and returning cmd_result dirctly. Accordingly changing the virsh_cmd > callers' > return value. > > Signed-off-by: Gu Yanhua <guyanhua-f...@cn.fujitsu.com> > --- > client/virt/libvirt_vm.py | 22 +++++++++++----------- > 1 files changed, 11 insertions(+), 11 deletions(-) > > diff --git a/client/virt/libvirt_vm.py b/client/virt/libvirt_vm.py > index cbed8aa..9e952dc 100644 > --- a/client/virt/libvirt_vm.py > +++ b/client/virt/libvirt_vm.py > @@ -86,7 +86,7 @@ def service_libvirtd_control(action): > raise error.TestError("Unknown action: %s" % action) > > > -def virsh_cmd(cmd, uri = ""): > +def virsh_cmd(cmd, uri = "", ignore_status=False): > """ > Append cmd to 'virsh' and execute, optionally return full results. > > @@ -101,29 +101,29 @@ def virsh_cmd(cmd, uri = ""): > if uri: > uri_arg = "-c " + uri > cmd = "%s %s %s" % (VIRSH_EXEC, uri_arg, cmd) > - cmd_result = utils.run(cmd, verbose=DEBUG) > - return cmd_result.stdout.strip() > + cmd_result = utils.run(cmd, verbose=DEBUG, ignore_status=ignore_status) > + return cmd_result > > > def virsh_uri(uri = ""): > """ > Return the hypervisor canonical URI. > """ > - return virsh_cmd("uri", uri) > + return virsh_cmd("uri", uri).stdout.strip() > > > def virsh_hostname(uri = ""): > """ > Return the hypervisor hostname. > """ > - return virsh_cmd("hostname", uri) > + return virsh_cmd("hostname", uri).stdout.strip() > > > def virsh_version(uri = ""): > """ > Return the major version info about what this built from. > """ > - return virsh_cmd("version", uri) > + return virsh_cmd("version", uri).stdout.strip() > > > def virsh_driver(uri = ""): > @@ -143,21 +143,21 @@ def virsh_domstate(name, uri = ""): > > @param name: VM name > """ > - return virsh_cmd("domstate %s" % name, uri) > + return virsh_cmd("domstate %s" % name, uri).stdout.strip() > > > def virsh_domid(name, uri = ""): > """ > Return VM's ID. > """ > - return virsh_cmd("domid %s" % (name), uri) > + return virsh_cmd("domid %s" % (name), uri).stdout.strip() > > > def virsh_dominfo(name, uri = ""): > """ > Return the VM information. > """ > - return virsh_cmd("dominfo %s" % (name), uri) > + return virsh_cmd("dominfo %s" % (name), uri).stdout.strip() > > > def virsh_uuid(name, uri = ""): > @@ -166,7 +166,7 @@ def virsh_uuid(name, uri = ""): > > @param name: VM name > """ > - return virsh_cmd("domuuid %s" % name, uri) > + return virsh_cmd("domuuid %s" % name, uri).stdout.strip() > > > def virsh_screenshot(name, filename, uri = ""): > @@ -185,7 +185,7 @@ def virsh_dumpxml(name, uri = ""): > > @param name: VM name > """ > - return virsh_cmd("dumpxml %s" % name, uri) > + return virsh_cmd("dumpxml %s" % name, uri).stdout.strip() > > > def virsh_is_alive(name, uri = ""): > -- > 1.7.1 > > >
Perfect, looks great. Simple, effective, and shouldn't break too much at all. Let's run some quick confirmation tests on it and get it committed ASAP. Thanks! -- Chris Evich, RHCA, RHCE, RHCDS, RHCSS Quality Assurance Engineer e-mail: cevich + `@' + redhat.com o: 1-888-RED-HAT1 x44214 _______________________________________________ Autotest mailing list Autotest@test.kernel.org http://test.kernel.org/cgi-bin/mailman/listinfo/autotest