Skip to content

Commit f5cacb5

Browse files
committed
Support for Elastic storage in ExaCC
1 parent a27ea38 commit f5cacb5

15 files changed

+951
-29
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
## 4.30.0 (June 09, 2021)
1+
## 4.31.0 (Unreleased)
22

33
### Added
44
- Support for Data Safe target database registration
5+
- Support for Elastic storage for ExaCC
56

67
## 4.30.0 (June 09, 2021)
78

examples/database/exadata_cc/exadata-infrastructure.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ resource "oci_database_exadata_infrastructure" "test_exadata_infrastructure" {
4545
shape = "ExadataCC.Quarter3.100"
4646
time_zone = "US/Pacific"
4747
activation_file = "activation.zip"
48+
storage_count = 3
49+
compute_count = 2
4850

4951
#Optional
5052
contacts {

oci/database_db_system_shape_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,19 @@ func TestDatabaseDbSystemShapeResource_basic(t *testing.T) {
5555
resource.TestCheckResourceAttrSet(datasourceName, "db_system_shapes.0.available_core_count"),
5656
resource.TestCheckResourceAttrSet(datasourceName, "db_system_shapes.0.available_core_count_per_node"),
5757
resource.TestCheckResourceAttrSet(datasourceName, "db_system_shapes.0.available_data_storage_in_tbs"),
58+
resource.TestCheckResourceAttrSet(datasourceName, "db_system_shapes.0.available_data_storage_per_server_in_tbs"),
59+
resource.TestCheckResourceAttrSet(datasourceName, "db_system_shapes.0.available_db_node_per_node_in_gbs"),
5860
resource.TestCheckResourceAttrSet(datasourceName, "db_system_shapes.0.available_db_node_storage_in_gbs"),
5961
resource.TestCheckResourceAttrSet(datasourceName, "db_system_shapes.0.available_memory_in_gbs"),
62+
resource.TestCheckResourceAttrSet(datasourceName, "db_system_shapes.0.available_memory_per_node_in_gbs"),
6063
resource.TestCheckResourceAttrSet(datasourceName, "db_system_shapes.0.core_count_increment"),
64+
resource.TestCheckResourceAttrSet(datasourceName, "db_system_shapes.0.max_storage_count"),
6165
resource.TestCheckResourceAttrSet(datasourceName, "db_system_shapes.0.maximum_node_count"),
6266
resource.TestCheckResourceAttrSet(datasourceName, "db_system_shapes.0.min_core_count_per_node"),
6367
resource.TestCheckResourceAttrSet(datasourceName, "db_system_shapes.0.min_data_storage_in_tbs"),
6468
resource.TestCheckResourceAttrSet(datasourceName, "db_system_shapes.0.min_db_node_storage_per_node_in_gbs"),
6569
resource.TestCheckResourceAttrSet(datasourceName, "db_system_shapes.0.min_memory_per_node_in_gbs"),
70+
resource.TestCheckResourceAttrSet(datasourceName, "db_system_shapes.0.min_storage_count"),
6671
resource.TestCheckResourceAttrSet(datasourceName, "db_system_shapes.0.minimum_core_count"),
6772
resource.TestCheckResourceAttrSet(datasourceName, "db_system_shapes.0.minimum_node_count"),
6873
resource.TestCheckResourceAttrSet(datasourceName, "db_system_shapes.0.name"),

oci/database_db_system_shapes_data_source.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ func DatabaseDbSystemShapesDataSource() *schema.Resource {
4949
Type: schema.TypeInt,
5050
Computed: true,
5151
},
52+
"available_data_storage_per_server_in_tbs": {
53+
Type: schema.TypeFloat,
54+
Computed: true,
55+
},
56+
"available_db_node_per_node_in_gbs": {
57+
Type: schema.TypeInt,
58+
Computed: true,
59+
},
5260
"available_db_node_storage_in_gbs": {
5361
Type: schema.TypeInt,
5462
Computed: true,
@@ -57,10 +65,18 @@ func DatabaseDbSystemShapesDataSource() *schema.Resource {
5765
Type: schema.TypeInt,
5866
Computed: true,
5967
},
68+
"available_memory_per_node_in_gbs": {
69+
Type: schema.TypeInt,
70+
Computed: true,
71+
},
6072
"core_count_increment": {
6173
Type: schema.TypeInt,
6274
Computed: true,
6375
},
76+
"max_storage_count": {
77+
Type: schema.TypeInt,
78+
Computed: true,
79+
},
6480
"maximum_node_count": {
6581
Type: schema.TypeInt,
6682
Computed: true,
@@ -81,6 +97,10 @@ func DatabaseDbSystemShapesDataSource() *schema.Resource {
8197
Type: schema.TypeInt,
8298
Computed: true,
8399
},
100+
"min_storage_count": {
101+
Type: schema.TypeInt,
102+
Computed: true,
103+
},
84104
"minimum_core_count": {
85105
Type: schema.TypeInt,
86106
Computed: true,
@@ -186,6 +206,14 @@ func (s *DatabaseDbSystemShapesDataSourceCrud) SetData() error {
186206
dbSystemShape["available_data_storage_in_tbs"] = *r.AvailableDataStorageInTBs
187207
}
188208

209+
if r.AvailableDataStoragePerServerInTBs != nil {
210+
dbSystemShape["available_data_storage_per_server_in_tbs"] = *r.AvailableDataStoragePerServerInTBs
211+
}
212+
213+
if r.AvailableDbNodePerNodeInGBs != nil {
214+
dbSystemShape["available_db_node_per_node_in_gbs"] = *r.AvailableDbNodePerNodeInGBs
215+
}
216+
189217
if r.AvailableDbNodeStorageInGBs != nil {
190218
dbSystemShape["available_db_node_storage_in_gbs"] = *r.AvailableDbNodeStorageInGBs
191219
}
@@ -194,10 +222,18 @@ func (s *DatabaseDbSystemShapesDataSourceCrud) SetData() error {
194222
dbSystemShape["available_memory_in_gbs"] = *r.AvailableMemoryInGBs
195223
}
196224

225+
if r.AvailableMemoryPerNodeInGBs != nil {
226+
dbSystemShape["available_memory_per_node_in_gbs"] = *r.AvailableMemoryPerNodeInGBs
227+
}
228+
197229
if r.CoreCountIncrement != nil {
198230
dbSystemShape["core_count_increment"] = *r.CoreCountIncrement
199231
}
200232

233+
if r.MaxStorageCount != nil {
234+
dbSystemShape["max_storage_count"] = *r.MaxStorageCount
235+
}
236+
201237
if r.MaximumNodeCount != nil {
202238
dbSystemShape["maximum_node_count"] = *r.MaximumNodeCount
203239
}
@@ -218,6 +254,10 @@ func (s *DatabaseDbSystemShapesDataSourceCrud) SetData() error {
218254
dbSystemShape["min_memory_per_node_in_gbs"] = *r.MinMemoryPerNodeInGBs
219255
}
220256

257+
if r.MinStorageCount != nil {
258+
dbSystemShape["min_storage_count"] = *r.MinStorageCount
259+
}
260+
221261
if r.MinimumCoreCount != nil {
222262
dbSystemShape["minimum_core_count"] = *r.MinimumCoreCount
223263
}

oci/database_exadata_infrastructure_data_source.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ func (s *DatabaseExadataInfrastructureDataSourceCrud) SetData() error {
6767

6868
s.D.SetId(*s.Res.Id)
6969

70+
if s.Res.ActivatedStorageCount != nil {
71+
s.D.Set("activated_storage_count", *s.Res.ActivatedStorageCount)
72+
}
73+
74+
if s.Res.AdditionalStorageCount != nil {
75+
s.D.Set("additional_storage_count", *s.Res.AdditionalStorageCount)
76+
}
77+
7078
if s.Res.AdminNetworkCIDR != nil {
7179
s.D.Set("admin_network_cidr", *s.Res.AdminNetworkCIDR)
7280
}
@@ -83,6 +91,10 @@ func (s *DatabaseExadataInfrastructureDataSourceCrud) SetData() error {
8391
s.D.Set("compartment_id", *s.Res.CompartmentId)
8492
}
8593

94+
if s.Res.ComputeCount != nil {
95+
s.D.Set("compute_count", *s.Res.ComputeCount)
96+
}
97+
8698
contacts := []interface{}{}
8799
for _, item := range s.Res.Contacts {
88100
contacts = append(contacts, ExadataInfrastructureContactToMap(item))
@@ -181,6 +193,10 @@ func (s *DatabaseExadataInfrastructureDataSourceCrud) SetData() error {
181193

182194
s.D.Set("state", s.Res.LifecycleState)
183195

196+
if s.Res.StorageCount != nil {
197+
s.D.Set("storage_count", *s.Res.StorageCount)
198+
}
199+
184200
if s.Res.TimeCreated != nil {
185201
s.D.Set("time_created", s.Res.TimeCreated.String())
186202
}

oci/database_exadata_infrastructure_resource.go

Lines changed: 69 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ func DatabaseExadataInfrastructureResource() *schema.Resource {
9797
Type: schema.TypeString,
9898
Optional: true,
9999
},
100+
"compute_count": {
101+
Type: schema.TypeInt,
102+
Optional: true,
103+
Computed: true,
104+
ForceNew: true,
105+
},
100106
"contacts": {
101107
Type: schema.TypeList,
102108
Optional: true,
@@ -230,8 +236,23 @@ func DatabaseExadataInfrastructureResource() *schema.Resource {
230236
},
231237
},
232238
},
239+
"storage_count": {
240+
Type: schema.TypeInt,
241+
Optional: true,
242+
Computed: true,
243+
ForceNew: true,
244+
},
233245

234246
// Computed
247+
"activated_storage_count": {
248+
Type: schema.TypeInt,
249+
Computed: true,
250+
},
251+
"additional_storage_count": {
252+
Type: schema.TypeInt,
253+
Optional: true,
254+
Computed: true,
255+
},
235256
"cpus_enabled": {
236257
Type: schema.TypeInt,
237258
Computed: true,
@@ -419,6 +440,11 @@ func (s *DatabaseExadataInfrastructureResourceCrud) Create() error {
419440
request.CompartmentId = &tmp
420441
}
421442

443+
if computeCount, ok := s.D.GetOkExists("compute_count"); ok {
444+
tmp := computeCount.(int)
445+
request.ComputeCount = &tmp
446+
}
447+
422448
if contacts, ok := s.D.GetOkExists("contacts"); ok {
423449
interfaces := contacts.([]interface{})
424450
tmp := make([]oci_database.ExadataInfrastructureContact, len(interfaces))
@@ -517,6 +543,11 @@ func (s *DatabaseExadataInfrastructureResourceCrud) Create() error {
517543
request.Shape = &tmp
518544
}
519545

546+
if storageCount, ok := s.D.GetOkExists("storage_count"); ok {
547+
tmp := storageCount.(int)
548+
request.StorageCount = &tmp
549+
}
550+
520551
if timeZone, ok := s.D.GetOkExists("time_zone"); ok {
521552
tmp := timeZone.(string)
522553
request.TimeZone = &tmp
@@ -575,12 +606,13 @@ func (s *DatabaseExadataInfrastructureResourceCrud) Update() error {
575606
}
576607
}
577608

578-
if s.D.Get("state").(string) == string(oci_database.ExadataInfrastructureLifecycleStateActive) {
579-
return fmt.Errorf("update not allowed on activated exadata infrastructure")
580-
}
581-
582609
request := oci_database.UpdateExadataInfrastructureRequest{}
583610

611+
if additionalStorageCount, ok := s.D.GetOkExists("additional_storage_count"); ok {
612+
tmp := additionalStorageCount.(int)
613+
request.AdditionalStorageCount = &tmp
614+
}
615+
584616
if adminNetworkCIDR, ok := s.D.GetOkExists("admin_network_cidr"); ok && s.D.HasChange("admin_network_cidr") {
585617
tmp := adminNetworkCIDR.(string)
586618
request.AdminNetworkCIDR = &tmp
@@ -694,6 +726,20 @@ func (s *DatabaseExadataInfrastructureResourceCrud) Update() error {
694726

695727
request.RequestMetadata.RetryPolicy = getRetryPolicy(s.DisableNotFoundRetries, "database")
696728

729+
if s.D.Get("state").(string) == string(oci_database.ExadataInfrastructureLifecycleStateRequiresActivation) ||
730+
s.D.Get("additional_storage_count").(int) > 0 {
731+
if activationFile, ok := s.D.GetOkExists("activation_file"); ok &&
732+
s.D.Get("activation_file").(string) != "" {
733+
response, err := s.activateExadataInfrastructure(activationFile.(string), s.D.Id())
734+
if err != nil {
735+
s.D.Set("activation_file", "")
736+
return err
737+
}
738+
s.Res = &response.ExadataInfrastructure
739+
return nil
740+
}
741+
}
742+
697743
response, err := s.Client.UpdateExadataInfrastructure(context.Background(), request)
698744
if err != nil {
699745
return err
@@ -705,14 +751,9 @@ func (s *DatabaseExadataInfrastructureResourceCrud) Update() error {
705751
return waitErr
706752
}
707753

708-
if activationFile, ok := s.D.GetOkExists("activation_file"); ok {
709-
response, err := s.activateExadataInfrastructure(activationFile.(string), s.D.Id())
710-
if err != nil {
711-
s.D.Set("activation_file", "")
712-
return err
713-
}
714-
s.Res = &response.ExadataInfrastructure
715-
}
754+
//if s.Res.Shape != s.D.Get("state") {
755+
// s.D.Set("shape", s.Res.Shape)
756+
//}
716757

717758
return nil
718759
}
@@ -730,6 +771,14 @@ func (s *DatabaseExadataInfrastructureResourceCrud) Delete() error {
730771
}
731772

732773
func (s *DatabaseExadataInfrastructureResourceCrud) SetData() error {
774+
if s.Res.ActivatedStorageCount != nil {
775+
s.D.Set("activated_storage_count", *s.Res.ActivatedStorageCount)
776+
}
777+
778+
if s.Res.AdditionalStorageCount != nil {
779+
s.D.Set("additional_storage_count", *s.Res.AdditionalStorageCount)
780+
}
781+
733782
if s.Res.AdminNetworkCIDR != nil {
734783
s.D.Set("admin_network_cidr", *s.Res.AdminNetworkCIDR)
735784
}
@@ -746,6 +795,10 @@ func (s *DatabaseExadataInfrastructureResourceCrud) SetData() error {
746795
s.D.Set("compartment_id", *s.Res.CompartmentId)
747796
}
748797

798+
if s.Res.ComputeCount != nil {
799+
s.D.Set("compute_count", *s.Res.ComputeCount)
800+
}
801+
749802
contacts := []interface{}{}
750803
for _, item := range s.Res.Contacts {
751804
contacts = append(contacts, ExadataInfrastructureContactToMap(item))
@@ -844,6 +897,10 @@ func (s *DatabaseExadataInfrastructureResourceCrud) SetData() error {
844897

845898
s.D.Set("state", s.Res.LifecycleState)
846899

900+
if s.Res.StorageCount != nil {
901+
s.D.Set("storage_count", *s.Res.StorageCount)
902+
}
903+
847904
if s.Res.TimeCreated != nil {
848905
s.D.Set("time_created", s.Res.TimeCreated.String())
849906
}

oci/database_exadata_infrastructure_resource_test.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"fmt"
88
"io/ioutil"
99
"os"
10-
"regexp"
1110
"testing"
1211

1312
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
@@ -35,9 +34,9 @@ var (
3534
"time_zone": Representation{repType: Required, create: `US/Pacific`, update: `UTC`},
3635
"contacts": RepresentationGroup{Optional, exadataInfrastructureContactsRepresentation},
3736
"corporate_proxy": Representation{repType: Optional, create: `http://192.168.19.1:80`, update: `http://192.168.19.2:80`},
38-
"defined_tags": Representation{repType: Optional, create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
39-
"freeform_tags": Representation{repType: Optional, create: map[string]string{"Department": "Finance"}, update: map[string]string{"Department": "Accounting"}},
40-
"maintenance_window": RepresentationGroup{Optional, exadataInfrastructureMaintenanceWindowRepresentationComplete},
37+
//"defined_tags": Representation{repType: Optional, create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
38+
"freeform_tags": Representation{repType: Optional, create: map[string]string{"Department": "Finance"}, update: map[string]string{"Department": "Accounting"}},
39+
"maintenance_window": RepresentationGroup{Optional, exadataInfrastructureMaintenanceWindowRepresentationComplete},
4140
}
4241

4342
exadataInfrastructureRepresentationWithContacts = getUpdatedRepresentationCopy("contacts", RepresentationGroup{Required, getUpdatedRepresentationCopy("phone_number", Representation{repType: Required, create: `1234567891`, update: `1234567892`}, exadataInfrastructureContactsRepresentation)}, exadataInfrastructureRepresentation)
@@ -84,7 +83,7 @@ func TestResourceDatabaseExadataInfrastructure_basic(t *testing.T) {
8483
resource.TestCheckResourceAttr(resourceName, "cloud_control_plane_server2", "10.32.88.4"),
8584
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
8685
resource.TestCheckResourceAttr(resourceName, "corporate_proxy", "http://192.168.19.2:80"),
87-
resource.TestCheckResourceAttr(resourceName, "defined_tags.%", "1"),
86+
//resource.TestCheckResourceAttr(resourceName, "defined_tags.%", "1"),
8887
resource.TestCheckResourceAttr(resourceName, "display_name", "tstExaInfra"),
8988
resource.TestCheckResourceAttr(resourceName, "dns_server.#", "2"),
9089
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
@@ -115,7 +114,7 @@ func TestResourceDatabaseExadataInfrastructure_basic(t *testing.T) {
115114
resource.TestCheckResourceAttr(resourceName, "cloud_control_plane_server2", "10.32.88.4"),
116115
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
117116
resource.TestCheckResourceAttr(resourceName, "corporate_proxy", "http://192.168.19.2:80"),
118-
resource.TestCheckResourceAttr(resourceName, "defined_tags.%", "1"),
117+
//resource.TestCheckResourceAttr(resourceName, "defined_tags.%", "1"),
119118
resource.TestCheckResourceAttr(resourceName, "display_name", "tstExaInfra"),
120119
resource.TestCheckResourceAttr(resourceName, "dns_server.#", "2"),
121120
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
@@ -148,7 +147,7 @@ func TestResourceDatabaseExadataInfrastructure_basic(t *testing.T) {
148147
resource.TestCheckResourceAttr(resourceName, "cloud_control_plane_server2", "10.32.88.4"),
149148
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
150149
resource.TestCheckResourceAttr(resourceName, "corporate_proxy", "http://192.168.19.2:80"),
151-
resource.TestCheckResourceAttr(resourceName, "defined_tags.%", "1"),
150+
//resource.TestCheckResourceAttr(resourceName, "defined_tags.%", "1"),
152151
resource.TestCheckResourceAttr(resourceName, "display_name", "tstExaInfra"),
153152
resource.TestCheckResourceAttr(resourceName, "dns_server.#", "2"),
154153
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
@@ -170,13 +169,6 @@ func TestResourceDatabaseExadataInfrastructure_basic(t *testing.T) {
170169
},
171170
),
172171
},
173-
// verify update on activated infrastructure
174-
{
175-
Config: config + compartmentIdVariableStr + ExadataInfrastructureResourceActivateDependencies +
176-
generateResourceFromRepresentationMap("oci_database_exadata_infrastructure", "test_exadata_infrastructure", Optional, Create,
177-
representationCopyWithNewProperties(exadataInfrastructureActivateRepresentation, map[string]interface{}{"activation_file": Representation{repType: Optional, update: activationFilePath}})),
178-
ExpectError: regexp.MustCompile("update not allowed on activated exadata infrastructure"),
179-
},
180172
},
181173
})
182174
}

0 commit comments

Comments
 (0)