Merge pull request #8186 from puetzk/issue8178
fix: set openstack metadata for use_blockstorage_volume
This commit is contained in:
commit
1731f87ad0
@ -55,6 +55,20 @@ func (s *stepCreateImage) Run(ctx context.Context, state multistep.StateBag) mul
|
|||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
volume := state.Get("volume_id").(string)
|
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{
|
image, err := volumeactions.UploadImage(blockStorageClient, volume, volumeactions.UploadImageOpts{
|
||||||
DiskFormat: config.ImageDiskFormat,
|
DiskFormat: config.ImageDiskFormat,
|
||||||
ImageName: config.ImageName,
|
ImageName: config.ImageName,
|
||||||
@ -92,21 +106,6 @@ func (s *stepCreateImage) Run(ctx context.Context, state multistep.StateBag) mul
|
|||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.UseBlockStorageVolume {
|
|
||||||
volume := state.Get("volume_id").(string)
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ func (s *StepCreateVolume) Run(ctx context.Context, state multistep.StateBag) mu
|
|||||||
AvailabilityZone: s.VolumeAvailabilityZone,
|
AvailabilityZone: s.VolumeAvailabilityZone,
|
||||||
Name: s.VolumeName,
|
Name: s.VolumeName,
|
||||||
ImageID: sourceImage,
|
ImageID: sourceImage,
|
||||||
|
Metadata: config.ImageMetadata,
|
||||||
}
|
}
|
||||||
volume, err := volumes.Create(blockStorageClient, volumeOpts).Extract()
|
volume, err := volumes.Create(blockStorageClient, volumeOpts).Extract()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user