Commit 33827556 by Bach Dániel

vm: rollback shutdown_net if migrate_vm fails

fixes #156
parent a0a784e7
...@@ -202,6 +202,10 @@ class MigrateOperation(InstanceOperation): ...@@ -202,6 +202,10 @@ class MigrateOperation(InstanceOperation):
name = _("migrate") name = _("migrate")
description = _("Live migrate running VM to another node.") description = _("Live migrate running VM to another node.")
def rollback(self, activity):
with activity.sub_activity('rollback_net'):
self.instance.deploy_net()
def _operation(self, activity, to_node=None, timeout=120): def _operation(self, activity, to_node=None, timeout=120):
if not to_node: if not to_node:
with activity.sub_activity('scheduling') as sa: with activity.sub_activity('scheduling') as sa:
...@@ -212,8 +216,13 @@ class MigrateOperation(InstanceOperation): ...@@ -212,8 +216,13 @@ class MigrateOperation(InstanceOperation):
with activity.sub_activity('shutdown_net'): with activity.sub_activity('shutdown_net'):
self.instance.shutdown_net() self.instance.shutdown_net()
with activity.sub_activity('migrate_vm'): try:
self.instance.migrate_vm(to_node=to_node, timeout=timeout) with activity.sub_activity('migrate_vm'):
self.instance.migrate_vm(to_node=to_node, timeout=timeout)
except Exception as e:
if hasattr(e, 'libvirtError'):
self.rollback(activity)
raise
# Refresh node information # Refresh node information
self.instance.node = to_node self.instance.node = to_node
......
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