Creating snapshots and new Glance images from the command line

When you have created a custom workflow or configuration on the API side, you can create a snapshot for your own use. In OpenStack, an instance snapshot is an image. The only difference between an image that has been uploaded directly to glance and an image you create by snapshot is that an image created by snapshot has additional properties in the glance database and defaults to being private.

Glance is a central image repository which provides discovering, registering, retrieving for disk and server images.

You can create an snapshot from a running server instance, but if you want to preserve data, you must shut down the source VM and verify the instance status is SHUTOFF before creating the snapshot. 

Before creating the snapshot and/or image, you'll want to make sure that cloud-init is installed on your instance as well as qemu-guest-agent  If your instance was based on one of the JS-Featured-API images, both cloud-init and qemu-guest-agent should be present unless you explicitly removed them.

To create the snapshot from the command line:

openstack server image create --name snapshot-image-name instance-name

(e.g. openstack server image create --name MyCustomCentos7Image-Feb-7-2017 my-CentOS7-instance)

Snapshots won't show in Horizon (this has been submitted as a bug and may be fixed real soon now) but for now, to make it visible you'll need to export it and bring it back as a Glance image. If you just plan to use this within your project and from the command line only, the rest of the steps aren't necessary. 

openstack image save --file whatever_file_name_you_like.raw UID

(e.g. openstack image save --file c7custom-image.raw 569677d8-c7b0-4606-86d8-7673a5ecd5cf )

Uploading a snapshot or new image into Glance:

openstack image create --disk-format raw --container-format bare --property visibility=community --property skip_atmosphere=yes --property hw_disk_bus=scsi --property hw_scsi_model=virtio-scsi --property hw_qemu_guest_agent=yes --property os_require_quiesce=yes --file c7custom-image.raw My-Custom-Image-Name

There are a lot of metadata tags there but those are important to insure that your instances will create properly from the stored image. You definitely want to make sure you get them all.

You can set the visibility property to community (all can see and boot), shared (only those you specify can see and boot), private (only your allocation can see and boot). For more information on Glance visibility properties, see

Boot the new image. Test it. Make sure it works. 
Do this before deleting. Please. Once it's gone, it's really gone. Be sure. 

Delete your snapshot if you no longer need it. For example:

openstack image delete 569677d8-c7b0-4606-86d8-7673a5ecd5cf