+1 from me =)
Best,
Regards
Daisy (运国莲)
VSM Team, China Systems & Technology Labs (CSTL)
E-mail: yunguol(a)cn.ibm.com
TEL: (86)-21-60922403
Building 10, 399 Ke Yuan Rd, Pudong Shanghai, 201203
Kaitlin Rupert <kaitlin(a)linux.vnet.ibm.com>
Sent by: libvirt-cim-bounces(a)redhat.com
2008-07-22 08:34
Please respond to
List for discussion and development of libvirt CIM
<libvirt-cim(a)redhat.com>
To
libvirt-cim(a)redhat.com
cc
Subject
[Libvirt-cim] [PATCH 2 of 2] [TEST] Add VSMS 10_referenced_config.py
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1216686405 25200
# Node ID c2c0ac1f88c47405a0326dc7d019bbf931870dec
# Parent e14f791f1cb4f84ed3cad03c9099d336e232fb48
[TEST] Add VSMS 10_referenced_config.py.
This test creates a guest using default RASDS. Then another guest is
defined using a reference of the first guest an the value for the
ReferencedConfiguration parameter. This second guest is created with an
additional network interface.
The test verifies that the second guest is defined properly. It also
verifies that the second guest has 2 network interfaces: one with a mac
address that matches that of the first guest and one with a different mac
address.
This test current fails on LXC because the test suite doesn't pass a
console device to the DefineSystem(). Will fix this in a follow up patch.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r e14f791f1cb4 -r c2c0ac1f88c4
suites/libvirt-cim/cimtest/VirtualSystemManagementService/10_referenced_config.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++
b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/10_referenced_config.py
Mon Jul 21 17:26:45 2008 -0700
@@ -0,0 +1,169 @@
+#!/usr/bin/python
+#
+# Copyright 2008 IBM Corp.
+#
+# Authors:
+# Kaitlin Rupert <karupert(a)us.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 sys
+import pywbem
+from XenKvmLib.common_util import create_using_definesystem, \
+ call_request_state_change, \
+ poll_for_state_change
+from XenKvmLib import vsms
+from VirtLib import utils
+from CimTest.Globals import logger, do_main
+from CimTest.ReturnCodes import FAIL, PASS
+from XenKvmLib.test_doms import destroy_and_undefine_domain
+from XenKvmLib.classes import get_typed_class
+from XenKvmLib import computersystem
+
+sup_types = ['Xen', 'XenFV', 'KVM', 'LXC']
+test_dom = 'rstest_domain'
+test_dom2 = 'rstest_domain2'
+
+mac = "aa:aa:aa:00:00:00"
+
+REQUESTED_STATE = 2
+TIME = "00000000000000.000000:000"
+
+def setup_first_guest(ip, virt):
+ status = create_using_definesystem(test_dom, ip, virt=virt)
+ if status != PASS:
+ logger.error("Unable to define %s using DefineSystem()" %
test_dom)
+ return FAIL
+
+ rc = call_request_state_change(test_dom, ip, REQUESTED_STATE, TIME,
virt)
+ if rc != 0:
+ logger.error("Unable to start %s" % test_dom)
+ return FAIL
+
+ status = poll_for_state_change(ip, virt, test_dom, REQUESTED_STATE)
+ if status != PASS:
+ logger.error("%s didn't change state as expected" % test_dom)
+ return FAIL
+
+ return PASS
+
+def get_ref(ip, virt):
+ cs_ref = None
+
+ cs = computersystem.enumerate_names(ip, virt)
+ if len(cs) < 1:
+ logger.error("ComputerSystem EnumerateNames() returned no
instances")
+ return cs_ref
+
+ for ref in cs:
+ for item in ref.items():
+ prop, val = item
+ if prop == "Name" and val == test_dom:
+ cs_ref = ref
+
+ return cs_ref
+
+def get_vssd_rasd(virt):
+ vssd, def_rasd = vsms.default_vssd_rasd_str(dom_name=test_dom2,
+ net_type='network',
+ net_mac=mac, virt=virt)
+
+ rasd = []
+ for inst in def_rasd:
+ cn = get_typed_class(virt, "NetResourceAllocationSettingData")
+ if cn in inst:
+ rasd.append(inst)
+
+ params = {}
+
+ if len(rasd) != 1:
+ return params
+
+ params['vssd'] = vssd
+ params['rasd'] = rasd
+
+ return params
+
+def get_dom_macs(server, dom, virt):
+ mac_list = []
+
+ cmd = "virsh -c %s dumpxml %s | grep mac" % (utils.virt2uri(virt),
dom)
+ ret, out = utils.run_remote(server, cmd)
+ if ret != 0:
+ return mac_list
+
+ lines = out.splitlines()
+ for l in lines:
+ mac = l.split('=')[1]
+ mac = mac.lstrip('\'')
+ mac = mac.rstrip('\'/>')
+ mac_list.append(mac)
+
+ return mac_list
+
+@do_main(sup_types)
+def main():
+ options = main.options
+
+ try:
+ status = setup_first_guest(options.ip, options.virt)
+ if status != PASS:
+ raise Exception("Unable to start %s" % test_dom)
+
+ ref = get_ref(options.ip, options.virt)
+ if ref is None:
+ raise Exception("Unable to get %s reference" % test_dom)
+
+ define_params = get_vssd_rasd(options.virt)
+ if len(define_params) != 2:
+ raise Exception("Unable to build VSSD and RASD instances for
%s" % \
+ test_dom2)
+
+ status = create_using_definesystem(test_dom2, options.ip,
+ params=define_params,
ref_config=ref,
+ virt=options.virt)
+ if status != PASS:
+ raise Exception("Unable to define %s" % test_dom2)
+
+ dom1_mac_list = get_dom_macs(options.ip, test_dom, options.virt)
+ if len(dom1_mac_list) != 1:
+ raise Exception("%s has %d macs, expected 1" % (test_dom,
+ len(dom1_mac_list)))
+
+ dom2_mac_list = get_dom_macs(options.ip, test_dom2, options.virt)
+ if len(dom2_mac_list) != 2:
+ raise Exception("%s has %d macs, expected 1" % (test_dom2,
+ len(dom2_mac_list)))
+
+ for item in dom2_mac_list:
+ if item != mac and item != dom1_mac_list[0]:
+ raise Exception("%s has unexpected mac value, exp: %s %s"
% \
+ (item, mac, dom1_mac_list[0]))
+
+ status = PASS
+
+ except Exception, details:
+ logger.error(details)
+ status = FAIL
+
+ destroy_and_undefine_domain(test_dom, options.ip, options.virt)
+ destroy_and_undefine_domain(test_dom2, options.ip, options.virt)
+
+ return status
+
+if __name__ == "__main__":
+ sys.exit(main())
+
_______________________________________________
Libvirt-cim mailing list
Libvirt-cim(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-cim