Untitled
unknown
plain_text
2 years ago
2.5 kB
11
Indexable
# Check if password is Expiring in coming two days
def check_vm_user_pwd_expiry_date(i,All_VM_Details):
vm_details = get_vm_details()
#print(vm_details)
vm_username = vm_details[i][i]['vm_username'][0]
vm_id = i
vm_user_password_expiry_date = vm_details[i][i]['vm_user_password_expiry_date']
#print(vm_user_password_expiry_date,type(vm_user_password_expiry_date))
expiry_date = list(datefinder.find_dates(vm_user_password_expiry_date[0]))
expiry_date = expiry_date[0].date()
date_approachingin2days = datetime.datetime.today() + datetime.timedelta(days=2)
date_approachingin2days = date_approachingin2days.date()
print("Expiry date for the VM user - {} with VM ID - {} is {}".format(vm_username,vm_id,expiry_date))
#print(date_approachingin2days)
if expiry_date==date_approachingin2days:
print("Password Reset is Required for this VM User - {} with VM ID - {}.".format(vm_username,vm_id))
logging.info("Password Reset is Required for this VM User - with VM ID - %s ", vm_username,vm_id)
reset_vm_user_password(i,vm_details)
elif expiry_date!=date_approachingin2days:
print("Expiry date is not approaching in coming two days. Hence, No Action is needed.")
logging.info("Expiry date is not approaching in coming two days. Hence, No Action is needed.")
return None
# Check Password Expiry Parameter/Policy for VM Users for all VMs in VM List through Iteration
def check_vm_user_password_expiry_parameter():
for i in VMList:
if All_VM_Details[i][i]['vm_user_password_expiry_date']==['Never Expires']:
print("Password Expiry Parameter was set to Never Expires for the VM User - {} with vm id - {}. Hence, No action is needed!".format(All_VM_Details[i][i]['vm_username'],i))
logging.info("Password Expiry Parameter was set to Never Expires for the VM User - {} with vm id - {}. Hence, No action is needed %s ")
elif All_VM_Details[i][i]['vm_user_password_expiry_date']!=['Never Expires']:
print("Password Expiry date was set for the VM User - {} with vm id - {}, Please check the Expiry date for password!".format(All_VM_Details[i][i]['vm_username'],i))
logging.info("Password Expiry date was set for the VM User - {} with vm id - {}, Please check the Expiry date for password! %s ")
check_vm_user_pwd_expiry_date(i,All_VM_Details[i])
return None
check_vm_user_password_expiry_parameter()
Editor is loading...