def fixup_restart_haproxy_in_collector_node(*args): contrail_analytics_api_server_lines = '' space = ' ' * 3 for host_string in env.roledefs['collector']: server_index = env.roledefs['collector'].index(host_string) + 1 mgmt_host_ip = hstr_to_ip(host_string) host_ip = hstr_to_ip(get_control_host_string(host_string)) contrail_analytics_api_server_lines +=\ '%s server %s %s:9081 check inter 2000 rise 2 fall 3\n'\ % (space, host_ip, host_ip) for host_string in env.roledefs['collector']: haproxy_config = collector_haproxy.template.safe_substitute({ '__contrail_analytics_api_backend_servers__': contrail_analytics_api_server_lines, '__contrail_hap_user__': 'haproxy', '__contrail_hap_passwd__': 'contrail123', }) for host_string in args: with settings(host_string=host_string): # chop old settings including pesky default from pkg... tmp_fname = "/tmp/haproxy-%s-config" % (host_string) get_as_sudo("/etc/haproxy/haproxy.cfg", tmp_fname) with settings(warn_only=True): local( "sed -i -e '/^#contrail-collector-marker-start/,/^#contrail-collector-marker-end/d' %s" % (tmp_fname)) local( "sed -i -e 's/frontend\s*main\s*\*:5000/frontend main *:5001/' %s" % (tmp_fname)) local( "sed -i -e 's/ssl-relay 0.0.0.0:8443/ssl-relay 0.0.0.0:5002/' %s" % (tmp_fname)) local( "sed -i -e 's/option\shttplog/option tcplog/' %s" % (tmp_fname)) local("sed -i -e 's/maxconn 4096/maxconn 100000/' %s" % (tmp_fname)) # Remove default HA config local("sed -i '/listen\sappli1-rewrite/,/rspidel/d' %s" % tmp_fname) local("sed -i '/listen\sappli3-relais/,/rspidel/d' %s" % tmp_fname) # ...generate new ones cfg_file = open(tmp_fname, 'a') cfg_file.write(haproxy_config) cfg_file.close() put(tmp_fname, "/etc/haproxy/haproxy.cfg", use_sudo=True) local("rm %s" % (tmp_fname)) # haproxy enable with settings(host_string=host_string, warn_only=True): sudo("chkconfig haproxy on") enable_haproxy() sudo("service haproxy restart")
def setup_openstack_keepalived(): """Task to provision VIP for openstack nodes with keepalived""" enable_haproxy() # HAProxy is moved to upstart. Stop any haproxy process which # was started using init.d script (if any) with settings(warn_only=True): sudo("/etc/init.d/haproxy stop") sudo("service haproxy restart") setup_keepalived_node('openstack')
def fixup_restart_haproxy_in_collector_node(*args): contrail_analytics_api_server_lines = "" space = " " * 3 for host_string in env.roledefs["collector"]: server_index = env.roledefs["collector"].index(host_string) + 1 mgmt_host_ip = hstr_to_ip(host_string) host_ip = hstr_to_ip(get_control_host_string(host_string)) contrail_analytics_api_server_lines += "%s server %s %s:9081 check inter 2000 rise 2 fall 3\n" % ( space, host_ip, host_ip, ) for host_string in env.roledefs["collector"]: haproxy_config = collector_haproxy.template.safe_substitute( { "__contrail_analytics_api_backend_servers__": contrail_analytics_api_server_lines, "__contrail_hap_user__": "haproxy", "__contrail_hap_passwd__": "contrail123", } ) for host_string in args: with settings(host_string=host_string): # chop old settings including pesky default from pkg... tmp_fname = "/tmp/haproxy-%s-config" % (host_string) get_as_sudo("/etc/haproxy/haproxy.cfg", tmp_fname) with settings(warn_only=True): local( "sed -i -e '/^#contrail-collector-marker-start/,/^#contrail-collector-marker-end/d' %s" % (tmp_fname) ) local("sed -i -e 's/frontend\s*main\s*\*:5000/frontend main *:5001/' %s" % (tmp_fname)) local("sed -i -e 's/ssl-relay 0.0.0.0:8443/ssl-relay 0.0.0.0:5002/' %s" % (tmp_fname)) local("sed -i -e 's/option\shttplog/option tcplog/' %s" % (tmp_fname)) local("sed -i -e 's/maxconn 4096/maxconn 100000/' %s" % (tmp_fname)) # Remove default HA config local("sed -i '/listen\sappli1-rewrite/,/rspidel/d' %s" % tmp_fname) local("sed -i '/listen\sappli3-relais/,/rspidel/d' %s" % tmp_fname) # ...generate new ones cfg_file = open(tmp_fname, "a") cfg_file.write(haproxy_config) cfg_file.close() put(tmp_fname, "/etc/haproxy/haproxy.cfg", use_sudo=True) local("rm %s" % (tmp_fname)) # haproxy enable with settings(host_string=host_string, warn_only=True): sudo("chkconfig haproxy on") enable_haproxy() sudo("service haproxy restart")
def fixup_restart_haproxy_in_collector_node(*args): contrail_analytics_api_server_lines = '' space = ' ' * 3 for host_string in env.roledefs['collector']: server_index = env.roledefs['collector'].index(host_string) + 1 mgmt_host_ip = hstr_to_ip(host_string) host_ip = hstr_to_ip(get_control_host_string(host_string)) contrail_analytics_api_server_lines +=\ '%s server %s %s:9081 check inter 2000 rise 2 fall 3\n'\ % (space, host_ip, host_ip) for host_string in env.roledefs['collector']: haproxy_config = collector_haproxy.template.safe_substitute({ '__contrail_analytics_api_backend_servers__' : contrail_analytics_api_server_lines, '__contrail_hap_user__': 'haproxy', '__contrail_hap_passwd__': 'contrail123', }) for host_string in args: with settings(host_string=host_string): # chop old settings including pesky default from pkg... tmp_fname = "/tmp/haproxy-%s-config" % (host_string) get("/etc/haproxy/haproxy.cfg", tmp_fname) with settings(warn_only=True): local("sed -i -e '/^#contrail-collector-marker-start/,/^#contrail-collector-marker-end/d' %s" % (tmp_fname)) local("sed -i -e 's/ssl-relay 0.0.0.0:8443/ssl-relay 0.0.0.0:5002/' %s" % (tmp_fname)) local("sed -i -e 's/option\shttplog/option tcplog/' %s" % (tmp_fname)) local("sed -i -e 's/maxconn 4096/maxconn 100000/' %s" % (tmp_fname)) # ...generate new ones cfg_file = open(tmp_fname, 'a') cfg_file.write(haproxy_config) cfg_file.close() put(tmp_fname, "/etc/haproxy/haproxy.cfg") local("rm %s" %(tmp_fname)) # haproxy enable with settings(host_string=host_string, warn_only=True): run("chkconfig haproxy on") enable_haproxy() run("service haproxy restart")
def join_contrail_keepalived_node(new_ctrl_host): """Task to provision a new node into a cluster of Contrail CFGM nodes with keepalived""" with settings(host_string = new_ctrl_host): enable_haproxy() sudo("service haproxy restart") setup_keepalived_node('cfgm')
def join_openstack_keepalived_node(new_ctrl_host): """Task to provision a new node into a cluster of openstack nodes with keepalived""" with settings(host_string = new_ctrl_host): enable_haproxy() sudo("service haproxy restart") setup_keepalived_node('openstack')
def fixup_restart_haproxy_in_openstack_node(*args): keystone_server_lines = '' keystone_admin_server_lines = '' glance_server_lines = '' heat_server_lines = '' cinder_server_lines = '' ceph_restapi_server_lines = '' nova_api_server_lines = '' nova_meta_server_lines = '' nova_vnc_server_lines = '' memcached_server_lines = '' rabbitmq_server_lines = '' mysql_server_lines = '' barbican_server_lines = '' space = ' ' * 3 for host_string in env.roledefs['openstack']: server_index = env.roledefs['openstack'].index(host_string) + 1 mgmt_host_ip = hstr_to_ip(host_string) host_ip = hstr_to_ip(get_control_host_string(host_string)) keystone_server_lines +=\ '%s server %s %s:6000 check inter 2000 rise 2 fall 1\n'\ % (space, host_ip, host_ip) keystone_admin_server_lines +=\ '%s server %s %s:35358 check inter 2000 rise 2 fall 1\n'\ % (space, host_ip, host_ip) glance_server_lines +=\ '%s server %s %s:9393 check inter 2000 rise 2 fall 1\n'\ % (space, host_ip, host_ip) heat_server_lines +=\ '%s server %s %s:8005 check inter 2000 rise 2 fall 1\n'\ % (space, host_ip, host_ip) cinder_server_lines +=\ '%s server %s %s:9776 check inter 2000 rise 2 fall 3\n'\ % (space, host_ip, host_ip) ceph_restapi_server_lines +=\ '%s server %s %s:5006 check inter 2000 rise 2 fall 3\n'\ % (space, host_ip, host_ip) nova_api_server_lines +=\ '%s server %s %s:9774 check inter 2000 rise 2 fall 1\n'\ % (space, host_ip, host_ip) nova_meta_server_lines +=\ '%s server %s %s:9775 check inter 2000 rise 2 fall 1\n'\ % (space, host_ip, host_ip) nova_vnc_server_lines +=\ '%s server %s %s:6999 check inter 2000 rise 2 fall 3\n'\ % (space, mgmt_host_ip, mgmt_host_ip) barbican_server_lines +=\ '%s server %s %s:9322 check inter 2000 rise 2 fall 1\n'\ % (space, host_ip, host_ip) if server_index <= 2: memcached_server_lines +=\ '%s server repcache%s %s:11211 check inter 2000 rise 2 fall 3\n'\ % (space, server_index, host_ip) if server_index == 1: rabbitmq_server_lines +=\ '%s server rabbit%s %s:5672 weight 200 check inter 2000 rise 2 fall 3\n'\ % (space, server_index, host_ip) else: rabbitmq_server_lines +=\ '%s server rabbit%s %s:5672 weight 100 check inter 2000 rise 2 fall 3 backup\n'\ % (space, server_index, host_ip) if server_index == 1: mysql_server_lines +=\ '%s server mysql%s %s:3306 weight 200 check inter 2000 rise 2 fall 3\n'\ % (space, server_index, host_ip) else: mysql_server_lines +=\ '%s server mysql%s %s:3306 weight 100 check inter 2000 rise 2 fall 3 backup\n'\ % (space, server_index, host_ip) for host_string in env.roledefs['openstack']: haproxy_config = openstack_haproxy.template.safe_substitute({ '__keystone_backend_servers__' : keystone_server_lines, '__keystone_admin_backend_servers__' : keystone_admin_server_lines, '__glance_backend_servers__' : glance_server_lines, '__heat_backend_servers__' : heat_server_lines, '__cinder_backend_servers__' : cinder_server_lines, '__ceph_restapi_backend_servers__' : ceph_restapi_server_lines, '__nova_api_backend_servers__' : nova_api_server_lines, '__nova_meta_backend_servers__' : nova_meta_server_lines, '__nova_vnc_backend_servers__' : nova_vnc_server_lines, '__barbican_backend_servers__' : barbican_server_lines, '__memcached_servers__' : memcached_server_lines, '__rabbitmq_servers__' : rabbitmq_server_lines, '__mysql_servers__' : mysql_server_lines, '__contrail_hap_user__': 'haproxy', '__contrail_hap_passwd__': get_haproxy_token('openstack'), }) for host_string in args: with settings(host_string=host_string): # chop old settings including pesky default from pkg... tmp_fname = "/tmp/haproxy-%s-config" % (host_string) get_as_sudo("/etc/haproxy/haproxy.cfg", tmp_fname) with settings(warn_only=True): local("sed -i -e '/^#contrail-openstack-marker-start/,/^#contrail-openstack-marker-end/d' %s" % (tmp_fname)) local("sed -i -e 's/frontend\s*main\s*\*:5000/frontend main *:5001/' %s" %(tmp_fname)) local("sed -i -e 's/*:5000/*:5001/' %s" % (tmp_fname)) local("sed -i -e 's/ssl-relay 0.0.0.0:8443/ssl-relay 0.0.0.0:5002/' %s" % (tmp_fname)) local("sed -i -e 's/option\shttplog/option tcplog/' %s" % (tmp_fname)) local("sed -i -e 's/maxconn 4096/maxconn 100000/' %s" % (tmp_fname)) local('sed -i "/^global/a\ spread-checks 4" %s' % tmp_fname) local('sed -i "/^global/a\ maxconn 10000" %s' % tmp_fname) local('grep -q "tune.bufsize 16384" %s || sed -i "/^global/a\\ tune.bufsize 16384" %s' % (tmp_fname, tmp_fname)) local('grep -q "tune.maxrewrite 1024" %s || sed -i "/^global/a\\ tune.maxrewrite 1024" %s' % (tmp_fname, tmp_fname)) local('grep -q "spread-checks 4" %s || sed -i "/^global/a\\ spread-checks 4" %s' % (tmp_fname, tmp_fname)) local('grep -q "maxconn 10000" %s || sed -i "/^global/a\\ maxconn 10000" %s' % (tmp_fname, tmp_fname)) # Remove default HA config local("sed -i '/listen\sappli1-rewrite/,/rspidel/d' %s" % tmp_fname) local("sed -i '/listen\sappli3-relais/,/rspidel/d' %s" % tmp_fname) # ...generate new ones cfg_file = open(tmp_fname, 'a') cfg_file.write(haproxy_config) cfg_file.close() put(tmp_fname, "/etc/haproxy/haproxy.cfg", use_sudo=True) local("rm %s" %(tmp_fname)) # haproxy enable with settings(host_string=host_string, warn_only=True): sudo("chkconfig haproxy on") sudo("service supervisor-openstack stop") enable_haproxy() sudo("service haproxy restart") #Change the keystone admin/public port sudo("openstack-config --set /etc/keystone/keystone.conf DEFAULT public_port 6000") sudo("openstack-config --set /etc/keystone/keystone.conf DEFAULT admin_port 35358")
def setup_contrail_keepalived(): """Task to provision VIP for cfgm nodes with keepalived""" enable_haproxy() sudo("service haproxy restart") setup_keepalived_node('cfgm')
def setup_openstack_keepalived(): """Task to provision VIP for openstack nodes with keepalived""" enable_haproxy() run("service haproxy restart") setup_keepalived_node('openstack')
def fixup_restart_haproxy_in_openstack_node(*args): keystone_server_lines = '' keystone_admin_server_lines = '' glance_server_lines = '' cinder_server_lines = '' ceph_restapi_server_lines = '' nova_api_server_lines = '' nova_meta_server_lines = '' nova_vnc_server_lines = '' memcached_server_lines = '' rabbitmq_server_lines = '' mysql_server_lines = '' space = ' ' * 3 for host_string in env.roledefs['openstack']: server_index = env.roledefs['openstack'].index(host_string) + 1 mgmt_host_ip = hstr_to_ip(host_string) host_ip = hstr_to_ip(get_control_host_string(host_string)) keystone_server_lines +=\ '%s server %s %s:6000 check inter 2000 rise 2 fall 1\n'\ % (space, host_ip, host_ip) keystone_admin_server_lines +=\ '%s server %s %s:35358 check inter 2000 rise 2 fall 1\n'\ % (space, host_ip, host_ip) glance_server_lines +=\ '%s server %s %s:9393 check inter 2000 rise 2 fall 1\n'\ % (space, host_ip, host_ip) cinder_server_lines +=\ '%s server %s %s:9776 check inter 2000 rise 2 fall 3\n'\ % (space, host_ip, host_ip) ceph_restapi_server_lines +=\ '%s server %s %s:5006 check inter 2000 rise 2 fall 3\n'\ % (space, host_ip, host_ip) nova_api_server_lines +=\ '%s server %s %s:9774 check inter 2000 rise 2 fall 1\n'\ % (space, host_ip, host_ip) nova_meta_server_lines +=\ '%s server %s %s:9775 check inter 2000 rise 2 fall 1\n'\ % (space, host_ip, host_ip) nova_vnc_server_lines +=\ '%s server %s %s:6999 check inter 2000 rise 2 fall 3\n'\ % (space, mgmt_host_ip, mgmt_host_ip) if server_index <= 2: memcached_server_lines +=\ '%s server repcache%s %s:11211 check inter 2000 rise 2 fall 3\n'\ % (space, server_index, host_ip) if server_index == 1: rabbitmq_server_lines +=\ '%s server rabbit%s %s:5672 weight 200 check inter 2000 rise 2 fall 3\n'\ % (space, server_index, host_ip) else: rabbitmq_server_lines +=\ '%s server rabbit%s %s:5672 weight 100 check inter 2000 rise 2 fall 3 backup\n'\ % (space, server_index, host_ip) if server_index == 1: mysql_server_lines +=\ '%s server mysql%s %s:3306 weight 200 check inter 2000 rise 2 fall 3\n'\ % (space, server_index, host_ip) else: mysql_server_lines +=\ '%s server mysql%s %s:3306 weight 100 check inter 2000 rise 2 fall 3 backup\n'\ % (space, server_index, host_ip) for host_string in env.roledefs['openstack']: haproxy_config = openstack_haproxy.template.safe_substitute({ '__keystone_backend_servers__': keystone_server_lines, '__keystone_admin_backend_servers__': keystone_admin_server_lines, '__glance_backend_servers__': glance_server_lines, '__cinder_backend_servers__': cinder_server_lines, '__ceph_restapi_backend_servers__': ceph_restapi_server_lines, '__nova_api_backend_servers__': nova_api_server_lines, '__nova_meta_backend_servers__': nova_meta_server_lines, '__nova_vnc_backend_servers__': nova_vnc_server_lines, '__memcached_servers__': memcached_server_lines, '__rabbitmq_servers__': rabbitmq_server_lines, '__mysql_servers__': mysql_server_lines, '__contrail_hap_user__': 'haproxy', '__contrail_hap_passwd__': 'contrail123', }) for host_string in args: with settings(host_string=host_string): # chop old settings including pesky default from pkg... tmp_fname = "/tmp/haproxy-%s-config" % (host_string) get_as_sudo("/etc/haproxy/haproxy.cfg", tmp_fname) with settings(warn_only=True): local( "sed -i -e '/^#contrail-openstack-marker-start/,/^#contrail-openstack-marker-end/d' %s" % (tmp_fname)) local( "sed -i -e 's/frontend\s*main\s*\*:5000/frontend main *:5001/' %s" % (tmp_fname)) local("sed -i -e 's/*:5000/*:5001/' %s" % (tmp_fname)) local( "sed -i -e 's/ssl-relay 0.0.0.0:8443/ssl-relay 0.0.0.0:5002/' %s" % (tmp_fname)) local( "sed -i -e 's/option\shttplog/option tcplog/' %s" % (tmp_fname)) local("sed -i -e 's/maxconn 4096/maxconn 100000/' %s" % (tmp_fname)) local('sed -i "/^global/a\\ tune.bufsize 16384" %s' % tmp_fname) local('sed -i "/^global/a\\ tune.maxrewrite 1024" %s' % tmp_fname) local('sed -i "/^global/a\ spread-checks 4" %s' % tmp_fname) # Remove default HA config local("sed -i '/listen\sappli1-rewrite/,/rspidel/d' %s" % tmp_fname) local("sed -i '/listen\sappli3-relais/,/rspidel/d' %s" % tmp_fname) # ...generate new ones cfg_file = open(tmp_fname, 'a') cfg_file.write(haproxy_config) cfg_file.close() put(tmp_fname, "/etc/haproxy/haproxy.cfg", use_sudo=True) local("rm %s" % (tmp_fname)) # haproxy enable with settings(host_string=host_string, warn_only=True): sudo("chkconfig haproxy on") sudo("service supervisor-openstack stop") enable_haproxy() sudo("service haproxy restart") #Change the keystone admin/public port sudo( "openstack-config --set /etc/keystone/keystone.conf DEFAULT public_port 6000" ) sudo( "openstack-config --set /etc/keystone/keystone.conf DEFAULT admin_port 35358" )
def setup_openstack_keepalived(): """Task to provision VIP for openstack nodes with keepalived""" enable_haproxy() sudo("service haproxy restart") setup_keepalived_node('openstack')
def fixup_restart_haproxy_in_openstack_node(*args): keystone_server_lines = '' keystone_admin_server_lines = '' glance_server_lines = '' cinder_server_lines = '' nova_api_server_lines = '' nova_meta_server_lines = '' memcached_server_lines = '' rabbitmq_server_lines = '' mysql_server_lines = '' space = ' ' * 3 for host_string in env.roledefs['cfgm']: server_index = env.roledefs['cfgm'].index(host_string) + 1 host_ip = hstr_to_ip(get_control_host_string(host_string)) keystone_server_lines +=\ '%s server %s %s:6000 check inter 2000 rise 2 fall 3\n'\ % (space, host_ip, host_ip) keystone_admin_server_lines +=\ '%s server %s %s:35358 check inter 2000 rise 2 fall 3\n'\ % (space, host_ip, host_ip) glance_server_lines +=\ '%s server %s %s:9393 check inter 2000 rise 2 fall 3\n'\ % (space, host_ip, host_ip) cinder_server_lines +=\ '%s server %s %s:9776 check inter 2000 rise 2 fall 3\n'\ % (space, host_ip, host_ip) nova_api_server_lines +=\ '%s server %s %s:9774 check inter 2000 rise 2 fall 3\n'\ % (space, host_ip, host_ip) nova_meta_server_lines +=\ '%s server %s %s:9775 check inter 2000 rise 2 fall 3\n'\ % (space, host_ip, host_ip) if server_index <= 2: memcached_server_lines +=\ '%s server repcache%s %s:11211 check inter 2000 rise 2 fall 3\n'\ % (space, server_index, host_ip) rabbitmq_server_lines +=\ '%s server rabbit%s %s:5672 check inter 2000 rise 2 fall 3 weight 1 maxconn 500\n'\ % (space, server_index, host_ip) mysql_server_lines +=\ '%s server mysql%s %s:3306 weight 1\n'\ % (space, server_index, host_ip) for host_string in env.roledefs['cfgm']: haproxy_config = openstack_haproxy.template.safe_substitute({ '__keystone_backend_servers__' : keystone_server_lines, '__keystone_admin_backend_servers__' : keystone_admin_server_lines, '__glance_backend_servers__' : glance_server_lines, '__cinder_backend_servers__' : cinder_server_lines, '__nova_api_backend_servers__' : nova_api_server_lines, '__nova_meta_backend_servers__' : nova_meta_server_lines, '__memcached_servers__' : memcached_server_lines, '__rabbitmq_servers__' : rabbitmq_server_lines, '__mysql_servers__' : mysql_server_lines, '__contrail_hap_user__': 'haproxy', '__contrail_hap_passwd__': 'contrail123', }) for host_string in args: with settings(host_string=host_string): # chop old settings including pesky default from pkg... tmp_fname = "/tmp/haproxy-%s-config" % (host_string) get("/etc/haproxy/haproxy.cfg", tmp_fname) with settings(warn_only=True): local("sed -i -e '/^#contrail-openstack-marker-start/,/^#contrail-openstack-marker-end/d' %s" % (tmp_fname)) local("sed -i -e 's/*:5000/*:5001/' %s" % (tmp_fname)) local("sed -i -e 's/ssl-relay 0.0.0.0:8443/ssl-relay 0.0.0.0:5002/' %s" % (tmp_fname)) local("sed -i -e 's/option\shttplog/option tcplog/' %s" % (tmp_fname)) # ...generate new ones cfg_file = open(tmp_fname, 'a') cfg_file.write(haproxy_config) cfg_file.close() put(tmp_fname, "/etc/haproxy/haproxy.cfg") local("rm %s" %(tmp_fname)) # haproxy enable with settings(host_string=host_string, warn_only=True): run("chkconfig haproxy on") run("service supervisor-openstack stop") enable_haproxy() run("service haproxy restart") #Change the keystone admin/public port run("openstack-config --set /etc/keystone/keystone.conf DEFAULT public_port 6000") run("openstack-config --set /etc/keystone/keystone.conf DEFAULT admin_port 35358")
def setup_cmon_param_zkonupgrade(): cmon_param = '/etc/contrail/ha/cmon_param' zoo_ip_list = [hstr_to_ip(get_control_host_string(\ cassandra_host)) for cassandra_host in env.roledefs['database']] zk_servers_ports = ','.join(['%s:2181' %(s) for s in zoo_ip_list]) zks = 'ZK_SERVER_IP=("' + '" "'.join(zk_servers_ports) + '")' monitor_galera="False" if get_contrail_internal_vip(): monitor_galera="True" # Assuming that keystone is the user and pass # if changed we need to fetch and update these fields keystone_db_user="******" keystone_db_pass="******" cmon_db_user="******" cmon_db_pass="******" sudo("grep -q 'ZK_SERVER_IP' %s || echo '%s' >> %s" % (cmon_param, zks, cmon_param)) sudo("grep -q 'OS_KS_USER' %s || echo 'OS_KS_USER=%s' >> %s" % (cmon_param, keystone_db_user, cmon_param)) sudo("grep -q 'OS_KS_PASS' %s || echo 'OS_KS_PASS=%s' >> %s" % (cmon_param, keystone_db_pass, cmon_param)) sudo("grep -q 'CMON_USER' %s || echo 'CMON_USER=%s' >> %s" % (cmon_param, cmon_db_user, cmon_param)) sudo("grep -q 'CMON_PASS' %s || echo 'CMON_PASS=%s' >> %s" % (cmon_param, cmon_db_pass, cmon_param)) sudo("grep -q 'MONITOR_GALERA' %s || echo 'MONITOR_GALERA=%s' >> %s" % (cmon_param, monitor_galera, cmon_param)) for host_string in env.roledefs['openstack']: haproxy_config = openstack_haproxy.template.safe_substitute({ '__keystone_backend_servers__' : keystone_server_lines, '__keystone_admin_backend_servers__' : keystone_admin_server_lines, '__glance_backend_servers__' : glance_server_lines, '__heat_backend_servers__' : heat_server_lines, '__cinder_backend_servers__' : cinder_server_lines, '__ceph_restapi_backend_servers__' : ceph_restapi_server_lines, '__nova_api_backend_servers__' : nova_api_server_lines, '__nova_meta_backend_servers__' : nova_meta_server_lines, '__nova_vnc_backend_servers__' : nova_vnc_server_lines, '__memcached_servers__' : memcached_server_lines, '__rabbitmq_servers__' : rabbitmq_server_lines, '__mysql_servers__' : mysql_server_lines, '__contrail_hap_user__': 'haproxy', '__contrail_hap_passwd__': 'contrail123', }) for host_string in args: with settings(host_string=host_string): # chop old settings including pesky default from pkg... tmp_fname = "/tmp/haproxy-%s-config" % (host_string) get_as_sudo("/etc/haproxy/haproxy.cfg", tmp_fname) with settings(warn_only=True): local("sed -i -e '/^#contrail-openstack-marker-start/,/^#contrail-openstack-marker-end/d' %s" % (tmp_fname)) local("sed -i -e 's/frontend\s*main\s*\*:5000/frontend main *:5001/' %s" %(tmp_fname)) local("sed -i -e 's/*:5000/*:5001/' %s" % (tmp_fname)) local("sed -i -e 's/ssl-relay 0.0.0.0:8443/ssl-relay 0.0.0.0:5002/' %s" % (tmp_fname)) local("sed -i -e 's/option\shttplog/option tcplog/' %s" % (tmp_fname)) local("sed -i -e 's/maxconn 4096/maxconn 100000/' %s" % (tmp_fname)) local('sed -i "/^global/a\ spread-checks 4" %s' % tmp_fname) local('sed -i "/^global/a\ maxconn 10000" %s' % tmp_fname) local('grep -q "tune.bufsize 16384" %s || sed -i "/^global/a\\ tune.bufsize 16384" %s' % (tmp_fname, tmp_fname)) local('grep -q "tune.maxrewrite 1024" %s || sed -i "/^global/a\\ tune.maxrewrite 1024" %s' % (tmp_fname, tmp_fname)) local('grep -q "spread-checks 4" %s || sed -i "/^global/a\\ spread-checks 4" %s' % (tmp_fname, tmp_fname)) local('grep -q "maxconn 10000" %s || sed -i "/^global/a\\ maxconn 10000" %s' % (tmp_fname, tmp_fname)) # Remove default HA config local("sed -i '/listen\sappli1-rewrite/,/rspidel/d' %s" % tmp_fname) local("sed -i '/listen\sappli3-relais/,/rspidel/d' %s" % tmp_fname) # ...generate new ones cfg_file = open(tmp_fname, 'a') cfg_file.write(haproxy_config) cfg_file.close() put(tmp_fname, "/etc/haproxy/haproxy.cfg", use_sudo=True) local("rm %s" %(tmp_fname)) # haproxy enable with settings(host_string=host_string, warn_only=True): sudo("chkconfig haproxy on") sudo("service supervisor-openstack stop") enable_haproxy() sudo("service haproxy restart") #Change the keystone admin/public port sudo("openstack-config --set /etc/keystone/keystone.conf DEFAULT public_port 6000") sudo("openstack-config --set /etc/keystone/keystone.conf DEFAULT admin_port 35358")