attach volume after instance booted
This commit is contained in:
parent
b68f214ca4
commit
2febfa2c7d
|
@ -75,7 +75,6 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
var steps []multistep.Step
|
||||
if b.config.PersistentVolumeSize > 0 {
|
||||
steps = []multistep.Step{
|
||||
// TODO: make volume names UUIDs
|
||||
&stepCreatePersistentVolume{
|
||||
volumeSize: fmt.Sprintf("%d", b.config.PersistentVolumeSize),
|
||||
volumeName: fmt.Sprintf("master-storage_%s", runID),
|
||||
|
|
|
@ -31,8 +31,13 @@ type Config struct {
|
|||
// Image
|
||||
// PersistentVolumeSize lets us control the volume size by using persistent boot storage
|
||||
PersistentVolumeSize int `mapstructure:"persistent_volume_size"`
|
||||
//TODO
|
||||
// builder image
|
||||
/* TODO:
|
||||
builder image list
|
||||
default to OL image
|
||||
make sure if set then PVS is above
|
||||
some way to choose which connection to use for master
|
||||
possible ignore everything for builder and always use SSH keys
|
||||
*/
|
||||
|
||||
ImageName string `mapstructure:"image_name"`
|
||||
Shape string `mapstructure:"shape"`
|
||||
|
|
|
@ -3,6 +3,7 @@ package classic
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/hashicorp/go-oracle-terraform/compute"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
|
@ -48,10 +49,6 @@ func (s *stepCreatePVBuilder) Run(_ context.Context, state multistep.StateBag) m
|
|||
Volume: s.builderVolumeName,
|
||||
Index: 2,
|
||||
},
|
||||
{
|
||||
Volume: s.masterVolumeName,
|
||||
Index: 3,
|
||||
},
|
||||
},
|
||||
BootOrder: []int{1},
|
||||
Attributes: config.attribs,
|
||||
|
@ -65,6 +62,20 @@ func (s *stepCreatePVBuilder) Run(_ context.Context, state multistep.StateBag) m
|
|||
state.Put("error", err)
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
log.Printf("Created instance %s", instanceInfo.Name)
|
||||
|
||||
saClient := client.StorageAttachments()
|
||||
saInput := &compute.CreateStorageAttachmentInput{
|
||||
Index: 3,
|
||||
InstanceName: s.name,
|
||||
StorageVolumeName: s.masterVolumeName,
|
||||
}
|
||||
if _, err := saClient.CreateStorageAttachment(saInput); err != nil {
|
||||
err = fmt.Errorf("Problem attaching master volume: %s", err)
|
||||
ui.Error(err.Error())
|
||||
state.Put("error", err)
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
state.Put("builder_instance_info", instanceInfo)
|
||||
state.Put("builder_instance_id", instanceInfo.ID)
|
||||
|
|
Loading…
Reference in New Issue