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 |
+--------------------------------------+-----------------------------------------------+--------+
| 997b2e1a-832d-4803-9b00-f57fd1052bde | C8 - x86_64 [2020-10-01] | active |
| 3ca4fb6d-6fe0-48e2-8438-88de46a72d9c | CC7 - x86_64 [2020-11-20] | active |
| 61eef33f-f27c-46ad-b71f-519e58fbee22 | Windows 10 Professional | active |
...
The CERN CentOS 7 image CC7
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. Change the hostname (my-vm in the example) to the name of the host you wish to create.
$ openstack server create --key-name lxplus --flavor m2.small --image "C8 - x86_64 [2020-10-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-10-28T14:14:44Z |
| flavor | m2.small (17895) |
| hostId | |
| id | ce30ke9e-9f50-47b1-a9c5-0fcced31ae56 |
| image | C8 - x86_64 [2020-10-01] (997b2e1a-832d-4803-9b00-f57fd1052bde) |
| key_name | lxplus |
| name | my-vm |
| progress | 0 |
| project_id | 5e59549f-6da2-476e-912b-d920e391aaf3 |
| properties | |
| security_groups | name='default' |
| status | BUILD |
| updated | 2020-10-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 | 2019-10-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 | 2020-10-28T14:14:43Z |
| flavor | m2.small (17895) |
| hostId | 34d8eda808d8asdger2f6747bb224f808f59a84611713db9917f515d |
| id | ce30ke9e-9f50-47b1-a9c5-0fcced31ae56 |
| image | C8 - x86_64 [2020-10-01] (997b2e1a-832d-4803-9b00-f57fd1052bde) |
| key_name | lxplus |
| name | my-vm |
| progress | 0 |
| project_id | 5e59549f-6da2-476e-912b-d920e391aaf3 |
| properties | |
| security_groups | name='default' |
| status | ACTIVE |
| updated | 2020-10-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