Skip to content

Commit f4fb948

Browse files
committed
Automation Toolkit Release v2024.4.0
1 parent 88041dc commit f4fb948

File tree

2 files changed

+86
-76
lines changed

2 files changed

+86
-76
lines changed

cd3_automation_toolkit/cd3Validator.py

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -886,20 +886,23 @@ def validate_instances(filename,comp_ids,subnetobj,vcn_subnet_list,vcn_nsg_list)
886886
log(f'ROW {i+3} : Empty value at column Display Name')
887887
inst_empty_check = True
888888

889-
if columnname == 'Subnet Name':
889+
if columnname == 'Network Details':
890890
if columnvalue.lower()=='nan':
891-
log(f'ROW {i+3} : Empty value at column Subnet Name.')
891+
log(f'ROW {i+3} : Empty value at column Network Details.')
892892
inst_empty_check = True
893893
else:
894894
# Cross check the VCN names in Instances and VCNs sheet
895-
vcn_subnet_check = compare_values(vcn_subnet_list.tolist(), columnvalue,[i, 'Subnet Name', 'SubnetsVLANs'])
895+
#vcn_subnet_check = compare_values(vcn_subnet_list.tolist(), columnvalue,[i, 'Subnet Name', 'SubnetsVLANs'])
896+
if ("::" not in columnvalue):
897+
vcn_subnet_check = True
898+
896899

897900
if columnname == 'Source Details':
898901
if columnvalue.lower()== 'nan':
899902
log(f'ROW {i+3} : Empty value at column "Source Details".')
900903
inst_empty_check = True
901904

902-
elif (not columnvalue.startswith("image::") and not columnvalue.startswith("bootVolume::")):
905+
elif (not columnvalue.startswith("image::") and not columnvalue.startswith("bootVolume::") and not columnvalue.startswith("ocid1.image.oc")):
903906
log(f'ROW {i+3} : Wrong value at column Source Details - {columnvalue}. Valid format is image::<var_name> or bootVolume::<var_name>.')
904907
inst_invalid_check = True
905908

@@ -918,10 +921,11 @@ def validate_instances(filename,comp_ids,subnetobj,vcn_subnet_list,vcn_nsg_list)
918921
log(f'ROW {i+3} : Wrong value at column Shape - {columnvalue}.Valid format for Flex Shapes is VM.Standard.E3.Flex::<ocpus>.')
919922
inst_invalid_check = True
920923

921-
if vcn_subnet_check==False and columnname == "NSGs":
922-
subnet_name = str(dfinst.loc[i, "Display Name"]).strip()
923-
if(columnvalue!='nan'):
924-
vcn_nsg_check = validate_nsgs_column(i,region,columnvalue,subnet_name,subnetobj,vcn_nsg_list)
924+
925+
#if vcn_subnet_check==False and columnname == "NSGs":
926+
# subnet_name = str(dfinst.loc[i, "Display Name"]).strip()
927+
# if(columnvalue!='nan'):
928+
# vcn_nsg_check = validate_nsgs_column(i,region,columnvalue,subnet_name,subnetobj,vcn_nsg_list)
925929

926930
if any([inst_empty_check, inst_comp_check, inst_invalid_check, vcn_subnet_check,vcn_nsg_check]):
927931
print("Null or Wrong value Check failed!!")
@@ -1100,13 +1104,13 @@ def validate_fss(filename,comp_ids,subnetobj,vcn_subnet_list,vcn_nsg_list):
11001104
comp_name = str(df_fss.loc[i, 'Compartment Name']).strip()
11011105
ad_name = str(df_fss.loc[i, 'Availability Domain(AD1|AD2|AD3)']).strip()
11021106
mt_name = str(df_fss.loc[i, 'MountTarget Name']).strip()
1103-
mt_subnet_name = str(df_fss.loc[i, 'MountTarget SubnetName']).strip()
1107+
mt_subnet_name = str(df_fss.loc[i, 'Network Details']).strip()
11041108
my_list = [region, comp_name.lower(),ad_name.lower(),mt_name.lower(),mt_subnet_name.lower()]
11051109

11061110
if all(j == 'nan' for j in my_list):
11071111
pass
11081112
elif 'nan' in my_list:
1109-
log(f'ROW {i + 3} : Empty value for any of the columns "Region", "Compartment Name", "Availability Domain(AD1|AD2|AD3)", "MountTarget Name", "MountTarget SubnetName"')
1113+
log(f'ROW {i + 3} : Empty value for any of the columns "Region", "Compartment Name", "Availability Domain(AD1|AD2|AD3)", "MountTarget Name", "Network Details"')
11101114
fss_empty_check = True
11111115

11121116
if region!='nan' and region not in ct.all_regions:
@@ -1129,15 +1133,17 @@ def validate_fss(filename,comp_ids,subnetobj,vcn_subnet_list,vcn_nsg_list):
11291133
log(f'ROW {i+3} : Wrong value at column "Availability Domain" - {columnvalue}.')
11301134
fss_invalid_check = True
11311135

1132-
if columnname == 'MountTarget SubnetName':
1136+
if columnname == 'Network Details':
11331137
# Cross check the VCN names in Instances and VCNs sheet
11341138
if(columnvalue!='nan'):
1135-
vcn_subnet_check = compare_values(vcn_subnet_list.tolist(), columnvalue,[i, 'Display Name <vcn-name_subnet-name>', 'SubnetsVLANs'])
1136-
1137-
if vcn_subnet_check==False and columnname == "NSGs":
1138-
subnet_name = str(df_fss.loc[i, "MountTarget SubnetName"]).strip()
1139-
if (columnvalue != 'nan'):
1140-
vcn_nsg_check = validate_nsgs_column(i,region,columnvalue,subnet_name,subnetobj,vcn_nsg_list)
1139+
# vcn_subnet_check = compare_values(vcn_subnet_list.tolist(), columnvalue,[i, 'Display Name <vcn-name_subnet-name>', 'SubnetsVLANs'])
1140+
if ("::" not in columnvalue):
1141+
vcn_subnet_check = True
1142+
1143+
#if vcn_subnet_check==False and columnname == "NSGs":
1144+
# subnet_name = str(df_fss.loc[i, "MountTarget SubnetName"]).strip()
1145+
# if (columnvalue != 'nan'):
1146+
# vcn_nsg_check = validate_nsgs_column(i,region,columnvalue,subnet_name,subnetobj,vcn_nsg_list)
11411147

11421148
if any([fss_empty_check, fss_comp_check, fss_invalid_check, vcn_subnet_check,vcn_nsg_check]):
11431149
print("Null or Wrong value Check failed!!")

othertools/oci-fsdr/export_drplan.py

Lines changed: 63 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -149,62 +149,8 @@ def normalize_other_data(df):
149149
sheet = sheet[1:-1]
150150

151151
# Check if the file exists and the sheet exists
152-
if os.path.isfile(excel_file):
152+
if os.path.exists(excel_file):
153153
wb = load_workbook(excel_file)
154-
if "Readme" not in wb.sheetnames:
155-
# Create a new Readme sheet with instructions
156-
readme_sheet = wb.create_sheet(title="Readme")
157-
readme_content = """
158-
Instructions to update columns in Excel sheet
159-
160-
For New Plan step update the row values as below:
161-
- id, steps.id - leave these row values empty column empty
162-
- Display_name : Display name for Plan Group name (mandatory)
163-
steps.display_name : Display name for the step (mandatory)
164-
steps.error_mode : STOP_ON_ERROR/CONTINUE_ON_ERROR (mandatory)
165-
steps.is_enabled : TRUE/FALSE (mandatory)
166-
steps.timeout : timeout value in seconds (mandatory)
167-
type: USER_DEFINED (mandatory)
168-
steps.user_defined_step.step_type : RUN_LOCAL_SCRIPT/RUN_OBJECTSTORE_SCRIPT/INVOKE_FUNCTION
169-
170-
Based on the step type from above fill in the row values as mentioned :
171-
RUN_LOCAL_SCRIPT:
172-
- steps.user_defined_step.run_as_user, (description: user as which the script needs to run)
173-
- steps.user_defined_step.run_on_instance_id, (description: Instance OCID where the script is located)
174-
- steps.user_defined_step.script_command (description: script command which needs to run)
175-
RUN_OBJECTSTORE_SCRIPT:
176-
- steps.user_defined_step.run_on_instance_id, (description: Instance OCID where the script is located)
177-
- steps.user_defined_step.object_storage_script_location.bucket, (description: OCI Bucket name)
178-
- steps.user_defined_step.object_storage_script_location.namespace, (description: OCI Bucket namespace)
179-
- steps.user_defined_step.object_storage_script_location.object (description: object/scriptname name inside the bucket that needs to run)
180-
INVOKE_FUNCTION :
181-
- steps.user_defined_step.function_id, (description: OCI Functions OCID)
182-
- steps.user_defined_step.request_body (description: request which needs to be invoked)
183-
184-
Updating existing plan :
185-
186-
- Change the required row values(except group id and step id - these should remain the same).
187-
"""
188-
189-
# Insert the content into a single cell (A1)
190-
readme_sheet["A1"] = readme_content.strip()
191-
192-
# Expand the row height to accommodate the text
193-
readme_sheet.row_dimensions[1].height = 750 # You can adjust this value
194-
195-
# Auto-adjust column width to fit the content
196-
readme_sheet.column_dimensions['A'].width = 150 # You can adjust this value
197-
198-
# Set text wrapping for the cell
199-
readme_sheet["A1"].alignment = Alignment(wrap_text=True, vertical='top')
200-
readme_sheet["A1"].font = Font(size=14, color="FFFFFF", bold=True) # Set font size to 14 and color to white
201-
readme_sheet["A1"].fill = PatternFill(start_color="346EC9", end_color="346EC9", fill_type="solid") # Set background to blue
202-
readme_index = wb.sheetnames.index("Readme")
203-
wb._sheets.insert(0, wb._sheets.pop(readme_index))
204-
205-
# Save the workbook with the new Readme sheet
206-
wb.save(excel_file)
207-
208154
if sheet in wb.sheetnames:
209155
with pd.ExcelWriter(excel_file, engine='openpyxl', mode='a', if_sheet_exists='replace') as writer:
210156
print(f"Writing to sheet: {sheet}")
@@ -221,8 +167,7 @@ def normalize_other_data(df):
221167
combined_data.to_excel(writer, sheet_name=sheet, index=False)
222168
worksheet = writer.sheets[sheet]
223169

224-
225-
wb = load_workbook(excel_file)
170+
wb = load_workbook(excel_file)
226171
ws = wb[sheet]
227172

228173

@@ -239,6 +184,7 @@ def merge_and_center(ws, col):
239184
merged_cell = ws.cell(row=start_row, column=col)
240185
merged_cell.alignment = Alignment(horizontal='center', vertical='center')
241186

187+
242188
columns_to_merge = ['A', 'B']
243189

244190
for col in columns_to_merge:
@@ -275,6 +221,64 @@ def merge_and_center(ws, col):
275221
# Save the modified workbook
276222
wb.save(excel_file)
277223
print("Excel file updated successfully.")
224+
225+
if "Readme" not in wb.sheetnames:
226+
readme_sheet = wb.create_sheet(title="Readme")
227+
readme_content = """
228+
Instructions to update columns in Excel sheet
229+
230+
For New Plan step update the row values as below:
231+
- id, steps.id - leave these row values empty column empty
232+
- Display_name : Display name for Plan Group name (mandatory)
233+
steps.display_name : Display name for the step (mandatory)
234+
steps.error_mode : STOP_ON_ERROR/CONTINUE_ON_ERROR (mandatory)
235+
steps.is_enabled : TRUE/FALSE (mandatory)
236+
steps.timeout : timeout value in seconds (mandatory)
237+
type: USER_DEFINED (mandatory)
238+
steps.user_defined_step.step_type : RUN_LOCAL_SCRIPT/RUN_OBJECTSTORE_SCRIPT/INVOKE_FUNCTION
239+
240+
Based on the step type from above fill in the row values as mentioned :
241+
RUN_LOCAL_SCRIPT:
242+
- steps.user_defined_step.run_as_user, (description: user as which the script needs to run)
243+
- steps.user_defined_step.run_on_instance_id, (description: Instance OCID where the script is located)
244+
- steps.user_defined_step.script_command (description: script command which needs to run)
245+
RUN_OBJECTSTORE_SCRIPT:
246+
- steps.user_defined_step.run_on_instance_id, (description: Instance OCID where the script is located)
247+
- steps.user_defined_step.object_storage_script_location.bucket, (description: OCI bucket name)
248+
- steps.user_defined_step.object_storage_script_location.namespace, (description: OCI bucket namespace name)
249+
- steps.user_defined_step.object_storage_script_location.object, (description: script name)
250+
- steps.user_defined_step.run_on_instance_region, (description: Instance region name)
251+
- steps.user_defined_step.script_command (description: script command which needs to run)
252+
INVOKE_FUNCTION:
253+
- steps.user_defined_step.function_id (description: OCI Function OCID which needs to be invoked)
254+
- steps.user_defined_step.function_region (description: OCI Function region)
255+
- steps.user_defined_step.request_body (description: OCI Function request body)
256+
"""
257+
258+
# Insert the content into a single cell (A1)
259+
readme_sheet["A1"] = readme_content.strip()
260+
261+
# Expand the row height to accommodate the text
262+
readme_sheet.row_dimensions[1].height = 750 # You can adjust this value
263+
264+
# Auto-adjust column width to fit the content
265+
readme_sheet.column_dimensions['A'].width = 150 # You can adjust this value
266+
267+
# Set text wrapping for the cell
268+
readme_sheet["A1"].alignment = Alignment(wrap_text=True, vertical='top')
269+
readme_sheet["A1"].font = Font(size=14, color="FFFFFF", bold=True) # Set font size to 14 and color to white
270+
readme_sheet["A1"].fill = PatternFill(start_color="346EC9", end_color="346EC9",
271+
fill_type="solid") # Set background to blue
272+
readme_index = wb.sheetnames.index("Readme")
273+
wb._sheets.insert(0, wb._sheets.pop(readme_index))
274+
275+
# Save the workbook with the new Readme sheet
276+
wb.save(excel_file)
277+
278+
279+
280+
wb.save(excel_file)
281+
wb.close()
282+
278283
except Exception as e:
279-
print(f"An error occurred: {str(e)}")
280-
exit(1)
284+
print(f"Error: {str(e)}")

0 commit comments

Comments
 (0)