Skip to content

Create a virtual machine

Pre-requisities

  • Subscribe to cloud service
  • Download your openstack profile

List images

An OpenStack image is used to define the operating system for a virtual machine. The images available can be listed using

$ openstack image list
+--------------------------------------+-----------------------------------------------+--------+
| ID                                   | Name                                          | Status |
+--------------------------------------+-----------------------------------------------+--------+
| cc526ba5-37db-4e2c-9497-2044f3b71e5d | CS8 - x86_64 [2021-11-01]                     | active |
| 214e130a-aecb-485a-89cb-3b6b85fd87b0 | CC7 - x86_64 [2021-11-01]                     | active |
| 61eef33f-f27c-46ad-b71f-519e58fbee22 | Windows 10 Professional                       | active |
...

The CentOS Stream 8 image CS8 will be used for the next steps in the tutorial.

Creating your first VM

With the image ID from above, you can create a new VM:

$ openstack server create --key-name my-key --flavor m2.small --image "CS8 - x86_64 [2021-11-01]" my-vm
+-----------------------------+-------------------------------------------------------------------+
| Field                       | Value                                                             |
+-----------------------------+-------------------------------------------------------------------+
| OS-DCF:diskConfig           | MANUAL                                                            |
| OS-EXT-AZ:availability_zone |                                                                   |
| OS-EXT-STS:power_state      | NOSTATE                                                           |
| OS-EXT-STS:task_state       | scheduling                                                        |
| OS-EXT-STS:vm_state         | building                                                          |
| OS-SRV-USG:launched_at      | None                                                              |
| OS-SRV-USG:terminated_at    | None                                                              |
| accessIPv4                  |                                                                   |
| accessIPv6                  |                                                                   |
| addresses                   |                                                                   |
| config_drive                |                                                                   |
| created                     | 2020-11-28T14:14:44Z                                              |
| flavor                      | m2.small (17895)                                                  |
| hostId                      |                                                                   |
| id                          | ce30ke9e-9f50-47b1-a9c5-0fcced31ae56                              |
| image                       | CS8 - x86_64 [2021-11-01] (cc526ba5-37db-4e2c-9497-2044f3b71e5d)  |
| key_name                    | my-key                                                            |
| name                        | my-vm                                                             |
| progress                    | 0                                                                 |
| project_id                  | 5e59549f-6da2-476e-912b-d920e391aaf3                              |
| properties                  |                                                                   |
| security_groups             | name='default'                                                    |
| status                      | BUILD                                                             |
| updated                     | 2021-11-28T14:14:43Z                                              |
| user_id                     | my-user-name                                                      |
| volumes_attached            |                                                                   |
+-----------------------------+-------------------------------------------------------------------+

Follow the VM creation

Follow the VM creation until the state becomes ACTIVE(and the VM is booting)

$ openstack server show my-vm
+-----------------------------+------------------------------------------------------------------+
| Field                       | Value                                                            |
+-----------------------------+------------------------------------------------------------------+
| OS-DCF:diskConfig           | MANUAL                                                           |
| OS-EXT-AZ:availability_zone | cern-geneva-b                                                    |
| OS-EXT-STS:power_state      | Running                                                          |
| OS-EXT-STS:task_state       | None                                                             |
| OS-EXT-STS:vm_state         | active                                                           |
| OS-SRV-USG:launched_at      | 2021-11-28T14:15:29Z                                             |
| OS-SRV-USG:terminated_at    | None                                                             |
| accessIPv4                  |                                                                  |
| accessIPv6                  |                                                                  |
| addresses                   | CERN_NETWORK=188.184.95.89, 2001:1458:201:e4::100:753            |
| config_drive                |                                                                  |
| created                     | 2021-11-28T14:14:43Z                                             |
| flavor                      | m2.small (17895)                                                 |
| hostId                      | 34d8eda808d8asdger2f6747bb224f808f59a84611713db9917f515d         |
| id                          | ce30ke9e-9f50-47b1-a9c5-0fcced31ae56                             |
| image                       | CS8 - x86_64 [2021-11-01] (cc526ba5-37db-4e2c-9497-2044f3b71e5d)  |
| key_name                    | my-key                                                           |
| name                        | my-vm                                                            |
| progress                    | 0                                                                |
| project_id                  | 5e59549f-6da2-476e-912b-d920e391aaf3                             |
| properties                  |                                                                  |
| security_groups             | name='default'                                                   |
| status                      | ACTIVE                                                           |
| updated                     | 2021-11-28T14:15:29Z                                             |
| user_id                     | my-user-name                                                     |
| volumes_attached            |                                                                  |
+-----------------------------+------------------------------------------------------------------+

Check console of virtual machine

The console for a Linux VM can be displayed using console log.

$ openstack console log show --line 20 my-vm

Reboot a virtual machine

$ openstack server reboot my-vm

Last update: November 30, 2021