/
generate_haproxy.erb
executable file
·730 lines (607 loc) · 22.2 KB
/
generate_haproxy.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
#!/usr/bin/python
#
# Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
#
import string
import sys
import platform
(pdist, pdistversion, pdistrelease) = platform.dist()
if pdist in ['fedora', 'centos', 'redhat']:
stats_cmd = "stats socket /var/lib/haproxy/stats"
err_str=""
if pdist == 'Ubuntu':
stats_cmd = "stats socket /run/haproxy/admin.sock mode 660 level admin"
err_str="\
errorfile 400 /etc/haproxy/errors/400.http\n\
errorfile 403 /etc/haproxy/errors/403.http\n\
errorfile 408 /etc/haproxy/errors/408.http\n\
errorfile 500 /etc/haproxy/errors/500.http\n\
errorfile 502 /etc/haproxy/errors/502.http\n\
errorfile 503 /etc/haproxy/errors/503.http\n\
errorfile 504 /etc/haproxy/errors/504.http\n"
#contrail-collector-marker-start
haproxy_template = string.Template("""
global
maxconn 10000
spread-checks 4
tune.maxrewrite 1024
tune.bufsize 16384
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
%s
stats timeout 30s
user haproxy
group haproxy
daemon
# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
# Default ciphers to use on SSL-enabled listening sockets.
# For more information, see ciphers(1SSL).
ssl-default-bind-ciphers kEECDH+aRSA+AES:kRSA+AES:+AES256:RC4-SHA:!kEDH:!LOW:!EXP:!MD5:!aNULL:!eNULL
defaults
log global
mode http
option tcplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
%s
$__collector_ha_proxy
#contrail-collector-marker-end
#contrail-openstack-marker-start
$__openstack_ha_proxy
#contrail-openstack-marker-end
#contrail-config-marker-start
$__config_ha_proxy
#contrail-config-marker-end
#contrail-global-controller-marker-start
$__global_controller_ha_proxy
#contrail-global-controller-marker-end
#toragent-config-marker-start
$__toragent_ha_proxy
#toragent-config-marker-end
"""%(stats_cmd,err_str))
collector_ha_template = string.Template("""#contrail-collector-marker-start
listen contrail-collector-stats :5938
mode http
stats enable
stats uri /
stats auth $__contrail_hap_user__:$__contrail_hap_passwd__
frontend contrail-analytics-api *:8081
default_backend contrail-analytics-api
backend contrail-analytics-api
option nolinger
timeout server 3m
balance roundrobin
$__contrail_analytics_api_backend_servers__
#contrail-collector-marker-end
""")
openstack_ha_template = string.Template("""#contrail-openstack-marker-start
listen contrail-openstack-stats :5936
mode http
stats enable
stats uri /
stats auth $__contrail_hap_user__:$__contrail_hap_passwd__
frontend openstack-keystone *:5000
default_backend keystone-backend
backend keystone-backend
option tcpka
option nolinger
timeout server 24h
balance roundrobin
option tcp-check
tcp-check connect port 3306
default-server error-limit 1 on-error mark-down
#option tcp-check
#option httpchk
#tcp-check connect port 3337
#tcp-check send Host:localhost
#http-check expect ! rstatus ^5
#default-server error-limit 1 on-error mark-down
option tcp-check
tcp-check connect port 6000
default-server error-limit 1 on-error mark-down
$__keystone_backend_servers__
frontend openstack-keystone-admin *:35357
default_backend keystone-admin-backend
backend keystone-admin-backend
option tcpka
option nolinger
timeout server 24h
balance roundrobin
option tcp-check
tcp-check connect port 3306
default-server error-limit 1 on-error mark-down
option tcp-check
option httpchk
tcp-check connect port 3337
tcp-check send Host:localhost
http-check expect ! rstatus ^5
default-server error-limit 1 on-error mark-down
option tcp-check
tcp-check connect port 35358
default-server error-limit 1 on-error mark-down
$__keystone_admin_backend_servers__
frontend openstack-glance *:9292
default_backend glance-backend
backend glance-backend
option tcpka
option nolinger
timeout server 24h
balance roundrobin
option tcp-check
tcp-check connect port 3306
default-server error-limit 1 on-error mark-down
option tcp-check
option httpchk
tcp-check connect port 3337
tcp-check send Host:localhost
http-check expect ! rstatus ^5
default-server error-limit 1 on-error mark-down
option tcp-check
tcp-check connect port 9393
default-server error-limit 1 on-error mark-down
$__glance_backend_servers__
frontend openstack-cinder *:8776
default_backend cinder-backend
backend cinder-backend
option tcpka
option nolinger
timeout server 24h
balance roundrobin
$__cinder_backend_servers__
frontend ceph-rest-api-server *:5005
default_backend ceph-rest-api-server-backend
backend ceph-rest-api-server-backend
option tcpka
option nolinger
timeout server 24h
balance roundrobin
$__ceph_restapi_backend_servers__
frontend openstack-nova-api *:8774
default_backend nova-api-backend
backend nova-api-backend
option tcpka
option nolinger
timeout server 24h
balance roundrobin
option tcp-check
tcp-check connect port 3306
default-server error-limit 1 on-error mark-down
option tcp-check
option httpchk
tcp-check connect port 3337
tcp-check send Host:localhost
http-check expect ! rstatus ^5
default-server error-limit 1 on-error mark-down
option tcp-check
tcp-check connect port 9774
default-server error-limit 1 on-error mark-down
$__nova_api_backend_servers__
frontend openstack-nova-meta *:8775
default_backend nova-meta-backend
backend nova-meta-backend
option tcpka
option nolinger
timeout server 24h
balance roundrobin
option tcp-check
tcp-check connect port 3306
default-server error-limit 1 on-error mark-down
option tcp-check
option httpchk
tcp-check connect port 3337
tcp-check send Host:localhost
http-check expect ! rstatus ^5
default-server error-limit 1 on-error mark-down
option tcp-check
tcp-check connect port 9775
default-server error-limit 1 on-error mark-down
$__nova_meta_backend_servers__
frontend openstack-nova-vnc *:6080
default_backend nova-vnc-backend
backend nova-vnc-backend
option tcpka
option nolinger
timeout server 5h
balance roundrobin
$__nova_vnc_backend_servers__
frontend heat-cfn *:8000
default_backend heat-cfn-api-backend
frontend heat-srv *:8004
default_backend heat-api-backend
backend heat-api-backend
option tcpka
option nolinger
timeout server 24h
balance roundrobin
option tcp-check
tcp-check connect port 3306
default-server error-limit 1 on-error mark-down
option tcp-check
option httpchk
tcp-check connect port 3337
tcp-check send Host:localhost
http-check expect ! rstatus ^5
default-server error-limit 1 on-error mark-down
option tcp-check
tcp-check connect port 8005
$__heat_api_backend_servers__
backend heat-cfn-api-backend
option tcpka
option nolinger
timeout server 24h
balance roundrobin
option tcp-check
tcp-check connect port 3306
default-server error-limit 1 on-error mark-down
option tcp-check
option httpchk
tcp-check connect port 3337
tcp-check send Host:localhost
http-check expect ! rstatus ^5
default-server error-limit 1 on-error mark-down
option tcp-check
tcp-check connect port 8001
$__heat_cfn_api_backend_servers__
listen memcached 0.0.0.0:11222
mode tcp
balance roundrobin
option tcplog
maxconn 10000
balance roundrobin
option tcpka
option nolinger
timeout connect 5s
timeout client 48h
timeout server 48h
$__memcached_servers__
listen mysql 0.0.0.0:33306
mode tcp
balance leastconn
option tcpka
option nolinger
option forceclose
maxconn 10000
timeout connect 30s
timeout client 24h
timeout server 24h
timeout client-fin 60s
timeout server-fin 60s
$__mysql_servers__
#contrail-openstack-marker-end
""")
config_ha_template = string.Template("""
#contrail-config-marker-start
listen contrail-config-stats :5937
mode http
stats enable
stats uri /
stats auth $__contrail_hap_user__:$__contrail_hap_passwd__
frontend quantum-server *:9696
default_backend quantum-server-backend
frontend contrail-api *:8082
default_backend contrail-api-backend
frontend contrail-discovery *:5998
default_backend contrail-discovery-backend
backend quantum-server-backend
option nolinger
balance roundrobin
$__contrail_quantum_servers__
#server 10.84.14.2 10.84.14.2:9697 check
backend contrail-api-backend
option nolinger
balance roundrobin
$__contrail_api_backend_servers__
#server 10.84.14.2 10.84.14.2:9100 check
#server 10.84.14.2 10.84.14.2:9101 check
backend contrail-discovery-backend
option nolinger
balance roundrobin
$__contrail_disc_backend_servers__
#server 10.84.14.2 10.84.14.2:9110 check
#server 10.84.14.2 10.84.14.2:9111 check
#contrail-config-marker-end
""")
global_controller_ha_template = string.Template("""
#contrail-global-controller-marker-start
listen contrail-global-controller-stats :5938
mode http
stats enable
stats uri /
stats auth $__contrail_hap_user__:$__contrail_hap_passwd__
frontend global-controller-server *:9500
default_backend global-controller-server-backend
backend global-controller-server-backend
option nolinger
balance roundrobin
$__servers__
#contrail-global-controller-marker
""")
def main(args_str=None):
config_stanza = ""
global_controller_stanza = ""
collector_stanza = ""
openstack_stanza = ""
host_ip = "<%=@host_ip%>"
internal_vip = "<%=@ha_internal_vip%>"
contrail_internal_vip = "<%=@ha_contrail_internal_vip%>"
config_host_list_str = "<%=@config_name_list_shell%>"
config_ip_list_str = "<%=@config_ip_list_shell%>"
openstack_host_list_str = "<%=@openstack_name_list_shell%>"
openstack_ip_list_str = "<%=@openstack_ip_list_shell%>"
collector_host_list_str = "<%=@collector_name_list_shell%>"
collector_ip_list_str = "<%=@collector_ip_list_shell%>"
global_controller_host_list_str = "<%=@global_controller_name_list_shell%>"
global_controller_ip_list_str = "<%=@global_controller_ip_list_shell%>"
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(",")
openstack_host_list = openstack_host_list_str.split(",")
openstack_ip_list = openstack_ip_list_str.split(",")
collector_host_list = collector_host_list_str.split(",")
collector_ip_list = collector_ip_list_str.split(",")
global_controller_host_list = global_controller_host_list_str.split(",")
global_controller_ip_list = global_controller_ip_list_str.split(",")
toragent_stanza = tor_agent_ha_config(tor_details)
if host_ip in config_ip_list:
config_stanza = generate_config_ha_config(config_ip_list, openstack_ip_list, host_ip, internal_vip, contrail_internal_vip)
if host_ip in config_ip_list and (internal_vip != "none" or contrail_internal_vip != "none"):
collector_stanza = generate_collector_ha_config(collector_ip_list, host_ip)
if (internal_vip != "none") and (host_ip in openstack_ip_list):
openstack_stanza = generate_openstack_ha_config(openstack_ip_list, host_ip)
if host_ip in global_controller_ip_list:
global_controller_stanza = generate_global_controller_ha_config(global_controller_ip_list)
haproxy_config = haproxy_template.safe_substitute({
'__collector_ha_proxy' : collector_stanza,
'__config_ha_proxy' : config_stanza,
'__global_controller_ha_proxy' : global_controller_stanza,
'__openstack_ha_proxy' : openstack_stanza,
'__toragent_ha_proxy' : toragent_stanza,
})
cfg_file = open('/etc/haproxy/haproxy.cfg', 'w+')
cfg_file.write(haproxy_config)
cfg_file.close()
def get_standby_info(tor_details,skip_host,match_tor_name):
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)
# Get HA proxy configuration for a TOR agent
def get_tor_agent_haproxy_config(proxy_name, key, ha_dict):
tor_agent_ha_config = '\n'
port_list = ha_dict[key]
ha_dict_len = len(port_list)
if ha_dict_len == 0:
return tor_agent_ha_config
ip2 = None
if "-" in key:
ip1 = key.split('-')[0]
ip2 = key.split('-')[1]
else:
ip1 = key
tor_agent_ha_config = tor_agent_ha_config + 'listen %s\n' %(proxy_name)
tor_agent_ha_config = tor_agent_ha_config + ' option tcpka\n'
tor_agent_ha_config = tor_agent_ha_config + ' mode tcp\n'
tor_agent_ha_config = tor_agent_ha_config + ' bind :%s' %(port_list[0])
for i in range(1, ha_dict_len):
tor_agent_ha_config = tor_agent_ha_config + ',:%s' %(port_list[i])
tor_agent_ha_config = tor_agent_ha_config + '\n'
tor_agent_ha_config = tor_agent_ha_config + ' server %s %s check inter 2000\n' %(ip1, ip1)
if ip2 != None:
tor_agent_ha_config = tor_agent_ha_config + ' server %s %s check inter 2000\n' %(ip2, ip2)
tor_agent_ha_config = tor_agent_ha_config + ' balance leastconn\n'
tor_agent_ha_config = tor_agent_ha_config + '\n'
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 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])):
## Only SSL supports haproxy
#if tor_details[host][i]['protocol'] != 'pssl':
#print tor_details[host][i]
#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)
i = 1
cfg_str = ""
for key in master_ha_proxy.keys():
proxy_name = "contrail-tor-agent-" + str(i)
i = i + 1
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
for server_index, host_ip in enumerate(collector_ip_list):
contrail_analytics_api_server_lines +=\
'%s server %s %s:9081 check inter 2000 rise 2 fall 3\n'\
% (space, host_ip, host_ip)
haproxy_config = collector_ha_template.safe_substitute({
'__contrail_analytics_api_backend_servers__' : contrail_analytics_api_server_lines,
'__contrail_hap_user__': 'haproxy',
'__contrail_hap_passwd__': 'contrail123',
})
return haproxy_config
def generate_config_ha_config(config_ip_list, openstack_ip_list, mgmt_ip, internal_vip, contrail_internal_vip):
q_listen_port = 9697
q_server_lines = ''
api_listen_port = 9100
api_server_lines = ''
disc_listen_port = 9110
disc_server_lines = ''
nworkers = 1
space = ' ' * 3
for server_index, host_ip in enumerate(config_ip_list):
q_server_lines = q_server_lines + \
' server %s %s:%s check inter 2000 rise 2 fall 3\n' \
%(host_ip, host_ip, str(q_listen_port))
for i in range(nworkers):
api_server_lines = api_server_lines + \
' server %s %s:%s check inter 2000 rise 2 fall 3\n' \
%(host_ip, host_ip, str(api_listen_port + i))
disc_server_lines = disc_server_lines + \
' server %s %s:%s check inter 2000 rise 2 fall 3\n' \
%(host_ip, host_ip, str(disc_listen_port + i))
haproxy_config = config_ha_template.safe_substitute({
'__contrail_quantum_servers__': q_server_lines,
'__contrail_api_backend_servers__': api_server_lines,
'__contrail_disc_backend_servers__': disc_server_lines,
'__contrail_hap_user__': 'haproxy',
'__contrail_hap_passwd__': 'contrail123'
})
return haproxy_config
def generate_global_controller_ha_config(global_controller_ip_list):
listen_port = 9501
server_lines = ''
nworkers = 1
space = ' ' * 3
for server_index, host_ip in enumerate(global_controller_ip_list):
server_lines = server_lines + \
' server %s %s:%s check inter 2000 rise 2 fall 3\n' \
%(host_ip, host_ip, str(listen_port))
haproxy_config = global_controller_ha_template.safe_substitute({
'__servers__': server_lines,
'__contrail_hap_user__': 'haproxy',
'__contrail_hap_passwd__': 'contrail123'
})
return haproxy_config
def generate_openstack_ha_config(openstack_ip_list, mgmt_host_ip):
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 = ''
heat_api_server_lines= ''
heat_cfn_api_server_lines = ''
memcached_server_lines = ''
mysql_server_lines = ''
space = ' ' * 3
for server_index, host_ip in enumerate(openstack_ip_list):
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, host_ip, host_ip)
heat_api_server_lines +=\
'%s server %s %s:8005 check inter 2000 rise 2 fall 1\n'\
% (space, host_ip, host_ip)
heat_cfn_api_server_lines +=\
'%s server %s %s:8001 check inter 2000 rise 2 fall 1\n'\
% (space, host_ip, host_ip)
if server_index <= 1:
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 == 0:
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)
haproxy_config = openstack_ha_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,
'__heat_api_backend_servers__': heat_api_server_lines,
'__heat_cfn_api_backend_servers__': heat_cfn_api_server_lines,
'__memcached_servers__' : memcached_server_lines,
'__mysql_servers__' : mysql_server_lines,
'__contrail_hap_user__': 'haproxy',
'__contrail_hap_passwd__': 'contrail123',
})
return haproxy_config
if __name__ == "__main__":
main(sys.argv[1:])