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

Deepti B Kalakeri deeptik at linux.vnet.ibm.com
Mon Sep 22 18:35:01 UTC 2008



Kaitlin Rupert wrote:
> # HG changeset patch
> # User Kaitlin Rupert <karupert at 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 at 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 at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-cim
>   




More information about the Libvirt-cim mailing list