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:

Launching an instance

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:

  1. First, list the images available:
    openstack image list
    
  2. Now we list the networks available (it will be the UUID of the Network we will use):
    openstack network list
    
  3. We need a flavor, if you need reminding of them, list them with the following command:
    openstack flavor list
    
  4. If you require specific security groups, list them with the following command:
    openstack security group list
    
  5. If you need to get the name of the key pair to use, use the following command:
    openstack keypair list
    
  6. 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
    

Listing OpenStack Instances

To list the OpenStack instances launched, issue the following command:

openstack server list

Create instance snapshot

To create a snapshot of a running instance, carry out the following command:

openstack server image create
    --name snapshotRunningWebserver1
    myRunningWebserver1

Resizing an instance

To alter the flavor of a running instance and respawn with the new settings, carry out the following commands:

  1. We first specify the new flavor size with the following command:
    openstack server resize --flavor m1.small myWebserver1
    
  2. Next, list the running instances to confirm the state. The status should be VERIFY_RESIZE:
    openstack server list
    

    This shows output like the following:

    Resizing an instance
  3. Then we confirm the action with the following command:
    openstack server resize --confirm myWebserver1
    

Creating a flavor

To create a flavor, called m1.tiny, which is made up of 512 MB RAM, 1 vCPU, and no fixed size disk, carry out the following:

openstack flavor create
    --ram 512
    --disk 0
  
  --vcpus 1
    --public
    m1.tiny
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.197.135