Merge pull request #1397 from jfrazelle/disk_size

add disk size to google compute
This commit is contained in:
Eric Johnson 2014-08-08 11:54:58 -07:00
commit a5bc5beccb
6 changed files with 13 additions and 2 deletions

View File

@ -18,6 +18,7 @@ type Config struct {
BucketName string `mapstructure:"bucket_name"` BucketName string `mapstructure:"bucket_name"`
ClientSecretsFile string `mapstructure:"client_secrets_file"` ClientSecretsFile string `mapstructure:"client_secrets_file"`
DiskSizeGb int64 `mapstructure:"disk_size"`
ImageName string `mapstructure:"image_name"` ImageName string `mapstructure:"image_name"`
ImageDescription string `mapstructure:"image_description"` ImageDescription string `mapstructure:"image_description"`
InstanceName string `mapstructure:"instance_name"` InstanceName string `mapstructure:"instance_name"`
@ -64,6 +65,10 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
c.Network = "default" c.Network = "default"
} }
if c.DiskSizeGb == 0 {
c.DiskSizeGb = 10
}
if c.ImageDescription == "" { if c.ImageDescription == "" {
c.ImageDescription = "Created by Packer" c.ImageDescription = "Created by Packer"
} }

View File

@ -25,6 +25,7 @@ type Driver interface {
type InstanceConfig struct { type InstanceConfig struct {
Description string Description string
DiskSizeGb int64
Image string Image string
MachineType string MachineType string
Metadata map[string]string Metadata map[string]string

View File

@ -177,6 +177,7 @@ func (d *driverGCE) RunInstance(c *InstanceConfig) (<-chan error, error) {
AutoDelete: true, AutoDelete: true,
InitializeParams: &compute.AttachedDiskInitializeParams{ InitializeParams: &compute.AttachedDiskInitializeParams{
SourceImage: image.SelfLink, SourceImage: image.SelfLink,
DiskSizeGb: c.DiskSizeGb,
}, },
}, },
}, },

View File

@ -31,8 +31,8 @@ func (s *StepCreateImage) Run(state multistep.StateBag) multistep.StepAction {
ui.Say("Creating image...") ui.Say("Creating image...")
cmd := new(packer.RemoteCmd) cmd := new(packer.RemoteCmd)
cmd.Command = fmt.Sprintf("%s%s --output_file_name %s", cmd.Command = fmt.Sprintf("%s%s --output_file_name %s --fssize %d",
sudoPrefix, imageBundleCmd, imageFilename) sudoPrefix, imageBundleCmd, imageFilename, config.DiskSizeGb*1024*1024*1024)
err := cmd.StartWithUi(comm, ui) err := cmd.StartWithUi(comm, ui)
if err == nil && cmd.ExitStatus != 0 { if err == nil && cmd.ExitStatus != 0 {
err = fmt.Errorf( err = fmt.Errorf(

View File

@ -28,6 +28,7 @@ func (s *StepCreateInstance) Run(state multistep.StateBag) multistep.StepAction
errCh, err := driver.RunInstance(&InstanceConfig{ errCh, err := driver.RunInstance(&InstanceConfig{
Description: "New instance created by Packer", Description: "New instance created by Packer",
DiskSizeGb: config.DiskSizeGb,
Image: config.SourceImage, Image: config.SourceImage,
MachineType: config.MachineType, MachineType: config.MachineType,
Metadata: map[string]string{ Metadata: map[string]string{

View File

@ -91,6 +91,9 @@ each category, the available options are alphabetized and described.
### Optional: ### Optional:
* `disk_size` (integer) - The size of the disk in GB.
This defaults to 10, which is 10GB.
* `image_name` (string) - The unique name of the resulting image. * `image_name` (string) - The unique name of the resulting image.
Defaults to `packer-{{timestamp}}`. Defaults to `packer-{{timestamp}}`.