OpenStack User Tip: Add a new Image to OpenStack
What's an OpenStack image?
An OpenStack image is a "template" for a new instance. It could be as simple as a bare operating system ISO, or it could be a complete suite of applications that have been installed, configured, and saved as an image.When you launch a new instance, one of the most common ways is to base it on an image, as in Figure 1:
Figure 1: Launching an instance
Once you've specified that you want to boot from an image, you'll need to choose the image from which you want to boot. In this case, we're booting from an image that simply represents the Ubuntu installer.
Where can I download OpenStack images?
While it's possible to create your own images, in most cases you're going to be downloading existing images. Where you get them will depend on what it is you're trying to accomplish, but here are some commonly used sources:- Cirros: Often you'll just want a minimal test image to use, and in fact many OpenStack distributions (including DevStack and Mirantis OpenStack) come with Cirros, which was designed for just that purpose. You can download a Cirros image here. The username is cirros, and the password is cubswin:).
- Ubuntu: You can get the latest long term support version of Ubuntu, 14.04 (Trusty Tahr) from the official Ubuntu site. You can use the ISO version, but for KVM it's recommended that you use the qcow2 version, trusty-server-cloudimg-amd64-disk1.img.
- Red Hat Enterprise Linux: If you have a valid Red Hat subscription, you can download the Red Hat Enterprise Linux 7 KVM Guest Image.
- Microsoft Windows: If you must use Windows, you can download the OpenStack Windows Server 2012 Standard Evaluation image from Cloudbase Solutions.
How do I add an image to my OpenStack cluster?
Once you've identified the image that you want to add, you've got two choices. You can either upload it, or if you don't have it on your local drive, you can add it directly from the URL at which it resides.To add the image from the OpenStack Dashboard (Horizon), follow these steps:
- Log into Horizon.
- Navigate to Project -> Compute -> Images.Figure 2: List of images
- Click +Create Image.
Figure 3: Create the image - Enter the relevant information for the image you're creating. You'll need to include:
- Name: The name of the image, to be shown in the list of images in Horizon.
- Description (optional): A simple description explaining what the image is, or what it's for.
- Image Source: How to specify the image source depends on whether you choose Image File or Image Location. If you have the image stored locally, choose Image File and click Choose File to specify the actual location on your local drive, as in Figure 3. If not, choose Image Location and specify the URL for the image file, as in Figure 4.Figure 4: Specify an image by location
Specifying the location directly can be a much better answer for larger images, particularly if
the OpenStack host has better bandwidth than your local connection supports, as the image will
be transferred directly over high speed links. - Format: Images can be specified in a variety of formats, from qcow2, the format for QEMU, to ISO, the same format used for CDs, to VDI, the format used by VirtualBox, to raw, which is essentially a block-by-block copy of the original.
- Architecture: Every CPU conforms to a specific architecture, such as x86_64, ppc64 for 64-bit PowerPC, or arm for, well, ARM. This field specifies the required architecture for VMs running this image.
- Minimum Disk and Minimum RAM (optional): Specifying these optional values makes it possible to tell whether an image can be launched on a particular flavor of VM.
- Copy Data: If you've chosen to load the image from a URL, you can also decide whether to actually copy the image into Glance, or to simply note the URL. In the latter case, leave the box unchecked, and when a user specifies this image, OpenStack will pull a fresh copy. (Note that while this method saves time when creating the image, it can make launching subsequent VMs much slower.)
- Public: If an image is specified as Public, anyone else on the cluster can see it, even from within another tenant. (Admins will frequently use this method to make images available to all their users.)
- Protected: Make an image Protected to keep it from being deleted accidentally. (Or on purpose, actually, If you DO need to delete it, unprotect the image from the command line.)
- Click Create Image.Once the image has been created, you should see it in the list of images, as in Figure 5:Figure 5: Images available to the tenant.
How do I add an image using the command line?
For completeness' sake, let's take a quick look at creating an image from the CLI. Assuming you've installed the glance client, sourced your credentials, and so on, you can execute a command such as:glance --os-image-api-version 2 image-create --architecture x86_64c\The command line client supports many more parameters than the Horizon client does; you can see all of them in the official OpenStack Image Service (Glance) documentation.
--protected False --min-disk 1 --disk-format qcow2 --min-ram 256 \
--file ./cirros-0.3.4-x86_64-disk.img
Looking for an easier way to deploy OpenStack? OpenStack Fuel lets you deploy OpenStack with a few clicks of your mouse.Download it now with Mirantis OpenStack.