
Common OpenStack server (instances) tasks
This section outlines a number of common commands that can be run when operating with instances (for example, virtual machines). For more detailed information and explanation of each task, refer to Chapter 5, Nova – OpenStack Compute.
Getting ready
Ensure that you have the OpenStack clients installed as described in the first recipes of this chapter.
How to do it…
Carry out the following to launch and manipulate running instances:
To launch in an instance from the command line, you need the following information:
- An image
- A network
- A flavor
- An optional security group (default is used otherwise)
- An optional key (if you intend to access the instance)
Carry out the following steps to launch an instance from the command line:
- First, list the images available:
openstack image list
- Now we list the networks available (it will be the UUID of the Network we will use):
openstack network list
- We need a flavor, if you need reminding of them, list them with the following command:
openstack flavor list
- If you require specific security groups, list them with the following command:
openstack security group list
- If you need to get the name of the key pair to use, use the following command:
openstack keypair list
- Now you can boot the instance with the following command:
openstack server create --image IMAGE --flavor FLAVOR --security-group SECGROUP --nic net-id=NETWORK_UUID --key-name KEYPAIR_NAME INSTANCE_NAME
To list the OpenStack instances launched, issue the following command:
openstack server list
To create a snapshot of a running instance, carry out the following command:
openstack server image create --name snapshotRunningWebserver1 myRunningWebserver1
To alter the flavor of a running instance and respawn with the new settings, carry out the following commands:
- We first specify the new flavor size with the following command:
openstack server resize --flavor m1.small myWebserver1
- Next, list the running instances to confirm the state. The status should be
VERIFY_RESIZE
:openstack server list
This shows output like the following:
- Then we confirm the action with the following command:
openstack server resize --confirm myWebserver1