Commit ffbca82d by Bach Dániel

Merge branch 'fix-operations' into 'master'

Fix operations 

See merge request !308
parents bd850078 dd1cb983
...@@ -69,7 +69,8 @@ def activitycontextimpl(act, on_abort=None, on_commit=None): ...@@ -69,7 +69,8 @@ def activitycontextimpl(act, on_abort=None, on_commit=None):
# system-exiting exceptions, e.g. KeyboardInterrupt # system-exiting exceptions, e.g. KeyboardInterrupt
result = create_readable( result = create_readable(
ugettext_noop("Failure."), ugettext_noop("Failure."),
ugettext_noop("Unhandled exception: %(error)s"), ugettext_noop("Unhandled exception: %(e)s: %(error)s"),
e=str(e.__class__.__name__),
error=get_error_msg(e)) error=get_error_msg(e))
raise raise
except: except:
......
...@@ -377,7 +377,12 @@ class DeployOperation(InstanceOperation): ...@@ -377,7 +377,12 @@ class DeployOperation(InstanceOperation):
self.instance.allocate_node() self.instance.allocate_node()
# Deploy virtual images # Deploy virtual images
self.instance._deploy_disks(parent_activity=activity) try:
self.instance._deploy_disks(parent_activity=activity)
except:
self.instance.yield_node()
self.instance.yield_vnc_port()
raise
# Deploy VM on remote machine # Deploy VM on remote machine
if self.instance.state not in ['PAUSED']: if self.instance.state not in ['PAUSED']:
...@@ -452,6 +457,9 @@ class DestroyOperation(InstanceOperation): ...@@ -452,6 +457,9 @@ class DestroyOperation(InstanceOperation):
required_perms = () required_perms = ()
resultant_state = 'DESTROYED' resultant_state = 'DESTROYED'
def on_abort(self, activity, error):
activity.resultant_state = None
def _operation(self, activity, system): def _operation(self, activity, system):
# Destroy networks # Destroy networks
with activity.sub_activity( with activity.sub_activity(
...@@ -1093,16 +1101,17 @@ class ResetNodeOperation(NodeOperation): ...@@ -1093,16 +1101,17 @@ class ResetNodeOperation(NodeOperation):
"You cannot reset a disabled or online node."), Exception()) "You cannot reset a disabled or online node."), Exception())
def _operation(self, activity, user): def _operation(self, activity, user):
if self.node.enabled:
DisableOperation(self.node).call(parent_activity=activity,
user=user)
for i in self.node.instance_set.all(): for i in self.node.instance_set.all():
name = create_readable(ugettext_noop( name = create_readable(ugettext_noop(
"migrate %(instance)s (%(pk)s)"), instance=i.name, pk=i.pk) "redeploy %(instance)s (%(pk)s)"), instance=i.name, pk=i.pk)
with activity.sub_activity('migrate_instance_%d' % i.pk, with activity.sub_activity('migrate_instance_%d' % i.pk,
readable_name=name): readable_name=name):
i.redeploy(user=user) i.redeploy(user=user)
self.node.enabled = False
self.node.schedule_enabled = False
self.node.save()
@register_operation @register_operation
class FlushOperation(NodeOperation): class FlushOperation(NodeOperation):
......
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