blob: 7163c7c41ee85370c5e9eec7addd660f1dd0cb80 [file] [log] [blame]
Scott Baker32624952013-09-07 17:38:22 -07001#! /usr/bin/python
2import os
3import sys
4import subprocess
5import time
6
7def get_systemd_status(service):
8 p=subprocess.Popen(["/bin/systemctl", "is-active", service], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
9 (out, err) = p.communicate()
10 out = out.strip()
11 return out
12
13libvirt_enabled = os.system("systemctl -q is-enabled libvirtd.service")==0
14nova_compute_enabled = os.system("systemctl -q is-enabled openstack-nova-compute.service")==0
15openvswitch_agent_enabled = os.system("systemctl -q is-enabled quantum-openvswitch-agent.service")==0
16
17print "enabled:"
18print " libvirtd=", libvirt_enabled
19print " openstack-nova-compute=", nova_compute_enabled
20print " quantum-openvswitch-agent=", openvswitch_agent_enabled
21
22if (not libvirt_enabled) or (not nova_compute_enabled) or (not openvswitch_agent_enabled):
23 print "services are not enabled. exiting"
24 sys.exit(0)
25
26libvirt_status = get_systemd_status("libvirtd.service")
27nova_compute_status = get_systemd_status("openstack-nova-compute.service")
28openvswitch_agent_status = get_systemd_status("quantum-openvswitch-agent.service")
29
30print "status:"
31print " libvirtd=", libvirt_status
32print " openstack-nova-compute=", nova_compute_status
33print " quantum-openvswitch-agent=", openvswitch_agent_status
34
35if (libvirt_status=="failed") or (nova_compute_status=="failed") or (openvswitch_agent_status=="failed"):
36 print "services have failed. doing the big restart"
37 os.system("systemctl stop openstack-nova-compute.service")
38 os.system("systemctl stop quantum-openvswitch-agent.service")
39 os.system("systemctl stop libvirtd.service")
40 time.sleep(5)
41 os.system("systemctl start libvirtd.service")
42 time.sleep(5)
43 os.system("systemctl start quantum-openvswitch-agent.service")
44 time.sleep(5)
45 os.system("systemctl start openstack-nova-compute.service")
46 print "done"
47
48
49
50