OpenStack CLI tutorial

We list a few common commands for using the OpenStack cli. We assume you have already Installed the CLI utility and installed your Application Credential.

List all OpenStack commands

::

$ openstack help

List servers

::

$ openstack server list

List volumes

::

$ openstack volume list

List images

::

$ openstack image list

List SSH key pairs

::

$ openstack keypair list

List security groups

::

$ openstack security group list

List flavors

::

$ openstack flavor list

List networks

::

$ network list

Create a new server

::

$ server create –image $IMAGE –flavor $FLAVOR –security-group $SECGROUPT –key-name $KEYPAIR –nic net-id=$NETWORK $VM_NAME

where $IMAGE, $FLAVOR, etc. are chosen from the lists returned with the corresponding commands. Note: $NETWORK is the network ID of a private network accessible by the project (e.g. the default shared network of the GARR cloud). Do not choose the external network floating-ip!

Add a floating IP to the server

::

$ openstack ip floating create floating-ip

$ openstack ip floating add $FLOATING_IP $VM_NAME

where $FLOATING_IP is the floating ip returned with the first command.

Server snapshots

To create a snapshot image of a server, first stop the VM:

$ openstack server stop $VM_NAME
$ openstack server image create --name $SNAP_NAME $VM_NAME

where $SNAP_NAME is the name of the snapshot, $VM_NAME is the name of the VM.

To create a new server from the snapshot:

$ server create --image $SNAP_NAME --flavor $FLAVOR --security-group $SECGROUPT \
   --key-name $KEYPAIR --nic net-id=$NETWORK $VM_NAME

Delete the server

::

$ openstack server delete $VM_NAME