From 3e0914b6a2fdb434339557f41e2a0d6f5601437c Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Wed, 6 Jan 2016 14:49:39 -0800 Subject: [PATCH] openstack builder: Set image_type to "image" so that built images are treated as images and not as snapshots. Fixes: GH-3038 --- builder/openstack/image_config.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/builder/openstack/image_config.go b/builder/openstack/image_config.go index b52ad2c67..6a40296b1 100644 --- a/builder/openstack/image_config.go +++ b/builder/openstack/image_config.go @@ -18,6 +18,17 @@ func (c *ImageConfig) Prepare(ctx *interpolate.Context) []error { errs = append(errs, fmt.Errorf("An image_name must be specified")) } + // By default, OpenStack seems to create the image with an image_type of + // "snapshot", since it came from snapshotting a VM. A "snapshot" looks + // slightly different in the OpenStack UI and OpenStack won't show "snapshot" + // images as a choice in the list of images to boot from for a new instance. + // See https://github.com/mitchellh/packer/issues/3038 + if c.ImageMetadata == nil { + c.ImageMetadata = map[string]string{"image_type": "image"} + } else if c.ImageMetadata["image_type"] == "" { + c.ImageMetadata["image_type"] = "image" + } + if len(errs) > 0 { return errs }