Merge pull request #10017 from kostasns/oci_boot_volume
Allow to specify boot volume size in OCI builder
This commit is contained in:
commit
157b5cdc28
|
@ -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:"disk_size"`
|
||||||
|
|
||||||
// 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("'disk_size' 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:"disk_size" cty:"disk_size" hcl:"disk_size"`
|
||||||
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},
|
||||||
|
"disk_size": &hcldec.AttrSpec{Name: "disk_size", 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",
|
||||||
|
"disk_size": 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 {
|
||||||
|
|
|
@ -139,7 +139,7 @@ can also be supplied to override the typical auto-generated key:
|
||||||
- `instance_name` (string) - The name to assign to the instance used for the image creation process.
|
- `instance_name` (string) - The name to assign to the instance used for the image creation process.
|
||||||
If not set a name of the form `instanceYYYYMMDDhhmmss` will be used.
|
If not set a name of the form `instanceYYYYMMDDhhmmss` will be used.
|
||||||
|
|
||||||
- `instance_tags` (map of strings) - Add one or more freeform tags to the instance used for the
|
- `instance_tags` (map of strings) - Add one or more freeform tags to the instance used for the
|
||||||
image creation process.
|
image creation process.
|
||||||
|
|
||||||
- `instance_defined_tags` (map of maps of strings) - Add one or more defined tags for a given namespace
|
- `instance_defined_tags` (map of maps of strings) - Add one or more defined tags for a given namespace
|
||||||
|
@ -153,6 +153,10 @@ can also be supplied to override the typical auto-generated key:
|
||||||
[the Oracle docs](https://docs.cloud.oracle.com/en-us/iaas/Content/Network/Tasks/managingVNICs.htm)
|
[the Oracle docs](https://docs.cloud.oracle.com/en-us/iaas/Content/Network/Tasks/managingVNICs.htm)
|
||||||
for more information about VNICs.
|
for more information about VNICs.
|
||||||
|
|
||||||
|
- `disk_size` (int64) - The size of the boot volume in GBs. Minimum value is 50 and maximum value is 16384 (16TB).
|
||||||
|
Sets the [BootVolumeSizeInGBs](https://godoc.org/github.com/oracle/oci-go-sdk/core#InstanceConfigurationInstanceSourceViaImageDetails)
|
||||||
|
when launching the instance. Defaults to `50`.
|
||||||
|
|
||||||
- `use_private_ip` (boolean) - Use private ip addresses to connect to the
|
- `use_private_ip` (boolean) - Use private ip addresses to connect to the
|
||||||
instance via ssh.
|
instance via ssh.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue