[Libvirt-cim] [PATCH] [TEST] #2 Fix ResourceAllocationFromPool.01 & 02

yunguol at cn.ibm.com yunguol at cn.ibm.com
Thu Aug 7 09:17:36 UTC 2008


# HG changeset patch
# User Guolian Yun <yunguol at cn.ibm.com>
# Date 1218100649 25200
# Node ID c96db4410fd7b152f803726132378ec0caa9f1ad
# Parent  0f568c2c36035da2574e11d128780833392e43af
[TEST] #2 Fix ResourceAllocationFromPool.01 & 02

Removing the create_netpool_conf(), getting the bridge name
using xml_get_net_bridge() and network name info by using
xml_get_net_network()

Signed-off-by: Guolian Yun <yunguol at cn.ibm.com>

diff -r 0f568c2c3603 -r c96db4410fd7 suites/libvirt-cim/cimtest/ResourceAllocationFromPool/01_forward.py
--- a/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/01_forward.py	Wed Aug 06 06:08:02 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/01_forward.py	Thu Aug 07 02:17:29 2008 -0700
@@ -23,7 +23,7 @@
 #
 
 import sys
-from VirtLib import utils
+from VirtLib import utils, live
 from XenKvmLib import assoc
 from XenKvmLib import enumclass
 from XenKvmLib.classes import get_typed_class
@@ -42,7 +42,7 @@
 test_mem    = 128
 test_mac    = "00:11:22:33:44:aa"
 
-def setup_env(server, virt):
+def setup_env(server, virt, nettype='network'):
     destroy_and_undefine_all(server)
     vsxml = None
     if virt == "Xen":
@@ -58,6 +58,20 @@
     else:
         vsxml = virtxml(test_dom, mem=test_mem, vcpus = test_vcpus,
                         mac = test_mac, disk = test_disk)
+    if nettype == 'bridge':
+        int_name = vsxml.xml_get_net_bridge()
+    else:
+        int_name = vsxml.xml_get_net_network()
+
+    if int_name == None:
+        devices = vsxml.get_node('/domain/devices')
+        vsxml.set_interface_details(devices, test_mac, nettype, virt)
+
+    if nettype == 'bridge':
+        vsxml.set_bridge_name(int_name)
+    else:
+        vsxml.set_net_name(int_name)
+
     try:
         ret = vsxml.define(server)
         if not ret:
@@ -68,7 +82,7 @@
         logger.error("Exception : %s", details)
         return FAIL, vsxml, test_disk
 
-    return PASS, vsxml, test_disk
+    return PASS, vsxml, test_disk, int_name
 
 def get_instance(server, pool, list, virt='Xen'):
     try:
@@ -111,17 +125,12 @@
     status = PASS
 
    
-    status, vsxml, test_disk = setup_env(options.ip, options.virt)
+    status, vsxml, test_disk, test_network = setup_env(options.ip, options.virt)
     if status != PASS:
+        vsxml.undefine(options.ip)
         return status
     
     status, diskid = create_diskpool_conf(options.ip, options.virt)
-    if status != PASS:
-        cleanup_restore(options.ip, options.virt)
-        vsxml.undefine(options.ip)
-        return status
-
-    status, test_network = create_netpool_conf(options.ip, options.virt)
     if status != PASS:
         cleanup_restore(options.ip, options.virt)
         vsxml.undefine(options.ip)
@@ -152,7 +161,6 @@
             break
 
     cleanup_restore(options.ip, options.virt)
-    destroy_netpool(options.ip, options.virt, test_network)
     vsxml.undefine(options.ip)
     return status 
         
diff -r 0f568c2c3603 -r c96db4410fd7 suites/libvirt-cim/cimtest/ResourceAllocationFromPool/02_reverse.py
--- a/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/02_reverse.py	Wed Aug 06 06:08:02 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/02_reverse.py	Thu Aug 07 02:17:29 2008 -0700
@@ -24,7 +24,7 @@
 #
 
 import sys
-from VirtLib import utils
+from VirtLib import utils, live
 from XenKvmLib import assoc
 from XenKvmLib.test_doms import destroy_and_undefine_all
 from XenKvmLib.vxml import get_class
@@ -43,7 +43,7 @@
 test_mem    = 128
 test_mac    = "00:11:22:33:44:aa"
 
-def setup_env(server, virt):
+def setup_env(server, virt, nettype='network'):
     destroy_and_undefine_all(server)
     vsxml = None
     if virt == "Xen":
@@ -57,6 +57,20 @@
     else:
         vsxml = virtxml(test_dom, mem=test_mem, vcpus = test_vcpus,
                         mac = test_mac, disk = test_disk)
+    if nettype == 'bridge':
+        int_name = vsxml.xml_get_net_bridge()
+    else:
+        int_name = vsxml.xml_get_net_network()
+
+    if int_name == None:
+        devices = vsxml.get_node('/domain/devices')
+        vsxml.set_interface_details(devices, test_mac, nettype, virt)
+
+    if nettype == 'bridge':
+        vsxml.set_bridge_name(int_name)
+    else:
+        vsxml.set_net_name(int_name)
+
     try:
         ret = vsxml.define(server)
         if not ret:
@@ -67,7 +81,7 @@
         logger.error("Exception : %s", details)
         return FAIL, vsxml, test_disk
 
-    return PASS, vsxml, test_disk
+    return PASS, vsxml, test_disk, int_name
 
 def init_list(test_disk, diskid, test_network, virt='Xen'):
 
@@ -163,16 +177,13 @@
     server = options.ip
     virt = options.virt
     
-    status, vsxml, test_disk = setup_env(server, virt)
+    status, vsxml, test_disk, test_network = setup_env(server, virt)
     if status != PASS:
         return status
 
     status, diskid = create_diskpool_conf(server, virt)
     if status != PASS:
-        return status
-
-    status, test_network = create_netpool_conf(server, virt)
-    if status != PASS:
+        vsxml.undefine(server)
         return status
 
     cn_id_list = init_list(test_disk, diskid, test_network, options.virt)
@@ -181,10 +192,11 @@
         status = get_rasdinst_verify_pool_from_RAFP(server, virt, vsxml, 
                                                     rasd_cn, id_info)
         if status != PASS:
+            cleanup_restore(server, virt)
+            vsxml.undefine(server)
             return status
 
     cleanup_restore(server, virt)
-    destroy_netpool(server, virt, test_network)
     vsxml.undefine(server)    
     return status
 




More information about the Libvirt-cim mailing list