Skip to content

Commit 0034437

Browse files
sai pranavi manthanisagarp337
authored andcommitted
Added - Support for ADB on ExaCC | Long Term Backup Retention
1 parent 00ed254 commit 0034437

20 files changed

+407
-37
lines changed

examples/database/exadata_cc/adbd/acd.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ resource "random_string" "db_unique_name" {
66

77
resource "oci_database_autonomous_container_database" "autonomous_container_database" {
88
autonomous_vm_cluster_id = oci_database_autonomous_vm_cluster.test_autonomous_vm_cluster.id
9+
db_version = "19.18.0.1.0"
910
backup_config {
1011
backup_destination_details {
1112
type = "LOCAL"

examples/database/exadata_cc/adbd/adb.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ resource "oci_database_autonomous_database" "test_autonomous_database" {
1010
#Required
1111
admin_password = random_string.autonomous_database_admin_password.result
1212
compartment_id = var.compartment_ocid
13-
cpu_core_count = "1"
13+
compute_count = "2"
1414
data_storage_size_in_tbs = "1"
1515
db_name = "atpdb1"
1616

internal/integrationtest/database_autonomous_container_database_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ var (
5454
"version_preference": acctest.Representation{RepType: acctest.Optional, Create: `LATEST_RELEASE_UPDATE`, Update: `NEXT_RELEASE_UPDATE`},
5555
"display_name": acctest.Representation{RepType: acctest.Required, Create: `containerDatabase2`, Update: `displayName2`},
5656
"patch_model": acctest.Representation{RepType: acctest.Required, Create: `RELEASE_UPDATES`, Update: `RELEASE_UPDATE_REVISIONS`},
57+
"db_version": acctest.Representation{RepType: acctest.Required, Create: `19.18.0.1.0`},
5758
"cloud_autonomous_vm_cluster_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_database_cloud_autonomous_vm_cluster.test_cloud_autonomous_vm_cluster.id}`},
5859
"backup_config": acctest.RepresentationGroup{RepType: acctest.Optional, Group: ACDatabaseBackupConfigRepresentation},
5960
"compartment_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.compartment_id}`},

internal/integrationtest/database_autonomous_database_backup_test.go

Lines changed: 191 additions & 0 deletions
Large diffs are not rendered by default.

internal/integrationtest/database_autonomous_exadata_infrastructure_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ var (
6161
"nsg_ids": acctest.Representation{RepType: acctest.Optional, Create: []string{`${oci_core_network_security_group.test_network_security_group.id}`}, Update: []string{`${oci_core_network_security_group.test_network_security_group2.id}`}},
6262
}
6363
DatabaseAutonomousExadataInfrastructureMaintenanceWindowDetailsRepresentation = map[string]interface{}{
64-
"preference": acctest.Representation{RepType: acctest.Required, Create: `NO_PREFERENCE`, Update: `CUSTOM_PREFERENCE`},
6564
"custom_action_timeout_in_mins": acctest.Representation{RepType: acctest.Optional, Create: `10`, Update: `11`},
6665
"days_of_week": acctest.RepresentationGroup{RepType: acctest.Optional, Group: DatabaseAutonomousExadataInfrastructureMaintenanceWindowDetailsDaysOfWeekRepresentation},
6766
"hours_of_day": acctest.Representation{RepType: acctest.Optional, Create: []string{`4`}, Update: []string{`8`}},
@@ -70,6 +69,7 @@ var (
7069
"lead_time_in_weeks": acctest.Representation{RepType: acctest.Optional, Create: `10`, Update: `11`},
7170
"months": acctest.RepresentationGroup{RepType: acctest.Optional, Group: DatabaseAutonomousExadataInfrastructureMaintenanceWindowDetailsMonthsRepresentation},
7271
"patching_mode": acctest.Representation{RepType: acctest.Optional, Create: `ROLLING`, Update: `NONROLLING`},
72+
"preference": acctest.Representation{RepType: acctest.Optional, Create: `NO_PREFERENCE`, Update: `CUSTOM_PREFERENCE`},
7373
"weeks_of_month": acctest.Representation{RepType: acctest.Optional, Create: []string{`1`}, Update: []string{`2`}},
7474
}
7575
DatabaseAutonomousExadataInfrastructureMaintenanceWindowDetailsDaysOfWeekRepresentation = map[string]interface{}{

internal/integrationtest/database_autonomous_vm_cluster_test.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,16 @@ var (
8080
})
8181

8282
DatabaseAutonomousVmClusterMaintenanceWindowDetailsRepresentation = map[string]interface{}{
83-
"preference": acctest.Representation{RepType: acctest.Required, Create: `CUSTOM_PREFERENCE`, Update: `CUSTOM_PREFERENCE`},
84-
"days_of_week": acctest.RepresentationGroup{RepType: acctest.Optional, Group: DatabaseAutonomousVmClusterMaintenanceWindowDetailsDaysOfWeekRepresentation},
85-
"hours_of_day": acctest.Representation{RepType: acctest.Optional, Create: []string{`0`}, Update: []string{`4`}},
86-
"lead_time_in_weeks": acctest.Representation{RepType: acctest.Optional, Create: `1`, Update: `2`},
87-
"months": []acctest.RepresentationGroup{{RepType: acctest.Optional, Group: DatabaseAutonomousVmClusterMaintenanceWindowDetailsMonthsRepresentation}, {RepType: acctest.Optional, Group: DatabaseAutonomousVmClusterMaintenanceWindowDetailsMonthsRepresentation2}, {RepType: acctest.Optional, Group: DatabaseAutonomousVmClusterMaintenanceWindowDetailsMonthsRepresentation3}, {RepType: acctest.Optional, Group: DatabaseAutonomousVmClusterMaintenanceWindowDetailsMonthsRepresentation4}},
88-
"weeks_of_month": acctest.Representation{RepType: acctest.Optional, Create: []string{`1`}, Update: []string{`2`}},
83+
"preference": acctest.Representation{RepType: acctest.Optional, Create: `CUSTOM_PREFERENCE`, Update: `CUSTOM_PREFERENCE`},
84+
"days_of_week": acctest.RepresentationGroup{RepType: acctest.Optional, Group: DatabaseAutonomousVmClusterMaintenanceWindowDetailsDaysOfWeekRepresentation},
85+
"hours_of_day": acctest.Representation{RepType: acctest.Optional, Create: []string{`0`}, Update: []string{`4`}},
86+
"lead_time_in_weeks": acctest.Representation{RepType: acctest.Optional, Create: `1`, Update: `2`},
87+
"months": []acctest.RepresentationGroup{{RepType: acctest.Optional, Group: DatabaseAutonomousVmClusterMaintenanceWindowDetailsMonthsRepresentation}, {RepType: acctest.Optional, Group: DatabaseAutonomousVmClusterMaintenanceWindowDetailsMonthsRepresentation2}, {RepType: acctest.Optional, Group: DatabaseAutonomousVmClusterMaintenanceWindowDetailsMonthsRepresentation3}, {RepType: acctest.Optional, Group: DatabaseAutonomousVmClusterMaintenanceWindowDetailsMonthsRepresentation4}},
88+
"weeks_of_month": acctest.Representation{RepType: acctest.Optional, Create: []string{`1`}, Update: []string{`2`}},
89+
"custom_action_timeout_in_mins": acctest.Representation{RepType: acctest.Optional, Create: `10`, Update: `11`},
90+
"is_custom_action_timeout_enabled": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `true`},
91+
"is_monthly_patching_enabled": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `true`},
92+
"patching_mode": acctest.Representation{RepType: acctest.Optional, Create: `ROLLING`, Update: `NONROLLING`},
8993
}
9094
DatabaseAutonomousVmClusterMaintenanceWindowDetailsDaysOfWeekRepresentation = map[string]interface{}{
9195
"name": acctest.Representation{RepType: acctest.Required, Create: `MONDAY`, Update: `TUESDAY`},
@@ -338,6 +342,7 @@ func TestDatabaseAutonomousVmClusterResource_basic(t *testing.T) {
338342
resource.TestCheckResourceAttrSet(datasourceName, "autonomous_vm_clusters.0.available_container_databases"),
339343
//resource.TestCheckResourceAttr(datasourceName, "autonomous_vm_clusters.0.autonomous_data_storage_size_in_tbs", "1"),
340344
resource.TestCheckResourceAttrSet(datasourceName, "autonomous_vm_clusters.0.available_cpus"),
345+
resource.TestCheckResourceAttr(datasourceName, "autonomous_vm_clusters.0.compute_model", "OCPU"),
341346
resource.TestCheckResourceAttrSet(datasourceName, "autonomous_vm_clusters.0.available_data_storage_size_in_tbs"),
342347
resource.TestCheckResourceAttr(datasourceName, "autonomous_vm_clusters.0.compartment_id", compartmentId),
343348
resource.TestCheckResourceAttr(datasourceName, "autonomous_vm_clusters.0.compute_model", "OCPU"),
@@ -383,6 +388,7 @@ func TestDatabaseAutonomousVmClusterResource_basic(t *testing.T) {
383388
//resource.TestCheckResourceAttr(singularDatasourceName, "autonomous_data_storage_size_in_tbs", "1"),
384389
resource.TestCheckResourceAttrSet(singularDatasourceName, "available_cpus"),
385390
resource.TestCheckResourceAttrSet(singularDatasourceName, "available_data_storage_size_in_tbs"),
391+
resource.TestCheckResourceAttr(singularDatasourceName, "compute_model", "OCPU"),
386392
resource.TestCheckResourceAttr(singularDatasourceName, "compartment_id", compartmentId),
387393
resource.TestCheckResourceAttr(singularDatasourceName, "compute_model", "OCPU"),
388394
resource.TestCheckResourceAttr(singularDatasourceName, "cpu_core_count_per_node", "10"),

internal/integrationtest/database_cloud_autonomous_vm_cluster_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ var (
6969
"ignore_changes": acctest.Representation{RepType: acctest.Optional, Create: []string{`autonomous_data_storage_size_in_tbs`, `cpu_core_count_per_node`}},
7070
}
7171
DatabaseCloudAutonomousVmClusterMaintenanceWindowDetailsRepresentation = map[string]interface{}{
72-
"preference": acctest.Representation{RepType: acctest.Required, Create: `NO_PREFERENCE`, Update: `NO_PREFERENCE`},
72+
"preference": acctest.Representation{RepType: acctest.Optional, Create: `NO_PREFERENCE`, Update: `NO_PREFERENCE`},
7373
"custom_action_timeout_in_mins": acctest.Representation{RepType: acctest.Optional, Create: `10`, Update: `11`},
7474
"days_of_week": acctest.RepresentationGroup{RepType: acctest.Optional, Group: DatabaseCloudAutonomousVmClusterMaintenanceWindowDetailsDaysOfWeekRepresentation},
7575
"hours_of_day": acctest.Representation{RepType: acctest.Optional, Create: []string{`0`}, Update: []string{`4`}},

internal/service/database/database_autonomous_container_database_resource.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,6 @@ func DatabaseAutonomousContainerDatabaseResource() *schema.Resource {
183183
Elem: &schema.Resource{
184184
Schema: map[string]*schema.Schema{
185185
// Required
186-
"preference": {
187-
Type: schema.TypeString,
188-
Required: true,
189-
},
190186

191187
// Optional
192188
"custom_action_timeout_in_mins": {
@@ -260,6 +256,11 @@ func DatabaseAutonomousContainerDatabaseResource() *schema.Resource {
260256
Optional: true,
261257
Computed: true,
262258
},
259+
"preference": {
260+
Type: schema.TypeString,
261+
Optional: true,
262+
Computed: true,
263+
},
263264
"weeks_of_month": {
264265
Type: schema.TypeList,
265266
Optional: true,

internal/service/database/database_autonomous_database_backup_data_source.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ func (s *DatabaseAutonomousDatabaseBackupDataSourceCrud) SetData() error {
7070
s.D.Set("autonomous_database_id", *s.Res.AutonomousDatabaseId)
7171
}
7272

73+
if s.Res.BackupDestinationDetails != nil {
74+
s.D.Set("backup_destination_details", []interface{}{AutonomousBackupDestinationDetailsToMap(s.Res.BackupDestinationDetails)})
75+
} else {
76+
s.D.Set("backup_destination_details", nil)
77+
}
78+
7379
if s.Res.CompartmentId != nil {
7480
s.D.Set("compartment_id", *s.Res.CompartmentId)
7581
}

internal/service/database/database_autonomous_database_backup_resource.go

Lines changed: 120 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package database
55

66
import (
77
"context"
8+
"fmt"
89
"time"
910

1011
"github.com/oracle/terraform-provider-oci/internal/client"
@@ -51,9 +52,51 @@ func DatabaseAutonomousDatabaseBackupResource() *schema.Resource {
5152
Computed: true,
5253
},
5354

54-
// Optional
55-
5655
// Computed
56+
"backup_destination_details": {
57+
Type: schema.TypeList,
58+
Optional: true,
59+
Computed: true,
60+
ForceNew: true,
61+
MaxItems: 1,
62+
MinItems: 1,
63+
Elem: &schema.Resource{
64+
Schema: map[string]*schema.Schema{
65+
"type": {
66+
Type: schema.TypeString,
67+
Required: true,
68+
ForceNew: true,
69+
},
70+
71+
// Optional
72+
"id": {
73+
Type: schema.TypeString,
74+
Optional: true,
75+
Computed: true,
76+
ForceNew: true,
77+
},
78+
"internet_proxy": {
79+
Type: schema.TypeString,
80+
Optional: true,
81+
Computed: true,
82+
ForceNew: true,
83+
},
84+
"vpc_password": {
85+
Type: schema.TypeString,
86+
Optional: true,
87+
Computed: true,
88+
ForceNew: true,
89+
Sensitive: true,
90+
},
91+
"vpc_user": {
92+
Type: schema.TypeString,
93+
Optional: true,
94+
Computed: true,
95+
ForceNew: true,
96+
},
97+
},
98+
},
99+
},
57100
"compartment_id": {
58101
Type: schema.TypeString,
59102
Computed: true,
@@ -222,6 +265,17 @@ func (s *DatabaseAutonomousDatabaseBackupResourceCrud) Create() error {
222265
request.RetentionPeriodInDays = &tmp
223266
}
224267

268+
if backupDestinationDetails, ok := s.D.GetOkExists("backup_destination_details"); ok {
269+
if tmpList := backupDestinationDetails.([]interface{}); len(tmpList) > 0 {
270+
fieldKeyFormat := fmt.Sprintf("%s.%d.%%s", "backup_destination_details", 0)
271+
tmp, err := s.mapToAutonomousBackupDestinationDetails(fieldKeyFormat)
272+
if err != nil {
273+
return err
274+
}
275+
request.BackupDestinationDetails = &tmp
276+
}
277+
}
278+
225279
request.RequestMetadata.RetryPolicy = tfresource.GetRetryPolicy(s.DisableNotFoundRetries, "database")
226280

227281
response, err := s.Client.CreateAutonomousDatabaseBackup(context.Background(), request)
@@ -304,6 +358,16 @@ func (s *DatabaseAutonomousDatabaseBackupResourceCrud) SetData() error {
304358
s.D.Set("autonomous_database_id", *s.Res.AutonomousDatabaseId)
305359
}
306360

361+
if s.Res.BackupDestinationDetails != nil {
362+
s.D.Set("backup_destination_details", []interface{}{AutonomousBackupDestinationDetailsToMap(s.Res.BackupDestinationDetails)})
363+
} else {
364+
s.D.Set("backup_destination_details", nil)
365+
}
366+
367+
//if s.Res.DbVersion != nil {
368+
// s.D.Set("db_version", *s.Res.DbVersion)
369+
//}
370+
307371
if s.Res.CompartmentId != nil {
308372
s.D.Set("compartment_id", *s.Res.CompartmentId)
309373
}
@@ -378,3 +442,57 @@ func (s *DatabaseAutonomousDatabaseBackupResourceCrud) SetData() error {
378442

379443
return nil
380444
}
445+
446+
func (s *DatabaseAutonomousDatabaseBackupResourceCrud) mapToAutonomousBackupDestinationDetails(fieldKeyFormat string) (oci_database.BackupDestinationDetails, error) {
447+
result := oci_database.BackupDestinationDetails{}
448+
449+
if id, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "id")); ok {
450+
tmp := id.(string)
451+
result.Id = &tmp
452+
}
453+
454+
if internetProxy, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "internet_proxy")); ok {
455+
tmp := internetProxy.(string)
456+
result.InternetProxy = &tmp
457+
}
458+
459+
if type_, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "type")); ok {
460+
result.Type = oci_database.BackupDestinationDetailsTypeEnum(type_.(string))
461+
}
462+
463+
if vpcPassword, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "vpc_password")); ok {
464+
tmp := vpcPassword.(string)
465+
result.VpcPassword = &tmp
466+
}
467+
468+
if vpcUser, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "vpc_user")); ok {
469+
tmp := vpcUser.(string)
470+
result.VpcUser = &tmp
471+
}
472+
473+
return result, nil
474+
}
475+
476+
func AutonomousBackupDestinationDetailsToMap(obj *oci_database.BackupDestinationDetails) map[string]interface{} {
477+
result := map[string]interface{}{}
478+
479+
if obj.Id != nil {
480+
result["id"] = string(*obj.Id)
481+
}
482+
483+
if obj.InternetProxy != nil {
484+
result["internet_proxy"] = string(*obj.InternetProxy)
485+
}
486+
487+
result["type"] = string(obj.Type)
488+
489+
if obj.VpcPassword != nil {
490+
result["vpc_password"] = string(*obj.VpcPassword)
491+
}
492+
493+
if obj.VpcUser != nil {
494+
result["vpc_user"] = string(*obj.VpcUser)
495+
}
496+
497+
return result
498+
}

0 commit comments

Comments
 (0)