Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 973277fa authored by Ricardo SILVA's avatar Ricardo SILVA
Browse files

Bug fix in sid users, groups and leankit scripts refs #31854

parent d1d8c3e7
No related branches found
No related tags found
No related merge requests found
...@@ -374,8 +374,11 @@ def main(): ...@@ -374,8 +374,11 @@ def main():
'username': 'Mesut.YILDIRIM@ext.ec.europa.eu' 'username': 'Mesut.YILDIRIM@ext.ec.europa.eu'
} }
''' '''
try:
leankit_inv_results = leankit.get_invitations() leankit_inv_results = leankit.get_invitations()
except Exception as e:
leankit_inv_results = None
logger.error(e)
# print(pformat(leankit_inv_results)) # print(pformat(leankit_inv_results))
''' '''
{ {
...@@ -412,17 +415,18 @@ def main(): ...@@ -412,17 +415,18 @@ def main():
continue continue
leankit_account.append(duser['emailAddress']) leankit_account.append(duser['emailAddress'])
for duser in leankit_inv_results['invitations']: if leankit_inv_results is not None:
# print(duser) for duser in leankit_inv_results['invitations']:
if 'isExpired' in duser and duser['isExpired'] is True: # print(duser)
continue if 'isExpired' in duser and duser['isExpired'] is True:
if 'isRevoked' in duser and duser['isRevoked'] is True: continue
continue if 'isRevoked' in duser and duser['isRevoked'] is True:
continue
if duser['emailAddress'] not in snet_mail_index and duser['emailAddress'].lower() not in snet_mail_index_lc and duser['emailAddress'] not in donotdelete and duser['emailAddress'].lower() not in donotdelete and duser['emailAddress'].lower() not in extra_leankit_results_idx: if duser['emailAddress'] not in snet_mail_index and duser['emailAddress'].lower() not in snet_mail_index_lc and duser['emailAddress'] not in donotdelete and duser['emailAddress'].lower() not in donotdelete and duser['emailAddress'].lower() not in extra_leankit_results_idx:
print('Leankit user ' + duser['emailAddress'] + ' should be deleted.') print('Leankit user ' + duser['emailAddress'] + ' should be deleted.')
continue continue
leankit_account.append(duser['emailAddress']) leankit_account.append(duser['emailAddress'])
for usermail in snet_mail_index: for usermail in snet_mail_index:
usermail_lc = usermail.lower() usermail_lc = usermail.lower()
......
...@@ -209,7 +209,7 @@ def main(): ...@@ -209,7 +209,7 @@ def main():
to_print = pformat(block_to_update) to_print = pformat(block_to_update)
for i in list(range(0, int(round(len(to_print) / 250)) + 1)): for i in list(range(0, int(round(len(to_print) / 250)) + 1)):
logger.info('scrat %s cmd: %s' % (str(i), to_print[250 * i:250 * (i + 1)])) logger.info('scrat %s cmd: %s' % (str(i), to_print[250 * i:250 * (i + 1)]))
sys.exit(1) sys.exit(0)
if __name__ == '__main__': if __name__ == '__main__':
main() main()
...@@ -232,7 +232,11 @@ def ec_ldap_get(): ...@@ -232,7 +232,11 @@ def ec_ldap_get():
def sid_create_user(diego, dfqdn, res_rw_user, user, block_to_update, context_uid=666000002, verify=True, error_stop=False): def sid_create_user(diego, dfqdn, res_rw_user, user, block_to_update, context_uid=666000002, verify=True, error_stop=False):
scrat_inst = Scrat(res_rw_user, '', fqdn=dfqdn, version=2, verify=verify) scrat_inst = Scrat(res_rw_user, '', fqdn=dfqdn, version=2, verify=verify)
(scrat_json, scratres) = scrat_inst.scratQuery(block_to_update, Full=True) try:
(scrat_json, scratres) = scrat_inst.scratQuery(block_to_update, Full=True)
except Exception as e:
scratres = '409'
scrat_json = e
if str(scratres) != '200': if str(scratres) != '200':
'''Scrat just add the vlan to the trunked list''' '''Scrat just add the vlan to the trunked list'''
...@@ -261,7 +265,11 @@ def sid_update_user(diego, dfqdn, res_rw_user, user, block_to_update, context_ui ...@@ -261,7 +265,11 @@ def sid_update_user(diego, dfqdn, res_rw_user, user, block_to_update, context_ui
''' delete: need to check the line exist if not 409''' ''' delete: need to check the line exist if not 409'''
scrat_inst = Scrat(res_rw_user, '', fqdn=dfqdn, version=2, verify=verify) scrat_inst = Scrat(res_rw_user, '', fqdn=dfqdn, version=2, verify=verify)
(scrat_json, scratres) = scrat_inst.scratUpdate(block_to_update, overwrite_mode=True, Full=True) try:
(scrat_json, scratres) = scrat_inst.scratUpdate(block_to_update, overwrite_mode=True, Full=True)
except Exception as e:
scratres = '409'
scrat_json = e
if str(scratres) != '200': if str(scratres) != '200':
'''Scrat just add the vlan to the trunked list''' '''Scrat just add the vlan to the trunked list'''
...@@ -305,7 +313,11 @@ def sid_add_user_to_department(diego, dfqdn, res_rw_user, user, uid, department, ...@@ -305,7 +313,11 @@ def sid_add_user_to_department(diego, dfqdn, res_rw_user, user, uid, department,
''' delete: need to check the line exist if not 409''' ''' delete: need to check the line exist if not 409'''
scrat_inst = Scrat(res_rw_user, '', fqdn=dfqdn, version=2, verify=verify) scrat_inst = Scrat(res_rw_user, '', fqdn=dfqdn, version=2, verify=verify)
(scrat_json, scratres) = scrat_inst.scratUpdate(block_to_update, overwrite_mode=False, line_only=False, Full=True) try:
(scrat_json, scratres) = scrat_inst.scratUpdate(block_to_update, overwrite_mode=False, line_only=False, Full=True)
except Exception as e:
scrat_json = e
scratres = '409'
if str(scratres) != '200': if str(scratres) != '200':
to_print = pformat(block_to_update) to_print = pformat(block_to_update)
...@@ -344,7 +356,11 @@ def sid_update_user_to_resigned(diego, dfqdn, res_rw_user, user, uid, context_ui ...@@ -344,7 +356,11 @@ def sid_update_user_to_resigned(diego, dfqdn, res_rw_user, user, uid, context_ui
''' delete: need to check the line exist if not 409''' ''' delete: need to check the line exist if not 409'''
scrat_inst = Scrat(res_rw_user, '', fqdn=dfqdn, version=2, verify=verify) scrat_inst = Scrat(res_rw_user, '', fqdn=dfqdn, version=2, verify=verify)
(scrat_json, scratres) = scrat_inst.scratUpdate(block_to_update, overwrite_mode='exclusive', line_only=False, Full=True) try:
(scrat_json, scratres) = scrat_inst.scratUpdate(block_to_update, overwrite_mode='exclusive', line_only=False, Full=True)
except Exception as e:
scrat_json = e
scratres = '409'
if str(scratres) != '200': if str(scratres) != '200':
to_print = pformat(block_to_update) to_print = pformat(block_to_update)
...@@ -384,7 +400,10 @@ def sid_update_user_exlude_approver_scheduler_change_management(diego, dfqdn, re ...@@ -384,7 +400,10 @@ def sid_update_user_exlude_approver_scheduler_change_management(diego, dfqdn, re
''' delete: need to check the line exist if not 409''' ''' delete: need to check the line exist if not 409'''
scrat_inst = Scrat(res_rw_user, '', fqdn=dfqdn, version=2, verify=verify) scrat_inst = Scrat(res_rw_user, '', fqdn=dfqdn, version=2, verify=verify)
(scratres) = scrat_inst.deleteLine(block_to_update) try:
(scratres) = scrat_inst.deleteLine(block_to_update)
except Exception as e:
scratres = '409'
if str(scratres) != '200': if str(scratres) != '200':
print("not removed " + user + " from " + typeExclude) print("not removed " + user + " from " + typeExclude)
if error_stop is True: if error_stop is True:
...@@ -862,10 +881,10 @@ def main(): ...@@ -862,10 +881,10 @@ def main():
break break
if 'Security Policy' in block_to_update['properties']['has as role']: if 'Security Policy' in block_to_update['properties']['has as role']:
block_to_update['properties']['has as role'].remove('Security Policy') block_to_update['properties']['has as role'].remove('Security Policy')
if 'ISMS' not in block_to_update['properties']['has as role']: #if 'ISMS' not in block_to_update['properties']['has as role']:
block_to_update['properties']['has as role'].append('ISMS') # block_to_update['properties']['has as role'].append('ISMS')
if 'SMPM' not in block_to_update['properties']['has as role']: #if 'SMPM' not in block_to_update['properties']['has as role']:
block_to_update['properties']['has as role'].append('SMPM') # block_to_update['properties']['has as role'].append('SMPM')
elif mb == 'dev': elif mb == 'dev':
if need_to_update is False and need_to_create is True: if need_to_update is False and need_to_create is True:
if 'SNet SUP' not in block_to_update['properties']['belongs to']: if 'SNet SUP' not in block_to_update['properties']['belongs to']:
...@@ -1092,7 +1111,8 @@ def main(): ...@@ -1092,7 +1111,8 @@ def main():
for i in list(range(0, int(round(len(to_print) / 250)) + 1)): for i in list(range(0, int(round(len(to_print) / 250)) + 1)):
logger.info('scrat %s cmd: %s' % (str(i), to_print[250 * i:250 * (i + 1)])) logger.info('scrat %s cmd: %s' % (str(i), to_print[250 * i:250 * (i + 1)]))
sys.exit(1) logger.info('Finished Synchronization')
sys.exit(0)
params = {} params = {}
sid_s_results = diego.diego_run_dieget_by_name('sid_sheduler_check', params) sid_s_results = diego.diego_run_dieget_by_name('sid_sheduler_check', params)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment