8.2. Uploading a Disk Image
To launch instances based on images stored in the OpenStack Image service, you must first have added some images. You must either have downloaded or created suitable images to use in an OpenStack environment.
The simplest way is to download an image. Log in to https://rhn.redhat.com/rhn/software/channel/downloads/Download.do?cid=16952 with your Customer Portal user name and password. Download the 'KVM Guest Image' and use the file with the
--file parameter.
If you want to create an image, refer to the section on Building Images using Oz in the Red Hat Enterprise Linux OpenStack Platform Installation and Configuration Guide. You can also refer to the Red Hat Enterprise Linux Virtualization Host Configuration and Guest Installation Guide for more information.
Important
It is recommended that the
virt-sysprep command is run on Linux-based virtual machine images prior to uploading them to Image service. The virt-sysprep command re-initializes a disk image in preparation for use in a virtual environment. Operations it performs by default include removal of SSH keys, removal of persistent MAC addresses, and removal of user accounts.
The
virt-sysprep command is available in the libguestfs-tools package in Red Hat Enterprise Linux.
$yum install -y libguestfs-tools$virt-sysprep --add FILE
Refer to the
virt-sysprep manual page by running the man virt-sysprep command for information on enabling and disabling specific operations.
Procedure 8.1. Uploading a Disk Image Using the Command Line Interface
- Ensure that you have set the environment variables used for authenticating with OpenStack Identity service by loading them from the
keystonercfile associated with your user. Note that an administrative account is not required.$source ~/keystonerc_user - Use the
glance image-createcommand to import your disk image:$glance image-create --name "NAME" \--is-public IS_PUBLIC \--disk-format DISK_FORMAT \--container-format CONTAINER_FORMAT \--file IMAGEReplace the command line arguments inglance image-createwith the appropriate values for your environment and disk image:- Replace NAME with the name that users will refer to the disk image by.
- Replace IS_PUBLIC with
trueorfalse. Setting this value totruemeans that all users will be able to view and use the image. - Replace DISK_FORMAT with the format of the virtual machine disk image. Valid values include
raw,vhd,vmdk,vdi,iso,qcow2,aki, andami.If the format of the virtual machine disk image is unknown then use theqemu-img infocommand to try and identify it.Example 8.1. Using
qemu-img infoIn this example theqemu-img infocommand is used to determine the format of a disk image stored in the file./RHEL64.img.$image: ./RHEL64.img file format: qcow2 virtual size: 5.0G (5368709120 bytes) disk size: 136K cluster_size: 65536qemu-img info ./RHEL64.img - Replace CONTAINER_FORMAT with the container format of the image. The container format is
bareunless the image is packaged in a file format such asovforamithat includes additional metadata related to the image. - Replace IMAGE with the local path to the image file to upload.
Refer to the output of theglance help image-createcommand for more information about supported arguments toglance image-create.Note
If the image being uploaded is not locally accessible but is available using a remote URL then provide it using the--locationparameter instead of using the--fileparameter.Note however that unless you also specify the--copy-fromargument, the Image service will not copy the image into the object store but instead it will be accessed remotely each time it is required.Example 8.2. Uploading an Image
In this example theqcow2format image in the file namedrhel-64.qcow2is uploaded to the Image service. It is created in the Image service as a publicly accessible image namedRHEL 6.4.$glance image-create --name "RHEL 6.4" --is-public true --disk-format qcow2 \--container-format bare \+------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | 2f81976cae15c16ef0010c51e3a6c163 | | container_format | bare | | created_at | 2013-01-25T14:45:48 | | deleted | False | | deleted_at | None | | disk_format | qcow2 | | id | 0ce782c6-0d3e-41df-8fd5-39cd80b31cd9 | | is_public | True | | min_disk | 0 | | min_ram | 0 | | name | RHEL 6.4 | | owner | b1414433c021436f97e9e1e4c214a710 | | protected | False | | size | 25165824 | | status | active | | updated_at | 2013-01-25T14:45:50 | +------------------+--------------------------------------+--file rhel-64.qcow2 - Use the
glance image-listcommand to verify that your image was successfully uploaded.$glance image-list+--------------+----------+-------------+------------------+----------+--------+ | ID | Name | Disk Format | Container Format | Size | Status | +--------------+----------+-------------+------------------+----------+--------+ | 0ce78... | RHEL 6.4 | qcow2 | bare |213581824 | active | +--------------+----------+-------------+------------------+----------+--------+Use theglance image-showcommand to view more detailed information about an image. Use the identifier of the image to specify the image that you wish to view.$glance image-show 0ce782c6-0d3e-41df-8fd5-39cd80b31cd9+------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | 2f81976cae15c16ef0010c51e3a6c163 | | container_format | bare | | created_at | 2013-01-25T14:45:48 | | deleted | False | | disk_format | qcow2 | | id | 0ce782c6-0d3e-41df-8fd5-39cd80b31cd9 | | is_public | True | | min_disk | 0 | | min_ram | 0 | | name | RHEL 6.4 | | owner | b1414433c021436f97e9e1e4c214a710 | | protected | False | | size | 25165824 | | status | active | | updated_at | 2013-01-25T14:45:50 | +------------------+--------------------------------------+
You have successfully uploaded a disk image to the OpenStack Image service. This disk image can now be used as the basis for launching virtual machine instances in your OpenStack environment.