openstack-manuals/doc/admin-guide-cloud/source/cli_nova_migrate.rst
Gudrun Wolfgram 08f0c4aa46 Cloud Admin Guide CLI chapter
Moving (copying) Admin User Guide CLI content to
the Cloud Admin Guide as a part of the reorganization
goal. This patch does not include any new or original
content.

This patch is Part 1 to create a new command-
line client section for Admin Users in the Cloud Admin
Guide, as disucssed in the User Guide Specialty team
meetings.

1) Creating a new CLI section with cli.rst

2) Moving the non common files from user-guide-admin to
admin-guide-cloud, along with their sub files. (Rename
user-guide-admin files to user cli_ prefix in admin-
guide-cloud.)
manage_projects_users_and_roles.rst
nova_cli_manage_projects_security.rst
cli_manage_services.rst
cli_manage_shares.rst
cli_manage_flavors.rst
cli_admin_manage_environment.rst
cli_set_quotas.rst
analyzing-log-files-with-swift-cli.rst
cli_cinder_scheduling.rst

3) Attempt updates to several links.

Change-Id: I97f4ced4f5033c7e0f3bf00c410288a75699d110
Implements: blueprint user-guides-reorganised
2016-03-07 15:51:49 -06:00

2.2 KiB

Migrate a single instance to another compute host

When you want to move an instance from one compute host to another, you can use the nova migrate command. The scheduler chooses the destination compute host based on its settings. This process does not assume that the instance has shared storage available on the target host.

  1. To list the VMs you want to migrate, run:

    $ nova list
  2. After selecting a VM from the list, run this command where VM_ID is set to the ID in the list returned in the previous step:

    $ nova show VM_ID
  3. Use the nova migrate command.

    $ nova migrate VM_ID
  4. To migrate an instance and watch the status, use this example script:

    #!/bin/bash
    
    # Provide usage
    usage() {
    echo "Usage: $0 VM_ID"
    exit 1
    }
    
    [[ $# -eq 0 ]] && usage
    
    # Migrate the VM to an alternate hypervisor
    echo -n "Migrating instance to alternate host"
    VM_ID=$1
    nova migrate $VM_ID
    VM_OUTPUT=`nova show $VM_ID`
    VM_STATUS=`echo "$VM_OUTPUT" | grep status | awk '{print $4}'`
    while [[ "$VM_STATUS" != "VERIFY_RESIZE" ]]; do
    echo -n "."
    sleep 2
    VM_OUTPUT=`nova show $VM_ID`
    VM_STATUS=`echo "$VM_OUTPUT" | grep status | awk '{print $4}'`
    done
    nova resize-confirm $VM_ID
    echo " instance migrated and resized."
    echo;
    
    # Show the details for the VM
    echo "Updated instance details:"
    nova show $VM_ID
    
    # Pause to allow users to examine VM details
    read -p "Pausing, press <enter> to exit."

Note

If you see this error, it means you are either trying the command with the wrong credentials, such as a non-admin user, or the policy.json file prevents migration for your user:

ERROR (Forbidden): Policy doesn't allow compute_extension:admin_actions:migrate to be performed. (HTTP 403)

The instance is booted from a new host, but preserves its configuration including its ID, name, any metadata, IP address, and other properties.