Signed-off-by: Li Yang <[email protected]>
---
 libvirt/tests/virsh_net_name.py |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)
 create mode 100644 libvirt/tests/virsh_net_name.py

diff --git a/libvirt/tests/virsh_net_name.py b/libvirt/tests/virsh_net_name.py
new file mode 100644
index 0000000..1c7b065
--- /dev/null
+++ b/libvirt/tests/virsh_net_name.py
@@ -0,0 +1,35 @@
+from autotest.client.shared import error
+from virttest import virsh
+
+def run_virsh_net_name(test, params, env):
+    """
+    Test command: virsh net-name.
+
+    The command can convert a network UUID to network name.
+    1.Get all parameters from config file.
+    2.Perform virsh net-uuid operation.
+    3.Confirm the test result.`
+    """
+    vm_ref = params.get("net_name_vm_ref")
+    net_name = params.get("net_name_network", "default")
+    extra = params.get("net_name_extra", "")
+    status_error = params.get("status_error")
+
+    net_uuid = virsh.net_uuid(net_name)
+    if vm_ref == "uuid":
+        vm_ref = net_uuid
+    elif vm_ref == "name":
+        vm_ref = net_name
+
+    result = virsh.net_name(vm_ref, extra, ignore_status=True)
+    status = result.exit_status
+    output = result.stdout.strip()
+    err = result.stderr.strip()
+
+    #check status_error
+    if status_error == "yes":
+        if status == 0 or err == "":
+            raise error.TestFail("Run successfully with wrong command!")
+    elif status_error == "no":
+        if status != 0 or output == "":
+            raise error.TestFail("Run failed with right command")
--
1.7.1

--
Regards,
--------------------------------------------------
Li Yang
TEL:+86+25-86630566-8526
EMail:[email protected]
--------------------------------------------------



_______________________________________________
Virt-test-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virt-test-devel

Reply via email to