I am trying to do the following:
I have a list of users I want to remove from the database in the variable "users_to_rm". and I have setup a function that iterates though the users usernames field[0] on the list "users_to_rm" and deletes all users beside the user in "excluded_user"
def remove_users(users_to_rm):
""" Remove users and associated extensions that are no longer in the database """
excluded_user = "supervisor"
for users in users_to_rm:
if users[0] == excluded_user:
pass
else:
payloads_user_rm = '{"jsonrpc": "2.0", "method": "deleteUser", "id": "05", "params": {"username":' + '"' + str(users[0]) + '"' +'}}'
result = requests.request("GET", ucware_cfg.url_admin_user, data=payloads_user_rm, headers=ucware_cfg.headers)
Reports.log(Reports.LogLevel.INFO, "#########\nUser " + str(extensions[0]) + " removed", send_mail=False)
log_http_result(result)
Now, I would like that the excluded_user variable to be a list of users like this:
excluded_user=["supervisor","testuser","testuser2"]
I would like my fucntion to do the same as it is doing now, but check the list of users in excluded_user and pass all those in the list.
Hope I made any sense and thank you for your help.
Aucun commentaire:
Enregistrer un commentaire