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 |
+--------------------------------------+-----------------------------------------------+--------+
| 39501add-c044-4d96-837d-e94ef43e5f42 | ALMA9 - x86_64                                | active |
| 1fcfa1d3-51b2-4d49-a4db-5293ebff9a5d | RHEL9 - x86_64                                | active |
...

The AlmaLinux 9 image ALMA9 - x86_64 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 "ALMA9 - x86_64" 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                       | ALMA9 - x86_64 (39501add-c044-4d96-837d-e94ef43e5f42)  |
| 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                       | ALMA9 - x86_64 (39501add-c044-4d96-837d-e94ef43e5f42)   |
| 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