This page describes the steps to to create a VM using the Openstack CLI.


Pre-requisites

There is a set of mandatory inputs required to create a new VM which are:



The available selectable options could also be checked using the Opnstack CLI commands:

$ openstack keypair list

$ openstack image list

$ openstack flavor list 

$ openstack network list

$ openstack security group list


Create a new Virtual Machine

Once known all mandatory inputs listed in the pre-requisites, a new virtual machine can be created with the following command:

$ openstack server create --flavor <flavor name> --image <image name> --key-name <keyname> --network <network name> --security-group <security group name> <vm name>


Example:

$ openstack server create --flavor "2cpu-2gbmem-30gbdisk" --image "Rocky-9.4-2024071709441" --key-name "my-user-key" --network "private-my-tenancy-name" --security-group "default" --security-group "ssh" "my-new-vm"


Once created the VM details can be reviewed with the command:

$ openstack server show <vm name>

Attach a Floating-IP to the VM

If a VM is attached only to the "private" network, if required a floating-ip can be attached to the VM to provide also a public IP.


First create a new Floating IP :

$ openstack floating ip create <external network>

where "external network" is the external network that grants access to internet (e.g. external-internet for ECMWF )


Then it is possible to attach the created floating IP to the VM with :

$ openstack server add floating ip <vm name> <created floating ip>