Skip to content

Commit 7eece01

Browse files
committed
Support for oci_database_database resource for exadata infrastructure
1 parent 8c75867 commit 7eece01

19 files changed

+1564
-172
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### Added
44
- Support for `description` field in networking routing rules in `oci_core_route_table` and `oci_core_security_list`
55
- Support for Stop/Start Digital Assistant Instance
6+
- Support for `oci_database_database` resource for exadata infrastructure
67

78
## 3.57.0 (January 09, 2020)
89

examples/database/db_systems/db_exadata/resources.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,21 @@ resource "oci_database_exadata_iorm_config" "test_exadata_iorm_config" {
5959
share = 1
6060
}
6161
}
62+
63+
resource "oci_database_database" "test_database" {
64+
#Required
65+
database {
66+
admin_password = "${var.db_admin_password}"
67+
db_name = "${var.second_db_name}"
68+
character_set = "${var.character_set}"
69+
ncharacter_set = "${var.n_character_set}"
70+
db_workload = "${var.db_workload}"
71+
72+
db_backup_config {
73+
auto_backup_enabled = false
74+
}
75+
}
76+
77+
db_home_id = "${data.oci_database_db_homes.db_homes.db_homes.0.db_home_id}"
78+
source = "NONE"
79+
}

examples/database/db_systems/db_exadata/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ variable "db_name" {
3131
default = "aTFdb"
3232
}
3333

34+
variable "second_db_name" {
35+
default = "aTFdb2"
36+
}
37+
3438
variable "db_version" {
3539
default = "12.1.0.2"
3640
}

oci/database_database_data_source.go

Lines changed: 12 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -10,144 +10,12 @@ import (
1010
)
1111

1212
func DatabaseDatabaseDataSource() *schema.Resource {
13-
return &schema.Resource{
14-
Read: readSingularDatabaseDatabase,
15-
Schema: map[string]*schema.Schema{
16-
"database_id": {
17-
Type: schema.TypeString,
18-
Required: true,
19-
},
20-
// Computed
21-
"character_set": {
22-
Type: schema.TypeString,
23-
Computed: true,
24-
},
25-
"compartment_id": {
26-
Type: schema.TypeString,
27-
Computed: true,
28-
},
29-
"connection_strings": {
30-
Type: schema.TypeList,
31-
Computed: true,
32-
Elem: &schema.Resource{
33-
Schema: map[string]*schema.Schema{
34-
// Required
35-
36-
// Optional
37-
38-
// Computed
39-
"all_connection_strings": {
40-
Type: schema.TypeMap,
41-
Computed: true,
42-
Elem: schema.TypeString,
43-
},
44-
"cdb_default": {
45-
Type: schema.TypeString,
46-
Computed: true,
47-
},
48-
"cdb_ip_default": {
49-
Type: schema.TypeString,
50-
Computed: true,
51-
},
52-
},
53-
},
54-
},
55-
"db_backup_config": {
56-
Type: schema.TypeList,
57-
Computed: true,
58-
MaxItems: 1,
59-
MinItems: 1,
60-
Elem: &schema.Resource{
61-
Schema: map[string]*schema.Schema{
62-
// Required
63-
64-
// Optional
65-
66-
// Computed
67-
"auto_backup_enabled": {
68-
Type: schema.TypeBool,
69-
Computed: true,
70-
},
71-
"auto_backup_window": {
72-
Type: schema.TypeString,
73-
Computed: true,
74-
},
75-
"backup_destination_details": {
76-
Type: schema.TypeList,
77-
Computed: true,
78-
Elem: &schema.Resource{
79-
Schema: map[string]*schema.Schema{
80-
// Required
81-
82-
// Optional
83-
84-
// Computed
85-
"id": {
86-
Type: schema.TypeString,
87-
Computed: true,
88-
},
89-
"type": {
90-
Type: schema.TypeString,
91-
Computed: true,
92-
},
93-
},
94-
},
95-
},
96-
"recovery_window_in_days": {
97-
Type: schema.TypeInt,
98-
Computed: true,
99-
},
100-
},
101-
},
102-
},
103-
"db_home_id": {
104-
Type: schema.TypeString,
105-
Computed: true,
106-
},
107-
"db_name": {
108-
Type: schema.TypeString,
109-
Computed: true,
110-
},
111-
"db_unique_name": {
112-
Type: schema.TypeString,
113-
Computed: true,
114-
},
115-
"db_workload": {
116-
Type: schema.TypeString,
117-
Computed: true,
118-
},
119-
"defined_tags": {
120-
Type: schema.TypeMap,
121-
Computed: true,
122-
Elem: schema.TypeString,
123-
},
124-
"freeform_tags": {
125-
Type: schema.TypeMap,
126-
Computed: true,
127-
Elem: schema.TypeString,
128-
},
129-
"lifecycle_details": {
130-
Type: schema.TypeString,
131-
Computed: true,
132-
},
133-
"ncharacter_set": {
134-
Type: schema.TypeString,
135-
Computed: true,
136-
},
137-
"pdb_name": {
138-
Type: schema.TypeString,
139-
Computed: true,
140-
},
141-
"state": {
142-
Type: schema.TypeString,
143-
Computed: true,
144-
},
145-
"time_created": {
146-
Type: schema.TypeString,
147-
Computed: true,
148-
},
149-
},
13+
fieldMap := make(map[string]*schema.Schema)
14+
fieldMap["database_id"] = &schema.Schema{
15+
Type: schema.TypeString,
16+
Required: true,
15017
}
18+
return GetSingularDataSourceItemSchema(DatabaseDatabaseResource(), fieldMap, readSingularDatabaseDatabase)
15119
}
15220

15321
func readSingularDatabaseDatabase(d *schema.ResourceData, m interface{}) error {
@@ -222,6 +90,10 @@ func (s *DatabaseDatabaseDataSourceCrud) SetData() error {
22290
s.D.Set("db_name", *s.Res.DbName)
22391
}
22492

93+
if s.Res.DbSystemId != nil {
94+
s.D.Set("db_system_id", *s.Res.DbSystemId)
95+
}
96+
22597
if s.Res.DbUniqueName != nil {
22698
s.D.Set("db_unique_name", *s.Res.DbUniqueName)
22799
}
@@ -254,35 +126,9 @@ func (s *DatabaseDatabaseDataSourceCrud) SetData() error {
254126
s.D.Set("time_created", s.Res.TimeCreated.String())
255127
}
256128

257-
return nil
258-
}
259-
260-
func BackupDestinationDetailsToMap(obj oci_database.BackupDestinationDetails) map[string]interface{} {
261-
result := map[string]interface{}{}
262-
263-
if obj.Id != nil {
264-
result["id"] = string(*obj.Id)
129+
if s.Res.VmClusterId != nil {
130+
s.D.Set("vm_cluster_id", *s.Res.VmClusterId)
265131
}
266132

267-
result["type"] = string(obj.Type)
268-
269-
return result
270-
}
271-
272-
func DatabaseConnectionStringsToMap(obj *oci_database.DatabaseConnectionStrings) map[string]interface{} {
273-
result := map[string]interface{}{}
274-
275-
result["all_connection_strings"] = obj.AllConnectionStrings
276-
277-
if obj.CdbDefault != nil {
278-
result["cdb_default"] = string(*obj.CdbDefault)
279-
}
280-
281-
if obj.CdbIpDefault != nil {
282-
result["cdb_ip_default"] = string(*obj.CdbIpDefault)
283-
}
284-
285-
return result
133+
return nil
286134
}
287-
288-
// @CODEGEN 08/2018: Method DbBackupConfigToMap is available in database_db_system_resource.go

0 commit comments

Comments
 (0)