Commit a393864c authored by Antoine Millet's avatar Antoine Millet

Implemented start, stop, suspend and resume client handler methods using _vm_action private method.

parent 1bad4c94
......@@ -115,6 +115,34 @@ class ClientHandler(OnlineCCHandler):
logging.debug('Executed list function with query %s' % query)
return self._list(query)
def _vm_action(self, query, method, *args, **kwargs):
query += '&vm'
vms = self._list(query)
hypervisors = list(self._server.iterrole('hypervisor'))
for hv in hypervisors:
vm_to_start = [vm['vm'] for vm in vms if vm['hv'] == hv.login]
if vm_to_start:, vm_to_start, *args, **kwargs)
def start(self, query):
self._vm_action(query, 'start_vm')
def stop(self, query, force=False):
self._vm_action(query, 'stop_vm', force)
def suspend(self, query):
self._vm_action(query, 'suspend_vm')
def resume(self, query):
self._vm_action(query, 'resume_vm')
class AuthenticationError(Exception):
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