Working with OpenStack

SCM controller nodes have full administrator access to the OpenStack CLI when logged in as the root user. To enable this access, run this command on a controller:

# source ~/oscreds.sh

You will run OpenStack CLI commands to list, create, or modify images and flavors. SCM will handle the higher-level details of creating and deleting VMs from these base elements.

Full documentation of OpenStack commands is at the official site. The following sections are brief summaries.

Images

Listing Images

This command lists images that the Keystone-authenticated user can access:

# glance image-list
+--------------------------------------+---------------+-------------+------------------+-------------+--------+
| ID                                   | Name          | Disk Format | Container Format | Size        | Status |
+--------------------------------------+---------------+-------------+------------------+-------------+--------+
| 26322b71-4e67-45d4-9662-2ba58b55f5dd | apache        | raw         | bare             | 21474836480 | active |
| 3bb96ae9-6b7f-411d-9822-1f5e171c77b8 | CentOS-Apache | raw         | bare             | 2147483648  | active |
| e8568161-cf98-4601-ac20-24d875fc995a | centosImage   | raw         | bare             | 2147483648  | active |
+--------------------------------------+---------------+-------------+------------------+-------------+--------+

If you are authenticated as an admin, you can see all images by adding the --all-tenants argument.

Creating an Image

This is the command to make new images for OpenStack/Glance, and later used to create VMs in Scyld Cloud Portal. You provide a base image (single-file version of an operating system) and various parameters to create a Glance Image. This image’s data will be stored in our back-end storage system, such as Ceph, and the metadata describing the image will be stored in MySQL. Example:

# glance image-create \
    --name my_new_image \
    --is-public True \
    --file /root/images/my_image.raw \
    --disk-format raw \
    --container-format bare \
    --min-disk 15 \
    --min-ram 512 \
    --progress

Some of the arguments include:

  • name – What to call your new image. It doesn’t need to be unique, but makes it easier to refer to the image in other commands if it is.
  • is-publicTrue if you want this image to be visible for use
  • file – file system location of the source image
  • disk-image – format of the source image file. raw is the output of the dd command.
  • container-format – extra file format type; just use bare.
  • min-disk – minimum required disk space, in gigabytes
  • min-ram – minimum required memory, in megabytes
  • progress – show image creation status time bar

Showing Image Details

You can print more details about an existing image:

# glance image-show image_id

image_id can be the long hex string, or the name (if it’s unique).

Modifying an Image

You can modify an existing Glance image for various purposes: making a test image public, adding a property to describe a special feature of the image, and so on. In this example, make a private test image publicly available:

# glance image-update \
    --is-public True \
    my_private_image

Flavors

Listing Flavors

This command shows all of the currently defined flavors and their standard attributes:

# nova flavor-list
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| ID | Name      | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| 1  | m1.tiny   | 512       | 1    | 0         |      | 1     | 1.0         | True      |
| 2  | m1.small  | 2048      | 20   | 0         |      | 1     | 1.0         | True      |
| 3  | m1.medium | 4096      | 40   | 0         |      | 2     | 1.0         | True      |
| 4  | m1.large  | 8192      | 80   | 0         |      | 4     | 1.0         | True      |
| 5  | m1.xlarge | 16384     | 160  | 0         |      | 8     | 1.0         | True      |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+

Any flavor can have extra_specs – one or more name:value pairs to indicate some feature or restriction of the underlying hardware, such as the presence or absence of a GPU. In this example, we modified the standard flavors with some extra information. See the following section (Modifying an Existing Flavor) to see how to do this.

# nova flavor-list --extra-specs
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+-----------------------------------------------------------+
| ID | Name      | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public | extra_specs                                               |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+-----------------------------------------------------------+
| 1  | m1.tiny   | 512       | 1    | 0         |      | 1     | 1.0         | True      | {u'gpu': u'False'}                                        |
| 2  | m1.small  | 2048      | 20   | 0         |      | 1     | 1.0         | True      | {u'gpu': u'False'}                                        |
| 3  | m1.medium | 4096      | 40   | 0         |      | 2     | 1.0         | True      | {u'gpu': u'False'}                                        |
| 4  | m1.large  | 8192      | 80   | 0         |      | 4     | 1.0         | True      | {u'gpu': u'True', u'pci_passthrough:alias': u'K2_Grid:1'} |
| 5  | m1.xlarge | 16384     | 160  | 0         |      | 8     | 1.0         | True      | {u'gpu': u'False'}                                        |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+-----------------------------------------------------------+

Creating a Flavor

To create new flavors in OpenStack, use the nova flavor-create command. It has this syntax:

nova flavor-create \
   --is-public [True|False] \
   name \
   id \
   ram_mb \
   disk_gb \
   vcpus

Note

Other than the is-public argument, the others are order-dependent.

The arguments are:

  • is-public – should this flavor be visible to others (True) or not (False)?
  • name – give this image a memorable name
  • id – specify a unique integer id; you can use one more than the highest existing flavor id
  • ram_mb – the maximum amount of RAM, in megabytes
  • disk_gb – the maximum amount of disk storage, in gigabytes
  • vcpus – the maximum number of CPUs

Example:

The highest flavor id (from nova flavor-list above) was 5, so we’ll use 6 for our new id. We’ll name the image scm.login_small, with 512 MB of RAM, 5 GB of disk, and one CPU. Also, make it public:

# nova flavor-create \
     --is-public True \
     scm.login_small \
     6 \
     512 \
     5 \
     1

+----+-----------------+-----------+------+-----------+------+-------+-------------+-----------+
| ID | Name            | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+----+-----------------+-----------+------+-----------+------+-------+-------------+-----------+
| 6  | scm.login_small | 512       | 5    | 0         |      | 1     | 1.0         | True      |
+----+-----------------+-----------+------+-----------+------+-------+-------------+-----------+

Modifying a Flavor

You can change the standard values or extra_specs of a flavor:

# nova flavor-key \
     flavor \
     action \
     key=value
  • flavor – the numeric ID or Name from the
  • actionset to assign a key, unset to delete it
  • key – an extra flavor attribute to assign or delete a value

Example:

# nova flavor-key 6 set gpu=true

Public IP Addresses

Each instance can have one or more private IP addresses and one public one. Private IP addresses are used for communication between instances and internal infrastructure, and public ones are used for communication with the outside world. When you launch an instance, it is automatically assigned a private IP address that stays the same until you explicitly terminate the instance. Rebooting an instance has no effect on the private IP address. A pool of floating IPs, configured by the SCM administrator, is available to instances. SCM will automatically allocate and assign a public IP address from the pool of floating IPs to each instance as it is created.

If no more floating IP addresses are available in the pool, the VM will show as “FAILED” in its status, and will be unreachable to external users.

To show the list of IP addresses in the pool:

# nova-manage floating list
None        172.16.100.204        None        nova        eth1
None        172.16.100.205        None        nova        eth1

To add a new IP address to the pool:

# nova-manage floating create --ip_range IP

To delete an IP:

# nova-manage floating delete --ip_range IP