Skip to content

Commit 8a251da

Browse files
Gaurav Singhpvkrishnachaitanya
authored andcommitted
Added - Support for ADB-S: Maintenance Window Enhancements
1 parent 8c532de commit 8a251da

12 files changed

+203
-21
lines changed

internal/integrationtest/database_autonomous_database_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,6 @@ func TestDatabaseAutonomousDatabaseResource_basic(t *testing.T) {
416416
acctest.RepresentationCopyWithRemovedProperties(acctest.RepresentationCopyWithNewProperties(DatabaseAutonomousDatabaseRepresentation, map[string]interface{}{
417417
"secret_id": acctest.Representation{RepType: acctest.Required, Create: `${var.okv_secret}`},
418418
"secret_version_number": acctest.Representation{RepType: acctest.Required, Create: `1`},
419-
"subscription_id": acctest.Representation{RepType: acctest.Required, Create: `subscriptionId1`},
420419
}), []string{"admin_password"})),
421420
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
422421
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
@@ -426,7 +425,6 @@ func TestDatabaseAutonomousDatabaseResource_basic(t *testing.T) {
426425
resource.TestCheckResourceAttr(resourceName, "db_name", adbName),
427426
// verify computed field db_workload to be defaulted to OLTP
428427
resource.TestCheckResourceAttr(resourceName, "db_workload", "OLTP"),
429-
resource.TestCheckResourceAttr(resourceName, "subscription_id", "subscriptionId1"),
430428

431429
func(s *terraform.State) (err error) {
432430
resId, err = acctest.FromInstanceState(s, resourceName, "id")
@@ -510,7 +508,7 @@ func TestDatabaseAutonomousDatabaseResource_basic(t *testing.T) {
510508
acctest.GenerateResourceFromRepresentationMap("oci_database_autonomous_database", "test_autonomous_database", acctest.Optional, acctest.Create, autonomousDatabaseRepresentationECPU),
511509
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
512510
resource.TestCheckResourceAttr(resourceName, "compute_model", "ECPU"),
513-
511+
resource.TestCheckResourceAttrSet(resourceName, "maintenance_target_component"),
514512
resource.TestCheckResourceAttr(resourceName, "db_tools_details.#", "7"),
515513
acctest.CheckResourceSetContainsElementWithProperties(resourceName, "db_tools_details", map[string]string{
516514
"name": "APEX",

internal/service/database/database_autonomous_database_data_source.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,10 @@ func (s *DatabaseAutonomousDatabaseDataSourceCrud) SetData() error {
491491
s.D.Set("time_maintenance_end", s.Res.TimeMaintenanceEnd.String())
492492
}
493493

494+
if s.Res.MaintenanceTargetComponent != nil {
495+
s.D.Set("maintenance_target_component", *s.Res.MaintenanceTargetComponent)
496+
}
497+
494498
if s.Res.TimeOfAutoRefreshStart != nil {
495499
s.D.Set("time_of_auto_refresh_start", s.Res.TimeOfAutoRefreshStart.Format(time.RFC3339Nano))
496500
}

internal/service/database/database_autonomous_database_resource.go

Lines changed: 80 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,10 @@ func DatabaseAutonomousDatabaseResource() *schema.Resource {
10871087
Type: schema.TypeString,
10881088
Computed: true,
10891089
},
1090+
"maintenance_target_component": {
1091+
Type: schema.TypeString,
1092+
Computed: true,
1093+
},
10901094
"state": {
10911095
Type: schema.TypeString,
10921096
Computed: true,
@@ -1099,6 +1103,14 @@ func DatabaseAutonomousDatabaseResource() *schema.Resource {
10991103
Type: schema.TypeString,
11001104
Computed: true,
11011105
},
1106+
"time_maintenance_begin": {
1107+
Type: schema.TypeString,
1108+
Computed: true,
1109+
},
1110+
"time_maintenance_end": {
1111+
Type: schema.TypeString,
1112+
Computed: true,
1113+
},
11021114
},
11031115
},
11041116
},
@@ -1137,6 +1149,10 @@ func DatabaseAutonomousDatabaseResource() *schema.Resource {
11371149
},
11381150
},
11391151
},
1152+
"maintenance_target_component": {
1153+
Type: schema.TypeString,
1154+
Computed: true,
1155+
},
11401156
"memory_per_oracle_compute_unit_in_gbs": {
11411157
Type: schema.TypeInt,
11421158
Computed: true,
@@ -1300,6 +1316,10 @@ func DatabaseAutonomousDatabaseResource() *schema.Resource {
13001316
Type: schema.TypeString,
13011317
Computed: true,
13021318
},
1319+
"maintenance_target_component": {
1320+
Type: schema.TypeString,
1321+
Computed: true,
1322+
},
13031323
"state": {
13041324
Type: schema.TypeString,
13051325
Computed: true,
@@ -1312,6 +1332,14 @@ func DatabaseAutonomousDatabaseResource() *schema.Resource {
13121332
Type: schema.TypeString,
13131333
Computed: true,
13141334
},
1335+
"time_maintenance_begin": {
1336+
Type: schema.TypeString,
1337+
Computed: true,
1338+
},
1339+
"time_maintenance_end": {
1340+
Type: schema.TypeString,
1341+
Computed: true,
1342+
},
13151343
},
13161344
},
13171345
},
@@ -2043,6 +2071,11 @@ func (s *DatabaseAutonomousDatabaseResourceCrud) Update() error {
20432071
}
20442072
}
20452073

2074+
//if maxCpuCoreCount, ok := s.D.GetOkExists("max_cpu_core_count"); ok && s.D.HasChange("max_cpu_core_count") {
2075+
// tmp := maxCpuCoreCount.(int)
2076+
// request.MaxCpuCoreCount = &tmp
2077+
//}
2078+
20462079
var updateNewtworkAccessFlag = false
20472080
if _, ok := s.D.GetOkExists("nsg_ids"); ok && s.D.HasChange("nsg_ids") {
20482081
updateNewtworkAccessFlag = true
@@ -2537,10 +2570,21 @@ func (s *DatabaseAutonomousDatabaseResourceCrud) SetData() error {
25372570
s.D.Set("long_term_backup_schedule", nil)
25382571
}
25392572

2573+
if s.Res.MaintenanceTargetComponent != nil {
2574+
s.D.Set("maintenance_target_component", *s.Res.MaintenanceTargetComponent)
2575+
}
2576+
//if s.Res.MaxCpuCoreCount != nil {
2577+
// s.D.Set("max_cpu_core_count", *s.Res.MaxCpuCoreCount)
2578+
//}
2579+
25402580
if s.Res.MemoryPerOracleComputeUnitInGBs != nil {
25412581
s.D.Set("memory_per_oracle_compute_unit_in_gbs", *s.Res.MemoryPerOracleComputeUnitInGBs)
25422582
}
25432583

2584+
//if s.Res.MaxCpuCoreCount != nil {
2585+
// s.D.Set("max_cpu_core_count", *s.Res.MaxCpuCoreCount)
2586+
//}
2587+
25442588
if s.Res.NcharacterSet != nil {
25452589
s.D.Set("ncharacter_set", *s.Res.NcharacterSet)
25462590
}
@@ -3055,6 +3099,10 @@ func AutonomousDatabaseStandbySummaryToMap(obj *oci_database.AutonomousDatabaseS
30553099
result["lifecycle_details"] = string(*obj.LifecycleDetails)
30563100
}
30573101

3102+
if obj.MaintenanceTargetComponent != nil {
3103+
result["maintenance_target_component"] = string(*obj.MaintenanceTargetComponent)
3104+
}
3105+
30583106
result["state"] = string(obj.LifecycleState)
30593107

30603108
if obj.TimeDataGuardRoleChanged != nil {
@@ -3065,6 +3113,14 @@ func AutonomousDatabaseStandbySummaryToMap(obj *oci_database.AutonomousDatabaseS
30653113
result["time_disaster_recovery_role_changed"] = obj.TimeDisasterRecoveryRoleChanged.String()
30663114
}
30673115

3116+
if obj.TimeMaintenanceBegin != nil {
3117+
result["time_maintenance_begin"] = obj.TimeMaintenanceBegin.String()
3118+
}
3119+
3120+
if obj.TimeMaintenanceEnd != nil {
3121+
result["time_maintenance_end"] = obj.TimeMaintenanceEnd.String()
3122+
}
3123+
30683124
return result
30693125
}
30703126

@@ -3511,7 +3567,10 @@ func (s *DatabaseAutonomousDatabaseResourceCrud) populateTopLevelPolymorphicCrea
35113567
if licenseModel, ok := s.D.GetOkExists("license_model"); ok {
35123568
details.LicenseModel = oci_database.CreateAutonomousDatabaseBaseLicenseModelEnum(licenseModel.(string))
35133569
}
3514-
3570+
//if maxCpuCoreCount, ok := s.D.GetOkExists("max_cpu_core_count"); ok {
3571+
// tmp := maxCpuCoreCount.(int)
3572+
// details.MaxCpuCoreCount = &tmp
3573+
//}
35153574
if ncharacterSet, ok := s.D.GetOkExists("ncharacter_set"); ok {
35163575
tmp := ncharacterSet.(string)
35173576
details.NcharacterSet = &tmp
@@ -3828,7 +3887,10 @@ func (s *DatabaseAutonomousDatabaseResourceCrud) populateTopLevelPolymorphicCrea
38283887
if licenseModel, ok := s.D.GetOkExists("license_model"); ok {
38293888
details.LicenseModel = oci_database.CreateAutonomousDatabaseBaseLicenseModelEnum(licenseModel.(string))
38303889
}
3831-
3890+
//if maxCpuCoreCount, ok := s.D.GetOkExists("max_cpu_core_count"); ok {
3891+
// tmp := maxCpuCoreCount.(int)
3892+
// details.MaxCpuCoreCount = &tmp
3893+
//}
38323894
if ncharacterSet, ok := s.D.GetOkExists("ncharacter_set"); ok {
38333895
tmp := ncharacterSet.(string)
38343896
details.NcharacterSet = &tmp
@@ -4128,7 +4190,10 @@ func (s *DatabaseAutonomousDatabaseResourceCrud) populateTopLevelPolymorphicCrea
41284190
if licenseModel, ok := s.D.GetOkExists("license_model"); ok {
41294191
details.LicenseModel = oci_database.CreateAutonomousDatabaseBaseLicenseModelEnum(licenseModel.(string))
41304192
}
4131-
4193+
//if maxCpuCoreCount, ok := s.D.GetOkExists("max_cpu_core_count"); ok {
4194+
// tmp := maxCpuCoreCount.(int)
4195+
// details.MaxCpuCoreCount = &tmp
4196+
//}
41324197
if ncharacterSet, ok := s.D.GetOkExists("ncharacter_set"); ok {
41334198
tmp := ncharacterSet.(string)
41344199
details.NcharacterSet = &tmp
@@ -4956,7 +5021,10 @@ func (s *DatabaseAutonomousDatabaseResourceCrud) populateTopLevelPolymorphicCrea
49565021
if licenseModel, ok := s.D.GetOkExists("license_model"); ok {
49575022
details.LicenseModel = oci_database.CreateAutonomousDatabaseBaseLicenseModelEnum(licenseModel.(string))
49585023
}
4959-
5024+
//if maxCpuCoreCount, ok := s.D.GetOkExists("max_cpu_core_count"); ok {
5025+
// tmp := maxCpuCoreCount.(int)
5026+
// details.MaxCpuCoreCount = &tmp
5027+
//}
49605028
if ncharacterSet, ok := s.D.GetOkExists("ncharacter_set"); ok {
49615029
tmp := ncharacterSet.(string)
49625030
details.NcharacterSet = &tmp
@@ -5240,7 +5308,10 @@ func (s *DatabaseAutonomousDatabaseResourceCrud) populateTopLevelPolymorphicCrea
52405308
if licenseModel, ok := s.D.GetOkExists("license_model"); ok {
52415309
details.LicenseModel = oci_database.CreateAutonomousDatabaseBaseLicenseModelEnum(licenseModel.(string))
52425310
}
5243-
5311+
//if maxCpuCoreCount, ok := s.D.GetOkExists("max_cpu_core_count"); ok {
5312+
// tmp := maxCpuCoreCount.(int)
5313+
// details.MaxCpuCoreCount = &tmp
5314+
//}
52445315
if ncharacterSet, ok := s.D.GetOkExists("ncharacter_set"); ok {
52455316
tmp := ncharacterSet.(string)
52465317
details.NcharacterSet = &tmp
@@ -5527,7 +5598,10 @@ func (s *DatabaseAutonomousDatabaseResourceCrud) populateTopLevelPolymorphicCrea
55275598
if licenseModel, ok := s.D.GetOkExists("license_model"); ok {
55285599
details.LicenseModel = oci_database.CreateAutonomousDatabaseBaseLicenseModelEnum(licenseModel.(string))
55295600
}
5530-
5601+
//if maxCpuCoreCount, ok := s.D.GetOkExists("max_cpu_core_count"); ok {
5602+
// tmp := maxCpuCoreCount.(int)
5603+
// details.MaxCpuCoreCount = &tmp
5604+
//}
55315605
if ncharacterSet, ok := s.D.GetOkExists("ncharacter_set"); ok {
55325606
tmp := ncharacterSet.(string)
55335607
details.NcharacterSet = &tmp

internal/service/database/database_autonomous_databases_clones_data_source.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,10 @@ func DatabaseAutonomousDatabasesClonesDataSource() *schema.Resource {
715715
Type: schema.TypeString,
716716
Computed: true,
717717
},
718+
"maintenance_target_component": {
719+
Type: schema.TypeString,
720+
Computed: true,
721+
},
718722
"state": {
719723
Type: schema.TypeString,
720724
Computed: true,
@@ -727,6 +731,14 @@ func DatabaseAutonomousDatabasesClonesDataSource() *schema.Resource {
727731
Type: schema.TypeString,
728732
Computed: true,
729733
},
734+
"time_maintenance_begin": {
735+
Type: schema.TypeString,
736+
Computed: true,
737+
},
738+
"time_maintenance_end": {
739+
Type: schema.TypeString,
740+
Computed: true,
741+
},
730742
},
731743
},
732744
},
@@ -763,6 +775,10 @@ func DatabaseAutonomousDatabasesClonesDataSource() *schema.Resource {
763775
},
764776
},
765777
},
778+
"maintenance_target_component": {
779+
Type: schema.TypeString,
780+
Computed: true,
781+
},
766782
"max_cpu_core_count": {
767783
Type: schema.TypeInt,
768784
Computed: true,
@@ -1008,6 +1024,10 @@ func DatabaseAutonomousDatabasesClonesDataSource() *schema.Resource {
10081024
Type: schema.TypeString,
10091025
Computed: true,
10101026
},
1027+
"maintenance_target_component": {
1028+
Type: schema.TypeString,
1029+
Computed: true,
1030+
},
10111031
"state": {
10121032
Type: schema.TypeString,
10131033
Computed: true,
@@ -1020,6 +1040,14 @@ func DatabaseAutonomousDatabasesClonesDataSource() *schema.Resource {
10201040
Type: schema.TypeString,
10211041
Computed: true,
10221042
},
1043+
"time_maintenance_begin": {
1044+
Type: schema.TypeString,
1045+
Computed: true,
1046+
},
1047+
"time_maintenance_end": {
1048+
Type: schema.TypeString,
1049+
Computed: true,
1050+
},
10231051
},
10241052
},
10251053
},
@@ -1506,10 +1534,21 @@ func (s *DatabaseAutonomousDatabasesClonesDataSourceCrud) SetData() error {
15061534
autonomousDatabasesClone["long_term_backup_schedule"] = nil
15071535
}
15081536

1537+
if r.MaintenanceTargetComponent != nil {
1538+
autonomousDatabasesClone["maintenance_target_component"] = *r.MaintenanceTargetComponent
1539+
}
1540+
//if r.MaxCpuCoreCount != nil {
1541+
// autonomousDatabasesClone["max_cpu_core_count"] = *r.MaxCpuCoreCount
1542+
//}
1543+
15091544
if r.MemoryPerOracleComputeUnitInGBs != nil {
15101545
autonomousDatabasesClone["memory_per_oracle_compute_unit_in_gbs"] = *r.MemoryPerOracleComputeUnitInGBs
15111546
}
15121547

1548+
//if r.MaxCpuCoreCount != nil {
1549+
// autonomousDatabasesClone["max_cpu_core_count"] = *r.MaxCpuCoreCount
1550+
//}
1551+
15131552
if r.NcharacterSet != nil {
15141553
autonomousDatabasesClone["ncharacter_set"] = *r.NcharacterSet
15151554
}

internal/service/database/database_autonomous_databases_data_source.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,10 +472,21 @@ func (s *DatabaseAutonomousDatabasesDataSourceCrud) SetData() error {
472472
autonomousDatabase["long_term_backup_schedule"] = nil
473473
}
474474

475+
if r.MaintenanceTargetComponent != nil {
476+
autonomousDatabase["maintenance_target_component"] = *r.MaintenanceTargetComponent
477+
}
478+
//if r.MaxCpuCoreCount != nil {
479+
// autonomousDatabase["max_cpu_core_count"] = *r.MaxCpuCoreCount
480+
//}
481+
475482
if r.MemoryPerOracleComputeUnitInGBs != nil {
476483
autonomousDatabase["memory_per_oracle_compute_unit_in_gbs"] = *r.MemoryPerOracleComputeUnitInGBs
477484
}
478485

486+
//if r.MaxCpuCoreCount != nil {
487+
// autonomousDatabase["max_cpu_core_count"] = *r.MaxCpuCoreCount
488+
//}
489+
479490
if r.NcharacterSet != nil {
480491
autonomousDatabase["ncharacter_set"] = *r.NcharacterSet
481492
}

internal/service/database/database_maintenance_runs_data_source.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ func DatabaseMaintenanceRunsDataSource() *schema.Resource {
2727
Type: schema.TypeString,
2828
Required: true,
2929
},
30+
"is_local_adg": {
31+
Type: schema.TypeBool,
32+
Optional: true,
33+
},
3034
"maintenance_subtype": {
3135
Type: schema.TypeString,
3236
Optional: true,
@@ -87,6 +91,11 @@ func (s *DatabaseMaintenanceRunsDataSourceCrud) Get() error {
8791
request.CompartmentId = &tmp
8892
}
8993

94+
if isLocalAdg, ok := s.D.GetOkExists("is_local_adg"); ok {
95+
tmp := isLocalAdg.(bool)
96+
request.IsLocalAdg = &tmp
97+
}
98+
9099
if maintenanceSubtype, ok := s.D.GetOkExists("maintenance_subtype"); ok {
91100
request.MaintenanceSubtype = oci_database.MaintenanceRunSummaryMaintenanceSubtypeEnum(maintenanceSubtype.(string))
92101
}

website/docs/d/database_autonomous_database.html.markdown

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ The following attributes are exported:
216216
* `repeat_cadence` - The frequency of the long-term backup schedule
217217
* `retention_period_in_days` - Retention period, in days, for long-term backups
218218
* `time_of_backup` - The timestamp for the long-term backup schedule. For a MONTHLY cadence, months having fewer days than the provided date will have the backup taken on the last day of that month.
219+
* `maintenance_target_component` - The component chosen for maintenance.
219220
* `memory_per_oracle_compute_unit_in_gbs` - The amount of memory (in GBs) enabled per ECPU or OCPU.
220221
* `ncharacter_set` - The national character set for the autonomous database. The default is AL16UTF16. Allowed values are: AL16UTF16 or UTF8.
221222
* `net_services_architecture` - Enabling SHARED server architecture enables a database server to allow many client processes to share very few server processes, thereby increasing the number of supported users.
@@ -280,9 +281,12 @@ The following attributes are exported:
280281
* `availability_domain` - The availability domain of a local Autonomous Data Guard standby database of an Autonomous Database Serverless instance.
281282
* `lag_time_in_seconds` - The amount of time, in seconds, that the data of the standby database lags the data of the primary database. Can be used to determine the potential data loss in the event of a failover.
282283
* `lifecycle_details` - Additional information about the current lifecycle state.
284+
* `maintenance_target_component` - The component chosen for maintenance.
283285
* `state` - The current state of the Autonomous Database.
284286
* `time_data_guard_role_changed` - The date and time the Autonomous Data Guard role was switched for the standby Autonomous Database.
285287
* `time_disaster_recovery_role_changed` - The date and time the Disaster Recovery role was switched for the standby Autonomous Database.
288+
* `time_maintenance_begin` - The date and time when maintenance will begin.
289+
* `time_maintenance_end` - The date and time when maintenance will end.
286290
* `standby_whitelisted_ips` - The client IP access control list (ACL). This feature is available for [Autonomous Database Serverless] (https://docs.oracle.com/en/cloud/paas/autonomous-database/index.html) and on Exadata Cloud@Customer. Only clients connecting from an IP address included in the ACL may access the Autonomous Database instance. If `arePrimaryWhitelistedIpsUsed` is 'TRUE' then Autonomous Database uses this primary's IP access control list (ACL) for the disaster recovery peer called `standbywhitelistedips`.
287291

288292
For shared Exadata infrastructure, this is an array of CIDR (Classless Inter-Domain Routing) notations for a subnet or VCN OCID. Use a semicolon (;) as a deliminator between the VCN-specific subnets or IPs. Example: `["1.1.1.1","1.1.1.0/24","ocid1.vcn.oc1.sea.<unique_id>","ocid1.vcn.oc1.sea.<unique_id1>;1.1.1.1","ocid1.vcn.oc1.sea.<unique_id2>;1.1.0.0/16"]` For Exadata Cloud@Customer, this is an array of IP addresses or CIDR (Classless Inter-Domain Routing) notations. Example: `["1.1.1.1","1.1.1.0/24","1.1.2.25"]`

0 commit comments

Comments
 (0)