[PATCH] [TEST] Check return code of run_remote() in create_netpool_conf()

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1222101955 25200 # Node ID 16fd8f75598442d71eeb0199fb680ca6564656bc # Parent c76b2779aca9810f4c3bdf8a0ca768dc3dc9315f [TEST] Check return code of run_remote() in create_netpool_conf() Instead of checking the output. Also, add log_param to main.py debug messages for errors encountered by main.py will be printed to stderr/stdout. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r c76b2779aca9 -r 16fd8f755984 suites/libvirt-cim/lib/XenKvmLib/common_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Mon Sep 22 07:50:25 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Mon Sep 22 09:45:55 2008 -0700 @@ -431,7 +431,8 @@ cmd = "virsh -c %s net-list --all | grep %s" % \ (utils.virt2uri(virt), net_name) ret, out = utils.run_remote(server, cmd) - if out != "": + # If success, network pool with name net_name already exists + if ret == 0: logger.error("Network pool with name '%s' already exists", net_name) return FAIL, "Unknown" diff -r c76b2779aca9 -r 16fd8f755984 suites/libvirt-cim/main.py --- a/suites/libvirt-cim/main.py Mon Sep 22 07:50:25 2008 -0700 +++ b/suites/libvirt-cim/main.py Mon Sep 22 09:45:55 2008 -0700 @@ -27,6 +27,7 @@ import sys sys.path.append('../../lib') import TestSuite +from CimTest.Globals import logger, log_param import commands from VirtLib import groups import ConfigParser @@ -184,6 +185,7 @@ return 1 testsuite = TestSuite.TestSuite(log=True) + log_param(file_name=testsuite.log_file) set_python_path() @@ -209,6 +211,7 @@ status = setup_env(options.ip, options.virt) if status != PASS: print "Please check your environment.\n" + testsuite.finish() return 1 print "\nTesting " + options.virt + " hypervisor"

Kaitlin Rupert wrote:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1222101955 25200 # Node ID 16fd8f75598442d71eeb0199fb680ca6564656bc # Parent c76b2779aca9810f4c3bdf8a0ca768dc3dc9315f [TEST] Check return code of run_remote() in create_netpool_conf()
Instead of checking the output. Also, add log_param to main.py debug messages for errors encountered by main.py will be printed to stderr/stdout.
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r c76b2779aca9 -r 16fd8f755984 suites/libvirt-cim/lib/XenKvmLib/common_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Mon Sep 22 07:50:25 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Mon Sep 22 09:45:55 2008 -0700 @@ -431,7 +431,8 @@ cmd = "virsh -c %s net-list --all | grep %s" % \ (utils.virt2uri(virt), net_name)
Can you make this as an exact match as below: cmd = "virsh -c %s net-list --all | grep *-w *%s" % (utils.virt2uri(virt), net_name) This will avoid the cmd returning false positive if in case there is a network pool which is similar to the default networkpool like cimtest-networkpool10 or 10cimtest-networkpool10 exsisting on the machine.
ret, out = utils.run_remote(server, cmd) - if out != "": + # If success, network pool with name net_name already exists + if ret == 0: logger.error("Network pool with name '%s' already exists", net_name) return FAIL, "Unknown" diff -r c76b2779aca9 -r 16fd8f755984 suites/libvirt-cim/main.py --- a/suites/libvirt-cim/main.py Mon Sep 22 07:50:25 2008 -0700 +++ b/suites/libvirt-cim/main.py Mon Sep 22 09:45:55 2008 -0700 @@ -27,6 +27,7 @@ import sys sys.path.append('../../lib') import TestSuite +from CimTest.Globals import logger, log_param import commands from VirtLib import groups import ConfigParser @@ -184,6 +185,7 @@ return 1
testsuite = TestSuite.TestSuite(log=True) + log_param(file_name=testsuite.log_file)
set_python_path()
@@ -209,6 +211,7 @@ status = setup_env(options.ip, options.virt) if status != PASS: print "Please check your environment.\n" + testsuite.finish() return 1
print "\nTesting " + options.virt + " hypervisor"
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r c76b2779aca9 -r 16fd8f755984 suites/libvirt-cim/lib/XenKvmLib/common_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Mon Sep 22 07:50:25 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Mon Sep 22 09:45:55 2008 -0700 @@ -431,7 +431,8 @@ cmd = "virsh -c %s net-list --all | grep %s" % \ (utils.virt2uri(virt), net_name)
Can you make this as an exact match as below:
cmd = "virsh -c %s net-list --all | grep *-w *%s" % (utils.virt2uri(virt), net_name)
This will avoid the cmd returning false positive if in case there is a network pool which is similar to the default networkpool like cimtest-networkpool10 or 10cimtest-networkpool10 exsisting on the machine.
Excellent point - will send a new patch. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (2)
-
Deepti B Kalakeri
-
Kaitlin Rupert