Deepti B. Kalakeri wrote:
# HG changeset patch
# User Deepti B. Kalakeri<deeptik(a)linux.vnet.ibm.com
# Date 1227103041 28800
# Node ID 6b81367e87d574d3352f2752a4d303ff155367fd
# Parent 78b18dc8cbfccff5b50c8c7228ca3a7396facc61
[TEST] #2 Adding cim_state_change() to VirtCIM class of vxml.
Changes:
--------
Updates from Patch 1 to 2:
--------------------------
Removed the get_cs_instance() fn.
Declared VS states and TIME values in const.py.
Added cim_start(), cim_reboot(), cim_pause(), cim_suspend() fn's.
Patch 1:
--------
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.
Right now the cim_state_change() just returns the the status, Can modify to return the
domain if req.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 78b18dc8cbfc -r 6b81367e87d5
suites/libvirt-cim/cimtest/ComputerSystem/05_activate_defined_start.py
-# Success:
-# if
-# From state == 3
-# To state == 2
-# Enabled_state == RequestedState
+ # Success:
+ # if
+ # From state == 3
+ # To state == 2
+ # Enabled_state == RequestedState
Since the test doesn't really specify the requested state values by
number, I'd remove this comment or update it to make it more meaningful.
Something like: From state == defined To state == running or something
similar.
diff -r 78b18dc8cbfc -r 6b81367e87d5
suites/libvirt-cim/lib/XenKvmLib/const.py
--- a/suites/libvirt-cim/lib/XenKvmLib/const.py Thu Nov 13 21:42:27 2008 -0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/const.py Wed Nov 19 05:57:21 2008 -0800
@@ -30,6 +30,16 @@ platform_sup = ["Xen", "KVM", "XenFV"]
platform_sup = ["Xen", "KVM", "XenFV"]
VIRSH_ERROR_DEFINE = "Failed to define a domain with the name %s from virsh"
+
+#CIM values for VS State transitions
+CIM_START = 2
+CIM_DEFINE = 3
+CIM_SUSPEND = 6
+CIM_PAUSE = 9
+CIM_REBOOT = 10
+
The supported CIM states are:
CIM_STATE_ENABLED = 2,
CIM_STATE_DISABLED = 3,
CIM_STATE_SHUTDOWN = 4,
CIM_STATE_NOCHANGE = 5,
CIM_STATE_SUSPENDED = 6,
CIM_STATE_PAUSED = 9,
CIM_STATE_REBOOT = 10,
CIM_STATE_RESET = 11,
You'll should update the list with those that are missing.
We don't currently support NOCHANGE or SUSPENDED, but all others are.
+# Default TimeoutPeriod param for CS.RequestedStateChange()
+TIME = "00000000000000.000000:000"
# vxml.NetXML
default_bridge_name = 'testbridge'
Nice - I like having all of these defined in one place. Good idea. =)
diff -r 78b18dc8cbfc -r 6b81367e87d5
suites/libvirt-cim/lib/XenKvmLib/vxml.py
+
+ def cim_start(self, server, virt, domain_name,
+ req_time=const.TIME, poll_time=30):
+ return self.cim_state_change(server, virt, domain_name,
+ const.CIM_START, req_time, poll_time)
+
+ def cim_pause(self, server, virt, domain_name,
+ req_time=const.TIME, poll_time=30):
+ return self.cim_state_change(server, virt, domain_name,
+ const.CIM_PAUSE, req_time, poll_time)
+
+ def cim_reboot(self, server, virt, domain_name,
+ req_time=const.TIME, poll_time=30):
+ return self.cim_state_change(server, virt, domain_name,
+ const.CIM_REBOOT, req_time, poll_time)
+
+ def cim_suspend(self, server, virt, domain_name,
+ req_time=const.TIME, poll_time=30):
+ return self.cim_state_change(server, virt, domain_name,
+ const.CIM_SUSPEND, req_time, poll_time)
+
+
Can you also add cim_shutdown(), cim_disable(), cim_no_state_change(),
and cim_reset()?
This looks really good - thanks Deepti!
--
Kaitlin Rupert
IBM Linux Technology Center
kaitlin(a)linux.vnet.ibm.com