docs: def migrate(cls, resource, background=False, finalize=False):
          """ Migrate a virtual machine to another datacenter. """
          vm_id = cls.usable_id(resource)
          if finalize:
              verb = 'Finalizing'
              result = cls.call('hosting.vm.migrate', vm_id, True)
          else:
              verb = 'Starting'
              result = cls.call('hosting.vm.migrate', vm_id, False)
  
          dcs = {}
          for dc in Datacenter.list():
              dcs[dc['id']] = dc['dc_code']
  
          oper = cls.call('operation.info', result['id'])
          dc_from = dcs[oper['params']['from_dc_id']]
          dc_to = dcs[oper['params']['to_dc_id']]
          migration_msg = ('* %s the migration of VM %s '
                           'from datacenter %s to %s'
                           % (verb, resource, dc_from, dc_to))
          cls.echo(migration_msg)
  
          if background:
              return result
  
          cls.echo('VM migration in progress.')
          cls.display_progress(result)
          cls.echo('Your VM %s has been migrated.' % resource)
          return result