Deepti B. Kalakeri wrote:
# HG changeset patch
# User Deepti B. Kalakeri<deeptik(a)linux.vnet.ibm.com
# Date 1227012098 28800
# Node ID 588efe005eaaf7f56218e844b84bd63e347d0dc0
# Parent ac693577d27b1b5f24fdc6c50272b11d02c91c7f
[TEST] Adding cim_state_change() to VirtCIM class of vxml.
cim_state_change() fn can be used to start/reboot/suspend the domain.
The function verifies that the state of the domain is changed by calling
poll_for_state_change().
Included poll_for_state_change(), .get_cs_instance() fn in the vxml since including it
from common_util
was causing a circular chain and was failing.
Once tests are updated to use cim_state_change(), get_cs_instance() and
poll_for_state_change() will need to be removed from common_util.py to
prevent collisions (since the functions have the same names).
-#Get the value of the EnabledState property and RequestedState property.
try:
+ #Change the state of the VS to Start
+ status = cxml.cim_state_change(options.ip, options.virt, test_dom,
+ REQUESTED_STATE, TIME)
Instead of passing in the requested state, I would make a set of
functions (cim_start(), cim_reboot(), etc). This way, the test cases
don't have to be concerned with the appropriate requested state value.
Also, if the values ever change, they can be changed in one place.
diff -r ac693577d27b -r 588efe005eaa
suites/libvirt-cim/lib/XenKvmLib/vxml.py
+
class XMLClass:
xml_string = ""
@@ -524,6 +527,81 @@ class VirtCIM:
return False
return ret[0] == 0
+ def get_cs_instance(self, server, virt, domain_name, cs_class, keys):
I don't think there's a need for this function. In
poll_for_state_change(), you do something similar to get the instance..
I think this can be handled in a similar manner in cim_state_change().
+
+ def cim_state_change(self, server, virt, domain_name, rs, time,
+ poll_timeout=30):
I would make time an optional value. In most cases, the test case won't
need to set it. Also, I'd rename the value to something other than
time, because there is a python module of the same name (which might
cause some conflicts).
+
+ cs_class = get_typed_class(virt, 'ComputerSystem')
+ keys = { 'Name' : domain_name, 'CreationClassName' : cs_class }
+
+ status, cs = self.get_cs_instance(server, virt, domain_name,
+ cs_class, keys)
Replace this - just call GetInstance() directly here.
--
Kaitlin Rupert
IBM Linux Technology Center
kaitlin(a)linux.vnet.ibm.com