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

# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1207726653 25200 # Node ID e72f3a8d54c5f9e6b895f4930126acca1c97e380 # Parent 262153788503c8b10c76c77719bba081df9a7b88 [TEST] add KVM_default_net_type in const.py Signed-off-by: Guolian Yun <yunguol@cn.ibm.com> diff -r 262153788503 -r e72f3a8d54c5 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 00:37:33 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 1207726933 25200 # Node ID ca5633160e1cf78353d7b892a480f6fb5833e028 # Parent e72f3a8d54c5f9e6b895f4930126acca1c97e380 [TEST] add net_type setting in device node for KVM Signed-off-by: Guolian Yun <yunguol@cn.ibm.com> diff -r e72f3a8d54c5 -r ca5633160e1c suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Apr 09 00:37:33 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Apr 09 00:42:13 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_bridge(CIM_IP) def set_emulator(self, emu): return self._set_emulator(emu)

Guo Lian Yun wrote:
# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1207726933 25200 # Node ID ca5633160e1cf78353d7b892a480f6fb5833e028 # Parent e72f3a8d54c5f9e6b895f4930126acca1c97e380 [TEST] add net_type setting in device node for KVM
Signed-off-by: Guolian Yun <yunguol@cn.ibm.com>
diff -r e72f3a8d54c5 -r ca5633160e1c suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Apr 09 00:37:33 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Apr 09 00:42:13 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_bridge(CIM_IP)
I think we should make use of the set_vbridge() instead of set_bridge(). set_bridge() sets the first bridge available on the machine. This might not be useful in case there are more than one bridge that are available on the machine, and the virtual network present on the machine is not associated with the first bridge on the machine every time. Though the domain gets created with no problem, the tc which uses NetRASD will fail since it wont be able to associate with the virtual Network to which the domain belongs.
def set_emulator(self, emu): return self._set_emulator(emu)
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1207728133 25200 # Node ID 9fec39e06a000701e7f6f1393fcfdffc353498c3 # Parent ca5633160e1cf78353d7b892a480f6fb5833e028 [TEST] 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 ca5633160e1c -r 9fec39e06a00 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 01:02:13 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 = eval('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())

Guo Lian Yun wrote:
# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1207728133 25200 # Node ID 9fec39e06a000701e7f6f1393fcfdffc353498c3 # Parent ca5633160e1cf78353d7b892a480f6fb5833e028 [TEST] 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 ca5633160e1c -r 9fec39e06a00 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 01:02:13 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 = eval('devices.' + "KVM_NetworkPort")(options.ip, key_list) Because this test case is limited to KVM, how about: dev = devices.KVM_NetworkPort(options.ip, key_list) +1 for the rest of the patch.
+ 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())
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- - Zhengang

ZL> Because this test case is limited to KVM, how about: ZL> dev = devices.KVM_NetworkPort(options.ip, key_list) Agreed! -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com
participants (4)
-
Dan Smith
-
Deepti B Kalakeri
-
Guo Lian Yun
-
Zhengang Li