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):
# system-exiting exceptions, e.g. KeyboardInterrupt
result = create_readable(
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))
raise
except:
......
......@@ -377,7 +377,12 @@ class DeployOperation(InstanceOperation):
self.instance.allocate_node()
# 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
if self.instance.state not in ['PAUSED']:
......@@ -452,6 +457,9 @@ class DestroyOperation(InstanceOperation):
required_perms = ()
resultant_state = 'DESTROYED'
def on_abort(self, activity, error):
activity.resultant_state = None
def _operation(self, activity, system):
# Destroy networks
with activity.sub_activity(
......@@ -1093,16 +1101,17 @@ class ResetNodeOperation(NodeOperation):
"You cannot reset a disabled or online node."), Exception())
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():
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,
readable_name=name):
i.redeploy(user=user)
self.node.enabled = False
self.node.schedule_enabled = False
self.node.save()
@register_operation
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