Skip to content

Commit 589bf9e

Browse files
committed
Automation Toolkit Release v2026.1.0
1 parent 151f126 commit 589bf9e

14 files changed

Lines changed: 518 additions & 10 deletions

File tree

cd3_automation_toolkit/connectCloud.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ def main():
77
print("Usage: python connectCloud.py <cloud_provider> <properties_file_path>")
88
print("Example: python connectCloud.py oci connectOCI.properties")
99
print("Example: python connectCloud.py azure connectAzure.properties")
10+
print("Example: python connectCloud.py gcp connectGCP.properties")
1011
return
1112

1213
cloud_provider = sys.argv[1].lower()
@@ -16,8 +17,10 @@ def main():
1617
script_name = 'user-scripts/createTenancyConfig.py'
1718
elif cloud_provider == 'azure':
1819
script_name = 'user-scripts/connectAzure.py'
20+
elif cloud_provider == 'gcp':
21+
script_name = 'user-scripts/connectGCP.py'
1922
else:
20-
print("Invalid cloud provider. Use 'azure' or 'oci'.")
23+
print("Invalid cloud provider. Use 'azure' or 'oci' or 'gcp'.")
2124
return
2225

2326
try:
84.7 KB
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env python3
2+
3+
from .create_terraform_exa_infra_gcp import create_terraform_exa_infra_gcp
4+
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/usr/bin/python3
2+
# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
3+
#
4+
# This script will produce a Terraform file that will be used to set up OCI Database
5+
# Database EXA
6+
#
7+
# Author: Suruchi
8+
# Oracle Consulting
9+
#
10+
11+
import os
12+
import re
13+
import sys
14+
from jinja2 import Environment, FileSystemLoader
15+
from pathlib import Path
16+
sys.path.append(os.getcwd()+"/..")
17+
from common.python.commonTools import *
18+
import gcpcloud.python.gcpCommonTools as gcpCommonTools
19+
20+
21+
######
22+
# Required Inputs- CD3 excel file, prefix AND outdir
23+
######
24+
# Execution of the code begins here
25+
def create_terraform_exa_infra_gcp(inputfile, outdir, prefix):
26+
27+
filename = inputfile
28+
sheetName = "EXA-Infra-GCP"
29+
auto_tfvars_filename = prefix + '_' + sheetName.lower() + '.auto.tfvars'
30+
resource = sheetName.lower()
31+
32+
# Load the template file
33+
file_loader = FileSystemLoader(f'{Path(__file__).parent}/templates')
34+
env = Environment(loader=file_loader, keep_trailing_newline=True, trim_blocks=True, lstrip_blocks=True)
35+
template = env.get_template('exa-infra-gcp-template')
36+
37+
# Read cd3 using pandas dataframe
38+
df, col_headers = commonTools.read_cd3(filename, sheetName)
39+
40+
#Remove empty rows
41+
df = df.dropna(how='all')
42+
df = df.reset_index(drop=True)
43+
tfStr = ''
44+
45+
# List of the column headers
46+
dfcolumns = df.columns.values.tolist()
47+
48+
# Iterate over rows
49+
for i in df.index:
50+
location = str(df.loc[i, 'Location']).strip()
51+
52+
# Encountered <End>
53+
if (location in commonTools.endNames):
54+
break
55+
56+
if location.lower() == 'nan':
57+
continue
58+
59+
location=location.strip().lower()
60+
61+
# temporary dictionary1 and dictionary2
62+
tempStr = {}
63+
tempdict = {}
64+
65+
# Check if values are entered for mandatory fields
66+
if str(df.loc[i, 'Location']).lower() == 'nan' or \
67+
str(df.loc[i, 'GCP Oracle Zone']).lower() == 'nan' or \
68+
str(df.loc[i, 'Location']).lower() == 'nan' or \
69+
str(df.loc[i, 'Exadata Infra Display Name']).lower() == 'nan' or \
70+
str(df.loc[i, 'Shape']).lower() == 'nan':
71+
print("\nAll fields except Maintenane Window, Maintenance Contact and Labels are mandatory. Please enter a value and try again !!")
72+
73+
exit(1)
74+
75+
#tempdict = {'oracle_db_software_edition' : 'ENTERPRISE_EDITION_EXTREME_PERFORMANCE'}
76+
77+
for columnname in dfcolumns:
78+
# Column value
79+
columnvalue = str(df[columnname][i]).strip()
80+
81+
# Check for boolean/null in column values
82+
columnvalue = commonTools.check_columnvalue(columnvalue)
83+
84+
# Check for multivalued columns
85+
tempdict = commonTools.check_multivalues_columnvalue(columnvalue,columnname,tempdict)
86+
87+
88+
# Process Defined and Freeform Tags
89+
if columnname.lower() in gcpCommonTools.tagColumns:
90+
tempdict = gcpCommonTools.split_tag_values(columnname, columnvalue, tempdict)
91+
92+
if columnname == "Exadata Infra Display Name":
93+
display_name = columnvalue.strip()
94+
display_tf_name = commonTools.check_tf_variable(display_name)
95+
cloud_exadata_infrastructure_id = re.sub(r'[^a-z0-9-]', '', display_name.lower())
96+
tempdict = {'display_name': display_name, 'display_tf_name': display_tf_name, 'cloud_exadata_infrastructure_id' : cloud_exadata_infrastructure_id}
97+
98+
columnname = commonTools.check_column_headers(columnname)
99+
tempStr[columnname] = str(columnvalue).strip()
100+
tempStr.update(tempdict)
101+
102+
103+
# Write all info to TF string
104+
tfStr = tfStr + template.render(tempStr)
105+
106+
# Write TF string to the file
107+
if (tfStr != ''):
108+
outfile = outdir + "/" + auto_tfvars_filename
109+
commonTools.backup_file(outdir, resource, auto_tfvars_filename)
110+
src = "##Add New Exa-Infra @GCP here##"
111+
tfStr = template.render(count=0).replace(src, tfStr + "\n" + src)
112+
tfStr = "".join([s for s in tfStr.strip().splitlines(True) if s.strip("\r\n").strip()])
113+
oname = open(outfile, 'w')
114+
oname.write(tfStr)
115+
oname.close()
116+
print(outfile + " containing TF for Exa-Infra @GCP has been created")
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{% if count == 0 %}
2+
# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
#
5+
############################
6+
# Exa Infra @Azure
7+
# Exa Infra @Azure - tfvars
8+
############################
9+
10+
gcp_oci_exa_infra = {
11+
##Add New Exa-Infra @GCP here##
12+
}
13+
{% else %}
14+
15+
{{ display_tf_name }} = {
16+
location = "{{ location }}"
17+
gcp_oracle_zone = "{{ gcp_oracle_zone }}"
18+
project = "{{ project }}"
19+
20+
# Infrastructure Details
21+
# Allowed shapes: Exadata.X9M, Exadata.X11M
22+
cloud_exadata_infrastructure_id = "{{ cloud_exadata_infrastructure_id }}"
23+
shape = "{{ shape }}"
24+
compute_count = {{ database_servers }} # Valid range: 2-32
25+
storage_count = {{ storage_servers }} # Valid range: 3-64
26+
27+
28+
maintenance_window = {
29+
# Patching Mode: "ROLLING" (one by one) or "NONROLLING" (all at once)
30+
patching_mode="{{ maintenance_method }}"
31+
32+
{% if is_custom_action_timeout_enabled %}
33+
is_custom_action_timeout_enabled = {{ is_custom_action_timeout_enabled }} # true of false
34+
custom_action_timeout_in_mins = {{ custom_action_timeout_in_mins }} # Minimum = 15, Maximum = 30
35+
{% endif %}
36+
37+
{% if preference %}
38+
# Preference: "NO_PREFERENCE" (Oracle chooses) or "CUSTOM_PREFERENCE" (custom schedule)
39+
preference= "{{ preference }}"
40+
{% endif %}
41+
{% if hours_of_day %}
42+
hours_of_day = {{ hours_of_day.split(",") | map('int') | list | tojson }}
43+
{% endif %}
44+
{% if days_of_week %}
45+
days_of_week = {{ days_of_week.split(",") | map('trim') | list | tojson }}
46+
{% endif %}
47+
{% if weeks_of_month %}
48+
weeks_of_month = {{ weeks_of_month.split(",") | map('int') | list | tojson }}
49+
{% endif %}
50+
{% if lead_time_in_weeks %}
51+
lead_time_in_weeks = {{ lead_time_in_weeks }}
52+
{% endif %}
53+
{% if months %}
54+
months = {{ months.split(",") | map('trim') | list | tojson }}
55+
{% endif %}
56+
}
57+
58+
{% if email and email != "" and email != "nan" %}
59+
# Support Contacts
60+
email = "{{ email }}"
61+
{% endif %}
62+
63+
64+
{# ##Do not modify below this line## #}
65+
{# #}
66+
{# ###Section for adding Labels### #}
67+
{% if labels and labels != 'nan' and labels != '' and labels != [['nan']] %}
68+
{% if labels[0] %}
69+
labels = {
70+
{% for label in labels %}
71+
{% if not loop.last %}
72+
"{{ label[0] }}"= "{{ label[1] }}" ,
73+
{% else %}
74+
"{{ label[0] }}"= "{{ label[1] }}"
75+
{% endif %}
76+
{% endfor %}
77+
}
78+
{% endif %}
79+
{% endif %}
80+
81+
{# ###Section for adding Labels ends here### #}
82+
},
83+
84+
{% endif %}
85+

cd3_automation_toolkit/gcpcloud/python/gcpCommonTools.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,39 @@
55

66

77
class gcpCommonTools():
8+
tagColumns = {'labels'}
9+
810
def authenticate(self,config_file):
911
# Azure credential & client
1012
credentials = service_account.Credentials.from_service_account_file(config_file)
1113
return credentials
14+
15+
def split_tag_values(columnname, columnvalue, tempdict):
16+
columnvalue = columnvalue.replace("\n", "")
17+
if ";" in columnvalue:
18+
# If there are more than one tag; split them by ";" and "="
19+
20+
columnname = commonTools.check_column_headers(columnname)
21+
multivalues = columnvalue.split(";")
22+
multivalues = [part.split("=") for part in multivalues if part]
23+
"""for value in multivalues:
24+
try:
25+
value[1] = value[1].replace("\\","\\\\")
26+
except IndexError as e:
27+
pass"""
28+
tempdict = {columnname: multivalues}
29+
print("if")
30+
else:
31+
# If there is only one tag; split them only by "="; each key-value pair is stored as a list
32+
columnname = commonTools.check_column_headers(columnname)
33+
multivalues = columnvalue.split("=")
34+
multivalues = [str(part).strip() for part in multivalues if part]
35+
"""if multivalues != []:
36+
try:
37+
multivalues[1] = multivalues[1].replace("\\","\\\\")
38+
except IndexError as e:
39+
pass"""
40+
tempdict = {columnname: [multivalues]}
41+
print("else")
42+
print(tempdict)
43+
return tempdict

cd3_automation_toolkit/gcpcloud/terraform/modules/gcp-oci-exa-vmcluster/main.tf

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ resource "google_compute_network" "vpc_network" {
1010

1111
count = var.cluster_config.create_odb_network ? 1 : 0
1212
name = var.cluster_config.vpc_network_name
13-
project = var.cluster_config.project
13+
project = var.cluster_config.odb_network_project
1414
auto_create_subnetworks = false # Sets the VPC to "Custom" mode
1515
mtu = 1460
1616
}
@@ -22,7 +22,7 @@ resource "google_oracle_database_odb_network" "odb_network" {
2222
count = var.cluster_config.create_odb_network ? 1 : 0
2323
odb_network_id = var.cluster_config.odb_network_id
2424
location = var.cluster_config.location
25-
project = var.cluster_config.project
25+
project = var.cluster_config.odb_network_project
2626
network = google_compute_network.vpc_network[0].id
2727
gcp_oracle_zone = var.cluster_config.odb_network_gcp_oracle_zone
2828
labels = var.labels
@@ -36,7 +36,7 @@ resource "google_oracle_database_odb_subnet" "odb_client_subnet" {
3636
count = var.cluster_config.create_odb_network_subnets ? 1 : 0
3737
odb_subnet_id = var.cluster_config.odb_client_subnet_id
3838
location = var.cluster_config.location
39-
project = var.cluster_config.project
39+
project = var.cluster_config.odb_network_project
4040
odbnetwork = var.cluster_config.create_odb_network ==true ? google_oracle_database_odb_network.odb_network[0].odb_network_id : "projects/${var.cluster_config.project}/locations/${var.cluster_config.location}/odbNetworks/${var.cluster_config.odb_network_id}"
4141
cidr_range = var.cluster_config.client_subnet_cidr
4242
purpose = "CLIENT_SUBNET"
@@ -48,7 +48,7 @@ resource "google_oracle_database_odb_subnet" "odb_backup_subnet" {
4848
count = var.cluster_config.create_odb_network_subnets ? 1 : 0
4949
odb_subnet_id = var.cluster_config.odb_backup_subnet_id
5050
location = var.cluster_config.location
51-
project = var.cluster_config.project
51+
project = var.cluster_config.odb_network_project
5252
odbnetwork = var.cluster_config.create_odb_network ==true ? google_oracle_database_odb_network.odb_network[0].odb_network_id : "projects/${var.cluster_config.project}/locations/${var.cluster_config.location}/odbNetworks/${var.cluster_config.odb_network_id}"
5353
cidr_range = var.cluster_config.backup_subnet_cidr
5454
purpose = "BACKUP_SUBNET"
@@ -68,7 +68,6 @@ resource "google_oracle_database_cloud_vm_cluster" "vm_cluster" {
6868
odb_subnet = var.cluster_config.create_odb_network_subnets == true ? google_oracle_database_odb_subnet.odb_client_subnet[0].id : "projects/${var.cluster_config.project}/locations/${var.cluster_config.location}/odbNetworks/${var.cluster_config.odb_network_id}/odbSubnets/${var.cluster_config.odb_client_subnet_id}"
6969
backup_odb_subnet = var.cluster_config.create_odb_network_subnets == true ? google_oracle_database_odb_subnet.odb_backup_subnet[0].id : "projects/${var.cluster_config.project}/locations/${var.cluster_config.location}/odbNetworks/${var.cluster_config.odb_network_id}/odbSubnets/${var.cluster_config.odb_backup_subnet_id}"
7070
properties {
71-
# cluster_name = "pq-ppat4"
7271
gi_version = var.cluster_config.gi_version
7372
db_server_ocids = var.db_server_ocids
7473
cpu_core_count = var.cluster_config.cpu_core_count
@@ -93,7 +92,6 @@ resource "google_oracle_database_cloud_vm_cluster" "vm_cluster" {
9392
id = var.cluster_config.time_zone
9493
}
9594
scan_listener_port_tcp = var.cluster_config.scan_listener_port_tcp
96-
# scan_listener_port_tcp_ssl = 2484
9795
}
9896
labels = var.labels
9997

cd3_automation_toolkit/gcpcloud/terraform/modules/gcp-oci-exa-vmcluster/variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ variable "cluster_config" {
2929
location = string
3030
project = string
3131
exadata_infrastructure_id = string
32+
odb_network_project = string
3233
create_odb_network = bool
3334
create_odb_network_subnets = bool
3435
vpc_network_name = optional(string)

cd3_automation_toolkit/gcpcloud/terraform/variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ variable "gcp_oci_exa_vmclusters" {
5858
project = string
5959

6060
exadata_infrastructure_id = string
61+
odb_network_project = string
6162
create_odb_network = bool
6263
create_odb_network_subnets = bool
6364
vpc_network_name = optional(string)

cd3_automation_toolkit/setUpCloud.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ def main():
77
print("Usage: python setUpCloud.py <cloud_provider> <properties_file_path>")
88
print("Example: python setUpCloud.py azure setUpAzure.properties")
99
print("Example: python setUpCloud.py oci setUpOCI.properties")
10+
print("Example: python setUpCloud.py gcp setUpGCP.properties")
1011
return
1112

1213
cloud_provider = sys.argv[1].lower()
@@ -16,6 +17,8 @@ def main():
1617
script_name = 'setUpOCI.py'
1718
elif cloud_provider == 'azure':
1819
script_name = 'user-scripts/setUpAzure.py'
20+
elif cloud_provider == 'gcp':
21+
script_name = 'user-scripts/setUpGCP.py'
1922
else:
2023
print("Invalid cloud provider. Use 'azure' or 'oci'.")
2124
return

0 commit comments

Comments
 (0)