Skip to content

Commit e856ac4

Browse files
committed
Automation Toolkit Release v2024.2.2
1 parent dc44091 commit e856ac4

File tree

2 files changed

+87
-6
lines changed

2 files changed

+87
-6
lines changed

cd3_automation_toolkit/cd3Validator.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,14 +1386,17 @@ def validate_buckets(filename, comp_ids):
13861386
if columnvalue.lower() not in ['standard','archive']:
13871387
log(f'ROW {i + 3} : Value of "Storage Tier" can be only either "Standard" or "Archive".')
13881388
buckets_invalid_check = True
1389-
1389+
elif columnvalue.lower() == 'archive':
1390+
auto_tiering_index = dfcolumns.index('Auto Tiering')
1391+
if auto_tiering_index != -1 and str(dfbuckets.loc[i, 'Auto Tiering']).strip().lower() == 'enabled':
1392+
log(f'ROW {i + 3} : Auto Tiering cannot be "Enabled" when Storage Tier is "Archive".')
1393+
buckets_invalid_check = True
13901394

13911395
if columnname == 'Auto Tiering':
13921396
if columnvalue.lower() not in ['enabled','disabled']:
13931397
log(f'ROW {i + 3} : Value of "Auto Tiering" can be only either "Enabled" or "Disabled".')
13941398
buckets_invalid_check = True
13951399

1396-
13971400
if columnname == 'Object Versioning':
13981401
if columnvalue.lower() not in ['enabled','disabled']:
13991402
log(f'ROW {i + 3} : Value of "Object Versioning" can be only either "Enabled" or "Disabled".')
@@ -1410,7 +1413,7 @@ def validate_buckets(filename, comp_ids):
14101413
log(f'ROW {i + 3} : Value of "Visibility" can be only either "Private" or "Public".')
14111414
buckets_invalid_check = True
14121415

1413-
#Check for valid destination region for enabling the replication policy
1416+
# Check for valid destination region for enabling the replication policy
14141417
if columnname == 'Replication Policy' and columnvalue != "nan":
14151418
columnvalue = columnvalue.split("::")
14161419
if len(columnvalue) == 3:
@@ -1430,6 +1433,8 @@ def validate_buckets(filename, comp_ids):
14301433
log(f'ROW {i + 3} : The replication policy format is incorrect.')
14311434
buckets_invalid_check = True
14321435

1436+
# Get the current time
1437+
current_time = datetime.datetime.utcnow()
14331438
#Check for the retention policy details
14341439
if columnname == 'Retention Rules':
14351440
rule_values = columnvalue.split("\n")
@@ -1481,6 +1486,21 @@ def validate_buckets(filename, comp_ids):
14811486
log(f'ROW {i + 3} : "time_rule_locked" of retention rule is not in valid format. It should be in the format "dd-mm-yyyy".')
14821487
buckets_invalid_check = True
14831488
continue
1489+
# Parse the time_rule_locked into a datetime object
1490+
try:
1491+
time_rule_locked_datetime = datetime.datetime.strptime(time_rule_locked, "%Y-%m-%dT%H:%M:%SZ")
1492+
except ValueError:
1493+
log(f'ROW {i + 3} : "time_rule_locked" of retention rule is not in valid format. It should be in the format "YYYY-MM-DDThh:mm:ssZ".')
1494+
buckets_invalid_check = True
1495+
continue
1496+
1497+
# Calculate the difference between current time and time_rule_locked
1498+
time_difference = time_rule_locked_datetime - current_time
1499+
1500+
# Check if the difference is less than 14 days
1501+
if time_difference.days < 14:
1502+
log(f'ROW {i + 3} : "time_rule_locked" of retention rule must be more than 14 days from the current time.')
1503+
buckets_invalid_check = True
14841504

14851505
# Check for the Lifecycle Policy Details
14861506
if lifecycle_input == True:
@@ -1494,7 +1514,6 @@ def validate_buckets(filename, comp_ids):
14941514
'multipart-uploads::Abort'
14951515
]
14961516

1497-
14981517
# Check if "Lifecycle Target and Action" is empty
14991518
if columnname == 'Lifecycle Target and Action':
15001519
if columnvalue != 'nan' and columnvalue not in valid_options:

jenkins_install/tf-apply.groovy

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ pipeline {
151151
steps {
152152
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
153153
script {
154+
if (env.out_str == 'Multiple_Outdir') {
154155
try {
155156
sh '''
156157
set +x
@@ -160,7 +161,9 @@ pipeline {
160161
repo_name=${GIT_URL##*/}
161162
cd ${WORKSPACE}/../${BUILD_NUMBER}/${repo_name}
162163
git checkout main
163-
copy_path=${env.Region}/${env.Service}
164+
reg=`echo ${JOB_NAME}| cut -d "/" -f2`
165+
service=`echo ${JOB_NAME}| cut -d "/" -f3`
166+
copy_path=${reg}/${service}
164167
cp -r ${WORKSPACE}/${copy_path}/* ${copy_path}/
165168
git add ${copy_path}*
166169
'''
@@ -175,14 +178,73 @@ pipeline {
175178
sh '''
176179
set +x
177180
repo_name=${GIT_URL##*/}
181+
reg=`echo ${JOB_NAME}| cut -d "/" -f2`
182+
service=`echo ${JOB_NAME}| cut -d "/" -f3`
178183
cd ${WORKSPACE}/../${BUILD_NUMBER}/${repo_name}
179184
git_status=`git status --porcelain`
180185
if [[ $git_status ]]; then
181-
git commit -m "commit for terraform-apply build - ${BUILD_NUMBER} for "${env.Region}"/"${env.Service}
186+
git commit -m "commit for terraform-apply build - ${BUILD_NUMBER} for "${reg}"/"${service}
182187
else
183188
echo "Nothing to commit"
184189
fi
185190
'''
191+
status = sh(script: '''
192+
set +x
193+
repo_name=${GIT_URL##*/}
194+
cd ${WORKSPACE}/../${BUILD_NUMBER}/${repo_name}
195+
git pull --no-edit origin main
196+
git push --porcelain origin main
197+
''', returnStatus: true)
198+
199+
while (status != 0){
200+
println("Trying again ...")
201+
status = sh(script: '''
202+
set +x
203+
repo_name=${GIT_URL##*/}
204+
cd ${WORKSPACE}/../${BUILD_NUMBER}/${repo_name}
205+
git pull --no-edit origin main
206+
set -x
207+
git push --porcelain origin main
208+
''', returnStatus: true)
209+
}
210+
sh '''
211+
set +x
212+
rm -rf ${WORKSPACE}/../${BUILD_NUMBER}
213+
'''
214+
215+
} else {
216+
try {
217+
sh '''
218+
mkdir -p ${WORKSPACE}/../${BUILD_NUMBER}
219+
cd ${WORKSPACE}/../${BUILD_NUMBER}
220+
git clone ${GIT_URL}
221+
repo_name=${GIT_URL##*/}
222+
cd ${WORKSPACE}/../${BUILD_NUMBER}/${repo_name}
223+
git checkout main
224+
reg=`echo ${JOB_NAME}| cut -d "/" -f2`
225+
copy_path=${reg}
226+
cp -r ${WORKSPACE}/${copy_path}/* ${copy_path}/
227+
git add ${copy_path}*
228+
git_status=`git status --porcelain`
229+
if [[ $git_status ]]; then
230+
git commit -m "commit for terraform-apply build - ${BUILD_NUMBER} for "${reg}"/"${service}
231+
git push origin main
232+
else
233+
echo "Nothing to commit"
234+
fi
235+
cd ${WORKSPACE}/..
236+
rm -rf ${WORKSPACE}/../${BUILD_NUMBER}
237+
'''
238+
} catch(Exception e1) {
239+
println(e1)
240+
sh '''
241+
cd ${WORKSPACE}/..
242+
rm -rf ${WORKSPACE}/../${BUILD_NUMBER}
243+
exit 1
244+
'''
245+
}
246+
247+
}
186248
}
187249
}
188250
}

0 commit comments

Comments
 (0)