Skip to content

Commit 8d00399

Browse files
committed
Automation Toolkit Release v10
1 parent 29e0326 commit 8d00399

File tree

114 files changed

+3772
-355
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+3772
-355
lines changed

cd3_automation_toolkit/Compute/export_dedicatedvmhosts_nonGreenField.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,6 @@ def export_dedicatedvmhosts(inputfile, _outdir, _config, network_compartments=[]
123123
dedicatedvmhost=compute_client.get_dedicated_vm_host(dedicatedvmhost.id).data
124124
print_dedicatedvmhosts(region, dedicatedvmhost,values_for_column, ntk_compartment_name)
125125

126-
if "linux" in sys.platform:
127-
os.chmod(script_file, 0o755)
128-
129126
commonTools.write_to_cd3(values_for_column, cd3file, "DedicatedVMHosts")
130127

131128
print("Dedicated VM Hosts exported to CD3\n")

cd3_automation_toolkit/Compute/export_instances_nonGreenField.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ def __get_instances_info(compartment_name, compartment_id, reg_name, config,disp
9393
bc = oci.core.BlockstorageClient(config, retry_strategy=oci.retry.DEFAULT_RETRY_STRATEGY)
9494
instance_info = oci.pagination.list_call_get_all_results(compute.list_instances, compartment_id=compartment_id)
9595
# print(instance_info.data)
96-
vnic_defined_tags=""
97-
vnic_freeform_tags=""
96+
9897
for ins in instance_info.data:
9998
ins_details = compute.get_instance(instance_id=ins.id)
10099
# print(ins_details.data)
@@ -181,7 +180,8 @@ def __get_instances_info(compartment_name, compartment_id, reg_name, config,disp
181180
vnic_info = network.get_vnic(vnic_id=vnic_id).data
182181

183182
# print(vnic_info)
184-
183+
vnic_defined_tags = ""
184+
vnic_freeform_tags = ""
185185
for namespace,tagkey in vnic_info.defined_tags.items():
186186
for tag,value in tagkey.items():
187187
vnic_defined_tags=vnic_defined_tags+";"+namespace+"."+tag+"="+value
@@ -372,8 +372,6 @@ def export_instances(inputfile, outdir, config, network_compartments=[], display
372372
script_file = f'{outdir}/{reg}/tf_import_commands_instances_nonGF.sh'
373373
with open(script_file, 'a') as importCommands[reg]:
374374
importCommands[reg].write('\n\nterraform plan\n')
375-
if "linux" in sys.platform:
376-
os.chmod(script_file, 0o755)
377375

378376
commonTools.write_to_cd3(values_for_column_instances, cd3file, "Instances")
379377
print("{0} Instance Details exported into CD3.\n".format(len(values_for_column_instances["Region"])))

cd3_automation_toolkit/Compute/templates/dedicatedvmhosts-template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Dedicated VM Hosts - tfvars
77
# Allowed Values:
88
# compartment_id and network_compartment_id can be the ocid or the name of the compartment hierarchy delimited by double hiphens "--"
9-
# Example : compartment_id = "ocid1.compartment.oc1..aaaaaaaahwwiefb56epvdlzfic6ah6jy3xf3c" or compartment_id = "Network-root-cpt--Network" where "Network-root-cpt" is the parent of "Network" compartment
9+
# Example : compartment_id = "ocid1.compartment.oc1..aaaaaaaahwwiefb56epvdlzfic6ah6jy3xf3c" or compartment_id = "AppDev--Prod" where "AppDev" is the parent of "Prod" compartment
1010
# Sample import command for Dedicated VM Hosts:
1111
# terraform import "module.dedicated-hosts[\"<<dedicated_hosts terraform variable name>>\"].oci_core_dedicated_vm_host.dedicated_vm_host" <<dedicated vm host ocid>>
1212
############################

cd3_automation_toolkit/Compute/templates/instances-template

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
# vcn_name must be the name of the VCN as in OCI
99
# subnet_id can be the ocid of the subnet or the name as in OCI
1010
# compartment_id and network_compartment_id can be the ocid or the name of the compartment hierarchy delimited by double hiphens "--"
11-
# Example : compartment_id = "ocid1.compartment.oc1..aaaaaaaahwwiefb56epvdlzfic6ah6jy3xf3c" or compartment_id = "Network-root-cpt--Network" where "Network-root-cpt" is the parent of "Network" compartment
11+
# Example : compartment_id = "ocid1.compartment.oc1..aaaaaaaahwwiefb56epvdlzfic6ah6jy3xf3c" or compartment_id = "AppDev--Prod" where "AppDev" is the parent of "Prod" compartment
1212
# Sample import command for Instance and volume backup policy:
13-
# terraform import "module.instances[\"<<instances terraform variable name>>\"].oci_core_instance.instance" <<instance ocid>>
14-
# terraform import "module.instances[\"<<instances terraform variable name>>\"].oci_core_volume_backup_policy_assignment.volume_backup_policy_assignment[0]" <<volume backup policy ocid>>
13+
# terraform import "module.instances[\"<<instance terraform variable name>>\"].oci_core_instance.instance" <<instance ocid>>
14+
# terraform import "module.instances[\"<<instance terraform variable name>>\"].oci_core_volume_backup_policy_assignment.volume_backup_policy_assignment[0]" <<volume backup policy ocid>>
1515
############################
1616

1717
instances = {

cd3_automation_toolkit/Database/create_terraform_dbsystems_vm_bm.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def create_terraform_dbsystems_vm_bm(inputfile, outdir, prefix, config=DEFAULT_L
4444
oname = {}
4545
tfStr = {}
4646
ADS = ["AD1", "AD2", "AD3"]
47+
subnets = parseSubnets(filename)
4748

4849
# Load the template file
4950
file_loader = FileSystemLoader(f'{Path(__file__).parent}/templates')
@@ -157,10 +158,28 @@ def create_terraform_dbsystems_vm_bm(inputfile, outdir, prefix, config=DEFAULT_L
157158
tempdict = {'display_tf_name': display_tf_name}
158159

159160
if columnname == 'Subnet Name':
160-
columnvalue = commonTools.check_tf_variable(columnvalue)
161-
162-
if columnname == 'Backup Subnet Name':
163-
columnvalue = commonTools.check_tf_variable(columnvalue)
161+
subnet_tf_name = columnvalue.strip()
162+
if ("ocid1.subnet.oc1" in subnet_tf_name):
163+
network_compartment_id = ""
164+
vcn_name = ""
165+
subnet_id = subnet_tf_name
166+
else:
167+
try:
168+
key = region, subnet_tf_name
169+
network_compartment_id = subnets.vcn_subnet_map[key][0]
170+
vcn_name = subnets.vcn_subnet_map[key][1]
171+
subnet_id = subnets.vcn_subnet_map[key][2]
172+
except Exception as e:
173+
print("Invalid Subnet Name specified for row " + str(
174+
i + 3) + ". It Doesnt exist in Subnets sheet. Exiting!!!")
175+
exit()
176+
177+
tempdict = {'network_compartment_id': commonTools.check_tf_variable(network_compartment_id),
178+
'vcn_name': vcn_name,
179+
'subnet_id': subnet_id}
180+
181+
# if columnname == 'Backup Subnet Name':
182+
# columnvalue = commonTools.check_tf_variable(columnvalue)
164183

165184

166185
if columnname == 'Availability Domain(AD1|AD2|AD3)':

cd3_automation_toolkit/Database/create_terraform_exa_vmclusters.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def create_terraform_exa_vmclusters(inputfile, outdir, prefix, config=DEFAULT_LO
6161

6262
# List of the column headers
6363
dfcolumns = df.columns.values.tolist()
64+
subnets = parseSubnets(filename)
6465

6566
# Initialise empty TF string for each region
6667
for reg in ct.all_regions:
@@ -143,10 +144,44 @@ def create_terraform_exa_vmclusters(inputfile, outdir, prefix, config=DEFAULT_LO
143144
tempdict = {'exadata_infra_display_tf_name': display_tf_name}
144145

145146
if columnname == 'Client Subnet Name':
146-
columnvalue = commonTools.check_tf_variable(columnvalue)
147+
subnet_tf_name = columnvalue.strip()
148+
if ("ocid1.subnet.oc1" in subnet_tf_name):
149+
network_compartment_id = ""
150+
vcn_name = ""
151+
subnet_id = subnet_tf_name
152+
else:
153+
try:
154+
key = region, subnet_tf_name
155+
network_compartment_id = subnets.vcn_subnet_map[key][0]
156+
vcn_name = subnets.vcn_subnet_map[key][1]
157+
subnet_id = subnets.vcn_subnet_map[key][2]
158+
except Exception as e:
159+
print("Invalid Subnet Name specified for row " + str(
160+
i + 3) + ". It Doesnt exist in Subnets sheet. Exiting!!!")
161+
exit()
162+
163+
tempdict = {'network_compartment_id': commonTools.check_tf_variable(network_compartment_id),
164+
'vcn_name': vcn_name,
165+
'client_subnet_name': subnet_id}
147166

148167
if columnname == 'Backup Subnet Name':
149-
columnvalue = commonTools.check_tf_variable(columnvalue)
168+
subnet_tf_name = columnvalue.strip()
169+
if ("ocid1.subnet.oc1" in subnet_tf_name):
170+
network_compartment_id = ""
171+
vcn_name = ""
172+
subnet_id = subnet_tf_name
173+
else:
174+
try:
175+
key = region, subnet_tf_name
176+
network_compartment_id = subnets.vcn_subnet_map[key][0]
177+
vcn_name = subnets.vcn_subnet_map[key][1]
178+
subnet_id = subnets.vcn_subnet_map[key][2]
179+
except Exception as e:
180+
print("Invalid Subnet Name specified for row " + str(
181+
i + 3) + ". It Doesnt exist in Subnets sheet. Exiting!!!")
182+
exit()
183+
184+
tempdict = {'backup_subnet_name': subnet_id}
150185

151186
if columnname == 'NSGs':
152187
if columnvalue != '':

cd3_automation_toolkit/Database/export_dbsystems_vm_bm_nonGreenField.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,6 @@ def export_dbsystems_vm_bm(inputfile, _outdir, _config, network_compartments=[])
222222

223223
with open(script_file, 'a') as importCommands[reg]:
224224
importCommands[reg].write('\n\nterraform plan\n')
225-
if "linux" in sys.platform:
226-
os.chmod(script_file, 0o755)
227225

228226
commonTools.write_to_cd3(values_for_column, cd3file, sheetName)
229227
print("Virtual Machine and Bare Metal DB Systems exported to CD3\n")

cd3_automation_toolkit/Database/export_exa_infra_nonGreenField.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,6 @@ def export_exa_infra(inputfile, _outdir, _config, network_compartments=[]):
126126
for exa_infra in exa_infras.data:
127127
print_exa_infra(region, exa_infra,values_for_column, ntk_compartment_name)
128128

129-
if "linux" in sys.platform:
130-
os.chmod(script_file, 0o755)
131-
132129
commonTools.write_to_cd3(values_for_column, cd3file, sheetName)
133130

134131
print("Exadata Infra exported to CD3\n")

cd3_automation_toolkit/Database/export_exa_vmclusters_nonGreenField.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,6 @@ def export_exa_vmclusters(inputfile, _outdir, _config, network_compartments=[]):
201201

202202
with open(script_file, 'a') as importCommands[reg]:
203203
importCommands[reg].write('\n\nterraform plan\n')
204-
if "linux" in sys.platform:
205-
os.chmod(script_file, 0o755)
206204

207205
commonTools.write_to_cd3(values_for_column, cd3file, sheetName)
208206

cd3_automation_toolkit/Database/templates/adb-template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# ADB - tfvars
77
# Allowed Values:
88
# compartment_id and network_compartment_id can be the ocid or the name of the compartment hierarchy delimited by double hiphens "--"
9-
# Example : compartment_id = "ocid1.compartment.oc1..aaaaaaaahwwiefb56epvdlzfic6ah6jy3xf3c" or compartment_id = "Network-root-cpt--Network" where "Network-root-cpt" is the parent of "Network" compartment
9+
# Example : compartment_id = "ocid1.compartment.oc1..aaaaaaaahwwiefb56epvdlzfic6ah6jy3xf3c" or compartment_id = "Database--Prod" where "Database" is the parent of "Prod" compartment
1010
############################
1111

1212
adb = {

0 commit comments

Comments
 (0)