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:
- keypair : configured SSH key which is needed to connect to the VM (see OpenStack: Install and use Command-Line client for how to import it )
- image : the Virtual Machine image (see EWC Virtual Images Available (these are the supported EWC images, other are not supported) and the users are described here: EWC - VM images and default users )
- flavor : the resources (CPU, RAM, Disk) configuration for the VM (see as reference EWC VM plans )
- network : the network to be attached to the VM : external-internet: access to the Internet with public IP ; private-<tenant>: local private network within the tenant.
- security group : security groups are sets of applied IP filter rules which define networking access to the instance
Once known all mandatory inputs listed in the pre-requisites, a new virtual machine can be created with the following command: Example: Once created the VM details can be reviewed with the command: 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 : 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 : A new block storage volume can be created and atttached to the VM. First create the new volume using one of the available images and selecting its size By default volumes will be created in the availability zone Then one needs to attach the newly created volume to the VM: where
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
$ openstack server create --flavor <flavor name> --image <image name> --key-name <keyname> --network <network name> --security-group <security group name> <vm name>
$ 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"
$ openstack server show <vm name>
Attach a Floating-IP to the VM
$ openstack floating ip create <external network>
$ openstack server add floating ip <vm name> <created floating ip>
Attach a volume to the VM
openstack volume create --image <image name> --size <size> <volume_name>
nova . To specify another availability zone, add the CLI option --availability-zone <availability_zone> .openstack server add volume <server_id> <volume_id> --device <mount_point>
mount_point refers to the mounting point in the server for the device, e.g. /dev/vda