Downloading/Uploading an Instance

At some point you may need to save a copy of one of your running instances. This is only possible by using the command line API for Openstack, which has been installed on openstackapi.crc.nd.edu. The openstackapi server has a private address, so in order to SSH to that machine you must do one of the following:

  • Be connected to the campus network.
  • Be connected to the VPN (visit vpnaccess.nd.edu for details).
  • First SSH to a public CRC machine (such as crcfe02.crc.nd.edu), and then SSH to openstackapi.crc.nd.edu.

Downloading your OpenStack RC user file (environment variables)

Before using the command line tools for OpenStack, you will need to download and load your environment file on openstackapi.crc.nd.edu. This will give you access to the tools for your project (tenant).

To download the file, navigate to the 'Access & Security' tab in the OpenStack web interface, select the 'API Access' tab, and click the 'Download OpenStack RC File v3' button in the upper right hand corner of the page.
Download os rc.png

You will need to make sure this file is in your AFS space before continuing.


Loading your environment variables using RC file

Once your RC file is downloaded and available in your AFS space, you can login to openstackapi.crc.nd.edu using your ND netID.

You must now switch to the bash environment if it is not already your default shell by issuing the command "bash". Here is an example of what it should look like:

[username@openstackapi ~]$ bash
bash-4.1$ 

Once in bash use the "source <path to RC file>" command to load your environmental variables from the RC file. Here is an example:

bash-4.1$ source "Amazing Project-openrc.sh"
Please enter your OpenStack Password: 
bash-4.1$ 

You will need to enter your password for OpenStack.


List your current instances

To see all of your Openstack instances, use the "nova list" command.

bash-4.1$ nova list
+--------------------------------------+-----------------+---------+------------+-------------+--------------------------------+ | ID | Name | Status | Task State | Power State | Networks | +--------------------------------------+-----------------+---------+------------+-------------+--------------------------------+ | 26c2fe46-c056-4329-9505-5a8f0ed652a7 | Steves_Instance | ACTIVE | - | Running | provider-network-2=10.32.8.194 | | b13c78cf-4bfc-406f-b6f1-9bb2ba8e3943 | sumsch02 | SHUTOFF | - | Shutdown | provider-network-2=10.32.8.170 | | 9b78c260-8705-49c3-9802-3766b075a938 | testing | ACTIVE | - | Running | provider-network-2=10.32.8.178 | +--------------------------------------+-----------------+---------+------------+-------------+--------------------------------+


Create an image

For each instance you want to save, you need to create a image (if you don't have one already created). This image is nothing more than a full copy snapshot of your instance. To create the image use the "image-create" command.

nova image-create <ID or Name> <new image name>

For example, let's say I want to create an image of "Steves_Instance", so I would do the following:

bash-4.1$ nova image-create Steves_Instance Steves_Image
bash-4.1$

Instead of "Steves_Instance", I could have used the ID "26c2fe46-c056-4329-9505-5a8f0ed652a7". The new image will now be available in the "Images & Snapshots" section in the Openstack web interface at https://openstack.crc.nd.edu.


Download an image

Now that we have a backup image of an instance we can download it to our AFS space for safe keeping. Before we download the image, first display all the images you can download by using the "nova image-list" command. Here is an example of my list of images:

bash-4.1$ nova image-list
+--------------------------------------+----------------------------------+--------+--------------------------------------+ | ID | Name | Status | Server | +--------------------------------------+----------------------------------+--------+--------------------------------------+ | 0d2420d9-f06f-43c2-8e49-526647dbcc76 | CRC-CirrOS Image Test | ACTIVE | | | 2ff14e8e-2287-4401-bd06-0cb34a6e48a2 | CRC-fedora-20-x86_64 | ACTIVE | | | f029bb1b-8872-4602-ab9e-c29ebb014f24 | CRC-ubuntu-server-12.04 | ACTIVE | | | fd7ce018-30c6-451f-9e2f-5497a7685aa2 | CRC_Front_End_Condor_For_Stephen | ACTIVE | | | 4c475bde-facb-438e-8b4d-a06a4d173e57 | Image Demo | ACTIVE | | | 98313a88-a195-4a9b-8ea8-17fcb7b988dc | Steves_Image | ACTIVE | 26c2fe46-c056-4329-9505-5a8f0ed652a7 | | 9e27fdae-9915-46f4-b996-05169a5fdc8e | rhel6_clean | ACTIVE | | +--------------------------------------+----------------------------------+--------+--------------------------------------+
bash-4.1$

You may notice that more than just your images showed up. This command lists all the images available to you including images other users created and marked as "Public". To download an image to your current directory use the following command.

glance image-download <ID or Name> --file <local file name>  

In this example I will download "Steves_Image" from the Openstack Glance service to my local AFS space on openstackapi.nd.edu with the file name "Steves_Image_Saved.img" and then show it is now in my current working directory:

bash-4.1$ glance image-download Steves_Image --file Steves_Image_Saved.img
bash-4.1$ 
bash-4.1$ ls
Steves_Image_Saved.img
bash-4.1$ 


Upload an image

You can upload local images (saved in AFS) into OpenStack with the following command:

glance image-create --name <Name of image to create in Openstack> --disk-format=qcow2 --container-format=bare --file <local image file to upload>

Here is an example of me uploading my file "Steves_Image_Saved.img" as a new image named "Steves_New_Image".

bash-4.1$ glance image-create --name Steves_New_Image --disk-format=qcow2  --container-format=bare --file Steves_Image_Saved.img
+------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | f74ad3fede92b5c78ccf54a5cd3ed0eb | | container_format | bare | | created_at | 2014-10-09T16:05:46 | | deleted | False | | deleted_at | None | | disk_format | qcow2 | | id | d15c4226-34d1-4f3f-9d77-c4eaf3f6058e | | is_public | False | | min_disk | 0 | | min_ram | 0 | | name | Steves_New_Image | | owner | 32c41739ca7248e39dc4df715464c7f0 | | protected | False | | size | 19398656 | | status | active | | updated_at | 2014-10-09T16:05:47 | +------------------+--------------------------------------+
bash-4.1$


Conclusion

Please keep in mind that if you are moving images that are several GB in size, some of the processes may take a while. You can track the progress for image-create using the --progress option, but it doesn't seem to work for image-download, currently). If you have multiple projects in Openstack you can download the RC file for each project (tenant) and source the file again to access each project, as described above in section 1.

back to top

OpenStack Main Page