Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Much of the power of Openstack OpenStack is in the suite of application program interfaces (APIs), allowing the same functionality of the dashboard with the advantage of automating much of the provisioning process with only a few commands. Using the API means that all the actions can be  added added to a script that can be called to automatically and repeatedly build instances. You can also create template-like scripts so that with only minor modification to instance name, image and volume size, it is possible to build other instances and volumes quickly and without the need for clicking through the dashboard.

...

Before the tools are installed, you will want an environment that can use Python, as all of the Openstack OpenStack command-line tools are written in that language. This can be your local desktop or it could be a virtual machine in the Rapid Access Cloud. The instructions outlined below will assume a Ubuntu 14.04 instance in the Rapid Access Cloud, a virtual machine running on your desktop or a native Ubuntu desktop.

From an Ubuntu 14.04 command-line:

  1. Install Python package management (pip) and required packages: 

    Code Block
    $ sudo apt-get install pythonpython3-pip pythonpython3-dev


  2. Install Openstack command-line tools using pip: 

    Code Block
    $ sudo pippip3 install python-openstackclient


Installing command-line tools (

...

macOS)

  1. Ensure you have the Developer Tools (Xcode) with the Command Line Tools for OS X.

  2. Open the Terminal application.

  3. Install pip (a package management system for software packages written in python): macOS:

    Code Block
     $ sudo easy_install pipxcode-select --install
    $ sudo pip3 install --upgrade pip


  4. Open the Terminal application.

  5. Install the openstack command line tool: 

    Code Block
    $ pippip3 install --user python-openstackclient

    Note: We recommend installing this as a user to avoid running into issues with system updates.

  6. Add the following to .bashrczshrc: 

    Code Block
    export PATH=/Users/<username>/Library/Python/23.78/bin:$PATH
    export PYTHONPATH=/Users/<username>/Library/Python/23.78/lib/python/site-packages



Openrc file

The ‘rc’ in "rc" in rc file stands for any or all of the following:

...

Using an rc file to outline your Rapid Access Cloud credentials allows you to pass your credentials to the cloud without needing to include them in your scripts. In fact, the rc file is a simple bash script that creates environment variables in your shell to be used by the openstack command (the ‘open’ 'open' in openrc). The environment variables, once set, exist only for the current session. If you open another concurrent session on the computer or log-out and back in, you will need to source the openrc file again.

...

  1. Log-in to the Rapid Access Cloud dashboard at https://cloud.cybera.ca.

  2. In the left-hand panel under “Compute”, click “Access & Security”.

  3. Click the “API Access” tab at the top then click the “Download Openstack RC file” file v3” on the right.

  4. The file downloaded will be named after your account name, e.g. <email>@<domain>-openrc.sh. This can be renamed to openrc if you like, or you can copy it and modify it so you can have one for the Calgary region and one for the Edmonton region. The rc file downloaded will be keyed for the region you are signed into in the dashboard.

    Add this line to the downloaded openrc file: 

    Code Block
    export OS_VOLUME_API_VERSION=2

Create openrc

You can use the downloaded rc file as a template or create one from scratch. The OS_USERNAME and OS_TENANTPROJECT_NAME variables are the same; each will be the email address for your Rapid Access Cloud account.

...

Code Block
#!/bin/bash
export OS_REGIONAUTH_NAME="Calgary"
export OS_VOLUME_API_VERSION=2
export OS_AUTH_URL=https://keystone-yyc.URL=https://yyc.cloud.cybera.ca:5000/v2.0v3
export OS_PROJECT_USERNAMENAME="<account_username>"
export OS_TENANT_NAMEUSERNAME="<account_username>"
echo "Please enter export OS_USER_DOMAIN_NAME="Default"
export OS_REGION_NAME="Calgary"
export OS_INTERFACE=public
export OS_IDENTITY_API_VERSION=3
echo "Please enter your OpenStack Password for project $OS_PROJECT_NAME as user $OS_USERNAME: "
read -sr OS_PASSWORD_INPUT
export OS_PASSWORD=$OS_PASSWORD_INPUT

...

Code Block
#!/bin/bash
export OS_REGIONAUTH_NAME="Edmonton"
export OS_VOLUME_API_VERSION=2
export OS_AUTH_URL=httpsURL=https://keystone-yeg.cloud.cybera.ca:5000/v2.0v3
export OS_PROJECT_USERNAMENAME="<account_username>"
export OS_TENANT_NAMEUSERNAME="<account_username>"
echo "Please enter export OS_USER_DOMAIN_NAME="Default"
export OS_REGION_NAME="Edmonton"
export OS_INTERFACE=public
export OS_IDENTITY_API_VERSION=3
echo "Please enter your OpenStack Password for project $OS_PROJECT_NAME as user $OS_USERNAME: "
read -sr OS_PASSWORD_INPUT
export OS_PASSWORD=$OS_PASSWORD_INPUT

...

Sourcing the rc File

Whether you downloaded the RC file or created your own, you will need to "source" into your shell environment:

Code Block
source /path/to/openrc/file


...

Using the openstack

client

This tutorial will walk through some of the steps outlined in the Basic Guide in building a single instance from scratch, with some notes about alternative functionality that each command offers, to show how flexible using the OpenStack command line client is.

...

  • Delete a volume. This is a destructive action and all data associated with the volume is lost

    Code Block
     $ openstack volume delete <volume_name>

...


Images

While it is true that instances in the Rapid Access Cloud are intended to be ephemeral, it is still possible to capture the state of an instance at any moment and save it as an image that can in turn be provisioned in a similar fashion to deploying a new instance using openstack server create as outlined above. This permits the ability to back-up an instance for safe keeping or create a base image with required applications already installed if you want to rapidly deploy many instances with a similar role. Volume snapshots are point-in-time stateful ‘freeze’ of a volume, meaning the volume itself cannot be attached after a snapshot is taken. (see volumes above for creating new volumes from snapshots)

Before snapshotting your instance, make sure it is in a shut-off state.


  • Create an image of an existing Create an image of an existing instance: 

    Code Block
    $ openstack server image create --name <image_name> <instance_name>

     

  • Download an image to a local computer: 

    Code Block
     $ openstack image save --file <file_name> <image_name>

    Snapshot an existing volume, unattached to an instance: 

    Code Block
    $ openstack snapshot create --name <snapshot_name> <volume_name>

    Snapshot an existing volume, attached to an instance: 

    Code Block
    $ openstack snapshot create --name <snapshot_name> --force <volume_name>
    Note
    Note about volume snapshots: Notice the use of the --force switch when taking a snapshot of an attached volume; the snapshot will work and not fail, however if there are open files being actively written to the validity of the data being cloned cannot be guaranteed.