This post is aimed at giving you about How to Migrate an OpenStack Instance across compute nodes.
Case A. boot volume on ephemeral disk
STOPPED/SHUTDOWN/PAUSED instances: migration
Migration for ephemeral instances with status stopped/suspended/paused:
$ openstack server migrate <intance_uuid>
Alternatively you can use the Nova command for the migration:
$ nova migrate --poll <intance_uuid>
After the migration command it will be necessary confirm the resize:
$ openstack server resize confirm <instance_uuid>
or
$ nova resize-confirm <instance_uuid>
ACTIVE instances: live migration
If the instance is built on Ephemeral storage, live migration is possible with the following command:
$ openstack server migrate <instance_uuid> --live <compute_target_host> --block-migration
Alternatively you can use the Nova command for the migration:
$ nova live-migration --block-migrate <instance_uuid> <compute_target_host>
After the migration, make sure to check if the istance needs a resize confirmation.
Case B: boot volume on non-ephemeral (Ceph) disk
STOPPED/SHUTDOWN/PAUSED instances: migration
Migration for non-ephemeral instances with status stopped/suspended/paused:
$ openstack server migrate --wait <instance_uuid>
ACTIVE instances: live migration
If the instance is built on Ceph volume, execute:
$ openstack server migrate <instance_uuid> --live <compute_target_host>
If the previous command returns an error, you can try with --block-migration option:
$ openstack server migrate <instance_uuid> --live <compute_target_host> --block-migration
Alternatively you can use the Nova command for the migration:
$ nova live-migration <instance_uuid>
Obstacle Workaround
If the openstack server shows status is still migrating, execute the reset state command below [ignore if the instance status is already ACTIVE]
$ nova migration-list --instance-uuid <instance-uuid>
$ nova live-migration-abort <instance-uuid> <migration-id>
$ nova reset-state --active <instance-uuid>