Untitled

Anonymous
plain_text
07/12/2023 10:11 AM
1.4 KB
17
Indexable
def restart_services(i, vm_details):
    vm_id = i
    vm_details = get_vm_details()
    vm_ip = vm_details[i][i]['vm_ip'][0]
    username = vm_details[i][i]['vm_username'][0]
    Services = ['CP-AGENT-SAP-COLLECTOR-MS.service','CP-AGENT-SAP-PERFORMER-MS.service','CP-AGENT-VM-COLLECTOR-MS.service']
    os.chdir('/etc/systemd/system/')
    print(os.getcwd())
    logging.info("OS CWD %s", os.getcwd)
    for i in Services:
        service_name = i
        subprocess.run(["sudo", "systemctl", "stop", service_name])
        subprocess.run(["sudo", "systemctl", "start", service_name])
        subprocess.run(["sudo", "systemctl", "status", service_name])
    print("Services have been restarted...")
    logging.info("Services have been restarted...")
    print("Notifying the support team on password reset, update in agent.properties, and restart of services...")
    logging.info("Notifying the support team on password reset, update in agent.properties, and restart of services...")
    notify_support_team(vm_id,vm_ip,username)
    return None
Editor is loading...