From 1432dc3dd9ccf02fe111f2b2c11e4efd802afac3 Mon Sep 17 00:00:00 2001 From: Antoine Millet Date: Fri, 27 May 2011 13:44:25 +0200 Subject: [PATCH] Update hot migration job with latest cc-node api. --- ccserver/jobs.py | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/ccserver/jobs.py b/ccserver/jobs.py index a9b5e26..7863d03 100644 --- a/ccserver/jobs.py +++ b/ccserver/jobs.py @@ -459,7 +459,7 @@ class HotMigrationJob(BaseMigrationJob): # Update the VM object: try: self.manager.server.objects.update(ids=(vm_id,)) - vm = self.manager.server.objects.get_by_id(vm_id) + vm = self.manager.server.objects.get_by_id(vm_id).to_dict(None) except UnknownObjectError: raise JobCancelError('Source VM not found') @@ -493,7 +493,7 @@ class HotMigrationJob(BaseMigrationJob): for disk in disks: to_cleanup += self._sync_disk(vm, disk, source, dest) - #... + # Libvirt tunnel setup: tunres_src = source.proxy.tun_setup() def rb_tun_src(): source.proxy.tun_destroy(tunres_src) @@ -503,13 +503,28 @@ class HotMigrationJob(BaseMigrationJob): def rb_tun_dst(): dest.proxy.tun_destroy(tunres_dst) self.checkpoint(rb_tun_dst) - + source.proxy.tun_connect(tunres_src, tunres_dst, dest.get_ip()) - dest.proxy.tun_connect_hv(tunres_dst, migration=True) + dest.proxy.tun_connect_hv(tunres_dst, migration=False) + + # Migration tunnel setup: + migtunres_src = source.proxy.tun_setup() + def rb_migtun_src(): + source.proxy.tun_destroy(migtunres_src) + self.checkpoint(rb_migtun_src) + + migtunres_dst = dest.proxy.tun_setup(local=False) + def rb_migtun_dst(): + dest.proxy.tun_destroy(migtunres_dst) + self.checkpoint(rb_migtun_dst) + + source.proxy.tun_connect(migtunres_src, migtunres_dst, dest.get_ip()) + dest.proxy.tun_connect_hv(migtunres_dst, migration=True) # Initiate the live migration: self.report('migration in progress') - source.proxy.vm_migrate_tunneled(self['vm_name'], tunres_src) + source.proxy.vm_migrate_tunneled(self['vm_name'], tunres_src, + migtunres_src) # At this point, if operation is a success, all we need is just to # cleanup source hypervisor from disk and vm. This operation *CAN'T* @@ -525,6 +540,8 @@ class HotMigrationJob(BaseMigrationJob): source.proxy.tun_destroy(tunres_src) dest.proxy.tun_destroy(tunres_dst) + source.proxy.tun_destroy(migtunres_src) + dest.proxy.tun_destroy(migtunres_dst) for cb_cleanup in reversed(to_cleanup): cb_cleanup() @@ -598,7 +615,8 @@ class HotMigrationJob(BaseMigrationJob): self.report(status_msg % 'sync %s%%' % status['completion']) time.sleep(2) - self.report(status_msg % 'setting both side as primary') + dest.proxy.drbd_role(res_dst, True) + source.proxy.drbd_takeover(res_src, True) def rb_takeover_src(): source.proxy.drbd_takeover(res_src, False) -- GitLab