add boot volume to builder instance

pull/6918/head
Matthew Hooker 8 years ago
parent ca3bffcb0d
commit b68f214ca4
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1

@ -82,6 +82,12 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
sourceImageList: b.config.SourceImageList, sourceImageList: b.config.SourceImageList,
bootable: true, bootable: true,
}, },
&stepCreatePersistentVolume{
volumeSize: fmt.Sprintf("%d", b.config.PersistentVolumeSize),
volumeName: fmt.Sprintf("builder-boot_%s", runID),
sourceImageList: b.config.SourceImageList,
bootable: true,
},
&stepCreatePersistentVolume{ &stepCreatePersistentVolume{
volumeSize: fmt.Sprintf("%d", b.config.PersistentVolumeSize*2), volumeSize: fmt.Sprintf("%d", b.config.PersistentVolumeSize*2),
volumeName: fmt.Sprintf("builder-storage_%s", runID), volumeName: fmt.Sprintf("builder-storage_%s", runID),
@ -109,6 +115,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
name: fmt.Sprintf("builder-instance_%s", runID), name: fmt.Sprintf("builder-instance_%s", runID),
masterVolumeName: fmt.Sprintf("master-storage_%s", runID), masterVolumeName: fmt.Sprintf("master-storage_%s", runID),
builderVolumeName: fmt.Sprintf("builder-storage_%s", runID), builderVolumeName: fmt.Sprintf("builder-storage_%s", runID),
builderBootName: fmt.Sprintf("builder-boot_%s", runID),
}, },
&communicator.StepConnect{ &communicator.StepConnect{
Config: &b.config.Comm, Config: &b.config.Comm,

@ -31,6 +31,8 @@ type Config struct {
// Image // Image
// PersistentVolumeSize lets us control the volume size by using persistent boot storage // PersistentVolumeSize lets us control the volume size by using persistent boot storage
PersistentVolumeSize int `mapstructure:"persistent_volume_size"` PersistentVolumeSize int `mapstructure:"persistent_volume_size"`
//TODO
// builder image
ImageName string `mapstructure:"image_name"` ImageName string `mapstructure:"image_name"`
Shape string `mapstructure:"shape"` Shape string `mapstructure:"shape"`

@ -13,6 +13,7 @@ type stepCreatePVBuilder struct {
name string name string
masterVolumeName string masterVolumeName string
builderVolumeName string builderVolumeName string
builderBootName string
} }
func (s *stepCreatePVBuilder) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { func (s *stepCreatePVBuilder) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
@ -40,15 +41,19 @@ func (s *stepCreatePVBuilder) Run(_ context.Context, state multistep.StateBag) m
}, },
Storage: []compute.StorageAttachmentInput{ Storage: []compute.StorageAttachmentInput{
{ {
Volume: s.builderVolumeName, Volume: s.builderBootName,
Index: 1, Index: 1,
}, },
{ {
Volume: s.masterVolumeName, Volume: s.builderVolumeName,
Index: 2, Index: 2,
}, },
{
Volume: s.masterVolumeName,
Index: 3,
},
}, },
ImageList: config.SourceImageList, BootOrder: []int{1},
Attributes: config.attribs, Attributes: config.attribs,
SSHKeys: []string{config.Comm.SSHKeyPairName}, SSHKeys: []string{config.Comm.SSHKeyPairName},
} }

Loading…
Cancel
Save