allow to specify boot volume size
This commit is contained in:
parent
2f4490fd73
commit
72166febee
|
@ -77,6 +77,7 @@ type Config struct {
|
||||||
InstanceTags map[string]string `mapstructure:"instance_tags"`
|
InstanceTags map[string]string `mapstructure:"instance_tags"`
|
||||||
InstanceDefinedTags map[string]map[string]interface{} `mapstructure:"instance_defined_tags"`
|
InstanceDefinedTags map[string]map[string]interface{} `mapstructure:"instance_defined_tags"`
|
||||||
Shape string `mapstructure:"shape"`
|
Shape string `mapstructure:"shape"`
|
||||||
|
BootVolumeSizeInGBs int64 `mapstructure:"boot_volume_size_in_gbs"`
|
||||||
|
|
||||||
// Metadata optionally contains custom metadata key/value pairs provided in the
|
// Metadata optionally contains custom metadata key/value pairs provided in the
|
||||||
// configuration. While this can be used to set metadata["user_data"] the explicit
|
// configuration. While this can be used to set metadata["user_data"] the explicit
|
||||||
|
@ -326,6 +327,15 @@ func (c *Config) Prepare(raws ...interface{}) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set default boot volume size to 50 if not set
|
||||||
|
// Check if size set is allowed by OCI
|
||||||
|
if c.BootVolumeSizeInGBs == 0 {
|
||||||
|
c.BootVolumeSizeInGBs = 50
|
||||||
|
} else if c.BootVolumeSizeInGBs < 50 || c.BootVolumeSizeInGBs > 16384 {
|
||||||
|
errs = packer.MultiErrorAppend(
|
||||||
|
errs, errors.New("'boot_volume_size_in_gbs' must be between 50 and 16384 GBs"))
|
||||||
|
}
|
||||||
|
|
||||||
if errs != nil && len(errs.Errors) > 0 {
|
if errs != nil && len(errs.Errors) > 0 {
|
||||||
return errs
|
return errs
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,7 @@ type FlatConfig struct {
|
||||||
InstanceTags map[string]string `mapstructure:"instance_tags" cty:"instance_tags" hcl:"instance_tags"`
|
InstanceTags map[string]string `mapstructure:"instance_tags" cty:"instance_tags" hcl:"instance_tags"`
|
||||||
InstanceDefinedTags map[string]map[string]interface{} `mapstructure:"instance_defined_tags" cty:"instance_defined_tags" hcl:"instance_defined_tags"`
|
InstanceDefinedTags map[string]map[string]interface{} `mapstructure:"instance_defined_tags" cty:"instance_defined_tags" hcl:"instance_defined_tags"`
|
||||||
Shape *string `mapstructure:"shape" cty:"shape" hcl:"shape"`
|
Shape *string `mapstructure:"shape" cty:"shape" hcl:"shape"`
|
||||||
|
BootVolumeSizeInGBs *int64 `mapstructure:"boot_volume_size_in_gbs" cty:"boot_volume_size_in_gbs" hcl:"boot_volume_size_in_gbs"`
|
||||||
Metadata map[string]string `mapstructure:"metadata" cty:"metadata" hcl:"metadata"`
|
Metadata map[string]string `mapstructure:"metadata" cty:"metadata" hcl:"metadata"`
|
||||||
UserData *string `mapstructure:"user_data" cty:"user_data" hcl:"user_data"`
|
UserData *string `mapstructure:"user_data" cty:"user_data" hcl:"user_data"`
|
||||||
UserDataFile *string `mapstructure:"user_data_file" cty:"user_data_file" hcl:"user_data_file"`
|
UserDataFile *string `mapstructure:"user_data_file" cty:"user_data_file" hcl:"user_data_file"`
|
||||||
|
@ -174,6 +175,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
||||||
"instance_tags": &hcldec.AttrSpec{Name: "instance_tags", Type: cty.Map(cty.String), Required: false},
|
"instance_tags": &hcldec.AttrSpec{Name: "instance_tags", Type: cty.Map(cty.String), Required: false},
|
||||||
"instance_defined_tags": &hcldec.AttrSpec{Name: "instance_defined_tags", Type: cty.Map(cty.String), Required: false},
|
"instance_defined_tags": &hcldec.AttrSpec{Name: "instance_defined_tags", Type: cty.Map(cty.String), Required: false},
|
||||||
"shape": &hcldec.AttrSpec{Name: "shape", Type: cty.String, Required: false},
|
"shape": &hcldec.AttrSpec{Name: "shape", Type: cty.String, Required: false},
|
||||||
|
"boot_volume_size_in_gbs": &hcldec.AttrSpec{Name: "boot_volume_size_in_gbs", Type: cty.Number, Required: false},
|
||||||
"metadata": &hcldec.AttrSpec{Name: "metadata", Type: cty.Map(cty.String), Required: false},
|
"metadata": &hcldec.AttrSpec{Name: "metadata", Type: cty.Map(cty.String), Required: false},
|
||||||
"user_data": &hcldec.AttrSpec{Name: "user_data", Type: cty.String, Required: false},
|
"user_data": &hcldec.AttrSpec{Name: "user_data", Type: cty.String, Required: false},
|
||||||
"user_data_file": &hcldec.AttrSpec{Name: "user_data_file", Type: cty.String, Required: false},
|
"user_data_file": &hcldec.AttrSpec{Name: "user_data_file", Type: cty.String, Required: false},
|
||||||
|
|
|
@ -44,7 +44,8 @@ func testConfig(accessConfFile *os.File) map[string]interface{} {
|
||||||
"create_vnic_details": map[string]interface{}{
|
"create_vnic_details": map[string]interface{}{
|
||||||
"nsg_ids": []string{"ocd1..."},
|
"nsg_ids": []string{"ocd1..."},
|
||||||
},
|
},
|
||||||
"shape": "VM.Standard1.1",
|
"shape": "VM.Standard1.1",
|
||||||
|
"boot_volume_size_in_gbs": 60,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,6 @@ func (d *driverOCI) CreateInstance(ctx context.Context, publicKey string) (strin
|
||||||
CompartmentId: &d.cfg.CompartmentID,
|
CompartmentId: &d.cfg.CompartmentID,
|
||||||
DefinedTags: d.cfg.InstanceDefinedTags,
|
DefinedTags: d.cfg.InstanceDefinedTags,
|
||||||
FreeformTags: d.cfg.InstanceTags,
|
FreeformTags: d.cfg.InstanceTags,
|
||||||
ImageId: &d.cfg.BaseImageID,
|
|
||||||
Shape: &d.cfg.Shape,
|
Shape: &d.cfg.Shape,
|
||||||
SubnetId: &d.cfg.SubnetID,
|
SubnetId: &d.cfg.SubnetID,
|
||||||
Metadata: metadata,
|
Metadata: metadata,
|
||||||
|
@ -82,6 +81,12 @@ func (d *driverOCI) CreateInstance(ctx context.Context, publicKey string) (strin
|
||||||
|
|
||||||
instanceDetails.CreateVnicDetails = &CreateVnicDetails
|
instanceDetails.CreateVnicDetails = &CreateVnicDetails
|
||||||
|
|
||||||
|
// Create Source details which will be used to Launch Instance
|
||||||
|
instanceDetails.SourceDetails = core.InstanceSourceViaImageDetails{
|
||||||
|
ImageId: &d.cfg.BaseImageID,
|
||||||
|
BootVolumeSizeInGBs: &d.cfg.BootVolumeSizeInGBs,
|
||||||
|
}
|
||||||
|
|
||||||
instance, err := d.computeClient.LaunchInstance(context.TODO(), core.LaunchInstanceRequest{LaunchInstanceDetails: instanceDetails})
|
instance, err := d.computeClient.LaunchInstance(context.TODO(), core.LaunchInstanceRequest{LaunchInstanceDetails: instanceDetails})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue