Commit 45e6d8fb authored by Benjamin Blanc's avatar Benjamin Blanc

testnode: add instance state getter

parent 9ea74ee8
...@@ -326,15 +326,18 @@ late a SlapOS (positive) answer." %(str(os.getpid()),str(os.getpid()),)) ...@@ -326,15 +326,18 @@ late a SlapOS (positive) answer." %(str(os.getpid()),str(os.getpid()),))
count = 0 count = 0
for configuration in configuration_list: for configuration in configuration_list:
# Stop instance # Stop instance
self.log("Instance state: %s", self.slapos_controler.getInstanceState(self.instance_title))
self.slapos_controler.stopInstance(self.instance_title) self.slapos_controler.stopInstance(self.instance_title)
self.log("Waiting for instance stop..") self.log("Waiting for instance stop..")
self._waitInstance(self.instance_title) self._waitInstance(self.instance_title)
# Update instance XML configuration # Update instance XML configuration
self.log("Instance state: %s", self.slapos_controler.getInstanceState(self.instance_title))
self._updateInstanceXML(configuration, self.instance_title, self._updateInstanceXML(configuration, self.instance_title,
node_test_suite.test_result, node_test_suite.test_suite) node_test_suite.test_result, node_test_suite.test_suite)
self.log("Waiting for XML updating instance ready..") self.log("Waiting for XML updating instance ready..")
self._waitInstance(self.instance_title) self._waitInstance(self.instance_title)
# Start instance # Start instance
self.log("Instance state: %s", self.slapos_controler.getInstanceState(self.instance_title))
self.slapos_controler.startInstance(self.instance_title) self.slapos_controler.startInstance(self.instance_title)
self.log("Waiting for instance start..") self.log("Waiting for instance start..")
self._waitInstance(self.instance_title) self._waitInstance(self.instance_title)
......
...@@ -135,6 +135,13 @@ class SlapOSControler(object): ...@@ -135,6 +135,13 @@ class SlapOSControler(object):
except: except:
raise ValueError("Instance '%s' not exist" %self.instance_config[reference]) raise ValueError("Instance '%s' not exist" %self.instance_config[reference])
def getInstanceState(self, reference):
try:
return self.instance_config[reference]['partition'].getState()
except:
raise ValueError("Impossible to get the instance state, instance "
"'%s' may not exist" %self.instance_config[reference])
def request(self, reference, software_url, software_type=None, def request(self, reference, software_url, software_type=None,
software_configuration=None, computer_guid=None, state='started'): software_configuration=None, computer_guid=None, state='started'):
""" """
...@@ -154,7 +161,8 @@ class SlapOSControler(object): ...@@ -154,7 +161,8 @@ class SlapOSControler(object):
'software_configuration':software_configuration, 'software_configuration':software_configuration,
'computer_guid':computer_guid, 'computer_guid':computer_guid,
'software_url':software_url, 'software_url':software_url,
'requested_state':state 'requested_state':state,
'partition':None
} }
self.instance_config[reference] = current_intance_config self.instance_config[reference] = current_intance_config
...@@ -176,6 +184,7 @@ class SlapOSControler(object): ...@@ -176,6 +184,7 @@ class SlapOSControler(object):
software_type = software_type, software_type = software_type,
filter_kw = filter_kw, filter_kw = filter_kw,
state = state) state = state)
self.instance_config[reference]['partition'] = partition
# print "Instance requested.\nState is : %s." % partition.getState() # print "Instance requested.\nState is : %s." % partition.getState()
# Is it possible to have the true state of the instance with getState() ? # Is it possible to have the true state of the instance with getState() ?
# Do a return partition ? # Do a return partition ?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment