# HG changeset patch
# User Zhengang Li <lizg(a)cn.ibm.com>
# Date 1207035096 -28800
# Node ID 322f822fa9b66dee2e5d76bfcb87071adf27a58e
# Parent ef540cdd8bb436318736e538eb75e82a87744fd8
[TEST] Move Xen/KVM/XenFV specific const values to new place.
Added const.py
Move reference to vxml default const values to use the new const module.
This is to avoid cyclic import between vsms and vxml
Signed-off-by: Zhengang Li <lizg(a)cn.ibm.com>
diff -r ef540cdd8bb4 -r 322f822fa9b6 suites/libvirt-cim/lib/XenKvmLib/const.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/suites/libvirt-cim/lib/XenKvmLib/const.py Tue Apr 01 15:31:36 2008 +0800
@@ -0,0 +1,64 @@
+#
+# Copyright 2008 IBM Corp.
+#
+# Authors:
+# Zhengang Li <lizg(a)cn.ibm.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import os
+import platform
+
+# vxml.NetXML
+default_bridge_name = 'testbridge'
+default_network_name = 'default-net'
+
+# vxml.VirtXML
+default_domname = 'domU1'
+default_memory = 128
+default_vcpus = 1
+
+
+_image_dir = '/tmp'
+
+# vxml.XenXML
+Xen_kernel_path = os.path.join(_image_dir, 'default-xen-kernel')
+Xen_init_path = os.path.join(_image_dir, 'default-xen-initrd')
+Xen_disk_path = os.path.join(_image_dir, 'default-xen-dimage')
+Xen_secondary_disk_path = os.path.join(_image_dir, 'default-xen-dimage.2ND')
+Xen_default_disk_dev = 'xvda'
+Xen_default_mac = '11:22:33:aa:bb:cc'
+Xen_default_net_type = 'ethernet'
+
+# vxml.KVMXML
+KVM_default_emulator = '/usr/bin/qemu'
+KVM_disk_path = os.path.join(_image_dir, 'default-kvm-dimage')
+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'
+
+# vxml.XenFVXML
+s, o = platform.architecture()
+if o == '32bit':
+ arch = 'lib'
+else:
+ arch = 'lib64'
+XenFV_default_loader = '/usr/lib/xen/boot/hvmloader'
+XenFV_default_emulator = '/usr/%s/xen/bin/qemu-dm' % arch
+XenFV_disk_path = os.path.join(_image_dir, 'default-kvm-dimage')
+XenFV_secondary_disk_path = os.path.join(_image_dir, 'default-kvm-dimage.2ND')
+XenFV_default_disk_dev = 'hda'
+XenFV_default_mac = '00:16:3e:5d:c7:9e'
+XenFV_default_net_type = 'bridge'
diff -r ef540cdd8bb4 -r 322f822fa9b6 suites/libvirt-cim/lib/XenKvmLib/vsms.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Tue Apr 01 15:31:27 2008 +0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Tue Apr 01 15:31:36 2008 +0800
@@ -26,7 +26,7 @@ from CimTest.CimExt import CIMMethodClas
from CimTest.CimExt import CIMMethodClass, CIMClassMOF
from CimTest import Globals
from VirtLib import live
-from XenKvmLib import vxml
+from XenKvmLib import const
from XenKvmLib.classes import get_typed_class, get_class_type, virt_types
RASD_TYPE_PROC = 3
@@ -102,8 +102,8 @@ class CIM_VirtualSystemSettingData(CIMCl
else:
self.Bootloader = live.bootloader(Globals.CIM_IP, 0)
self.BootloaderArgs = ''
- self.Kernel = vxml.XenXML.kernel_path
- self.Ramdisk = vxml.XenXML.init_path
+ self.Kernel = const.Xen_kernel_path
+ self.Ramdisk = const.Xen_init_path
class Xen_VirtualSystemSettingData(CIM_VirtualSystemSettingData):
@@ -199,9 +199,9 @@ def get_masd_class(virt):
def default_vssd_rasd_str(dom_name='test_domain',
disk_dev='xvda',
- disk_source=vxml.XenXML.disk_path,
+ disk_source=const.Xen_disk_path,
net_type='ethernet',
- net_mac=vxml.XenXML.default_mac,
+ net_mac=const.Xen_default_mac,
proc_vcpu=1,
mem_mb=512,
virt='Xen'):
@@ -211,19 +211,19 @@ def default_vssd_rasd_str(dom_name='test
class_dasd = get_dasd_class(virt)
if virt == 'KVM':
disk_dev = 'hda'
- disk_source = vxml.KVMXML.disk_path
+ disk_source = const.KVM_disk_path
elif virt == 'XenFV':
disk_dev = 'hda'
- disk_source = vxml.XenFVXML.disk_path
+ disk_source = const.XenFV_disk_path
d = class_dasd(
dev=disk_dev,
source=disk_source,
name=dom_name)
class_nasd = get_nasd_class(virt)
if virt == 'KVM':
- net_mac= vxml.KVMXML.default_mac
+ net_mac= const.KVM_default_mac
elif virt == 'XenFV':
- net_mac = vxml.XenFVXML.default_mac
+ net_mac = const.XenFV_default_mac
n = class_nasd(
type=net_type,
mac=net_mac,
diff -r ef540cdd8bb4 -r 322f822fa9b6 suites/libvirt-cim/lib/XenKvmLib/vxml.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Tue Apr 01 15:31:27 2008 +0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Tue Apr 01 15:31:36 2008 +0800
@@ -39,6 +39,7 @@ from VirtLib import utils, live
from VirtLib import utils, live
from XenKvmLib.test_doms import set_uuid, viruuid
from XenKvmLib import vsms
+from XenKvmLib import const
from CimTest.Globals import logger, CIM_IP
from CimTest.ReturnCodes import SKIP
from XenKvmLib.classes import virt_types
@@ -156,15 +157,12 @@ class Virsh:
return s == 0
class NetXML(Virsh, XMLClass):
- default_bridge_name = 'testbridge'
- default_network_name = 'default-net'
-
vbr = ''
net_name = ''
server = ''
- def __init__(self, server, bridgename=default_bridge_name,
- networkname=default_network_name,
+ def __init__(self, server, bridgename=const.default_bridge_name,
+ networkname=const.default_network_name,
virt='xen'):
def get_valid_bridge_name(server):
@@ -210,11 +208,6 @@ class VirtXML(Virsh, XMLClass):
class VirtXML(Virsh, XMLClass):
"""Base class for all XML generation &
operation"""
dname = "" # domain name
-
- # default values
- default_domname = 'domU1'
- default_memory = 128
- default_vcpus = 1
def __init__(self, domain_type, name, uuid, mem, vcpu):
XMLClass.__init__(self)
@@ -424,32 +417,25 @@ class VirtCIM:
class XenXML(VirtXML, VirtCIM):
-
- image_dir = "/tmp"
- kernel_path = os.path.join(image_dir, 'default-xen-kernel')
- init_path = os.path.join(image_dir, 'default-xen-initrd')
- disk_path = os.path.join(image_dir, 'default-xen-dimage')
- secondary_disk_path = os.path.join(image_dir, 'default-xen-dimage.2ND')
- default_disk_dev = 'xvda'
- default_mac = '11:22:33:aa:bb:cc'
- default_net_type = 'ethernet'
-
- def __init__(self, test_dom=VirtXML.default_domname, \
- mem=VirtXML.default_memory, \
- vcpus=VirtXML.default_vcpus, \
- mac=default_mac, \
- disk_file_path=disk_path, \
- disk=default_disk_dev):
- if not (os.path.exists(self.kernel_path) and os.path.exists(self.init_path)):
+
+ secondary_disk_path = const.Xen_secondary_disk_path
+
+ def __init__(self, test_dom=const.default_domname, \
+ mem=const.default_memory, \
+ vcpus=const.default_vcpus, \
+ mac=const.Xen_default_mac, \
+ disk_file_path=const.Xen_disk_path, \
+ disk=const.Xen_default_disk_dev):
+ if not (os.path.exists(const.Xen_kernel_path) and
os.path.exists(const.Xen_init_path)):
logger.error('ERROR: ' + \
'Either the kernel image or the init_path does not exist')
sys.exit(1)
VirtXML.__init__(self, 'xen', test_dom, set_uuid(), mem, vcpus)
- self._os(self.kernel_path, self.init_path)
- self._devices(disk_file_path, disk, self.default_net_type, mac)
+ self._os(const.Xen_kernel_path, const.Xen_init_path)
+ self._devices(disk_file_path, disk, const.Xen_default_net_type, mac)
VirtCIM.__init__(self, 'Xen', test_dom, disk, disk_file_path,
- self.default_net_type, mac, vcpus, mem)
+ const.Xen_default_net_type, mac, vcpus, mem)
def _os(self, os_kernel, os_initrd):
os = self.get_node('/domain/os')
@@ -485,26 +471,21 @@ class XenXML(VirtXML, VirtCIM):
class KVMXML(VirtXML):
-
- default_emulator = '/usr/bin/qemu'
- image_dir = '/tmp'
- disk_path = os.path.join(image_dir, 'default-kvm-dimage')
- secondary_disk_path = os.path.join(image_dir, 'default-kvm-dimage.2ND')
- default_disk_dev = 'hda'
- default_mac = '11:22:33:aa:bb:cc'
-
- def __init__(self, test_dom=VirtXML.default_domname, \
- mem=VirtXML.default_memory, \
- vcpus=VirtXML.default_vcpus, \
- mac=default_mac, \
- disk_file_path=disk_path, \
- disk=default_disk_dev):
+
+ secondary_disk_path = const.KVM_secondary_disk_path
+
+ def __init__(self, test_dom=const.default_domname, \
+ mem=const.default_memory, \
+ vcpus=const.default_vcpus, \
+ mac=const.KVM_default_mac, \
+ disk_file_path=const.KVM_disk_path, \
+ disk=const.KVM_default_disk_dev):
if not os.path.exists(disk_file_path):
logger.error('Error: Disk image does not exist')
sys.exit(1)
VirtXML.__init__(self, 'kvm', test_dom, set_uuid(), mem, vcpus)
self._os()
- self._devices(self.default_emulator, disk_file_path, disk, mac)
+ self._devices(const.KVM_default_emulator, disk_file_path, disk, mac)
def _os(self):
self.add_sub_node('/domain/os', 'type', 'hvm')
@@ -532,31 +513,20 @@ class KVMXML(VirtXML):
class XenFVXML(VirtXML):
- s, o = platform.architecture()
- if o == "32bit":
- arch = 'lib'
- else:
- arch = 'lib64'
- default_loader = '/usr/lib/xen/boot/hvmloader'
- default_emulator = '/usr/%s/xen/bin/qemu-dm' % arch
- image_dir = '/tmp'
- disk_path = os.path.join(image_dir, 'default-kvm-dimage')
- default_disk_dev = 'hda'
- default_mac = '00:16:3e:5d:c7:9e'
- default_net_type = 'bridge'
-
- def __init__(self, test_dom=VirtXML.default_domname, \
- mem=VirtXML.default_memory, \
- vcpus=VirtXML.default_vcpus, \
- mac=default_mac, \
- disk_file_path=disk_path, \
- disk=default_disk_dev):
+ secondary_disk_path = const.XenFV_secondary_disk_path
+
+ def __init__(self, test_dom=const.default_domname, \
+ mem=const.default_memory, \
+ vcpus=const.default_vcpus, \
+ mac=const.XenFV_default_mac, \
+ disk_file_path=const.XenFV_disk_path, \
+ disk=const.XenFV_default_disk_dev):
if not os.path.exists(disk_file_path):
logger.error('Error: Disk image does not exist')
sys.exit(1)
VirtXML.__init__(self, 'xen', test_dom, set_uuid(), mem, vcpus)
- self._os(self.default_loader)
- self._devices(self.default_emulator, self.default_net_type, mac, disk_file_path,
disk)
+ self._os(const.XenFV_default_loader)
+ self._devices(const.XenFV_default_emulator, const.XenFV_default_net_type, mac,
disk_file_path, disk)
def _os(self, os_loader):
os = self.get_node('/domain/os')