On Fri, Mar 29, 2013 at 4:54 AM, liyang <[email protected]> wrote:
> Signed-off-by: Li Yang <[email protected]> > --- > virttest/virsh.py | 16 ++++++++++++---- > 1 files changed, 12 insertions(+), 4 deletions(-) > > diff --git a/virttest/virsh.py b/virttest/virsh.py > index 21c6922..ecf8381 100644 > --- a/virttest/virsh.py > +++ b/virttest/virsh.py > @@ -1139,17 +1139,25 @@ def detach_interface(name, option="", **dargs): > return command(cmd, **dargs) > > > -def net_dumpxml(net_name="", extra="", **dargs): > +def net_dumpxml(net_name, to_file="", **dargs): > """ > Dump XML from network named net_name. > > @param: net_name: Name of a network > - @param: extra: extra parameters to pass to command > + @param: to_file: optional file to write XML output to > @param: dargs: standardized virsh function API keywords > @return: CmdResult object > """ > - cmd = "net-dumpxml %s %s" % (net_name, extra) > - return command(cmd, **dargs) > + dargs['ignore_status'] = True > + if to_file: > + cmd = "net-dumpxml %s > %s" % (net_name, to_file) > + else: > + cmd = "net-dumpxml %s" % net_name > + result = command(cmd, **dargs) > + if result.exit_status: > + raise error.CmdError(cmd, result, > + "Virsh net-dumpxml returned non-zero exit status") > + return result.stdout.strip() > This is a *very* intrusive change, and it doesn't need to be implemented this way. You can capture the stdout of the command and write to the file using the proper python apis, and return the cmd object, therefore not needing to modify other callers. I've sent an updated version of your patchset and sent it to next.
_______________________________________________ Virt-test-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/virt-test-devel
