7 def get_systemd_status(service):
8 p=subprocess.Popen(["/bin/systemctl", "is-active", service], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
9 (out, err) = p.communicate()
13 libvirt_enabled = os.system("systemctl -q is-enabled libvirtd.service")==0
14 nova_compute_enabled = os.system("systemctl -q is-enabled openstack-nova-compute.service")==0
15 openvswitch_agent_enabled = os.system("systemctl -q is-enabled quantum-openvswitch-agent.service")==0
18 print " libvirtd=", libvirt_enabled
19 print " openstack-nova-compute=", nova_compute_enabled
20 print " quantum-openvswitch-agent=", openvswitch_agent_enabled
22 if (not libvirt_enabled) or (not nova_compute_enabled) or (not openvswitch_agent_enabled):
23 print "services are not enabled. exiting"
26 libvirt_status = get_systemd_status("libvirtd.service")
27 nova_compute_status = get_systemd_status("openstack-nova-compute.service")
28 openvswitch_agent_status = get_systemd_status("quantum-openvswitch-agent.service")
31 print " libvirtd=", libvirt_status
32 print " openstack-nova-compute=", nova_compute_status
33 print " quantum-openvswitch-agent=", openvswitch_agent_status
35 if (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")
41 os.system("systemctl start libvirtd.service")
43 os.system("systemctl start quantum-openvswitch-agent.service")
45 os.system("systemctl start openstack-nova-compute.service")