Commit 1432dc3d authored by Antoine Millet's avatar Antoine Millet
Browse files

Update hot migration job with latest cc-node api.

parent f38c8483
Loading
Loading
Loading
Loading
+24 −6
Original line number Diff line number Diff line
@@ -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)
@@ -505,11 +505,26 @@ class HotMigrationJob(BaseMigrationJob):
            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)