Skip to content

Commit 47816d4

Browse files
authored
Merge pull request #67 from oracle-devrel/develop
Develop
2 parents a4595a7 + cccd6cd commit 47816d4

File tree

92 files changed

+2662
-412
lines changed

Some content is hidden

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

92 files changed

+2662
-412
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858

5959
<li> <a href = "/cd3_automation_toolkit/documentation/user_guide/RestructuringOutDirectory.md">Grouping of generated Terraform files</a></li>
6060
<li> <a href = "/cd3_automation_toolkit/documentation/user_guide/learn_more/ResourceManagerUpload.md">OCI Resource Manager Upload</a></li>
61+
<li> <a href = "/cd3_automation_toolkit/documentation/user_guide/learn_more/OPAForCompliance.md">OPA For Compliance with Terraform</a></li>
6162
<li> <a href = "/cd3_automation_toolkit/documentation/user_guide/learn_more/CISFeatures.md">Additional CIS Compliance Features</a></li>
6263
<li> <a href = "/cd3_automation_toolkit/documentation/user_guide/learn_more/SupportForCD3Validator.md">CD3 Validator Features</a></li>
6364

cd3_automation_toolkit/Compute/create_terraform_instances.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import sys
1313
import os
14+
import fnmatch
1415
from oci.config import DEFAULT_LOCATION
1516
from pathlib import Path
1617

@@ -100,6 +101,9 @@ def create_terraform_instances(inputfile, outdir, service_dir, prefix, config):
100101
"\nOne/All of the Column/Columns from Region, Shape, Compartment Name, Availability Domain, Display Name, Pub Address, Source Details and Subnet Name is empty in Instances sheet of CD3..exiting...Please check.")
101102
exit(1)
102103

104+
# Perform the plugin match
105+
plugin_match = None
106+
plugin_column = fnmatch.filter(df.columns.tolist(), 'Plugin*')
103107
for columnname in dfcolumns:
104108

105109
# Column value
@@ -115,6 +119,20 @@ def create_terraform_instances(inputfile, outdir, service_dir, prefix, config):
115119
if columnname.lower() in commonTools.tagColumns:
116120
tempdict = commonTools.split_tag_values(columnname, columnvalue, tempdict)
117121

122+
if columnname in plugin_column:
123+
columnvalue = columnvalue.strip()
124+
if columnvalue != "":
125+
plugin_match = True
126+
tempdict = {'plugin_match': plugin_match}
127+
128+
if columnname == 'Network Type':
129+
network_type = columnvalue.strip()
130+
tempdict = {'network_type': network_type}
131+
132+
if columnname == 'Platform Config Type':
133+
network_type = columnvalue.strip()
134+
tempdict = {'platform_config_type': network_type}
135+
118136
if columnname == 'Shape':
119137
if ".Flex" not in columnvalue and ".Micro" not in columnvalue:
120138
columnvalue = columnvalue.strip()
@@ -156,9 +174,9 @@ def create_terraform_instances(inputfile, outdir, service_dir, prefix, config):
156174
if ("@" in columnvalue):
157175
remote_execute = columnvalue.strip().split("@")
158176
tempdict = {'remote_execute': remote_execute[1],
159-
'bastion_ip': remote_execute[0]}
177+
'bastion_ip': remote_execute[0]}
160178
else:
161-
tempdict = {'remote_execute': columnvalue.strip() }
179+
tempdict = {'remote_execute': columnvalue.strip()}
162180

163181
if columnname == 'Custom Policy Compartment Name':
164182
if columnvalue != "":
@@ -232,4 +250,3 @@ def create_terraform_instances(inputfile, outdir, service_dir, prefix, config):
232250
print(outfile + " for instances and boot volume backup policy has been created for region " + reg)
233251
oname.write(tfStr[reg])
234252
oname.close()
235-

cd3_automation_toolkit/Compute/export_instances_nonGreenField.py

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,17 @@
77
import sys
88
import oci
99
import os
10-
from oci.config import DEFAULT_LOCATION
11-
from pathlib import Path
1210
sys.path.append(os.getcwd() + "/..")
1311
from commonTools import *
14-
from jinja2 import Environment, FileSystemLoader
1512

1613

1714
def adding_columns_values(region, ad, fd, vs, publicip, privateip, os_dname, shape, key_name, c_name,
18-
bkp_policy_name, nsgs, d_host, instance_data, values_for_column_instances, bdet,
19-
cpcn,shape_config,vnic_info,vnic_defined_tags,vnic_freeform_tags,launch_options):
20-
# print("CPCN=",cpcn)
15+
bkp_policy_name, nsgs, d_host, instance_data, values_for_column_instances, bdet,
16+
cpcn, shape_config, vnic_info, vnic_defined_tags, vnic_freeform_tags, launch_options,avail_config,ins_options,
17+
platform_config, plugin_config):
2118
for col_header in values_for_column_instances.keys():
2219
if (col_header == "Region"):
2320
values_for_column_instances[col_header].append(region)
24-
#elif (col_header == "Hostname"):
25-
# values_for_column_instances[col_header].append(hostname)
2621
elif (col_header == "Availability Domain(AD1|AD2|AD3)"):
2722
values_for_column_instances[col_header].append(ad)
2823
elif (col_header == "Fault Domain"):
@@ -51,7 +46,16 @@ def adding_columns_values(region, ad, fd, vs, publicip, privateip, os_dname, sha
5146
values_for_column_instances[col_header].append(vnic_freeform_tags)
5247
elif (col_header == "VNIC Display Name"):
5348
values_for_column_instances[col_header].append(vnic_info.display_name)
54-
elif (col_header == "Dedicated VM Host"):
49+
50+
elif(col_header.lower().startswith("plugin")):
51+
col_temp = col_header.lower().replace("plugin","")
52+
col_temp=col_temp.strip()
53+
col_temp=col_temp.strip("_")
54+
col_temp=col_temp.replace(" ","_")
55+
col_temp = col_temp.replace("-", "_")
56+
values_for_column_instances[col_header].append(plugin_config.get(col_temp))
57+
58+
elif(col_header == "Dedicated VM Host"):
5559
if (d_host == None):
5660
values_for_column_instances[col_header].append('')
5761
else:
@@ -62,12 +66,12 @@ def adding_columns_values(region, ad, fd, vs, publicip, privateip, os_dname, sha
6266
values_for_column_instances = commonTools.export_tags(instance_data, col_header,
6367
values_for_column_instances)
6468
else:
65-
oci_objs = [instance_data, bdet,shape_config,vnic_info,d_host,launch_options]
69+
oci_objs = [instance_data, bdet, shape_config, vnic_info, d_host, launch_options, avail_config, ins_options, platform_config]
6670
values_for_column_instances = commonTools.export_extra_columns(oci_objs, col_header, sheet_dict_instances,
6771
values_for_column_instances)
6872

6973

70-
def find_vnic(ins_id, config,compartment_id):
74+
def find_vnic(ins_id, config, compartment_id):
7175
compute = oci.core.ComputeClient(config, retry_strategy=oci.retry.DEFAULT_RETRY_STRATEGY)
7276
#for comp in all_compartments:
7377
net = oci.pagination.list_call_get_all_results(compute.list_vnic_attachments, compartment_id=compartment_id,
@@ -76,8 +80,7 @@ def find_vnic(ins_id, config,compartment_id):
7680
return net
7781

7882

79-
80-
def __get_instances_info(compartment_name, compartment_id, reg_name, config,display_names, ad_names,ct):
83+
def __get_instances_info(compartment_name, compartment_id, reg_name, config, display_names, ad_names, ct):
8184
config.__setitem__("region", ct.region_dict[reg_name])
8285
compute = oci.core.ComputeClient(config, retry_strategy=oci.retry.DEFAULT_RETRY_STRATEGY)
8386
network = oci.core.VirtualNetworkClient(config, retry_strategy=oci.retry.DEFAULT_RETRY_STRATEGY)
@@ -244,9 +247,21 @@ def __get_instances_info(compartment_name, compartment_id, reg_name, config,disp
244247
os_dname = "bootVolume::" + os_dname
245248

246249
launch_options = ins.launch_options
250+
avail_config = ins.availability_config
251+
ins_options = ins.instance_options
252+
platform_data = ins.platform_config
253+
plugins_config = getattr(ins.agent_config, 'plugins_config')
254+
plugin_config = {}
255+
if plugins_config is not None:
256+
for item in plugins_config:
257+
plugin_config[getattr(item, 'name').lower().replace(" ","_").replace("-","_")] = getattr(item, 'desired_state')
258+
247259
adding_columns_values(reg_name.title(), AD_name, ins_fd, vs, publicip, privateip, os_dname,
248-
ins_shape, key_name, compartment_name, bkp_policy_name, nsg_names, dedicated_host,
249-
ins, values_for_column_instances, bdet, cpcn,shape_config, vnic_info, vnic_defined_tags, vnic_freeform_tags, launch_options)
260+
ins_shape, key_name, compartment_name, bkp_policy_name, nsg_names, dedicated_host,
261+
ins, values_for_column_instances, bdet, cpcn, shape_config, vnic_info,
262+
vnic_defined_tags, vnic_freeform_tags, launch_options,avail_config,ins_options,
263+
platform_data, plugin_config)
264+
250265

251266
# Execution of the code begins here
252267
def export_instances(inputfile, outdir, service_dir,config,ct, export_compartments=[], export_regions=[],display_names=[],ad_names=[]):

cd3_automation_toolkit/Compute/templates/instances-template

Lines changed: 72 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,78 @@ instances = {
8787
create_is_pv_encryption_in_transit_enabled = {{ create_is_pv_encryption_in_transit_enabled }}
8888
{% endif %}
8989

90-
{% if update_is_pv_encryption_in_transit_enabled %}
91-
update_is_pv_encryption_in_transit_enabled = {{ update_is_pv_encryption_in_transit_enabled }}
90+
{% if plugin_match %}
91+
plugins_details = {
92+
{% if plugin_bastion %}
93+
Bastion = "{{ plugin_bastion.upper() }}",
94+
{% endif %}
95+
{% if plugin_management_agent %}
96+
"Management Agent" = "{{ plugin_management_agent.upper() }}",
97+
{% endif %}
98+
{% if plugin_vulnerability_scanning %}
99+
"Vulnerability Scanning" = "{{ plugin_vulnerability_scanning.upper() }}"
100+
{% endif %}
101+
{% if plugin_oracle_java_management_service %}
102+
"Oracle Java Management Service" = "{{ plugin_oracle_java_management_service.upper() }}"
103+
{% endif %}
104+
{% if plugin_os_management_service_agent %}
105+
"OS Management Service Agent" = "{{ plugin_os_management_service_agent.upper() }}"
106+
{% endif %}
107+
{% if plugin_custom_logs_monitoring %}
108+
"Custom Logs Monitoring" = "{{ plugin_custom_logs_monitoring.upper() }}"
109+
{% endif %}
110+
{% if plugin_compute_rdma_gpu_monitoring %}
111+
"Compute RDMA GPU Monitoring" = "{{ plugin_compute_rdma_gpu_monitoring.upper() }}"
112+
{% endif %}
113+
{% if plugin_compute_instance_run_command %}
114+
"Compute Instance Run Command" = "{{ plugin_compute_instance_run_command.upper() }}"
115+
{% endif %}
116+
{% if plugin_compute_instance_monitoring %}
117+
"Compute Instance Monitoring" = "{{ plugin_compute_instance_monitoring.upper() }}"
118+
{% endif %}
119+
{% if plugin_compute_hpc_rdma_authentication %}
120+
"Compute HPC RDMA Authentication" = "{{ plugin_compute_hpc_rdma_authentication.upper() }}"
121+
{% endif %}
122+
{% if plugin_block_volume_management %}
123+
"Block Volume Management" = "{{ plugin_block_volume_management.upper() }}"
124+
{% endif %}
125+
{% if plugin_compute_hpc_rdma_auto_configuration %}
126+
"Compute HPC RDMA Auto-Configuration" = "{{ plugin_compute_hpc_rdma_auto_configuration.upper() }}"
127+
{% endif %}
128+
}
129+
{% endif %}
92130

131+
{% if network_type or update_is_pv_encryption_in_transit_enabled %}
132+
launch_options = [{
133+
{% if firmware %}
134+
firmware = "{{ firmware }}",
135+
{% endif %}
136+
{% if is_consistent_volume_naming_enabled %}
137+
is_consistent_volume_naming_enabled = "{{is_consistent_volume_naming_enabled}}",
138+
{% endif %}
139+
{% if update_is_pv_encryption_in_transit_enabled %}
140+
is_pv_encryption_in_transit_enabled = {{update_is_pv_encryption_in_transit_enabled}},
141+
{% endif %}
142+
network_type = "{{network_type}}"
143+
}]
144+
{% endif %}
145+
146+
{% if platform_config_type %}
147+
platform_config = [{
148+
config_type = "{{platform_config_type}}"
149+
{% if is_secure_boot_enabled %}
150+
is_secure_boot_enabled = {{ is_secure_boot_enabled }},
151+
{% endif %}
152+
{% if is_measured_boot_enabled %}
153+
is_measured_boot_enabled = {{ is_measured_boot_enabled }},
154+
{% endif %}
155+
{% if is_trusted_platform_module_enabled %}
156+
is_trusted_platform_module_enabled = {{ is_trusted_platform_module_enabled }},
157+
{% endif %}
158+
{% if numa_nodes_per_socket %}
159+
numa_nodes_per_socket = "{{ numa_nodes_per_socket }}"
160+
{% endif %}
161+
}]
93162
{% endif %}
94163

95164
{% if ssh_key_var_name != '' %}
@@ -105,7 +174,7 @@ instances = {
105174
{% endif %}
106175

107176
{# ##All optional params required for TF root module is below ## #}
108-
{# {% if extended_metadata %}
177+
{% if extended_metadata %}
109178
extended_metadata = "{{ extended_metadata }}"
110179
{% endif %}
111180

@@ -133,10 +202,6 @@ instances = {
133202
is_monitoring_disabled = {{ is_monitoring_disabled }}
134203
{% endif %}
135204

136-
{% if plugins_details %}
137-
plugins_details = "{{ plugins_details }}"
138-
{% endif %}
139-
140205
{% if is_live_migration_preferred %}
141206
is_live_migration_preferred = {{ is_live_migration_preferred }}
142207
{% endif %}
@@ -153,26 +218,6 @@ instances = {
153218
boot_volume_type = "{{ boot_volume_type }}"
154219
{% endif %}
155220

156-
{% if firmware %}
157-
firmware = "{{ firmware }}"
158-
{% endif %}
159-
160-
{% if is_consistent_volume_naming_enabled %}
161-
is_consistent_volume_naming_enabled = {{ is_consistent_volume_naming_enabled }}
162-
{% endif %}
163-
164-
{% if network_type %}
165-
network_type = "{{ network_type }}"
166-
{% endif %}
167-
168-
{% if remote_data_volume_type %}
169-
remote_data_volume_type = "{{ remote_data_volume_type }}"
170-
{% endif %}
171-
172-
{% if platform_config %}
173-
platform_config = "{{ platform_config }}"
174-
{% endif %}
175-
176221
{% if ipxe_script %}
177222
ipxe_script = "{{ ipxe_script }}"
178223
{% endif %}

cd3_automation_toolkit/Database/create_terraform_exa_vmclusters.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ def create_terraform_exa_vmclusters(inputfile, outdir, service_dir, prefix, conf
8080
tempStr = {}
8181
tempdict = {}
8282
nsg_id = ''
83+
db_server_id = ''
8384
backup_nsg_id = ''
8485

8586
# Check if values are entered for mandatory fields
@@ -188,6 +189,25 @@ def create_terraform_exa_vmclusters(inputfile, outdir, service_dir, prefix, conf
188189
c += 1
189190
columnvalue = nsg_id
190191

192+
if columnname == 'DB Servers':
193+
if columnvalue != '':
194+
db_servers = str(columnvalue).strip().split(",")
195+
if len(db_servers) == 1:
196+
for db_server in db_servers:
197+
db_server_id = "\"" + db_server.strip() + "\""
198+
199+
elif len(db_servers) >= 2:
200+
c = 1
201+
for db_server in db_servers:
202+
data = "\"" + db_server.strip() + "\""
203+
204+
if c == len(db_servers):
205+
db_server_id = db_server_id + data
206+
else:
207+
db_server_id = db_server_id + data + ","
208+
c += 1
209+
columnvalue = db_server_id
210+
191211

192212
if columnname == 'Backup Network NSGs':
193213
if columnvalue != '':

cd3_automation_toolkit/Database/export_exa_vmclusters_nonGreenField.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
oci_obj_names = {}
2121

2222

23-
def print_exa_vmcluster(region, vnc_client,exa_infra, exa_vmcluster, key_name,values_for_column, ntk_compartment_name):
23+
def print_exa_vmcluster(region, vnc_client,exa_infra, exa_vmcluster, key_name,values_for_column, ntk_compartment_name, db_servers):
2424
exa_infra_tf_name = commonTools.check_tf_variable(exa_infra.display_name)
2525
exa_vmcluster_tf_name = commonTools.check_tf_variable(exa_vmcluster.display_name)
2626

@@ -54,6 +54,7 @@ def print_exa_vmcluster(region, vnc_client,exa_infra, exa_vmcluster, key_name,va
5454

5555
maintenance_window = exa_infra.maintenance_window
5656

57+
5758
importCommands[region.lower()].write("\nterraform import \"module.exa-vmclusters[\\\"" + exa_vmcluster_tf_name + "\\\"].oci_database_cloud_vm_cluster.exa_vmcluster\" " + str(exa_vmcluster.id))
5859

5960
for col_header in values_for_column:
@@ -73,6 +74,8 @@ def print_exa_vmcluster(region, vnc_client,exa_infra, exa_vmcluster, key_name,va
7374
values_for_column[col_header].append(nsg_names)
7475
elif (col_header == "Backup Network NSGs"):
7576
values_for_column[col_header].append(backup_nsg_names)
77+
elif (col_header == "DB Servers"):
78+
values_for_column[col_header].append(db_servers)
7679
elif col_header.lower() in commonTools.tagColumns:
7780
values_for_column = commonTools.export_tags(exa_vmcluster, col_header, values_for_column)
7881
else:
@@ -163,7 +166,14 @@ def export_exa_vmclusters(inputfile, _outdir, service_dir, _config, ct, export_c
163166
db_ssh_keys = json.dumps(db_ssh_keys)
164167
db[key_name] = db_ssh_keys
165168

166-
print_exa_vmcluster(region, vnc_client, exa_infra,exa_vmcluster,key_name, values_for_column, ntk_compartment_name_again)
169+
db_serverids = exa_vmcluster.db_servers
170+
db_servers = ''
171+
if (db_serverids is not None and len(db_serverids)):
172+
for db_server in db_serverids:
173+
db_server_name = db_client.get_db_server(exa_infra.id, db_server).data.display_name
174+
db_servers = db_server_name +","+db_servers
175+
176+
print_exa_vmcluster(region, vnc_client, exa_infra,exa_vmcluster,key_name, values_for_column, ntk_compartment_name_again,db_servers)
167177

168178
file = f'{outdir}/{reg}/{service_dir}/variables_{reg}.tf'
169179
# Read variables file data

cd3_automation_toolkit/Database/templates/exa-vmclusters-template

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,30 @@ exa_vmclusters = {
7676
data_storage_percentage = null
7777
{% endif %}
7878

79+
{% if db_node_storage_size_in_gbs %}
80+
db_node_storage_size_in_gbs = {{ db_node_storage_size_in_gbs }}
81+
{% else %}
82+
db_node_storage_size_in_gbs = null
83+
{% endif %}
84+
85+
{% if memory_size_in_gbs %}
86+
memory_size_in_gbs = {{ memory_size_in_gbs }}
87+
{% else %}
88+
memory_size_in_gbs = null
89+
{% endif %}
90+
91+
{% if data_storage_size_in_tbs %}
92+
data_storage_size_in_tbs = {{ data_storage_size_in_tbs }}
93+
{% else %}
94+
data_storage_size_in_tbs = null
95+
{% endif %}
96+
97+
{% if db_servers %}
98+
db_servers = [{{ db_servers }}]
99+
{% else %}
100+
db_servers = []
101+
{% endif %}
102+
79103
{% if nsgs %}
80104
nsg_ids = [{{ nsgs }}]
81105
{% else %}

0 commit comments

Comments
 (0)