Skip to content

Commit fd61494

Browse files
Gaurav Tanejaravinitp
authored andcommitted
Added - Support for Support Dynamic list of ZDM parameters for Oracle<>Oracle migrations
1 parent 5199230 commit fd61494

16 files changed

+341
-81
lines changed

examples/databasemigration/migration/migration.tf

Lines changed: 105 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,14 @@ data "oci_database_migration_job" "test_job" {
103103
job_id = var.jobId
104104
}
105105

106-
data "oci_database_migration_agent" "test_agent" {
107-
agent_id = "agentId"
108-
}
109106

107+
108+
variable "migration_id" {
109+
default = ""
110+
}
110111
data "oci_database_migration_migrations" "test_migrations" {
111112
#Required
112-
compartment_id = var.compartment_id
113+
migration_id = var.migration_id
113114
}
114115

115116
data "oci_database_migration_job_advisor_report" "test_job_advisor_report" {
@@ -123,8 +124,43 @@ data "oci_database_migration_job_output" "test_job_output" {
123124
data "oci_database_migration_migration_object_types" "test_migration_object_types" {
124125
connection_type = "MYSQL"
125126
}
127+
variable "connection_string" {
128+
default = ""
129+
}
130+
variable "nsg_ids" {
131+
default = ""
132+
}
133+
resource "oci_database_migration_connection" "test_connection_rds_source" {
134+
compartment_id = var.compartment_id
135+
display_name = "TF_display_test_rds_source"
136+
connection_type = "ORACLE"
137+
key_id = var.kms_key_id
138+
vault_id = var.kms_vault_id
139+
connection_string = var.connection_string
140+
password = "BEstrO0ng_#11"
141+
technology_type = "AMAZON_RDS_ORACLE"
142+
username = "ggfe"
143+
nsg_ids = var.nsg_ids
144+
replication_password="replicationPassword"
145+
replication_username="replicationUsername"
146+
}
126147

127-
data "oci_database_migration_agent_images" "test_agent_images" {}
148+
variable "database_autonomous_id" {
149+
default = ""
150+
}
151+
resource "oci_database_migration_connection" "test_connection_rds_target" {
152+
compartment_id = var.compartment_id
153+
display_name = "TF_display_test_rds_target"
154+
connection_type = "ORACLE"
155+
key_id = var.kms_key_id
156+
vault_id = var.kms_vault_id
157+
database_id = var.database_autonomous_id
158+
password = "BEstrO0ng_#11"
159+
technology_type = "OCI_AUTONOMOUS_DATABASE"
160+
username = "ggfe"
161+
replication_password="replicationPassword"
162+
replication_username="replicationUsername"
163+
}
128164

129165
resource "oci_database_migration_connection" "test_connection_target" {
130166
compartment_id = var.compartment_id
@@ -200,6 +236,70 @@ resource "oci_database_migration_migration" "test_migration" {
200236
display_name = "displayName"
201237
}
202238

239+
resource "oci_database_migration_migration" "test_offline_migration" {
240+
compartment_id = var.compartment_id
241+
database_combination = "MYSQL"
242+
source_database_connection_id = var.source_connection_mysql_id
243+
target_database_connection_id = var.target_connection_mysql_id
244+
type = "OFFLINE"
245+
display_name = "displayName"
246+
}
247+
248+
variable "source_connection_oracle_id" {
249+
default = ""
250+
}
251+
variable "source_connection_container_oracle_id" {
252+
default = ""
253+
}
254+
variable "target_connection_oracle_id" {
255+
default = ""
256+
}
257+
variable "bucket_oracle_id" {
258+
default = ""
259+
}
260+
resource "oci_database_migration_migration" "test_oracle_migration" {
261+
compartment_id = var.compartment_id
262+
database_combination = "ORACLE"
263+
source_database_connection_id = var.source_connection_oracle_id
264+
source_container_database_connection_id = var.source_connection_container_oracle_id
265+
target_database_connection_id = var.target_connection_oracle_id
266+
advanced_parameters {
267+
data_type = "STRING"
268+
name = "DATAPUMPSETTINGS_METADATAONLY"
269+
value = "True"
270+
}
271+
data_transfer_medium_details {
272+
type = "OBJECT_STORAGE"
273+
object_storage_bucket {
274+
bucket = var.bucket_oracle_id
275+
namespace = "namespace"
276+
}
277+
}
278+
type = "ONLINE"
279+
display_name = "displayName"
280+
}
281+
282+
resource "oci_database_migration_migration" "test_oracle_rds_migration" {
283+
compartment_id = var.compartment_id
284+
database_combination = "ORACLE"
285+
source_database_connection_id = oci_database_migration_connection.test_connection_rds_source.id
286+
target_database_connection_id = oci_database_migration_connection.test_connection_rds_target.id
287+
288+
data_transfer_medium_details {
289+
type = "AWS_S3"
290+
name = "rdsbucket"
291+
region = "us-east-1"
292+
secret_access_key = "12345/12345"
293+
access_key_id = "12345"
294+
object_storage_bucket {
295+
bucket = var.bucket_oracle_id
296+
namespace = "namespace"
297+
}
298+
}
299+
type = "ONLINE"
300+
display_name = "displayName"
301+
}
302+
203303
output "password" {
204304
sensitive = true
205305
value = random_string.autonomous_database_admin_password.result

internal/integrationtest/database_migration_migration_test.go

Lines changed: 90 additions & 64 deletions
Large diffs are not rendered by default.

internal/service/database_migration/database_migration_connection_resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ func (s *DatabaseMigrationConnectionResourceCrud) SetData() error {
622622
nsgIds = append(nsgIds, item)
623623
}
624624
//s.D.Set("nsg_ids", schema.NewSet(tfresource.LiteralTypeHashCodeForSets, nsgIds))
625-
s.D.Set("nsg_ids", v.NsgIds)
625+
s.D.Set("nsg_ids", nsgIds)
626626

627627
if v.Password != nil {
628628
s.D.Set("password", *v.Password)

internal/service/database_migration/database_migration_migration_data_source.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ func (s *DatabaseMigrationMigrationDataSourceCrud) SetData() error {
159159
case oci_database_migration.OracleMigration:
160160
s.D.Set("database_combination", "ORACLE")
161161

162+
advancedParameters := []interface{}{}
163+
for _, item := range v.AdvancedParameters {
164+
advancedParameters = append(advancedParameters, migrationParameterDetailsToMap(item))
165+
}
166+
s.D.Set("advanced_parameters", advancedParameters)
167+
162168
if v.AdvisorSettings != nil {
163169
s.D.Set("advisor_settings", []interface{}{OracleAdvisorSettingsToMap(v.AdvisorSettings)})
164170
} else {

internal/service/database_migration/database_migration_migration_resource.go

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,35 @@ func DatabaseMigrationMigrationResource() *schema.Resource {
6262
},
6363

6464
// Optional
65+
"advanced_parameters": {
66+
Type: schema.TypeList,
67+
Optional: true,
68+
Computed: true,
69+
Elem: &schema.Resource{
70+
Schema: map[string]*schema.Schema{
71+
// Required
72+
73+
// Optional
74+
"data_type": {
75+
Type: schema.TypeString,
76+
Optional: true,
77+
Computed: true,
78+
},
79+
"name": {
80+
Type: schema.TypeString,
81+
Optional: true,
82+
Computed: true,
83+
},
84+
"value": {
85+
Type: schema.TypeString,
86+
Optional: true,
87+
Computed: true,
88+
},
89+
90+
// Computed
91+
},
92+
},
93+
},
6594
"advisor_settings": {
6695
Type: schema.TypeList,
6796
Optional: true,
@@ -1221,6 +1250,14 @@ func (s *DatabaseMigrationMigrationResourceCrud) SetData() error {
12211250
case oci_database_migration.OracleMigration:
12221251
s.D.Set("database_combination", "ORACLE")
12231252

1253+
if v.AdvancedParameters != nil {
1254+
advancedParameters := []interface{}{}
1255+
for _, item := range v.AdvancedParameters {
1256+
advancedParameters = append(advancedParameters, migrationParameterDetailsToMap(item))
1257+
}
1258+
s.D.Set("advanced_parameters", advancedParameters)
1259+
}
1260+
12241261
if v.AdvisorSettings != nil {
12251262
s.D.Set("advisor_settings", []interface{}{OracleAdvisorSettingsToMap(v.AdvisorSettings)})
12261263
} else {
@@ -1323,6 +1360,22 @@ func (s *DatabaseMigrationMigrationResourceCrud) SetData() error {
13231360
return nil
13241361
}
13251362

1363+
func migrationParameterDetailsToMap(obj oci_database_migration.MigrationParameterDetails) map[string]interface{} {
1364+
result := map[string]interface{}{}
1365+
1366+
if obj.Name != nil {
1367+
result["name"] = string(*obj.Name)
1368+
}
1369+
1370+
if obj.Value != nil {
1371+
result["value"] = string(*obj.Value)
1372+
}
1373+
1374+
result["data_type"] = obj.DataType
1375+
1376+
return result
1377+
}
1378+
13261379
func (s *DatabaseMigrationMigrationResourceCrud) mapToAdminCredentials(fieldKeyFormat string) (oci_database_migration.AdminCredentials, error) {
13271380
result := oci_database_migration.AdminCredentials{}
13281381

@@ -2710,6 +2763,26 @@ func MetadataRemapToMap(obj oci_database_migration.MetadataRemap) map[string]int
27102763
return result
27112764
}
27122765

2766+
func (s *DatabaseMigrationMigrationResourceCrud) mapToMigrationParameterDetails(fieldKeyFormat string) (oci_database_migration.MigrationParameterDetails, error) {
2767+
result := oci_database_migration.MigrationParameterDetails{}
2768+
2769+
if dataType, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "data_type")); ok {
2770+
result.DataType = oci_database_migration.AdvancedParameterDataTypesEnum(dataType.(string))
2771+
}
2772+
2773+
if name, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "name")); ok {
2774+
tmp := name.(string)
2775+
result.Name = &tmp
2776+
}
2777+
2778+
if value, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "value")); ok {
2779+
tmp := value.(string)
2780+
result.Value = &tmp
2781+
}
2782+
2783+
return result, nil
2784+
}
2785+
27132786
func MigrationSummaryToMap(obj oci_database_migration.MigrationSummary) map[string]interface{} {
27142787
result := map[string]interface{}{}
27152788
switch v := (obj).(type) {
@@ -4783,6 +4856,22 @@ func (s *DatabaseMigrationMigrationResourceCrud) populateTopLevelPolymorphicCrea
47834856
request.CreateMigrationDetails = details
47844857
case strings.ToLower("ORACLE"):
47854858
details := oci_database_migration.CreateOracleMigrationDetails{}
4859+
if advancedParameters, ok := s.D.GetOkExists("advanced_parameters"); ok {
4860+
interfaces := advancedParameters.([]interface{})
4861+
tmp := make([]oci_database_migration.MigrationParameterDetails, len(interfaces))
4862+
for i := range interfaces {
4863+
stateDataIndex := i
4864+
fieldKeyFormat := fmt.Sprintf("%s.%d.%%s", "advanced_parameters", stateDataIndex)
4865+
converted, err := s.mapToMigrationParameterDetails(fieldKeyFormat)
4866+
if err != nil {
4867+
return err
4868+
}
4869+
tmp[i] = converted
4870+
}
4871+
if len(tmp) != 0 || s.D.HasChange("advanced_parameters") {
4872+
details.AdvancedParameters = tmp
4873+
}
4874+
}
47864875
if advisorSettings, ok := s.D.GetOkExists("advisor_settings"); ok {
47874876
if tmpList := advisorSettings.([]interface{}); len(tmpList) > 0 {
47884877
fieldKeyFormat := fmt.Sprintf("%s.%d.%%s", "advisor_settings", 0)
@@ -5010,6 +5099,22 @@ func (s *DatabaseMigrationMigrationResourceCrud) populateTopLevelPolymorphicUpda
50105099
request.UpdateMigrationDetails = details
50115100
case strings.ToLower("ORACLE"):
50125101
details := oci_database_migration.UpdateOracleMigrationDetails{}
5102+
if advancedParameters, ok := s.D.GetOkExists("advanced_parameters"); ok {
5103+
interfaces := advancedParameters.([]interface{})
5104+
tmp := make([]oci_database_migration.MigrationParameterDetails, len(interfaces))
5105+
for i := range interfaces {
5106+
stateDataIndex := i
5107+
fieldKeyFormat := fmt.Sprintf("%s.%d.%%s", "advanced_parameters", stateDataIndex)
5108+
converted, err := s.mapToMigrationParameterDetails(fieldKeyFormat)
5109+
if err != nil {
5110+
return err
5111+
}
5112+
tmp[i] = converted
5113+
}
5114+
if len(tmp) != 0 || s.D.HasChange("advanced_parameters") {
5115+
details.AdvancedParameters = tmp
5116+
}
5117+
}
50135118
if advisorSettings, ok := s.D.GetOkExists("advisor_settings"); ok {
50145119
if tmpList := advisorSettings.([]interface{}); len(tmpList) > 0 {
50155120
fieldKeyFormat := fmt.Sprintf("%s.%d.%%s", "advisor_settings", 0)

website/docs/d/database_migration_connection.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This data source provides details about a specific Connection resource in Oracle
1212

1313
Display Database Connection details.
1414

15-
Note: If you wish to use the DMS deprecated API version /20210929 it is necessary to pin the Terraform Provider version to v5.46.0. Newer Terraform provider versions will not support the DMS deprecated API version /20210929
15+
Note: If you wish to use the DMS deprecated API version /20210929 it is necessary to pin the Terraform Provider version to v5.47.0. Newer Terraform provider versions will not support the DMS deprecated API version /20210929
1616

1717
## Example Usage
1818

website/docs/d/database_migration_connections.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This data source provides the list of Connections in Oracle Cloud Infrastructure
1212

1313
List all Database Connections.
1414

15-
Note: If you wish to use the DMS deprecated API version /20210929 it is necessary to pin the Terraform Provider version to v5.46.0. Newer Terraform provider versions will not support the DMS deprecated API version /20210929
15+
Note: If you wish to use the DMS deprecated API version /20210929 it is necessary to pin the Terraform Provider version to v5.47.0. Newer Terraform provider versions will not support the DMS deprecated API version /20210929
1616

1717
## Example Usage
1818

website/docs/d/database_migration_job.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This data source provides details about a specific Job resource in Oracle Cloud
1212

1313
Get a migration job.
1414

15-
Note: If you wish to use the DMS deprecated API version /20210929 it is necessary to pin the Terraform Provider version to v5.46.0. Newer Terraform provider versions will not support the DMS deprecated API version /20210929
15+
Note: If you wish to use the DMS deprecated API version /20210929 it is necessary to pin the Terraform Provider version to v5.47.0. Newer Terraform provider versions will not support the DMS deprecated API version /20210929
1616

1717
## Example Usage
1818

website/docs/d/database_migration_job_advisor_report.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This data source provides details about a specific Job Advisor Report resource i
1212

1313
Get the Pre-Migration Advisor report details
1414

15-
Note: If you wish to use the DMS deprecated API version /20210929 it is necessary to pin the Terraform Provider version to v5.46.0. Newer Terraform provider versions will not support the DMS deprecated API version /20210929
15+
Note: If you wish to use the DMS deprecated API version /20210929 it is necessary to pin the Terraform Provider version to v5.47.0. Newer Terraform provider versions will not support the DMS deprecated API version /20210929
1616

1717

1818
## Example Usage

website/docs/d/database_migration_jobs.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This data source provides the list of Jobs in Oracle Cloud Infrastructure Databa
1313
List all the names of the Migration jobs associated to the specified
1414
migration site.
1515

16-
Note: If you wish to use the DMS deprecated API version /20210929 it is necessary to pin the Terraform Provider version to v5.46.0. Newer Terraform provider versions will not support the DMS deprecated API version /20210929
16+
Note: If you wish to use the DMS deprecated API version /20210929 it is necessary to pin the Terraform Provider version to v5.47.0. Newer Terraform provider versions will not support the DMS deprecated API version /20210929
1717

1818
## Example Usage
1919

0 commit comments

Comments
 (0)