Skip to content

Commit

Permalink
Merge "Add a new fab task to switch computes to new collector during …
Browse files Browse the repository at this point in the history
…ISSU" into R3.1
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Mar 24, 2017
2 parents 629cf06 + f6c0f1f commit a3602fe
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions fabfile/tasks/issu_process.py
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 a3602fe

Please sign in to comment.