fix: set openstack metadata for use_blockstorage_volume
Also set os-set_image_metadata on the tempoary volume before uploading (volume metadata does not automatically become image metadata) so the uploaded image will be created with the desired metadata
This commit is contained in:
parent
17d4e54947
commit
6e069c94e8
|
@ -55,6 +55,20 @@ func (s *stepCreateImage) Run(ctx context.Context, state multistep.StateBag) mul
|
|||
return multistep.ActionHalt
|
||||
}
|
||||
volume := state.Get("volume_id").(string)
|
||||
|
||||
// set ImageMetadata before uploading to glance so the new image captured the desired values
|
||||
if len(config.ImageMetadata) > 0 {
|
||||
err = volumeactions.SetImageMetadata(blockStorageClient, volume, volumeactions.ImageMetadataOpts{
|
||||
Metadata: config.ImageMetadata,
|
||||
}).ExtractErr()
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Error setting image metadata: %s", err)
|
||||
state.Put("error", err)
|
||||
ui.Error(err.Error())
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
}
|
||||
|
||||
image, err := volumeactions.UploadImage(blockStorageClient, volume, volumeactions.UploadImageOpts{
|
||||
DiskFormat: config.ImageDiskFormat,
|
||||
ImageName: config.ImageName,
|
||||
|
@ -92,19 +106,6 @@ func (s *stepCreateImage) Run(ctx context.Context, state multistep.StateBag) mul
|
|||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
volume := state.Get("volume_id").(string)
|
||||
if len(config.ImageMetadata) > 0 && s.UseBlockStorageVolume {
|
||||
err = volumeactions.SetImageMetadata(blockStorageClient, volume, volumeactions.ImageMetadataOpts{
|
||||
Metadata: config.ImageMetadata,
|
||||
}).ExtractErr()
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Error setting image metadata: %s", err)
|
||||
state.Put("error", err)
|
||||
ui.Error(err.Error())
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
}
|
||||
|
||||
return multistep.ActionContinue
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ func (s *StepCreateVolume) Run(ctx context.Context, state multistep.StateBag) mu
|
|||
AvailabilityZone: s.VolumeAvailabilityZone,
|
||||
Name: s.VolumeName,
|
||||
ImageID: sourceImage,
|
||||
Metadata: config.ImageMetadata,
|
||||
}
|
||||
volume, err := volumes.Create(blockStorageClient, volumeOpts).Extract()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue