Skip to content

Commit f4de26b

Browse files
committed
Automation Toolkit Release v2024.4.2
1 parent be52355 commit f4de26b

27 files changed

+698
-121
lines changed

cd3_automation_toolkit/Database/create_terraform_adb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ def create_terraform_adb(inputfile, outdir, service_dir, prefix, ct):
180180
k +=1
181181
else:
182182
wl_str = ""
183-
tempdict = {'whitelisted_ips': wl_str,'network_compartment_id': network_compartment_id, 'vcn_name': vcn_name,
184-
'subnet_id': subnet_id }
183+
#tempdict = {'whitelisted_ips': wl_str,'network_compartment_id': network_compartment_id, 'vcn_name': vcn_name,'subnet_id': subnet_id }
184+
tempdict = {'whitelisted_ips': wl_str }
185185
tempStr.update(tempdict)
186186

187187

cd3_automation_toolkit/Database/templates/adb-template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ adb = {
4343
database_edition = "{{ database_edition }}" #Only for BYOL license model
4444
{% endif %}
4545

46-
{% if data_storage_size_in_tbs == "" %}
46+
{% if data_storage_size_in_tb == "" %}
4747
data_storage_size_in_tbs = {{ data_storage_size_in_tb }}
4848
{% endif %}
4949
db_version = "19c"

cd3_automation_toolkit/Identity/Users/export_users_nonGreenField.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def export_users(inputfile, outdir, service_dir, config, signer, ct,export_domai
112112
domain_name = domain_key.split("@")[1]
113113
domain_client = oci.identity_domains.IdentityDomainsClient(config=config, signer=signer,
114114
service_endpoint=idcs_endpoint)
115-
users = domain_client.list_users()
115+
users = domain_client.list_users(limit=100000) # change this to pagination once api supports
116116
index = 0
117117
for user in users.data.resources:
118118
defined_tags_info = user.urn_ietf_params_scim_schemas_oracle_idcs_extension_oci_tags

cd3_automation_toolkit/Network/BaseNetwork/create_major_objects.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,10 @@ def create_drg_and_attachments(inputfile, outdir):
243243

244244
if columnname == "DRG Name":
245245
drg_name = columnvalue
246-
drg_tf_name = commonTools.check_tf_variable(drg_name)
246+
if ("ocid1.drg.oc" not in drg_name):
247+
drg_tf_name = commonTools.check_tf_variable(drg_name)
248+
else:
249+
drg_tf_name = drg_name
247250
tempdict['drg_tf_name'] = drg_tf_name
248251

249252
if (columnname == 'Attached To'):
@@ -327,6 +330,8 @@ def create_drg_and_attachments(inputfile, outdir):
327330
#if it is Auto Generated RT(during export) dont attach any RT to DRG attachment
328331
if(columnvalue in commonTools.drg_auto_RTs):
329332
drg_rt_tf_name = ''
333+
elif("ocid1.drgroutetable.oc1" in columnvalue):
334+
drg_rt_tf_name = columnvalue
330335
elif(columnvalue!=''):
331336
drg_rt_tf_name = commonTools.check_tf_variable(drg_name + "_" + columnvalue)
332337
tempStr['drg_rt_tf_name'] = drg_rt_tf_name
@@ -340,7 +345,9 @@ def create_drg_and_attachments(inputfile, outdir):
340345
drgstr_skeleton = drg_template.render(count=0)[:-1]
341346
region_included_drg.append(region)
342347
tempStr['drg_version'] = drg_versions[region, drg_name]
343-
drgstr = drg_template.render(tempStr)
348+
drgstr=''
349+
if ("ocid1.drg.oc" not in drg_tf_name):
350+
drgstr = drg_template.render(tempStr)
344351

345352
if(attachedto=="attached"):
346353
drg_attach = drg_attach_template.render(tempStr)
@@ -360,7 +367,8 @@ def create_drg_and_attachments(inputfile, outdir):
360367
if region in region_included_drg:
361368
if(drg_attach_tfStr[region]!=''):
362369
drg_attach_tfStr[region] = drg_attach_skeleton + drg_attach_tfStr[region]
363-
drg_tfStr[region] = drgstr_skeleton + drg_tfStr[region]
370+
if(drg_tfStr[region] != ''):
371+
drg_tfStr[region] = drgstr_skeleton + drg_tfStr[region]
364372

365373
def processVCN(tempStr):
366374
rt_tf_name = ''

cd3_automation_toolkit/Network/BaseNetwork/create_terraform_route.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ def create_terraform_drg_route(inputfile, outdir, service_dir, prefix, ct, non_g
218218
# Dont create any route table or route distribution name if using Auto Generated ones
219219
if (DRG_RT in commonTools.drg_auto_RTs and DRG_RD in commonTools.drg_auto_RDs):
220220
continue
221+
# Dont create any oute table or route distribution name if OCID is goven in DRG RT Name
222+
if ("ocid1.drgroutetable.oc" in DRG_RT):
223+
continue
221224

222225
region = region.strip().lower()
223226
if region not in ct.all_regions:

cd3_automation_toolkit/Network/BaseNetwork/exportRoutetable.py

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,39 @@ def get_network_entity_name(config,signer,network_identity_id):
1212
vcn1 = VirtualNetworkClient(config=config, retry_strategy=oci.retry.DEFAULT_RETRY_STRATEGY,signer=signer)
1313
if('internetgateway' in network_identity_id):
1414
igw=vcn1.get_internet_gateway(network_identity_id)
15-
network_identity_name = "igw:"+igw.data.display_name
15+
network_entity_comp_id=igw.data.compartment_id
16+
if network_entity_comp_id in export_compartment_ids:
17+
network_identity_name = "igw:"+igw.data.display_name
18+
else:
19+
network_identity_name = "igw:" + igw.data.id
1620
return network_identity_name
1721

1822
elif ('servicegateway' in network_identity_id):
1923
sgw = vcn1.get_service_gateway(network_identity_id)
20-
network_identity_name = "sgw:"+sgw.data.display_name
24+
network_entity_comp_id = sgw.data.compartment_id
25+
if network_entity_comp_id in export_compartment_ids:
26+
network_identity_name = "sgw:" + sgw.data.display_name
27+
else:
28+
network_identity_name = "sgw:"+sgw.data.id
2129
return network_identity_name
2230

2331

2432
elif ('natgateway' in network_identity_id):
2533
ngw = vcn1.get_nat_gateway(network_identity_id)
26-
network_identity_name = "ngw:"+ngw.data.display_name
34+
network_entity_comp_id = ngw.data.compartment_id
35+
if network_entity_comp_id in export_compartment_ids:
36+
network_identity_name = "ngw:" + ngw.data.display_name
37+
else:
38+
network_identity_name = "ngw:"+ngw.data.id
2739
return network_identity_name
2840

2941
elif ('localpeeringgateway' in network_identity_id):
3042
lpg = vcn1.get_local_peering_gateway(network_identity_id)
31-
network_identity_name = "lpg:"+lpg.data.display_name
43+
network_entity_comp_id = lpg.data.compartment_id
44+
if network_entity_comp_id in export_compartment_ids:
45+
network_identity_name = "lpg:" + lpg.data.display_name
46+
else:
47+
network_identity_name = "lpg:"+lpg.data.id
3248
return network_identity_name
3349
elif ('drgattachment' in network_identity_id):
3450
drg_attach = vcn1.get_drg_attachment(network_identity_id)
@@ -46,7 +62,11 @@ def get_network_entity_name(config,signer,network_identity_id):
4662
return network_identity_name
4763
elif ('drg' in network_identity_id):
4864
drg = vcn1.get_drg(network_identity_id)
49-
network_identity_name = "drg:"+drg.data.display_name
65+
network_entity_comp_id = drg.data.compartment_id
66+
if network_entity_comp_id in export_compartment_ids:
67+
network_identity_name = "drg:" + drg.data.display_name
68+
else:
69+
network_identity_name = "drg:"+drg.data.id
5070
return network_identity_name
5171

5272
"""
@@ -282,6 +302,7 @@ def export_routetable(inputfile, outdir, service_dir,config1,signer1, ct, export
282302
config=config1
283303
global signer,tf_or_tofu
284304
signer=signer1
305+
global export_compartment_ids
285306

286307
tf_or_tofu = ct.tf_or_tofu
287308
tf_state_list = [tf_or_tofu, "state", "list"]
@@ -316,6 +337,10 @@ def export_routetable(inputfile, outdir, service_dir,config1,signer1, ct, export
316337
"import_commands_network_routerules.sh")
317338
importCommands[reg] = ''
318339

340+
export_compartment_ids = []
341+
for comp in export_compartments:
342+
export_compartment_ids.append(ct.ntk_compartment_ids[comp])
343+
319344
for reg in export_regions:
320345
config.__setitem__("region", commonTools().region_dict[reg])
321346
state = {'path': f'{outdir}/{reg}/{service_dir}', 'resources': []}

cd3_automation_toolkit/Network/BaseNetwork/export_network_nonGreenField.py

Lines changed: 59 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,18 @@
2222

2323

2424
def print_drgv2(values_for_column_drgv2, region, comp_name, vcn_info, drg_info, drg_attachment_info, drg_rt_info,
25-
import_drg_route_distribution_info, drg_route_distribution_statements):
25+
import_drg_route_distribution_info, drg_route_distribution_statements,write_drg_ocids):
2626
for col_header in values_for_column_drgv2.keys():
2727
if (col_header == "Region"):
2828
values_for_column_drgv2[col_header].append(region)
2929
elif (col_header == "Compartment Name"):
3030
values_for_column_drgv2[col_header].append(comp_name)
3131
elif (col_header == "DRG Name"):
32-
values_for_column_drgv2[col_header].append(drg_info.display_name)
32+
if write_drg_ocids == True:
33+
values_for_column_drgv2[col_header].append(drg_info.id)
34+
else:
35+
values_for_column_drgv2[col_header].append(drg_info.display_name)
36+
3337
elif (col_header == "Attached To"):
3438
if (drg_attachment_info is None):
3539
values_for_column_drgv2[col_header].append('')
@@ -53,12 +57,19 @@ def print_drgv2(values_for_column_drgv2, region, comp_name, vcn_info, drg_info,
5357
if (drg_rt_info == None):
5458
values_for_column_drgv2[col_header].append("")
5559
else:
56-
values_for_column_drgv2[col_header].append(drg_rt_info.display_name)
60+
if write_drg_ocids==True:
61+
values_for_column_drgv2[col_header].append(drg_rt_info.id)
62+
else:
63+
values_for_column_drgv2[col_header].append(drg_rt_info.display_name)
64+
5765
elif (col_header == 'Import DRG Route Distribution Name'):
5866
if import_drg_route_distribution_info == None:
5967
values_for_column_drgv2[col_header].append("")
6068
else:
61-
values_for_column_drgv2[col_header].append(import_drg_route_distribution_info.display_name)
69+
if write_drg_ocids == True:
70+
values_for_column_drgv2[col_header].append(import_drg_route_distribution_info.id)
71+
else:
72+
values_for_column_drgv2[col_header].append(import_drg_route_distribution_info.display_name)
6273
elif (col_header == "Import DRG Route Distribution Statements"):
6374
statement_val = ''
6475
if (drg_route_distribution_statements == None):
@@ -90,7 +101,7 @@ def print_drgv2(values_for_column_drgv2, region, comp_name, vcn_info, drg_info,
90101

91102

92103
def print_vcns(values_for_column_vcns, region, comp_name, vnc,vcn_info, drg_attachment_info, igw_info, ngw_info, sgw_info,
93-
lpg_display_names,state):
104+
lpg_display_names,state,write_drg_ocids):
94105
drg_info=None
95106
for col_header in values_for_column_vcns.keys():
96107

@@ -106,10 +117,17 @@ def print_vcns(values_for_column_vcns, region, comp_name, vnc,vcn_info, drg_atta
106117
values_for_column_vcns[col_header].append("n")
107118
else:
108119
route_table_id = drg_attachment_info.route_table_id
109-
if (route_table_id is not None):
110-
val = drg_info.display_name + "::" + vnc.get_route_table(route_table_id).data.display_name
120+
if write_drg_ocids == True:
121+
if (route_table_id is not None):
122+
val = drg_info.id + "::" + vnc.get_route_table(route_table_id).data.display_name
123+
else:
124+
val = drg_info.id
111125
else:
112-
val = drg_info.display_name
126+
if (route_table_id is not None):
127+
val = drg_info.display_name + "::" + vnc.get_route_table(route_table_id).data.display_name
128+
else:
129+
val = drg_info.display_name
130+
113131
values_for_column_vcns[col_header].append(val)
114132
else:
115133
values_for_column_vcns[col_header].append("n")
@@ -620,6 +638,10 @@ def export_major_objects(inputfile, outdir, service_dir, config, signer, ct, exp
620638

621639
print("Tabs- VCNs and DRGs would be overwritten during export process!!!\n")
622640

641+
export_compartment_ids = []
642+
for comp in export_compartments:
643+
export_compartment_ids.append(ct.ntk_compartment_ids[comp])
644+
623645
# Fetch DRGs
624646
for reg in export_regions:
625647
current_region = reg
@@ -637,6 +659,7 @@ def export_major_objects(inputfile, outdir, service_dir, config, signer, ct, exp
637659
ntk_compartment_name],
638660
attachment_type="ALL") # ,lifecycle_state ="ATTACHED")#,attachment_type="ALL")
639661
rpc_execution = True
662+
write_drg_ocids=False
640663
for drg_attachment_info in DRG_Attachments.data:
641664
if (drg_attachment_info.lifecycle_state != "ATTACHED"):
642665
continue
@@ -647,6 +670,11 @@ def export_major_objects(inputfile, outdir, service_dir, config, signer, ct, exp
647670
# Attachment Data
648671
drg_display_name = drg_info.display_name
649672
drg_comp_id = drg_info.compartment_id
673+
674+
if drg_comp_id not in export_compartment_ids:
675+
drg_display_name=drg_id
676+
write_drg_ocids=True
677+
650678
for key, val in ct.ntk_compartment_ids.items():
651679
if val == drg_comp_id:
652680
if ("::" in key):
@@ -660,7 +688,7 @@ def export_major_objects(inputfile, outdir, service_dir, config, signer, ct, exp
660688
if (drg_id not in drg_ocid):
661689
oci_obj_names[reg].write("\nDRG Version::::" + drg_display_name + "::::" + drg_version)
662690
tf_resource = f'module.drgs[\\"{tf_name}\\"].oci_core_drg.drg'
663-
if tf_resource not in state["resources"]:
691+
if tf_resource not in state["resources"] and write_drg_ocids == False:
664692
importCommands[reg].write( f'\n{tf_or_tofu} import "{tf_resource}" {str(drg_info.id)}')
665693
drg_ocid.append(drg_id)
666694

@@ -700,15 +728,17 @@ def export_major_objects(inputfile, outdir, service_dir, config, signer, ct, exp
700728
drg_route_table_info = vnc.get_drg_route_table(drg_route_table_id).data
701729

702730
import_drg_route_distribution_id = drg_route_table_info.import_drg_route_distribution_id
731+
703732
if (import_drg_route_distribution_id != None):
704733
import_drg_route_distribution_info = vnc.get_drg_route_distribution(
705734
import_drg_route_distribution_id).data
735+
706736
drg_route_distribution_statements = vnc.list_drg_route_distribution_statements(
707737
import_drg_route_distribution_info.id)
708738

709739
tf_name = commonTools.check_tf_variable(
710740
drg_display_name + "_" + import_drg_route_distribution_info.display_name)
711-
if (import_drg_route_distribution_info.display_name not in commonTools.drg_auto_RDs):
741+
if (import_drg_route_distribution_info.display_name not in commonTools.drg_auto_RDs and "ocid1.drg.oc" not in drg_display_name):
712742
tf_resource = f'module.drg-route-distributions[\\"{tf_name}\\"].oci_core_drg_route_distribution.drg_route_distribution'
713743
if tf_resource not in state["resources"]:
714744
importCommands[reg].write(f'\n{tf_or_tofu} import "{tf_resource}" {str(import_drg_route_distribution_info.id)}')
@@ -722,7 +752,7 @@ def export_major_objects(inputfile, outdir, service_dir, config, signer, ct, exp
722752

723753
print_drgv2(values_for_column_drgv2, region, drg_comp_name, vcn_info, drg_info, drg_attachment_info,
724754
drg_route_table_info, import_drg_route_distribution_info,
725-
drg_route_distribution_statements)
755+
drg_route_distribution_statements,write_drg_ocids)
726756

727757
# RPC
728758
elif attach_type.upper() == "REMOTE_PEERING_CONNECTION" and rpc_execution:
@@ -747,7 +777,7 @@ def export_major_objects(inputfile, outdir, service_dir, config, signer, ct, exp
747777

748778
tf_name = commonTools.check_tf_variable(
749779
drg_display_name + "_" + import_drg_route_distribution_info.display_name)
750-
if (import_drg_route_distribution_info.display_name not in commonTools.drg_auto_RDs):
780+
if (import_drg_route_distribution_info.display_name not in commonTools.drg_auto_RDs and write_drg_ocids == False):
751781
tf_resource = f'module.drg-route-distributions[\\"{tf_name}\\"].oci_core_drg_route_distribution.drg_route_distribution'
752782
if tf_resource not in state["resources"]:
753783
importCommands[reg].write(f'\n{tf_or_tofu} import "{tf_resource}" {str(import_drg_route_distribution_info.id)}')
@@ -784,6 +814,13 @@ def export_major_objects(inputfile, outdir, service_dir, config, signer, ct, exp
784814
drg_info = vnc.get_drg(drg_id).data
785815
drg_display_name = drg_info.display_name
786816

817+
#Do not process if DRG (and its RTs/RDs are in different compartment than the export_compartments list
818+
drg_comp_id=drg_info.compartment_id
819+
if drg_comp_id not in export_compartment_ids:
820+
continue
821+
822+
write_drg_ocids=False
823+
787824
if drg_info.default_drg_route_tables is not None:
788825
DRG_RTs = oci.pagination.list_call_get_all_results(vnc.list_drg_route_tables,
789826
drg_id=drg_id)
@@ -820,7 +857,7 @@ def export_major_objects(inputfile, outdir, service_dir, config, signer, ct, exp
820857
print_drgv2(values_for_column_drgv2, region, drg_comp_name, vcn_info, drg_info,
821858
drg_attachment_info, drg_route_table_info,
822859
import_drg_route_distribution_info,
823-
drg_route_distribution_statements)
860+
drg_route_distribution_statements,write_drg_ocids)
824861

825862
commonTools.write_to_cd3(values_for_column_drgv2, cd3file, "DRGs")
826863
print("RPCs exported to CD3\n")
@@ -861,6 +898,14 @@ def export_major_objects(inputfile, outdir, service_dir, config, signer, ct, exp
861898
if (drg_attachment_info.lifecycle_state != "ATTACHED"):
862899
continue
863900

901+
write_drg_ocids=False
902+
if drg_attachment_info != None:
903+
drg_id = drg_attachment_info.drg_id
904+
drg_info = vnc.get_drg(drg_id).data
905+
drg_comp_id=drg_info.compartment_id
906+
if drg_comp_id not in export_compartment_ids:
907+
write_drg_ocids= True
908+
864909
# igw_display_name = "n"
865910
IGWs = oci.pagination.list_call_get_all_results(vnc.list_internet_gateways,
866911
compartment_id=ct.ntk_compartment_ids[
@@ -933,7 +978,7 @@ def export_major_objects(inputfile, outdir, service_dir, config, signer, ct, exp
933978

934979
# Fill VCNs Tab
935980
print_vcns(values_for_column_vcns, region, ntk_compartment_name, vnc,vcn_info, drg_attachment_info, igw_info, ngw_info,
936-
sgw_info, lpg_display_names,state)
981+
sgw_info, lpg_display_names,state,write_drg_ocids)
937982

938983
commonTools.write_to_cd3(values_for_column_vcns, cd3file, "VCNs")
939984
print("VCNs exported to CD3\n")

0 commit comments

Comments
 (0)