Commit d90e9949 by Szabolcs Gelencser

Implement basic operations

parent 896412ac
......@@ -319,8 +319,8 @@ class DestroyOperation(InstanceOperation):
resultant_state = 'DESTROYED'
os_policy_actions = (("compute", "compute:delete"),)
def _operation(self, activity, system):
pass
def _operation(self, request):
openstack_api.nova.server_delete(request, self.instance.id)
@register_operation
......@@ -392,8 +392,8 @@ class RebootOperation(InstanceOperation):
accept_states = ('ACTIVE',)
os_policy_actions = (("compute", "compute:reboot"),)
def _operation(self, activity):
pass
def _operation(self, request):
openstack_api.nova.server_reboot(request, self.instance.id)
@register_operation
......@@ -619,18 +619,8 @@ class SleepOperation(InstanceOperation):
accept_states = ('ACTIVE',)
os_policy_actions = (("compute", "compute:suspend"),)
def is_preferred(self):
return (not self.instance.is_base and
self.instance.status == self.instance.STATUS.RUNNING)
def on_abort(self, activity, error):
if isinstance(error, TimeLimitExceeded):
activity.resultant_state = None
else:
activity.resultant_state = 'ERROR'
def _operation(self, activity, system):
pass
def _operation(self, request):
openstack_api.nova.server_suspend(request, self.instance.id)
@register_operation
......@@ -653,8 +643,8 @@ class WakeUpOperation(InstanceOperation):
else:
activity.resultant_state = 'ERROR'
def _operation(self, activity):
pass
def _operation(self, request):
openstack_api.nova.server_resume(request, self.instance.id)
@register_operation
......
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 sign in to comment