Merge pull request #6702 from shield-9/disk_format

Add disk_format option for OpenStack builder
This commit is contained in:
Megan Marsh 2018-09-20 14:37:36 -07:00 committed by GitHub
commit ed38fe9bef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 1 deletions

View File

@ -52,6 +52,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
return nil, errs
}
if b.config.ImageConfig.ImageDiskFormat != "" && !b.config.RunConfig.UseBlockStorageVolume {
return nil, fmt.Errorf("use_blockstorage_volume must be true if image_disk_format is specified.")
}
// By default, instance name is same as image name
if b.config.InstanceName == "" {
b.config.InstanceName = b.config.ImageName

View File

@ -14,6 +14,7 @@ type ImageConfig struct {
ImageMetadata map[string]string `mapstructure:"metadata"`
ImageVisibility imageservice.ImageVisibility `mapstructure:"image_visibility"`
ImageMembers []string `mapstructure:"image_members"`
ImageDiskFormat string `mapstructure:"image_disk_format"`
}
func (c *ImageConfig) Prepare(ctx *interpolate.Context) []error {

View File

@ -47,6 +47,7 @@ func (s *stepCreateImage) Run(_ context.Context, state multistep.StateBag) multi
}
volume := state.Get("volume_id").(string)
image, err := volumeactions.UploadImage(blockStorageClient, volume, volumeactions.UploadImageOpts{
DiskFormat: config.ImageDiskFormat,
ImageName: config.ImageName,
}).Extract()
if err != nil {

View File

@ -275,6 +275,9 @@ builder.
zones aren't specified, the default enforced by your OpenStack cluster will
be used.
- `image_disk_format` (string) - Disk format of the resulting image.
This option works if `use_blockstorage_volume` is true.
## Basic Example: DevStack
Here is a basic example. This is a example to build on DevStack running in a VM.