Skip to content

Instantly share code, notes, and snippets.

@dims
Last active August 29, 2015 14:25
Show Gist options
  • Select an option

  • Save dims/3a0425d9371380f2e45f to your computer and use it in GitHub Desktop.

Select an option

Save dims/3a0425d9371380f2e45f to your computer and use it in GitHub Desktop.
Dmitry Mescheryakov's script
import subprocess
CONTROLLER_PROCS = [
'nova-api',
'nova-cert',
'nova-conductor',
'nova-consoleauth',
'nova-novncproxy',
'nova-objectstore',
'nova-scheduler',
# 'neutron-dhcp-agent',
# 'neutron-l3-agent',
# 'neutron-metadata-agent',
# 'neutron-ns-metadata-proxy',
# 'neutron-openvswitch-agent',
'neutron-server',
'cinder-api',
'cinder-backup',
'cinder-scheduler',
'cinder-volume',
'keystone',
'glance-api',
'glance-registry',
'heat-api',
'heat-api-cfn',
'heat-api-cloudwatch',
# 'heat-engine',
]
COMPUTE_PROCS = [
'nova-compute',
'neutron-plugin-openvswitch-agent'
]
PCS_RESOURCES = [
'p_neutron-plugin-openvswitch-agent',
'p_neutron-dhcp-agent',
'p_neutron-metadata-agent',
'p_neutron-l3-agent',
'p_heat-engine'
]
def get_command_output(cmd):
#print 'Executing cmd: %s' % cmd
pp = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
outp, err = pp.communicate()
if pp.returncode != 0:
raise RuntimeError('Process returned non-zero code %i' % pp.returncode)
return outp.strip()
def restart_processes_on_nodes(nodes, processes):
for node in sorted(nodes):
if not node:
continue
print '\nRestarting services on node %s' % node
for proc in processes:
print get_command_output("ssh %s 'service %s restart'" % (node, proc))
def restart_resources(node, resources):
print '\nRestarting resources on controller %s' % node
for res in resources:
print 'Restarting resource %s' % res
print get_command_output("ssh %s 'crm resource restart %s'" % (node, res))
controllers = get_command_output("fuel nodes 2>&1 | grep controller | awk '{ print $9 }'").split('\n')
computes = get_command_output("fuel nodes 2>&1 | grep compute | awk '{ print $9 }'").split('\n')
restart_resources(controllers[0], PCS_RESOURCES)
restart_processes_on_nodes(controllers, CONTROLLER_PROCS)
restart_processes_on_nodes(computes, COMPUTE_PROCS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment