Introduce an extra parameter to the function, an output file. If it is passed, write the output of the command to a file. This is necessary for the virsh net-list test.
Signed-off-by: Lucas Meneghel Rodrigues <[email protected]> --- virttest/virsh.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/virttest/virsh.py b/virttest/virsh.py index c2c7bd0..d2be1be 100644 --- a/virttest/virsh.py +++ b/virttest/virsh.py @@ -1228,17 +1228,23 @@ def detach_interface(name, option="", **dargs): return command(cmd, **dargs) -def net_dumpxml(net_name="", extra="", **dargs): +def net_dumpxml(net_name, extra="", 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: extra: Extra parameters to pass to command + @param: to_file: Send result to a file @param: dargs: standardized virsh function API keywords @return: CmdResult object """ cmd = "net-dumpxml %s %s" % (net_name, extra) - return command(cmd, **dargs) + result = command(cmd, **dargs) + if to_file: + result_file = open(to_file, 'w') + result_file.write(result.stdout.strip()) + result_file.close() + return result def net_create(xml_file, extra="", **dargs): -- 1.8.2 _______________________________________________ Virt-test-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/virt-test-devel
