In this tutorial we’re going to look at how to start adding images to Openstack Glance image service. I assume you already have a running Openstack setup, and glance service runs on the controller node. If you’re doing initial setup, look at

Openstack Liberty Lab Part Four: Configuring Glance Image Service

What is Openstack image service?

Openstack glance enables users to discover, register, and retrieve virtual machine images. The default location these images are stored is /var/lib/glance/images/ with its backend being a file.

Openstack image service also offers a REST API that enables you to query virtual machine image metadata and retrieve an actual image. You can store virtual machine images made available through the Image service in a variety of locations, from simple file systems to object-storage systems like OpenStack Object Storage.

Obtaining images?

The simplest way to obtain a virtual machine image that works with OpenStack is to download one that someone else has already created. Most of the images contain the cloud-init package to support the SSH key pair and user data injection. I’ll show you how to add images for various operating systems by downloading what other people already made. Of course you can create your own images, but it is faster to obtain ready made images.

Default Login credentials for the images

Below are the default login usernames for instances created from the images added shortly.

Debian: debian
Fedora: fedora
Ubuntu: ubuntu
RHEL: cloud-user
CentOS: centos
coreos: core
Arch Linux: arch
Gentoo: gentoo
OpenSUSE: root
Cirros:
    username: cirros
    Password: cubswin:)

Adding Cirros Test Image

  • Download image
    wget http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img
    
  • Adding image to glance
openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file cirros-0.3.5-x86_64-disk.img \
    Cirros-0.3.5-x86_64

Adding Fedora 26 Image

  • Download image
wget https://download.fedoraproject.org/pub/fedora/linux/releases/26/CloudImages/x86_64/images/Fedora-Cloud-Base-26-1.5.x86_64.qcow2
  • Adding image to glance
openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file debian-9-openstack-amd64.qcow2 \
    Fedora-26-x86_64

Add Debian 9 image to glance

  • Download image
wget http://cdimage.debian.org/cdimage/openstack/current-9/debian-9-openstack-amd64.qcow2
  • Adding image to glance
openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file debian-9-openstack-amd64.qcow2 \
    Debian-9-amd64

Adding Debian 8 image to glance

  • Download image
wget http://cdimage.debian.org/cdimage/openstack/current-8/debian-8-openstack-amd64.qcow2
  • Adding image to glance
openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file debian-8-openstack-amd64.qcow2 \
    Debian-8-amd64

Adding CentOS 7 image to glance

  • Download image
wget http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2
  • Adding image to glance
openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file CentOS-7-x86_64-GenericCloud.qcow2 \
    CentOS-7-x86_64

Adding CentOS 6 image to glance

  • Download image
wget http://cloud.centos.org/centos/6/images/CentOS-6-x86_64-GenericCloud.qcow2
  • Adding image to glance
openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file CentOS-6-x86_64-GenericCloud.qcow2 \
    CentOS-6-x86_64

Adding Ubuntu 16.04 image glance

  • Download image
wget http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img
  • Adding image to glance
openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file xenial-server-cloudimg-amd64-disk1.img \
    Ubuntu-16.04-x86_64

Adding Ubuntu 14.04 image glance

  • Download image
wget https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img
  • Adding image to glance
openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file trusty-server-cloudimg-amd64-disk1.img \
    Ubuntu-14.04-x86_64

Adding Ubuntu 17.04 image glance

  • Download image
wget https://cloud-images.ubuntu.com/zesty/current/zesty-server-cloudimg-amd64.img
  • Adding image to glance
openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file zesty-server-cloudimg-amd64.img \
    Ubuntu-17.04-x86_64

Adding OpenSUSE Leap 42.3 image to glance

  • Download image
wget http://download.opensuse.org/repositories/Cloud:/Images:/Leap_42.3/images/openSUSE-Leap-42.3-OpenStack.x86_64.qcow2
  • Adding image to glance
openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file openSUSE-Leap-42.3-OpenStack.x86_64.qcow2 \
    OpenSUSE-Leap-42.3-x86_64

Adding Windows Server 2012 image

  • Download image

https://cloudbase.it/windows-cloud-images/#download

  • Extract the image
gunzip -cd windows_server_2012_r2_standard_eval_kvm_20170321.qcow2.gz
  • Adding image to glance
openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file windows_server_2012_r2_standard_eval_kvm_20170321.qcow2 \
    Windows-Server-2012-R2-Std

Adding CoreOS image

  • Download image
wget https://stable.release.core-os.net/amd64-usr/current/coreos_production_openstack_image.img.bz2
bunzip2 coreos_production_openstack_image.img.bz2
  • Adding image to glance
openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file coreos_production_openstack_image.img \
    CoreOS-x86_64

Adding Arch Linux image

  • Download image
wget https://linuximages.de/openstack/arch/arch-openstack-LATEST-image-bootstrap.qcow2
  • Adding image to glance
openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file arch-openstack-LATEST-image-bootstrap.qcow2 \
    Arch-Linux-x86_64

Adding Gentoo image

  • Download image
wget https://linuximages.de/openstack/gentoo/gentoo-openstack-LATEST-image-bootstrap.qcow2
  • Adding image to glance
openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file gentoo-openstack-LATEST-image-bootstrap.qcow2 \
    Gentoo-Linux-x86_64

Confirm that all images were added successfully

$ openstack image list
+--------------------------------------+----------------------------+--------+
| ID                                   | Name                       | Status |
+--------------------------------------+----------------------------+--------+
| f047065f-c5ed-4596-8c35-0f60b5d21539 | Arch-Linux-x86_64          | active |
| b6f3e6e9-4fa7-4e45-b7ae-b48c9a36ecc8 | CentOS-6-x86_64            | active |
| 4019ee18-0447-420b-b3b9-2b99055c939a | CentOS-7-x86_64            | active |
| 10a08516-c8f8-433c-8fff-e56b0627512b | Cirros-0.3.5-x86_64        | active |
| 1d3265cf-0cb7-4834-a6e4-2dd9db167b24 | Debian-8-amd64             | active |
| 66b230c4-5339-4c8a-8a70-78f879ccc64b | Debian-9-amd64             | active |
| 3efaee22-35d2-4813-ad6e-62d6ad55df36 | Fedora-26-x86_64           | active |
| 8bc3a4e3-2ba6-4af3-a0bc-2dfc2e0dea53 | Gentoo-Linux-x86_64        | active |
| d0c9939c-beae-4ee4-9bbe-58784fe32a85 | OpenSUSE-Leap-42.3-x86_64  | active |
| 48ca423a-b8dc-44dc-b80a-e5c1b3c8b9f2 | Ubuntu-14.04-x86_64        | active |
| 24607d7b-f181-4845-9907-cac37ff5b1fa | Ubuntu-16.04-x86_64        | active |
| 82661205-9fed-4c80-ab81-706afdfecbf2 | Ubuntu-17.04-x86_64        | active |
| b1ba5cea-39f8-4f7c-bdee-796587c5e266 | Windows-Server-2012-R2-Std | active |
+--------------------------------------+----------------------------+--------+

Setting image options options

openstack image set  --help

Protect all images from being deleted

  • Now let’s set all images to be publicly visible and protect them from accidental deletion.
IMAGE_IDS=`openstack image list | egrep '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}' -o`
for i in ${IMAGE_IDS[@]}; do
    openstack image set --public $i
    openstack image set --protected $i
done
  • Confirm from Horizon Dashboard by going to Project > Compute > Images. You should notice Protected flag is set to yes for all images and Visibility set to Public as well.

openstack glance images