use openstack volume_size option on creation
if present. Otherwise fallback to to source image min disk value (if set) or calculated from the source image bytes size. Note that in some cases this needs to be specified, if `use_blockstorage_volume` is true. See #6957 for the discussion.
This commit is contained in:
parent
336c11c54a
commit
a545caa24a
|
@ -35,20 +35,25 @@ func (s *StepCreateVolume) Run(_ context.Context, state multistep.StateBag) mult
|
|||
state.Put("error", err)
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
imageClient, err := config.imageV2Client()
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Error initializing image client: %s", err)
|
||||
state.Put("error", err)
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
volumeSize := config.VolumeSize
|
||||
|
||||
// Get needed volume size from the source image.
|
||||
volumeSize, err := GetVolumeSize(imageClient, sourceImage)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Error creating volume: %s", err)
|
||||
state.Put("error", err)
|
||||
ui.Error(err.Error())
|
||||
return multistep.ActionHalt
|
||||
if volumeSize == 0 {
|
||||
imageClient, err := config.imageV2Client()
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Error initializing image client: %s", err)
|
||||
state.Put("error", err)
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
volumeSize, err = GetVolumeSize(imageClient, sourceImage)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Error creating volume: %s", err)
|
||||
state.Put("error", err)
|
||||
ui.Error(err.Error())
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
}
|
||||
|
||||
ui.Say("Creating volume...")
|
||||
|
|
Loading…
Reference in New Issue