Launching instances on specific Compute hosts

When an instance is launched, in most cases, the scheduler determines which host will run it. There are times, however, when it is good to be able to directly assign an instance to a host, for example, when helping to troubleshoot or perhaps when the orchestration is managing resource allocation.

Getting ready

Ensure you are logged in to an Ubuntu host that has access to our OpenStack environment on the 192.168.100.0/24 public network. This host will be used to run client tools against the OpenStack environment created. If you are using the accompanying Vagrant environment, as described in the Preface, you can use the controller node. This node has the python-novaclient package that provides the nova command-line client.

If you created this node with Vagrant, you can execute the following command:

vagrant ssh controller 

Ensure that you have set the following credentials (adjust the path to your certificates and key file to match your environment if not using the Vagrant environment):

export OS_TENANT_NAME=cookbook
export OS_USERNAME=admin
export OS_PASSWORD=openstack
export OS_AUTH_URL=https://192.168.100.200:5000/v2.0/
export OS_NO_CACHE=1
export OS_KEY=/vagrant/cakey.pem
export OS_CACERT=/vagrant/ca.pem

How to do it...

  1. To launch an instance onto a specific host, we use the following syntax:
    nova boot 
        --flavor $FLAVOR 
        --image $IMAGE 
        --availability-zone nova:$HYPERVISOR_NAME 
        $INSTANCE_NAME
    

    The name of the $HYPERVISOR_NAME comes from nova hypervisor-list. We use the complete hypervisor name as shown.

  2. To launch an instance called myInstance onto compute-02, issue the following command:
    nova hypervisor-list
    

    This will give you the following output:

    +----+----------------------+
    | ID | Hypervisor hostname  |
    +----+----------------------+
    | 1  | compute-01.cook.book |
    | 2  | compute-02.cook.book |
    +----+----------------------+
    
  3. We then boot this onto compute-02 using the following commands:
    nova boot 
        --flavor 1 
        --image trusty-image 
        --availability-zone nova:compute-02.cook.book 
        myInstance
    

    Tip

    Note that OpenStack can successfully launch an instance to a specific host only if there are enough cores and RAM available, as well as still satisfying quota counts. You will be presented with an error saying no more hosts available if the resources are not available.

How it works...

To launch an instance onto a specific compute host, we use the following flag to our nova boot command line:

--availability-zone nova:$HYPERVISOR_NAME

The name of the hypervisor can be obtained using the following command:

nova hypervisor-list

The preceding command lists the Compute hosts available in our environment.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset