Untitled
unknown
plain_text
2 years ago
3.1 kB
4
Indexable
Error -
Traceback (most recent call last):
File "private_vm_password_expiry_automation_script.py", line 311, in <module>
check_vm_user_password_expiry_parameter()
File "private_vm_password_expiry_automation_script.py", line 308, in check_vm_user_password_expiry_parameter
check_vm_user_pwd_expiry_date(i,All_VM_Details[i])
File "private_vm_password_expiry_automation_script.py", line 290, in check_vm_user_pwd_expiry_date
reset_vm_user_password(i, vm_details)
File "private_vm_password_expiry_automation_script.py", line 268, in reset_vm_user_password
update_agent_properties(i,new_password,new_expiry_date,vm_details=get_vm_details())
File "private_vm_password_expiry_automation_script.py", line 207, in update_agent_properties
restart_services(i,vm_details)
File "private_vm_password_expiry_automation_script.py", line 169, in restart_services
subprocess.run(["sudo", "systemctl", "status", service_name])
File "/usr/lib64/python3.6/subprocess.py", line 425, in run
stdout, stderr = process.communicate(input, timeout=timeout)
File "/usr/lib64/python3.6/subprocess.py", line 855, in communicate
self.wait()
File "/usr/lib64/python3.6/subprocess.py", line 1477, in wait
(pid, sts) = self._try_wait(0)
File "/usr/lib64/python3.6/subprocess.py", line 1424, in _try_wait
(pid, sts) = os.waitpid(self.pid, wait_flags)
Code-
def update_agent_properties(i,new_password,new_expiry_date,vm_details):
old_password = vm_details[i][i]['vm_user_password'][0]
new_password = new_password
old_expiry_date = vm_details[i][i]['vm_user_password_expiry_date'][0]
new_expiry_date = new_expiry_date
print("Old password is {}".format(old_password))
logging.info("Old password is %s", old_password)
print("New password is {}".format(new_password))
logging.info("New password is %s", new_password)
print("Old Expiry Date is {}".format(old_expiry_date))
logging.info("Old Expiry Date is %s", old_expiry_date)
print("New Expiry Date is {}".format(new_expiry_date))
logging.info("New Expiry Date is %s", new_expiry_date)
old_password_line = str(i)+".ssh.host_password="+old_password
new_password_line = str(i)+'.ssh.host_password='+new_password
old_expiry_date_line = str(i)+".ssh.pwd_expiry_date="+old_expiry_date
new_expiry_date_line = str(i)+'.ssh.pwd_expiry_date='+new_expiry_date
with open(agent_file, 'r') as file:
content = file.read()
content = content.replace(old_password_line, new_password_line)
content = content.replace(old_expiry_date_line, new_expiry_date_line)
# Write new content in write mode 'w'
with open(agent_file, 'w') as file:
file.write(content)
file.close()
print("New Password and New expiry date has been updated in agent.properties file...")
logging.info("New Password and New expiry date has been updated in agent.properties file...")
print("Restarting the Agent Services...")
logging.info("Restarting the Agent Services...")
restart_services(i,vm_details)
return None
Editor is loading...