OpenStack Images can take several forms, but generally an image consists of a static copy of a virtual machine with an operating system with some amount of storage. Each project starts out with a few base Linux and Windows images from which instances can be created. Images can also be created or uploaded to OpenStack, and then used to launch instances.
In OpenStack, there are several stock images from which you can easily launch new instances. Typically you will want to create an instance from one of these stock images. You can view the available images (once logged in) by going to the "Images" tab in the Web Interface.
You would only need to create/upload your own image if you are unhappy with the stock images available, or if you would like to make an image from one of your current instances (to easily launch new instances with the same software and data). Currently, we have images for:
Creating an Image
From an Instance
Snapshots in OpenStack can be used like images, so the simplest way to create an image from an instance is to create a snapshot:
- Shut Off the instance by selecting "Shut Off Instance" for the instance from the Instances tab
- Create a snapshot of the instance by selecting "Create Snapshot" for the instance
- You will have to give the snapshot a name (this will be the name of your image)
- Wait for the snapshot to finish being created, and it will show up on the Images tab
Note: You should not take a snapshot of a file system that's mounted. You will lose all the info that's still in Linux's write cache. So if you want to take a snapshot of the root file system, the OS cannot be running.
From a Volume
Create an image from the volume:
- Select "Upload Volume to Image" for the volume from the Volumes tab
- Give the image a name and select "Upload"
- Wait for the image to finish being created, and it will show up on the Images tab
You can now launch new instances from the image.
If you have a volume snapshot that you would like to create an image from, create a volume from the snapshot, then follow the above steps.
Upload an Image
Images can be uploaded if you already have an image file that you would like to use. For example, if you are unsatisfied with the stock image options available on Red Cloud, you can Get Images from elsewhere. Images can be uploaded via the Web Interface:
- Go to the Images tab
- Select the "Create Image" option
- Give the image a name
- Select the file of the source image to upload
- Select "Raw" for the Format
- Optional: Select "Yes" under Protected to ensure that the image cannot be changed or deleted accidentally (this setting can be changed later)
- Select "Create Image"
You can share an image from your project with a collaborator in a different project in OpenStack cloud so you can both launch instances using the same image. As the owner of the image, you can revoke the sharing privilege at any time. You can also use these methods to share an image with yourself in other projects, just think of yourself as the collaborator.
- Both you and your collaborator need to use the OpenStack CLI.
- You will need to set up the CLI to work with the project where the image to be shared is located.
- If you are sharing an image with yourself, you will need to download the RC File for both projects (the one you are sharing from and to).
- You will need to know the project name or ID of your collaborator.
1. Find the project ID of your collaborator first:
- The project ID is the string of the format
xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxcomposed of lowercase letters and numbers. The project name in the typical format will not work in the below commands. You will need to have sourced the RC File of the project where the image is located before running the OpenStack CLI command to get the project ID:
openstack project list
- and the first field of the output is the ID of your collaborator's project ID. If you know the name of your collaborator's project, you can find the ID by adding
| grep <collaborator's project name>to the above command.
2. Find the ID of the image you want to share:
openstack image show <image name>
- Similar to project ID, this will be a long string of letters and numbers next to the name of your image. You will use the image ID, rather than the name, in the commands below.
3. Share the image with your collaborator's project:
openstack image set --shared <image ID> openstack image add project <image ID> <collaborator's project ID>
4. Verify the image is now shared:
openstack image member list <image ID>
- The status field should say
pendinguntil your collaborator accepts the image.
5. Give the ID of the shared image to your collaborator so they can follow the steps in the Accept a Shared Image section to add the image to their project. If you are sharing the image with yourself, you will need to source the RC File of the second project and then perform the acceptance yourself.
- Currently this action can only be performed by cloud administrators.
- This generally shouldn't be done unless creating something that is a public resource that is intended to be used with any project.
- Additionally, don't use such an image from a third party unless you trust the source.
openstack image set --public <image ID>
openstack image set --accept <image ID>
3. Verify the image is now available to your project:
openstack image list
- If the image is listed in the output, it should also appear in OpenStack web console (Horizon).
- An image's owner can see which projects have access to the image:
openstack image member list <image ID>
- The owner can unshare an image like this:
openstack image remove project <image ID> <project ID>