On 03/15/2013 04:23 AM, Yu Mingfei wrote:
On 03/15/2013 02:44 PM, liyang wrote:
Signed-off-by: Li Yang <[email protected]>
---
virttest/virsh.py | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/virttest/virsh.py b/virttest/virsh.py
index f847d92..df41976 100644
--- a/virttest/virsh.py
+++ b/virttest/virsh.py
@@ -1080,6 +1080,18 @@ def detach_interface(name, option="", **dargs):
return command(cmd, **dargs)
+def net_uuid(network, extra="", **dargs):
+ """
+ Get network UUID on host.
+
+ @param: network: name/parameter for network option/argument
+ @param: extra: extra parameters to pass to command (e.g. --disable)
+ @param: dargs: standardized virsh function API keywords
+ @return: CmdResult object
+ """
+ return command("net-uuid %s %s" % (network, extra), **dargs)
+
+
def net_dumpxml(net_name="", extra="", **dargs):
"""
Dump XML from network named net_name.
@@ -1137,7 +1149,7 @@ def net_state_dict(only_names=False, **dargs):
@param: dargs: standardized virsh function API keywords
@return: dictionary
"""
- dargs['ignore_status'] = True # so persistent check can work
+ dargs['ignore_status'] = False # so persistent check can work
Oh, yes, No doubt I have not occurred CmdError in net_state_dict().
netlist = net_list("--all", print_info=True).stdout.strip().splitlines()
# First two lines contain table header
netlist = netlist[2:]
@@ -1162,7 +1174,7 @@ def net_state_dict(only_names=False, **dargs):
persistent = True
except error.CmdError, cmdstatus:
# Keep search fast & avoid first-letter capital problems
- if not bool(cmdstatus.stdout.count("ransient")):
+ if bool(cmdstatus.result_obj.stderr.count("ransient")):
LGTM, but how about judging by its exit_status, I think it's enough.
I'm afraid that the output may be changed someday. :(
Okay, I took a close look at this fix. Li's is correct, my code is bugged.
Unf. checking exit status here isn't helpful: When exception raised,
exit_status guaranteed to be non-zero.
The condition in exception clause is to see if the network is transient,
or if an unexpected problem happened.
But your question about this means to me: maybe more/better comments are
needed :) I will include them along with Li's fix.
Thanks!
--
Chris Evich, RHCA, RHCE, RHCDS, RHCSS
Quality Assurance Engineer
e-mail: cevich + `@' + redhat.com o: 1-888-RED-HAT1 x44214
_______________________________________________
Virt-test-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virt-test-devel