Launch an instance

After you configure the Compute services, you can launch an instance. An instance is a virtual machine that OpenStack provisions on a Compute servers. This example shows you how to launch a low-resource instance by using a downloaded image.

[Note]Note

This procedure assumes you have:

  1. Generate a keypair that consists of a private and public key to be able to launch instances on OpenStack. These keys are injected into the instances to make password-less SSH access to the instance. This depends on the way the necessary tools are bundled into the images. For more details, see the OpenStack Admin User Guide.

    $ ssh-keygen
    $ cd .ssh
    $ nova keypair-add --pub_key id_rsa.pub mykey

    You have just created the mykey keypair. The id_rsa private key is saved locally in ~/.ssh, which you can use to connect to an instance launched by using mykey as the keypair. To view available keypairs:

    $ nova keypair-list
    +--------+-------------------------------------------------+
    |  Name  |                   Fingerprint                   |
    +--------+-------------------------------------------------+
    | mykey  | b0:18:32:fa:4e:d4:3c:1b:c4:6c:dd:cb:53:29:13:82 |
    +--------+-------------------------------------------------+
  2. To launch an instance, you must specify the ID for the flavor you want to use for the instance. A flavor is a resource allocation profile. For example, it specifies how many virtual CPUs and how much RAM your instance gets. To see a list of the available profiles:

    $ nova flavor-list
    +----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
    | ID | Name      | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
    +----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
    | 1  | m1.tiny   | 512       | 1    | 0         |      | 1     | 1.0         | True      |
    | 2  | m1.small  | 2048      | 20   | 0         |      | 1     | 1.0         | True      |
    | 3  | m1.medium | 4096      | 40   | 0         |      | 2     | 1.0         | True      |
    | 4  | m1.large  | 8192      | 80   | 0         |      | 4     | 1.0         | True      |
    | 5  | m1.xlarge | 16384     | 160  | 0         |      | 8     | 1.0         | True      |
    +----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
  3. Get the ID of the image to use for the instance:

    $ nova image-list
    +--------------------------------------+--------------+--------+--------+
    | ID                                   | Name         | Status | Server |
    +--------------------------------------+--------------+--------+--------+
    | 9e5c2bee-0373-414c-b4af-b91b0246ad3b | CirrOS 0.3.1 | ACTIVE |        |
    +--------------------------------------+--------------+--------+--------+
  4. To use SSH and ping, you must configure security group rules. See the OpenStack User Guide.

    # nova secgroup-add-rule default tcp 22 22 0.0.0.0/0
    # nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0
  5. Launch the instance:

    $ nova boot --flavor flavorType --key_name keypairName --image ID newInstanceName 

    Create an instance by using flavor 1 or 2. For example:

    $ nova boot --flavor 1 --key_name mykey --image 9e5c2bee-0373-414c-b4af-b91b0246ad3b --security_group default cirrOS
    +--------------------------------------+--------------------------------------+
    | Property                             | Value                                |
    +--------------------------------------+--------------------------------------+
    | OS-EXT-STS:task_state                | scheduling                           |
    | image                                | CirrOS 0.3.1                         |
    | OS-EXT-STS:vm_state                  | building                             |
    | OS-EXT-SRV-ATTR:instance_name        | instance-00000001                    |
    | OS-SRV-USG:launched_at               | None                                 |
    | flavor                               | m1.tiny                              |
    | id                                   | 3bdf98a0-c767-4247-bf41-2d147e4aa043 |
    | security_groups                      | [{u'name': u'default'}]              |
    | user_id                              | 530166901fa24d1face95cda82cfae56     |
    | OS-DCF:diskConfig                    | MANUAL                               |
    | accessIPv4                           |                                      |
    | accessIPv6                           |                                      |
    | progress                             | 0                                    |
    | OS-EXT-STS:power_state               | 0                                    |
    | OS-EXT-AZ:availability_zone          | nova                                 |
    | config_drive                         |                                      |
    | status                               | BUILD                                |
    | updated                              | 2013-10-10T06:47:26Z                 |
    | hostId                               |                                      |
    | OS-EXT-SRV-ATTR:host                 | None                                 |
    | OS-SRV-USG:terminated_at             | None                                 |
    | key_name                             | mykey                                |
    | OS-EXT-SRV-ATTR:hypervisor_hostname  | None                                 |
    | name                                 | cirrOS                               |
    | adminPass                            | DWCDW6FnsKNq                         |
    | tenant_id                            | e66d97ac1b704897853412fc8450f7b9     |
    | created                              | 2013-10-10T06:47:23Z                 |
    | os-extended-volumes:volumes_attached | []                                   |
    | metadata                             | {}                                   |
    +--------------------------------------+--------------------------------------+
    [Note]Note

    If sufficient RAM is not available for the instance, Compute creates, but does not start, the instance and sets the status for the instance to ERROR.

  6. After the instance launches, use the nova list to view its status. The status changes from BUILD to ACTIVE:

    $ nova list
    +--------------------------------------+-----------+--------+------------+-------------+----------------+
    | ID                                   | Name      | Status | Task State | Power State | Networks       |
    +--------------------------------------+-----------+--------+------------+-------------+----------------+
    | dcc4a894-869b-479a-a24a-659eef7a54bd | cirrOS    | BUILD  | spawning   | NOSTATE     | vmnet=10.0.0.3 |
    +--------------------------------------+-----------+--------+------------+-------------+----------------+
    $ nova list
    +--------------------------------------+-----------+--------+------------+-------------+----------------+
    | ID                                   | Name      | Status | Task State | Power State | Networks       |
    +--------------------------------------+-----------+--------+------------+-------------+----------------+
    | dcc4a894-869b-479a-a24a-659eef7a54bd | cirrOS    | ACTIVE | None       | Running     | vmnet=10.0.0.3 |
    +--------------------------------------+-----------+--------+------------+-------------+----------------+
    
    [Note]Note

    To show details for a specified instance:

    $ nova show dcc4a894-869b-479a-a24a-659eef7a54bd
                 +--------------------------------------+----------------------------------------------------------+
    | Property                             | Value                                                    |
    +--------------------------------------+----------------------------------------------------------+
    | status                               | ACTIVE                                                   |
    | updated                              | 2013-10-16T21:55:24Z                                     |
    | OS-EXT-STS:task_state                | None                                                     |
    | OS-EXT-SRV-ATTR:host                 | compute-node                                             |
    | key_name                             | mykey                                                    |
    | image                                | cirros (918a1017-8a1b-41ff-8809-6106ba45366e)            |
    | vmnet network                        | 10.0.0.3                                                 |
    | hostId                               | 306d7c693911170ad4e5218f626f531cc68caa45f3a0f70f1aeba94d |
    | OS-EXT-STS:vm_state                  | active                                                   |
    | OS-EXT-SRV-ATTR:instance_name        | instance-0000000a                                        |
    | OS-SRV-USG:launched_at               | 2013-10-16T21:55:24.000000                               |
    | OS-EXT-SRV-ATTR:hypervisor_hostname  | compute-node                                             |
    | flavor                               | m1.tiny (1)                                              |
    | id                                   | dcc4a894-869b-479a-a24a-659eef7a54bd                     |
    | security_groups                      | [{u'name': u'default'}]                                  |
    | OS-SRV-USG:terminated_at             | None                                                     |
    | user_id                              | 887ac8736b5b473b9dc3c5430a88b15f                         |
    | name                                 | cirrOS                                                   |
    | created                              | 2013-10-16T21:54:52Z                                     |
    | tenant_id                            | 43ab520b2b484578bb6924c0ea926190                         |
    | OS-DCF:diskConfig                    | MANUAL                                                   |
    | metadata                             | {}                                                       |
    | os-extended-volumes:volumes_attached | []                                                       |
    | accessIPv4                           |                                                          |
    | accessIPv6                           |                                                          |
    | progress                             | 0                                                        |
    | OS-EXT-STS:power_state               | 1                                                        |
    | OS-EXT-AZ:availability_zone          | nova                                                     |
    | config_drive                         |                                                          |
    +--------------------------------------+----------------------------------------------------------+
  7. After the instance boots and initializes and you have configured security groups, you can ssh into the instance without a password by using the keypair you specified in the nova boot command. Use the nova list command to get the IP address for the instance. You do not need to specify the private key because it was stored in the default location, ~/.ssh/.id_rsa, for the ssh client.

    [Note]Note

    If using a CirrOS image to spawn an instance you must log in as the cirros, and not the root, user.

    You can also log in to the cirros account without an ssh key by using the cubswin:) password:

    $ ssh [email protected]
Log a bug against this page


loading table of contents...