[Libvirt-cim] [PATCH] [TEST] Adding code to verify if a subnet used in the test case already exists

Deepti B. Kalakeri deeptik at linux.vnet.ibm.com
Fri Jul 23 13:41:52 UTC 2010


# HG changeset patch
# User Deepti B. Kalakeri <deeptik at linux.vnet.ibm.com>
# Date 1279892502 25200
# Node ID 3976f0cbef2a1be8f6572ede485552684747ae18
# Parent  4f2909dd0e2f9be6d3f32b0926d564d112ec2572
[TEST] Adding code to verify if a subnet used in the test case already exists

The following tests failed because of the networkpool withe the same subnet existed
on the machine.

VirtualSystemManagementService - 06_addresource.py: FAIL
VirtualSystemManagementService - 18_define_sys_bridge.py: FAIL
VirtualSystemManagementService - 19_definenetwork_ers.py: FAIL
VirtualSystemManagementService - 22_addmulti_brg_interface.py: FAIL
VirtualSystemManagementService - 23_verify_duplicate_mac_err.py: FAIL
VirtualSystemManagementService - 27_definesystem_macvtap_dev.py: FAIL

This fix will verify if the subnet already is used and gives appropriate message.
Tested has been verified with KVM  Libvirt-CIM Sources.
Signed-off-by: Deepti B. Kalakeri <deeptik at linux.vnet.ibm.com>

diff -r 4f2909dd0e2f -r 3976f0cbef2a suites/libvirt-cim/lib/XenKvmLib/vxml.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py	Fri Jul 23 05:56:57 2010 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py	Fri Jul 23 06:41:42 2010 -0700
@@ -237,7 +237,7 @@
         self.add_sub_node(network, 'name', self.net_name)
         self.add_sub_node(network, 'uuid', set_uuid())
         self.add_sub_node(network, 'forward')
-        subnet = '192.168.123.'
+        subnet = '192.168.%d.' % (random.randint(1, 100))
         self.add_sub_node(network, 'bridge', name=self.vbr, stp='on',
                                              forwardDelay='0')
         ip_base = random.randint(1, 100)
@@ -249,6 +249,13 @@
                    awk '/ip address/ {print}' | \
                    cut -d ' ' -f 4 | sed 's/address=//'" % _net_name 
             s, in_use_addr = utils.run_remote(server, cmd)
+
+            sub_net_in_use = in_use_addr
+            sub_net_in_use = sub_net_in_use.rsplit('.', 1)[0].strip("'") + "."
+            if subnet == sub_net_in_use:
+                logger.error("Subnet address is in use by a different network")
+                return None 
+
             in_use_addr = in_use_addr.strip("'")
             if in_use_addr == addr:
                 logger.error("IP address is in use by a different network")




More information about the Libvirt-cim mailing list