Create instance : standard use

How to list all instances ?

You can list all instances of your project by using

$ openstack server list

Cela permet notamment de résumer les informations des instances et de vérifier leur état (status), c’est-à-dire si elles sont actives (ACTIVE), en extinction (SHUTOFF), en état d’erreur (ERROR), etc.

The result allows, among other things, to check the state of project’s instances :

  • active - Status=ACTIVE,
  • under construction - Status=BUILD,
  • extinction - Status=SHUTOFF,
  • error state - Status=ERROR.
  • etc.

On an example.

$ openstack server list
+--------------------------------------+----------------+---------+---------------------------------------------+----------------------------+-----------+
| ID                                   | Name           | Status  | Networks                                    | Image                      | Flavor    |
+--------------------------------------+----------------+---------+---------------------------------------------+----------------------------+-----------+
| 94d7d331-2c8d-4494-b49f-6eb8d3398d5b | youpi4         | BUILD   |                                             |                            | m1.small  |
| 31ed9e4f-93e6-451f-b3d6-c84194c3a12f | youpi3         | PAUSED  | perseus2-int-net=192.168.0.5                |                            | m1.small  |
| 486ec418-2a71-454d-b488-f912ca768600 | youpi2         | ERROR   |                                             |                            | m1.small  |
| 1af59776-a42f-4acb-b58e-84ed5bbc66ca | youpi0         | ACTIVE  | perseus2-int-net=192.168.0.8, 129.88.195.94 | ubuntu-19.10-eoan-x86_64   | m1.medium |
| 793edd3d-1947-4dad-834e-794216d9d8f3 | youpi          | SHUTOFF | perseus2-int-net=192.168.0.11               | ubuntu-18.04-bionic-x86_64 | m1.small  |
| 8b0a16ad-4c8a-44ef-bea1-c724533352e8 | virtualmachine | ACTIVE  | perseus2-int-net=192.168.0.4, 129.88.195.91 |                            | m1.medium |
+--------------------------------------+----------------+---------+---------------------------------------------+----------------------------+-----------+

Instance youpi0 is active and functioning correctly (Status = ACTIVE).
Instance youpi is off (Status = SHUT OFF).
Instance youpi2 failed to build or launch correctly and is in an error state (Status = ERROR).
Instance youpi3 has been paused or suspended (Status = PAUSED).
Instance youpi4 is under construction (Status = BUILD).

How to create a new instance ?

To create a new instance, please specify source image, flavor, network, security group and which ssh key to use.

$ openstack server create \
    --image <image> \
    --flavor <flavor> \
    --network <network> \
    --security-group <security_group> \
    --key-name <RSA_key> \
    <instance_name>

Please, always use the project-int-net network to launch your instances !

On an example :

We want to create an instance named my-instance with following specifications :

  • image: ubuntu-18.04-bionic-x86_64
  • flavor: m1.small
  • network: project-int-net
  • security group: default
  • ssh key: my-key

Now, to build this instance, we execute the following command

$ openstack server create --image ubuntu-18.04-bionic-x86_64 --flavor m1.small --network project-int-net --security-group default --key-name my-key my-instance

Some images have the same name but are available in different formats.
To have no conflict to create the instance, use the Image ID and not its name: --image <IMAGE_ID>

Note that the source from which we build an instance is not necessarily an image.
It can be a snapshot or a bootable volume. But these cases will be treated later.