From e6596a0a1db04ad46cf4c4b0c7e5dc5bbfc2ebde Mon Sep 17 00:00:00 2001 From: Avi Miller Date: Sun, 21 Mar 2021 12:46:21 +1100 Subject: [PATCH] [oracle-oci] Add support for E3/E4.Flex shapes This addes an optional shape_config stanza which allows you to specify how many ocpus and memory the Flex instance should be allocated. This required an upgrade of the OCI Go SDK version. Signed-off-by: Avi Miller --- builder/oracle/oci/config.go | 6 ++++++ builder/oracle/oci/driver_oci.go | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/builder/oracle/oci/config.go b/builder/oracle/oci/config.go index 7391e7693..6e369dc97 100644 --- a/builder/oracle/oci/config.go +++ b/builder/oracle/oci/config.go @@ -46,6 +46,11 @@ type ListImagesRequest struct { Shape *string `mapstructure:"shape"` } +type FlexShapeConfig struct { + Ocpus *float32 `mapstructure:"ocpus" required:"false"` + MemoryInGBs *float32 `mapstructure:"ocpus" required:"false"` +} + type Config struct { common.PackerConfig `mapstructure:",squash"` Comm communicator.Config `mapstructure:",squash"` @@ -91,6 +96,7 @@ type Config struct { InstanceTags map[string]string `mapstructure:"instance_tags"` InstanceDefinedTags map[string]map[string]interface{} `mapstructure:"instance_defined_tags"` Shape string `mapstructure:"shape"` + ShapeConfig FlexShapeConfig `mapstructure:"shape_config"` BootVolumeSizeInGBs int64 `mapstructure:"disk_size"` // Metadata optionally contains custom metadata key/value pairs provided in the diff --git a/builder/oracle/oci/driver_oci.go b/builder/oracle/oci/driver_oci.go index 94cfcc0c6..2d8ea27e8 100644 --- a/builder/oracle/oci/driver_oci.go +++ b/builder/oracle/oci/driver_oci.go @@ -95,6 +95,11 @@ func (d *driverOCI) CreateInstance(ctx context.Context, publicKey string) (strin FreeformTags: d.cfg.CreateVnicDetails.FreeformTags, } + LaunchInstanceShapeConfigDetails := core.LaunchInstanceShapeConfigDetails{ + Ocpus: d.cfg.ShapeConfig.Ocpus, + MemoryInGBs: d.cfg.ShapeConfig.MemoryInGBs, + } + // Determine base image ID var imageId *string if d.cfg.BaseImageID != "" { @@ -154,6 +159,7 @@ func (d *driverOCI) CreateInstance(ctx context.Context, publicKey string) (strin DisplayName: d.cfg.InstanceName, FreeformTags: d.cfg.InstanceTags, Shape: &d.cfg.Shape, + ShapeConfig: &LaunchInstanceShapeConfigDetails, SourceDetails: InstanceSourceDetails, Metadata: metadata, }