[PATCH 0 of 3] [TEST].2# Add one tc using 'user' as network type

# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1207731221 25200 # Node ID cc4dc206699ce32f35a68996d43c2b7fbd00abdd # Parent 262153788503c8b10c76c77719bba081df9a7b88 [TEST].2# add KVM_default_net_type in const.py Signed-off-by: Guolian Yun <yunguol@cn.ibm.com> diff -r 262153788503 -r cc4dc206699c suites/libvirt-cim/lib/XenKvmLib/const.py --- a/suites/libvirt-cim/lib/XenKvmLib/const.py Tue Apr 08 17:58:44 2008 +0530 +++ b/suites/libvirt-cim/lib/XenKvmLib/const.py Wed Apr 09 01:53:41 2008 -0700 @@ -48,6 +48,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' # vxml.XenFVXML s, o = platform.architecture()

# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1207731406 25200 # Node ID 769e4c7af2e850055b0aa536e696f677ea204357 # Parent cc4dc206699ce32f35a68996d43c2b7fbd00abdd [TEST].2# add net_type setting in device node for KVM Signed-off-by: Guolian Yun <yunguol@cn.ibm.com> diff -r cc4dc206699c -r 769e4c7af2e8 suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Apr 09 01:53:41 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Apr 09 01:56:46 2008 -0700 @@ -488,12 +488,12 @@ class KVMXML(VirtXML): sys.exit(1) VirtXML.__init__(self, 'kvm', test_dom, set_uuid(), mem, vcpus) self._os() - self._devices(const.KVM_default_emulator, disk_file_path, disk, mac) + self._devices(const.KVM_default_emulator, const.KVM_default_net_type, disk_file_path, disk, mac) def _os(self): self.add_sub_node('/domain/os', 'type', 'hvm') - def _devices(self, emu, disk_img, disk_dev, net_mac): + def _devices(self, emu, net_type, disk_img, disk_dev, net_mac): devices = self.get_node('/domain/devices') self.add_sub_node(devices, 'emulator', emu) @@ -501,9 +501,10 @@ class KVMXML(VirtXML): self.add_sub_node(disk, 'source', file=disk_img) self.add_sub_node(disk, 'target', dev=disk_dev) - interface = self.add_sub_node(devices, 'interface', type='bridge') + interface = self.add_sub_node(devices, 'interface', type=net_type) self.add_sub_node(interface, 'mac', address=net_mac) - self.set_bridge(CIM_IP) + if net_type == 'bridge': + self.set_vbridge(CIM_IP) def set_emulator(self, emu): return self._set_emulator(emu)

# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1207731971 25200 # Node ID 742b6f226bd7edad544fa1fa44130fa19abb1c57 # Parent 769e4c7af2e850055b0aa536e696f677ea204357 [TEST].2# add a tc that uses 'user' as network type, fais now, also keep track of issue Signed-off-by: Guolian Yun <yunguol@cn.ibm.com> diff -r 769e4c7af2e8 -r 742b6f226bd7 suites/libvirt-cim/cimtest/NetworkPort/03_user_netport.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/NetworkPort/03_user_netport.py Wed Apr 09 02:06:11 2008 -0700 @@ -0,0 +1,93 @@ +#!/usr/bin/python +# +# Copyright 2008 IBM Corp. +# +# Authors: +# Guolian Yun <yunguol@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 +# + +# This tc is used to verify the properties returned by the CIM_NetworkPort +# class. +# +# Date : 09-04-2008 + +import sys +import pywbem +from XenKvmLib import const +from XenKvmLib import devices +from XenKvmLib.vxml import KVMXML +from CimTest.Globals import log_param, logger +from CimTest.Globals import do_main +from CimTest.ReturnCodes import PASS, FAIL + +sup_types = ['KVM'] + +test_dom = "test_domain" +test_mac = "00:11:22:33:44:55" + +@do_main(sup_types) +def main(): + options = main.options + log_param() + const.KVM_default_net_type = 'user' + cxml = KVMXML(test_dom, mac = test_mac) + ret = cxml.define(options.ip) + if not ret: + logger.error('Unable to define domain %s' % test_dom) + return FAIL + + devid = "%s/%s" % (test_dom, test_mac) + key_list = { 'DeviceID' : devid, + 'CreationClassName' : "KVM_NetworkPort", + 'SystemName' : test_dom, + 'SystemCreationClassName' : "KVM_ComputerSystem" + } + + dev = None + try: + dev = devices.KVM_NetworkPort(options.ip, key_list) + except Exception, detail: + logger.error("Exception: %s" % detail) + cxml.undefine(options.ip) + return FAIL + + if dev == None: + logger.error("Error retrieving instance for devid %s" % devid) + cxml.undefine(options.ip) + return FAIL + + status = PASS + + addrs = dev.NetworkAddresses + if len(addrs) != 1: + logger.error("Too many NetworkAddress entries (%i instead of %i)" % \ + (len(addrs), 1)) + status = FAIL + + if addrs[0] != test_mac: + logger.error("MAC address reported incorrectly (%s instead of %s)" % \ + (addrs[0], test_mac)) + status = FAIL + + if status == FAIL: + logger.error("Checked interface %s" % test_mac) + + cxml.undefine(options.ip) + return status + +if __name__ == "__main__": + sys.exit(main())
participants (1)
-
Guo Lian Yun