Skip to content

Commit ffb6a74

Browse files
authored
Add VMDB and licenseModel support for DBSystem (#317)
* Add VMDB and licenseModel support for DBSystem * Change the delete DBSystem to wait until the operation completes. TestResourceDatabaseDBSystemTestSuite now succeeds.
1 parent f49e6e5 commit ffb6a74

File tree

10 files changed

+118
-38
lines changed

10 files changed

+118
-38
lines changed

data_source_obmcs_database_db_system.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,19 @@ func (s *DBSystemDatasourceCrud) SetData() {
101101
"compartment_id": r.CompartmentID,
102102
"cpu_core_count": int(r.CPUCoreCount),
103103
"data_storage_percentage": r.DataStoragePercentage,
104+
"data_storage_size_in_gb": int(r.DataStorageSizeInGBs),
104105
"database_edition": r.DatabaseEdition,
105106
"db_home": []interface{}{dbHome},
106107
"display_name": r.DisplayName,
107108
"disk_redundancy": r.DiskRedundancy,
108109
"domain": r.Domain,
109110
"hostname": r.Hostname,
110111
"id": r.ID,
112+
"license_model": r.LicenseModel,
111113
"lifecycle_details": r.LifecycleDetails,
112114
"listener_port": int(r.ListenerPort),
115+
"node_count": int(r.NodeCount),
116+
"reco_storage_size_in_gb": int(r.RecoStorageSizeInGB),
113117
"scan_dns_record_id": r.ScanDnsRecordId,
114118
"scan_ip_ids": r.ScanIpIds,
115119
"shape": r.Shape,

docs/examples/db_systems/DBSystem.tf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@ resource "oci_database_db_system" "TFDBNode" {
2222
display_name = "${var.DBNodeDisplayName}"
2323
domain = "${var.DBNodeDomainName}"
2424
hostname = "${var.DBNodeHostName}"
25-
data_storage_percentage = "40"
25+
data_storage_percentage = "40"
26+
initial_data_storage_size_in_gb = "${var.InitialDataStorageSizeInGB}"
27+
license_model = "${var.LicenseModel}"
28+
node_count = "${var.NodeCount}"
2629
}

docs/examples/db_systems/variables.tf

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ variable "AD" {
1717

1818
# DBSystem specific
1919
variable "DBNodeShape" {
20-
default = "BM.DenseIO1.36"
20+
default = "VM.Standard1.2"
2121
}
2222

2323
variable "CPUCoreCount" {
@@ -85,5 +85,14 @@ variable "PDBName" {
8585
default = "pdbName"
8686
}
8787

88+
variable "InitialDataStorageSizeInGB" {
89+
default = "256"
90+
}
8891

92+
variable "LicenseModel" {
93+
default = "LICENSE_INCLUDED"
94+
}
8995

96+
variable "NodeCount" {
97+
default = "1"
98+
}

docs/resources/database/db_system.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ resource "oci_database_db_system" "TFDBNode" {
3232
domain = "${var.DBNodeDomainName}"
3333
hostname = "${var.DBNodeHostName}"
3434
data_storage_percentage = "${var.DataStoragePercentage}"
35+
initial_data_storage_size_in_gb = "${var.InitialDataStorageSizeInGB}"
36+
license_model = "${var.LicenseModel}"
37+
node_count = "${var.NodeCount}"
3538
}
3639
```
3740

@@ -51,6 +54,9 @@ The following arguments are supported:
5154
* `display_name` - (Optional) The user-friendly name for the DB System. It does not have to be unique.
5255
* `domain` - (Optional) A domain name to assign to the DB System.
5356
* `hostname` - (Required) The host name to assign to the DB Node.
57+
* `data_storage_size_in_gb` - (Optional) Size, in GBs, of the data volume that will be created and attached to VM-shape based DB system. This storage can later be scaled up if needed. Note that the total storage size attached will be more than what is requested, to account for REDO/RECO space and software volume.
58+
* `license_model` - (Optional) The Oracle license model that applies to all the databases on the DB System. The default is LICENSE_INCLUDED.
59+
* `node_count` - (Optional) Number of nodes to launch for a VM-shape based RAC DB system.
5460
* `shape` - (Required) The shape of the DB System.
5561
* `ssh_public_keys` - (Required) The public key portion of the key pair to use for SSH access to the DB System.
5662
* `subnet_id` - (Required) The OCID of the subnet the DB System is associated with.
@@ -81,6 +87,7 @@ The following attributes are exported:
8187
* `id` - The OCID of the DB System.
8288
* `lifecycle_details` - Additional information about the current lifecycleState.
8389
* `listener_port` - The port number configured for the listener on the DB System.
90+
* `reco_storage_size_in_gb` - RECO/REDO storage size, in GBs, that is currently allocated to the DB system. This is applicable only for VM-based DBs.
8491
* `scan_dns_record_id` - The OCID of the DNS record for the SCAN IP addresses that are associated with the DB System.
8592
* `scan_ip_ids` - The OCID of the Single Client Access Name (SCAN) IP addresses associated with the DB System. SCAN IP addresses are typically used for load balancing and are not assigned to any interface.
8693
* `state` - The current state of the DB System.

resource_obmcs_database_db_system.go

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package main
44

55
import (
66
"github.com/hashicorp/terraform/helper/schema"
7+
"github.com/hashicorp/terraform/helper/validation"
78
"github.com/oracle/bmcs-go-sdk"
89

910
"github.com/oracle/terraform-provider-oci/crud"
@@ -171,6 +172,27 @@ func DBSystemResource() *schema.Resource {
171172
Optional: true,
172173
ForceNew: true,
173174
},
175+
"data_storage_size_in_gb": {
176+
Type: schema.TypeInt,
177+
Computed: true,
178+
Optional: true,
179+
ForceNew: true,
180+
},
181+
"license_model": {
182+
Type: schema.TypeString,
183+
Computed: true,
184+
Optional: true,
185+
ForceNew: true,
186+
ValidateFunc: validation.StringInSlice([]string{
187+
string(baremetal.LicenseIncluded),
188+
string(baremetal.BringYourOwnLicense)}, false),
189+
},
190+
"node_count": {
191+
Type: schema.TypeInt,
192+
Computed: true,
193+
Optional: true,
194+
ForceNew: true,
195+
},
174196

175197
//Computed
176198
"id": {
@@ -185,6 +207,10 @@ func DBSystemResource() *schema.Resource {
185207
Type: schema.TypeInt,
186208
Computed: true,
187209
},
210+
"reco_storage_size_in_gb": {
211+
Type: schema.TypeInt,
212+
Computed: true,
213+
},
188214
"scan_dns_record_id": {
189215
Type: schema.TypeString,
190216
Computed: true,
@@ -240,7 +266,7 @@ func deleteDBSystem(d *schema.ResourceData, m interface{}) (e error) {
240266
sync := &DBSystemResourceCrud{}
241267
sync.D = d
242268
sync.Client = client.clientWithoutNotFoundRetries
243-
return sync.Delete()
269+
return crud.DeleteResource(d, sync)
244270
}
245271

246272
type DBSystemResourceCrud struct {
@@ -343,6 +369,15 @@ func (s *DBSystemResourceCrud) Create() (e error) {
343369
if domain, ok := s.D.GetOk("domain"); ok {
344370
opts.Domain = domain.(string)
345371
}
372+
if initialDataStorageSizeInGB, ok := s.D.GetOk("data_storage_size_in_gb"); ok {
373+
opts.InitialDataStorageSizeInGB = initialDataStorageSizeInGB.(int)
374+
}
375+
if licenseModel, ok := s.D.GetOk("license_model"); ok {
376+
opts.LicenseModel = baremetal.LicenseModel(licenseModel.(string))
377+
}
378+
if nodeCount, ok := s.D.GetOk("node_count"); ok {
379+
opts.NodeCount = nodeCount.(int)
380+
}
346381

347382
s.Res, e = s.Client.LaunchDBSystem(
348383
availabilityDomain, compartmentID, cpuCoreCount, databaseEdition, dbHomeDetails,
@@ -378,14 +413,18 @@ func (s *DBSystemResourceCrud) SetData() {
378413
s.D.Set("backup_subnet_id", s.Res.BackupSubnetID)
379414
s.D.Set("cluster_name", s.Res.ClusterName)
380415
s.D.Set("data_storage_percentage", s.Res.DataStoragePercentage)
416+
s.D.Set("data_storage_size_in_gb", s.Res.DataStorageSizeInGBs)
381417
s.D.Set("disk_redundancy", s.Res.DiskRedundancy)
382418
s.D.Set("display_name", s.Res.DisplayName)
383419
s.D.Set("domain", s.Res.Domain)
420+
s.D.Set("license_model", s.Res.LicenseModel)
421+
s.D.Set("node_count", s.Res.NodeCount)
384422

385423
//Computed
386424
s.D.Set("id", s.Res.ID)
387425
s.D.Set("lifecycle_details", s.Res.LifecycleDetails)
388426
s.D.Set("listener_port", s.Res.ListenerPort)
427+
s.D.Set("reco_storage_size_in_gb", s.Res.RecoStorageSizeInGB)
389428
s.D.Set("scan_dns_record_id", s.Res.ScanDnsRecordId)
390429
s.D.Set("scan_ip_ids", s.Res.ScanIpIds)
391430
s.D.Set("state", s.Res.State)

resource_obmcs_database_db_system_test.go

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ func (s *ResourceDatabaseDBSystemTestSuite) SetupTest() {
2525
s.Provider = testAccProvider
2626
s.Providers = testAccProviders
2727
s.Config = testProviderConfig() + `
28-
2928
data "oci_identity_availability_domains" "ADs" {
3029
compartment_id = "${var.compartment_id}"
3130
}
@@ -34,6 +33,7 @@ func (s *ResourceDatabaseDBSystemTestSuite) SetupTest() {
3433
compartment_id = "${var.compartment_id}"
3534
cidr_block = "10.0.0.0/16"
3635
display_name = "-tf-vcn"
36+
dns_label = "tfvcn"
3737
}
3838

3939
resource "oci_core_subnet" "t" {
@@ -44,31 +44,8 @@ func (s *ResourceDatabaseDBSystemTestSuite) SetupTest() {
4444
vcn_id = "${oci_core_virtual_network.t.id}"
4545
route_table_id = "${oci_core_virtual_network.t.default_route_table_id}"
4646
dhcp_options_id = "${oci_core_virtual_network.t.default_dhcp_options_id}"
47-
security_list_ids = ["${oci_core_virtual_network.t.default_security_list_id}"]
48-
}
49-
50-
resource "oci_database_db_system" "t" {
51-
availability_domain = "${data.oci_identity_availability_domains.ADs.availability_domains.0.name}"
52-
compartment_id = "${var.compartment_id}"
53-
subnet_id = "${oci_core_subnet.t.id}"
54-
database_edition = "ENTERPRISE_EDITION"
55-
disk_redundancy = "NORMAL"
56-
shape = "BM.DenseIO1.36"
57-
cpu_core_count = "2"
58-
ssh_public_keys = ["ssh-rsa KKKLK3NzaC1yc2EAAAADAQABAAABAQC+UC9MFNA55NIVtKPIBCNw7++ACXhD0hx+Zyj25JfHykjz/QU3Q5FAU3DxDbVXyubgXfb/GJnrKRY8O4QDdvnZZRvQFFEOaApThAmCAM5MuFUIHdFvlqP+0W+ZQnmtDhwVe2NCfcmOrMuaPEgOKO3DOW6I/qOOdO691Xe2S9NgT9HhN0ZfFtEODVgvYulgXuCCXsJs+NUqcHAOxxFUmwkbPvYi0P0e2DT8JKeiOOC8VKUEgvVx+GKmqasm+Y6zHFW7vv3g2GstE1aRs3mttHRoC/JPM86PRyIxeWXEMzyG5wHqUu4XZpDbnWNxi6ugxnAGiL3CrIFdCgRNgHz5qS1l MustWin"]
59-
display_name = "-tf-db-system"
60-
domain = "mycompany.com"
61-
hostname = "myOracleDB"
62-
db_home {
63-
db_version = "12.1.0.2"
64-
display_name = "-tf-db-home"
65-
database {
66-
"admin_password" = "BEstrO0ng_#11"
67-
"db_name" = "aTFdb"
68-
character_set = "AL32UTF8"
69-
ncharacter_set = "AL16UTF16"
70-
}
71-
}
47+
security_list_ids = ["${oci_core_virtual_network.t.default_security_list_id}"]
48+
dns_label = "tfsubnet"
7249
}`
7350
s.ResourceName = "oci_database_db_system.t"
7451
}
@@ -77,10 +54,37 @@ func (s *ResourceDatabaseDBSystemTestSuite) TestAccResourceDatabaseDBSystem() {
7754
resource.Test(s.T(), resource.TestCase{
7855
Providers: s.Providers,
7956
Steps: []resource.TestStep{
57+
// verify create
8058
{
8159
ImportState: true,
8260
ImportStateVerify: true,
83-
Config: s.Config,
61+
Config: s.Config + `
62+
resource "oci_database_db_system" "t" {
63+
availability_domain = "${data.oci_identity_availability_domains.ADs.availability_domains.0.name}"
64+
compartment_id = "${var.compartment_id}"
65+
subnet_id = "${oci_core_subnet.t.id}"
66+
database_edition = "ENTERPRISE_EDITION"
67+
disk_redundancy = "NORMAL"
68+
shape = "VM.Standard1.2"
69+
cpu_core_count = "2"
70+
ssh_public_keys = ["ssh-rsa KKKLK3NzaC1yc2EAAAADAQABAAABAQC+UC9MFNA55NIVtKPIBCNw7++ACXhD0hx+Zyj25JfHykjz/QU3Q5FAU3DxDbVXyubgXfb/GJnrKRY8O4QDdvnZZRvQFFEOaApThAmCAM5MuFUIHdFvlqP+0W+ZQnmtDhwVe2NCfcmOrMuaPEgOKO3DOW6I/qOOdO691Xe2S9NgT9HhN0ZfFtEODVgvYulgXuCCXsJs+NUqcHAOxxFUmwkbPvYi0P0e2DT8JKeiOOC8VKUEgvVx+GKmqasm+Y6zHFW7vv3g2GstE1aRs3mttHRoC/JPM86PRyIxeWXEMzyG5wHqUu4XZpDbnWNxi6ugxnAGiL3CrIFdCgRNgHz5qS1l MustWin"]
71+
display_name = "-tf-db-system"
72+
domain = "mycompany.com"
73+
hostname = "myOracleDB"
74+
data_storage_size_in_gb = "256"
75+
license_model = "LICENSE_INCLUDED"
76+
node_count = "1"
77+
db_home {
78+
db_version = "12.1.0.2"
79+
display_name = "-tf-db-home"
80+
database {
81+
"admin_password" = "BEstrO0ng_#11"
82+
"db_name" = "aTFdb"
83+
character_set = "AL32UTF8"
84+
ncharacter_set = "AL16UTF16"
85+
}
86+
}
87+
}`,
8488
Check: resource.ComposeTestCheckFunc(
8589
resource.TestCheckResourceAttrSet(s.ResourceName, "id"),
8690
resource.TestCheckResourceAttrSet(s.ResourceName, "time_created"),

vendor/github.com/oracle/bmcs-go-sdk/constants.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/oracle/bmcs-go-sdk/database_db_system.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/oracle/bmcs-go-sdk/request_options.go

Lines changed: 8 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/vendor.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2972,10 +2972,12 @@
29722972
"revisionTime": "2017-01-25T16:36:56Z"
29732973
},
29742974
{
2975-
"checksumSHA1": "0lB36Au95tRAfvQ8rA93XEz3tLk=",
2975+
"checksumSHA1": "16wWla3HWHMOrJHo0yN7iu1YIhw=",
29762976
"path": "github.com/oracle/bmcs-go-sdk",
2977-
"revision": "9482e75ceee221a25ad6edbbc5ca3f5657e4c371",
2978-
"revisionTime": "2017-10-12T00:22:16Z"
2977+
"revision": "2f3eb845627cb625dc2de52ccd7c4b69ecf60240",
2978+
"revisionTime": "2017-10-20T17:32:20Z",
2979+
"version": "add-db-license-model",
2980+
"versionExact": "add-db-license-model"
29792981
},
29802982
{
29812983
"checksumSHA1": "ImgLNIpeXsGjZGXw4rd+rwzQxpo=",

0 commit comments

Comments
 (0)