Skip to content

Create / Delete

Creating instances needs a combination of:

  • An image from which the instance should be created
  • A flavor defining the size of the instance
  • A keypair to define the authentication for logging in as administrator
  • Optionally, you can also supply contextualisation to customise the instance contents after creation (See cloud-init)

Simple instance creation

openstack server create --key-name mykeypair --flavor a2-ram4-disk20 --network ext-net1 --image "Debian 11 bullseye" my-instance-name
$ openstack server show my-instance-name
+-----------------------------+------------------------------------------------------------------------+
| Field                       | Value                                                                  |
+-----------------------------+------------------------------------------------------------------------+
| OS-DCF:diskConfig           | MANUAL                                                                 |
| OS-EXT-AZ:availability_zone | b4                                                                     |
| OS-EXT-STS:power_state      | Running                                                                |
| OS-EXT-STS:task_state       | None                                                                   |
| OS-EXT-STS:vm_state         | active                                                                 |
| OS-SRV-USG:launched_at      | 2021-03-01T09:51:00.000000                                             |
| OS-SRV-USG:terminated_at    | None                                                                   |
| accessIPv4                  |                                                                        |
| accessIPv6                  |                                                                        |
| addresses                   | ext-net1=2001:1600:115:1::14e, 195.15.241.108                          |
| config_drive                |                                                                        |
| created                     | 2021-03-01T09:50:38Z                                                   |
| flavor                      | a2-ram4-disk20 (2655c1e3-a43a-4dea-a957-650517e8fa72)                |
| hostId                      | 4f05eec8d5205bc49371dac73832b37b0b07c043caba0d8bcb90cfcf               |
| id                          | e02bdb90-6fd2-41c3-a81f-95e1f2e39e11                                   |
| image                       | Debian 11 bullseye                                                |
| key_name                    | mykeypair                                                              |
| name                        | my-instance-name                                                       |
| progress                    | 0                                                                      |
| project_id                  | ac4fafd60021431585bbb23470119557                                       |
| properties                  |                                                                        |
| security_groups             | name='default'                                                         |
| status                      | ACTIVE                                                                 |
| updated                     | 2021-03-01T09:51:00Z                                                   |
| user_id                     | b1580497f51e4d10b9110c60c154562c                                       |
| volumes_attached            |                                                                        |
+-----------------------------+------------------------------------------------------------------------+

d_i_1.png

Errors

The following error messages can be produced by the commands for instance creation.

Error Description
ERROR: You must provide a username via either --os_username or env[OS_USERNAME] The openrc file was not sourced correctly. Follow the procedures "setting up your environnement"
ERROR: openstack Authentication type must be selected with --os-auth-type As above
ERROR: Invalid OpenStack Nova credentials. Check the password of the openrc file is sourced.
ERROR: Quota exceeded for cores: The project you are running in has now reached its maximum number of compute cores. Please review the usage of the project and if required, raise a support request for further resources. Personal project quotas are fixed.
ERROR: Invalid key_name provided. The argument to the key-name parameter was incorrect. Do not add the .pem extension for the file name.
Error: Instance type's disk is too small for requested image. (HTTP 400) The flavor chosen has a disk which is not big enough for the image requested. Select a larger flavor and try again.
ERROR: [Errno 1] _ssl.c:492: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed The certificate settings were incorrect. The variable OS_CACERT should not be set in the environment (unset OS_CACERT; export OS_CACERT to clear it).If the problem persists, rise a ticket
ERROR: [Errno 8] _ssl.c:492: EOF occurred in violation of protocol As above
ERROR: Instance name is not a valid hostname The server name will be used as the DNS entry for the instance. The server name provided is not a valid name for a TCP/IP hostname. Underscores and other special characters are not permitted in hostnames.
ERROR: cliff.app The resource could not be found. (HTTP 404) Check the environment variables set in your profile. This error message can appear if you do not have the OS_IDENTITY_API_VERSION variable set correctly.
ERROR: 'NoneType' object has no attribute 'rstrip' The Kerberos and X.509 endpoints aren't supported
The requested availability zone is not available The --availability-zone parameter is not set correctly. Check the list of available zones.

Instance Error Status

There are scenarios where the openstack server create command is accepted but there is an error in the actual creation of the instance. These errors are given in the output of the openstack server show command.

Fault Message Description
fault
NoValidHost A hypervisor could not be found where the request could be placed. There may be different reasons for this, please raise a ticket if needed.
Invalid hostname. The hostname used is not a valid DNS name. An alternative server name should be chosen.

Instance deletion

Instances can be deleted using either the OpenStack dashboard or via the openstack server delete command.

Delete instance

Warning

This will immediately terminate the instance, delete all content of the instance and erase the disk. This operation is not recoverable. There are other options available if you wish to keep the instance for future usage. These do, however, continue to use quota for the project even though the instance is not running.

  • Suspend the instance which saves the state of the instance to disk so it could be restarted later
  • Snapshot the instance to keep an offline copy of the instance

If, however, the instance is no longer required and no data on the associated system or ephemeral disk needs to be preserved, the following command can be run:

$ openstack server delete my-instance-name

The quota associated with this instance will be returned to the project within an hour. If the quota does not return, please raise a ticket.