diff --git a/contrail/environment/modules/contrail/manifests/lib/top_of_rack.pp b/contrail/environment/modules/contrail/manifests/lib/top_of_rack.pp index e8b91a56..5d667a23 100644 --- a/contrail/environment/modules/contrail/manifests/lib/top_of_rack.pp +++ b/contrail/environment/modules/contrail/manifests/lib/top_of_rack.pp @@ -19,6 +19,7 @@ $keystone_admin_user, $keystone_admin_password, $keystone_admin_tenant, + $tsn_ip, $host_control_ip) { notify { "**** ${module_name} - ${name} => ${tunnel_ip_address}, ${ovs_port}, ${http_server_port} , ${ip_address}, ${id}, ${vendor_name}, ${ovs_protocol}, ${ovs_protocol}, ${switch_name}": ; } @@ -32,7 +33,7 @@ mode => '0755', owner => root, group => root, - source => "puppet:///tor_certs/tor.${switch_name}.cert.pem", + source => "puppet:///ssl_certs/tor.${switch_name}.cert.pem", } -> file { "tor-agent-ssl-key-${id}" : @@ -41,7 +42,7 @@ mode => '0755', owner => root, group => root, - source => "puppet:///tor_certs/tor.${switch_name}.privkey.pem", + source => "puppet:///ssl_certs/tor.${switch_name}.privkey.pem", } File ["tor-agent-ssl-key-${id}"] -> File["tor-agent-config-${id}"] } else { diff --git a/contrail/environment/modules/contrail/templates/generate_haproxy.erb b/contrail/environment/modules/contrail/templates/generate_haproxy.erb index f2ac9dc4..902a8e7c 100755 --- a/contrail/environment/modules/contrail/templates/generate_haproxy.erb +++ b/contrail/environment/modules/contrail/templates/generate_haproxy.erb @@ -402,7 +402,9 @@ def main(args_str=None): collector_host_list_str = "<%=@collector_name_list_shell%>" collector_ip_list_str = "<%=@collector_ip_list_shell%>" - tor_details = "<%=@tor_ha_proxy_config%>" + tor_details_str = '<%=@tor_ha_proxy_config%>' + + tor_details = tor_details_str.replace('=>', ':') config_host_list = config_host_list_str.split(",") config_ip_list = config_ip_list_str.split(",") @@ -436,13 +438,19 @@ def main(args_str=None): cfg_file.close() def get_standby_info(tor_details,skip_host,match_tor_name): - for host in tor_details: - if host == skip_host: - continue - for i in range(len(tor_details[host])): - tor_name=tor_details[host][i]['tor_name'] - if tor_name == match_tor_name: - return (i, host) + for hostname in tor_details.keys(): + myhost = tor_details[hostname] + host_tors = myhost.values() + if hostname == skip_host: + continue + for i in range(len(host_tors)): + tor_name=host_tors[i]['switch_name'] + if tor_name == match_tor_name: + return (i, hostname) + #end if tor_name == + # end for i in range + # end for hostname in tor_details + return (-1, None) @@ -474,35 +482,64 @@ def get_tor_agent_haproxy_config(proxy_name, key, ha_dict): return tor_agent_ha_config #end get_tor_agent_haproxy_config + def tor_agent_ha_config(tor_details_str): if tor_details_str == "": return "#No TOR Details Found" tor_details = eval(tor_details_str) master_ha_proxy = {} - for host in tor_details: + + for hostname in tor_details.keys(): + myhost = tor_details[hostname] + host_tors = myhost.values() + + for i in range(len(host_tors)): + if host_tors[i]['ovs_protocol'] != 'pssl': + continue + tor_name= host_tors[i]['switch_name'] + tsn1 = host_tors[i]['tsn_ip'] + port1 = host_tors[i]['ovs_port'] + standby_tor_idx, standby_host = get_standby_info(tor_details, hostname, tor_name) + key = tsn1 + if (standby_tor_idx != -1 and standby_host != None): + tor_host = tor_details[standby_host] + tor_host_switches = tor_host.values() + tsn2 =tor_host_switches[standby_tor_idx]['tsn_ip'] + if tsn1 < tsn2: + key = tsn1 + "-" + tsn2 + else: + key = tsn2 + "-" + tsn1 + + if not key in master_ha_proxy: + master_ha_proxy[key] = [] + if not port1 in master_ha_proxy[key]: + master_ha_proxy[key].append(port1) + + + #for host in tor_details: #print host - for i in range(len(tor_details[host])): + #for i in range(len(tor_details[host])): ## Only SSL supports haproxy - if tor_details[host][i]['protocol'] != 'pssl': + #if tor_details[host][i]['protocol'] != 'pssl': #print tor_details[host][i] - continue + #continue #print tor_details[host][i] - tor_name= tor_details[host][i]['tor_name'] - tsn1 = tor_details[host][i]['tsn_ip'] - port1 = tor_details[host][i]['ovs_port'] - standby_tor_idx, standby_host = get_standby_info(tor_details, host, tor_name) - key = tsn1 - if (standby_tor_idx != -1 and standby_host != None): - tsn2 =tor_details[standby_host][standby_tor_idx]['tsn_ip'] - if tsn1 < tsn2: - key = tsn1 + "-" + tsn2 - else: - key = tsn2 + "-" + tsn1 - - if not key in master_ha_proxy: - master_ha_proxy[key] = [] - if not port1 in master_ha_proxy[key]: - master_ha_proxy[key].append(port1) + #tor_name= tor_details[host][i]['tor_name'] + #tsn1 = tor_details[host][i]['tsn_ip'] + #port1 = tor_details[host][i]['ovs_port'] + #standby_tor_idx, standby_host = get_standby_info(tor_details, host, tor_name) + #key = tsn1 + #if (standby_tor_idx != -1 and standby_host != None): + #tsn2 =tor_details[standby_host][standby_tor_idx]['tsn_ip'] + #if tsn1 < tsn2: + #key = tsn1 + "-" + tsn2 + #else: + #key = tsn2 + "-" + tsn1 +# + #if not key in master_ha_proxy: + #master_ha_proxy[key] = [] + #if not port1 in master_ha_proxy[key]: + #master_ha_proxy[key].append(port1) i = 1 cfg_str = "" @@ -512,6 +549,15 @@ def tor_agent_ha_config(tor_details_str): cfg_str = cfg_str + get_tor_agent_haproxy_config(proxy_name, key, master_ha_proxy) return cfg_str +def tor_agent_filter_data(tor_details): + #if tor_details_str == "": + #return "#No TOR Details Found" + #tor_details = eval(tor_details_str) + master_ha_proxy = {} + for host in tor_details: + print host['switch_name'] + + def generate_collector_ha_config(collector_ip_list, mgmt_host_ip): contrail_analytics_api_server_lines = '' space = ' ' * 3