Skip to content

Commit

Permalink
Add a new fab task to switch computes to new collector during ISSU
Browse files Browse the repository at this point in the history
This commit is to add new fab task to change the config files of all processes
on the compute node to point to new collector during ISSU process. This switch
should be done once the controllers are upgraded to v2, but before the computes
are upgraded to v2.

Change-Id: I89a6931d7078d50cec245b1dde7d96d81f33611f
Closes-Bug: #1675122
  • Loading branch information
Raj Reddy committed Mar 23, 2017
1 parent cb2497c commit f6c0f1f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions fabfile/tasks/issu_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,34 @@
issu_process_bash_file="issu_process.sh"
issu_process_bash_path="/opt/contrail/utils/issu_process.sh"

@task
@roles('compute')
def issu_contrail_switch_collector_in_compute():
"""Migrate the contrail compute nodes to new collector."""
execute("issu_contrail_switch_collector_in_compute_node", env.host_string)

@task
def issu_contrail_switch_collector_in_compute_node(*args):
num_collectors = len(env.roledefs['collector'])
if num_collectors >= 2:
max_collectors = 2
else:
max_collectors = 1
import random
host_num = random.randint(0,num_collectors-1)
for host in args:
collector_list = ''
with settings(host_string=host):
for i in range(0, max_collectors):
collector_list += "%s:8086 " %(hstr_to_ip(get_control_host_string(env.roledefs['collector'][host_num])))
host_num = (host_num + 1) % num_collectors
import glob
file_list = glob.glob('/etc/contrail/contrail-tor-agent*.conf')
file_list.append('/etc/contrail/contrail-vrouter-agent.conf')
for cfile in file_list:
run('openstack-config --set %s DEFAULT collectors %s' % (cfile, collector_list))
run('openstack-config --set /etc/contrail/contrail-vrouter-nodemgr.conf COLLECTOR server_list %s' % (collector_list))

@task
@roles('compute')
def issu_contrail_switch_compute(discovery_ip):
Expand Down

0 comments on commit f6c0f1f

Please sign in to comment.