Merge branch 'openstack_metadata' of https://github.com/trumant/packer into trumant-openstack_metadata

This commit is contained in:
Chris Bednarski 2015-07-30 14:38:03 -07:00
commit 28d1295460
3 changed files with 7 additions and 2 deletions

View File

@ -8,7 +8,8 @@ import (
// ImageConfig is for common configuration related to creating Images. // ImageConfig is for common configuration related to creating Images.
type ImageConfig struct { type ImageConfig struct {
ImageName string `mapstructure:"image_name"` ImageName string `mapstructure:"image_name"`
ImageMetadata map[string]string `mapstructure:"metadata"`
} }
func (c *ImageConfig) Prepare(ctx *interpolate.Context) []error { func (c *ImageConfig) Prepare(ctx *interpolate.Context) []error {

View File

@ -30,7 +30,8 @@ func (s *stepCreateImage) Run(state multistep.StateBag) multistep.StepAction {
// Create the image // Create the image
ui.Say(fmt.Sprintf("Creating the image: %s", config.ImageName)) ui.Say(fmt.Sprintf("Creating the image: %s", config.ImageName))
imageId, err := servers.CreateImage(client, server.ID, servers.CreateImageOpts{ imageId, err := servers.CreateImage(client, server.ID, servers.CreateImageOpts{
Name: config.ImageName, Name: config.ImageName,
Metadata: config.ImageMetadata,
}).ExtractImageID() }).ExtractImageID()
if err != nil { if err != nil {
err := fmt.Errorf("Error creating image: %s", err) err := fmt.Errorf("Error creating image: %s", err)

View File

@ -100,6 +100,9 @@ builder.
Rackconnect to assign the machine an IP address before connecting via SSH. Rackconnect to assign the machine an IP address before connecting via SSH.
Defaults to false. Defaults to false.
- `metadata` (object of key/value strings) - Glance metadata that will be applied
to the image.
## Basic Example: Rackspace public cloud ## Basic Example: Rackspace public cloud
Here is a basic example. This is a working example to build a Ubuntu 12.04 LTS Here is a basic example. This is a working example to build a Ubuntu 12.04 LTS