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

Sharad Mishra snmishra at us.ibm.com
Fri Jul 23 18:34:28 UTC 2010


+1
Code looks good, ran a minimal test. Haven't tested it thoroughly.

Sharad Mishra
Open Virtualization
Linux Technology Center
IBM


                                                                           
             "Deepti B.                                                    
             Kalakeri"                                                     
             <deeptik at linux.vn                                          To 
             et.ibm.com>               libvirt-cim at redhat.com              
             Sent by:                                                   cc 
             libvirt-cim-bounc                                             
             es at redhat.com                                         Subject 
                                       [Libvirt-cim] [PATCH] [TEST] Adding 
                                       code to verify if a subnet used     
             07/23/2010 06:41          in the test case	already exists    
             AM                                                            
                                                                           
                                                                           
             Please respond to                                             
                 List for                                                  
              discussion and                                               
              development of                                               
              libvirt CIM                                               
             <libvirt-cim at redh                                             
                  at.com>                                                  
                                                                           
                                                                           




# 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")

_______________________________________________
Libvirt-cim mailing list
Libvirt-cim at redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-cim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvirt-cim/attachments/20100723/8b930cd3/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvirt-cim/attachments/20100723/8b930cd3/attachment.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pic16442.gif
Type: image/gif
Size: 1255 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvirt-cim/attachments/20100723/8b930cd3/attachment-0001.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ecblank.gif
Type: image/gif
Size: 45 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvirt-cim/attachments/20100723/8b930cd3/attachment-0002.gif>


More information about the Libvirt-cim mailing list