# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1211804430 25200
# Node ID 3e9db2a1534d0565e06596b3ebebd33c09bd6587
# Parent 3233a070377270931b4cc1d790b6782fee17d1b6
[TEST] Modifying the KVMXML to make use network as the deafult net_type.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 3233a0703772 -r 3e9db2a1534d suites/libvirt-cim/lib/XenKvmLib/const.py
--- a/suites/libvirt-cim/lib/XenKvmLib/const.py Fri May 23 18:14:28 2008 +0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/const.py Mon May 26 05:20:30 2008 -0700
@@ -66,7 +66,7 @@ KVM_secondary_disk_path = os.path.join(_
KVM_secondary_disk_path = os.path.join(_image_dir, 'default-kvm-dimage.2ND')
KVM_default_disk_dev = 'hda'
KVM_default_mac = '11:22:33:aa:bb:cc'
-KVM_default_net_type = 'bridge'
+KVM_default_net_type = 'network'
# vxml.XenFVXML
s, o = platform.architecture()
diff -r 3233a0703772 -r 3e9db2a1534d suites/libvirt-cim/lib/XenKvmLib/vxml.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Fri May 23 18:14:28 2008 +0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Mon May 26 05:20:30 2008 -0700
@@ -574,8 +574,30 @@ class KVMXML(VirtXML):
interface = self.add_sub_node(devices, 'interface', type=net_type)
self.add_sub_node(interface, 'mac', address=net_mac)
+
if net_type == 'bridge':
self.set_vbridge(CIM_IP)
+ elif net_type == 'network':
+ self.set_vnetwork(interface)
+ else:
+ logger.error("%s is not a valid network type", net_type)
+ sys.exit(1)
+
+ def set_vnetwork(self, interface):
+ network_list = live.net_list(CIM_IP, virt='KVM')
+ if len(network_list) > 0:
+ nname = network_list[0]
+ else:
+ logger.info('No virutal network found')
+ logger.info('Trying to create one ......')
+ netxml = NetXML(CIM_IP, virt='KVM')
+ ret = netxml.create_vnet()
+ if not ret:
+ logger.error('Failed to create the virtual network
"%s"',
+ netxml.net_name)
+ sys.exit(SKIP)
+ nname = netxml.xml_get_netpool_name()
+ self.add_sub_node(interface, 'source', network=nname)
def set_emulator(self, emu):
return self._set_emulator(emu)