# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1222108082 25200
# Node ID c87a451fbf690b718e800be49ecc7ec83b83ad9b
# Parent 892ce3fce2340df3fb51a1160f510d15838f2d54
[TEST] Fixing 05_RAPF_err.py tc of RAFP.
Removed the verification for wrong bridge type as this is not yet supported in the
providers.
Tested with Xen/XenFV, KVM[F9] with current sources.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 892ce3fce234 -r c87a451fbf69
suites/libvirt-cim/cimtest/ResourceAllocationFromPool/05_RAPF_err.py
--- a/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/05_RAPF_err.py Fri Sep 12
14:35:12 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/05_RAPF_err.py Mon Sep 22
11:28:02 2008 -0700
@@ -52,46 +52,19 @@ from CimTest import Globals
from CimTest import Globals
from CimTest.Globals import logger, CIM_ERROR_ENUMERATE
from CimTest.ReturnCodes import PASS, FAIL
-from XenKvmLib.const import do_main, platform_sup
+from XenKvmLib.const import do_main
from XenKvmLib import vxml
from XenKvmLib.classes import get_typed_class
+from XenKvmLib.const import default_network_name
+from XenKvmLib.common_util import create_netpool_conf, destroy_netpool
test_dom = "RAPF_domain"
test_mac = "00:11:22:33:44:aa"
test_vcpus = 1
+npool_name = default_network_name + str(random.randint(1, 100))
+sup_types = ['KVM', 'Xen', 'XenFV']
-def get_unique_interface(server, virt, nettype='network'):
- interface = "wrong-int"
- if nettype == 'bridge':
- int_list = live.available_bridges(server)
- else:
- int_list = live.net_list(server, virt)
-
- while interface in int_list:
- interface = interface + str(random.randint(1, 100))
-
- return interface
-
-def modify_net_name(server, virt, nettype, vsxml):
- 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)
-
- int_name = get_unique_interface(server, virt, nettype)
-
- if nettype == 'bridge':
- vsxml.set_bridge_name(int_name)
- else:
- vsxml.set_net_name(int_name)
-
- return vsxml
-
-def setup_env(server, virt, nettype='network'):
+def setup_env(server, virt, net_name, nettype='network'):
vsxml_info = None
if virt == "Xen":
test_disk = "xvda"
@@ -101,14 +74,16 @@ def setup_env(server, virt, nettype='net
virt_xml = vxml.get_class(virt)
vsxml_info = virt_xml(test_dom, vcpus = test_vcpus,
mac = test_mac, disk = test_disk,
- ntype = nettype)
-
- vsxml_info = modify_net_name(server, virt, nettype, vsxml_info)
+ ntype = nettype, net_name=net_name)
ret = vsxml_info.cim_define(server)
if not ret:
- Globals.logger.error("Failed to define the dom '%s' for '%s'
type"
- " interface", test_dom, nettype)
+ logger.error("Failed to define the dom '%s' for '%s'
type"
+ " interface", test_dom, nettype)
+ if virt != 'KVM':
+ status = destroy_netpool(server, virt, net_name)
+ if status != PASS:
+ logger.error("Failed to destroy the networkpool %s", net_name)
return FAIL, vsxml_info
return PASS, vsxml_info
@@ -196,31 +171,50 @@ def verify_rapf_err(server, virt, vsxml)
return status
-@do_main(platform_sup)
+@do_main(sup_types)
def main():
options = main.options
server = options.ip
virt = options.virt
destroy_and_undefine_all(server)
- in_list = [ 'bridge', 'network' ]
+ in_list = 'network'
- for interface in in_list:
- # This is req bcs virsh does not support the defining a guest
- # when an invalid network poolname is passed.
- if interface == 'network' and virt != 'KVM':
- continue
+ # libvirt does not allow to define a guest with invalid networkpool info
+ # for Xen and XenFV, but it does not restrict to do so for KVM.
+ # Hence passing wrong networkpool for KVM and a valid networkpool for
+ # Xen and XenFV otherwise.
+ if virt == 'KVM':
+ int_name = 'wrong-int'
+ else:
+ status, int_name = create_netpool_conf(options.ip, options.virt,
+ use_existing=False,
+ net_name=npool_name)
+ if status != PASS:
+ logger.error('Unable to create network pool')
+ return FAIL
- status, vsxml = setup_env(server, virt, interface)
+
+ # Since we cannot create a Xen/XenFV guest with invalid networkpool info,
+ # we first create a guest with valid networkpool info and then
+ # then destroy the networkpool info as a work around to, verify if the
+ # provider returns an exception for Xen/XenFV guest when its networkpool
+ # does not exist anymore on the machine.
+ status, vsxml = setup_env(server, virt, int_name, in_list)
+ if status != PASS:
+ logger.error("Failed to setup the domain")
+ vsxml.undefine(server)
+ return status
+
+ if virt != 'KVM':
+ status = destroy_netpool(server, virt, int_name)
if status != PASS:
- logger.error("Failed to setup the domain")
+ logger.error("Failed to destroy the virtual network %s", net_name)
vsxml.undefine(server)
return status
- ret = verify_rapf_err(server, virt, vsxml)
- if ret:
- logger.error("------FAILED: to verify the RAFP.------")
- vsxml.undefine(server)
- return ret
+ status = verify_rapf_err(server, virt, vsxml)
+ if status != PASS:
+ logger.error("------FAILED: to verify the RAFP.------")
vsxml.undefine(server)
return status
diff -r 892ce3fce234 -r c87a451fbf69 suites/libvirt-cim/lib/XenKvmLib/vsms.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Fri Sep 12 14:35:12 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Mon Sep 22 11:28:02 2008 -0700
@@ -233,6 +233,7 @@ def default_vssd_rasd_str(dom_name='test
disk_source=const.Xen_disk_path,
net_type='ethernet',
net_mac=const.Xen_default_mac,
+ net_name=None,
proc_vcpu=1,
mem_mb=512,
malloc_units="MegaBytes",
@@ -279,7 +280,8 @@ def default_vssd_rasd_str(dom_name='test
n = class_nasd(
type=net_type,
mac=net_mac,
- name=dom_name)
+ name=dom_name,
+ virt_net=net_name)
class_pasd = get_pasd_class(virt)
p = class_pasd(
vcpu=proc_vcpu,
diff -r 892ce3fce234 -r c87a451fbf69 suites/libvirt-cim/lib/XenKvmLib/vxml.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Fri Sep 12 14:35:12 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Mon Sep 22 11:28:02 2008 -0700
@@ -467,7 +467,7 @@ class VirtXML(Virsh, XMLClass):
class VirtCIM:
def __init__(self, virt, dom_name, disk_dev, disk_source,
- net_type, net_mac, vcpus, mem, mem_allocunits):
+ net_type, net_name, net_mac, vcpus, mem, mem_allocunits):
self.virt = virt
self.domain_name = dom_name
self.vssd = vsms.get_vssd_class(virt)(name=dom_name, virt=virt)
@@ -476,7 +476,8 @@ class VirtCIM:
name=dom_name)
self.nasd = vsms.get_nasd_class(virt)(type=net_type,
mac=net_mac,
- name=dom_name)
+ name=dom_name,
+ virt_net=net_name)
self.pasd = vsms.get_pasd_class(virt)(vcpu=vcpus, name=dom_name)
self.masd = vsms.get_masd_class(virt)(megabytes=mem,
mallocunits=mem_allocunits,
@@ -545,7 +546,7 @@ class XenXML(VirtXML, VirtCIM):
self._devices(disk_file_path, disk, ntype, mac, net_name)
VirtCIM.__init__(self, 'Xen', test_dom, disk, disk_file_path,
- ntype, mac, vcpus, mem, mem_allocunits)
+ ntype, net_name, mac, vcpus, mem, mem_allocunits)
def _os(self, os_kernel, os_initrd):
os = self.get_node('/domain/os')
@@ -596,7 +597,7 @@ class KVMXML(VirtXML, VirtCIM):
sys.exit(1)
VirtXML.__init__(self, 'kvm', test_dom, set_uuid(), mem, vcpus)
VirtCIM.__init__(self, 'KVM', test_dom, disk, disk_file_path,
- ntype, mac, vcpus, mem, mem_allocunits)
+ ntype, net_name, mac, vcpus, mem, mem_allocunits)
self._os()
self._devices(const.KVM_default_emulator, ntype,
disk_file_path, disk, mac, net_name)
@@ -643,7 +644,7 @@ class XenFVXML(VirtXML, VirtCIM):
sys.exit(1)
VirtXML.__init__(self, 'xenfv', test_dom, set_uuid(), mem, vcpus)
VirtCIM.__init__(self, 'XenFV', test_dom, disk, disk_file_path,
- ntype, mac, vcpus, mem, mem_allocunits)
+ ntype, net_name, mac, vcpus, mem, mem_allocunits)
self._features()
self._os(const.XenFV_default_loader)
self._devices(const.XenFV_default_emulator,