-
Notifications
You must be signed in to change notification settings - Fork 0
/
templ.py
30 lines (22 loc) · 981 Bytes
/
templ.py
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
from string import Template
##ipbind = '192.168.100.27'
##node1 = 'beta'
##node2 = 'gamma'
##ipnode1 = 'xxxx'
##ipnode2 = 'yyyy'
def HaprxyTemplHandler(haproxytempl, ipbind, IPs, nodes) :
readingtemplate = open( haproxytempl )
realsrc = Template(readingtemplate.read())
##variabila = ['unspe', 'doispe', 'treispe', 'paispe']
##d = {'variabila':'\n'.join(variabila)} // pentru liste cu fiecare element din rand nou
d = {'ipbind':ipbind,
'node1' :nodes[0], 'node2' :nodes[1], 'node3' :nodes[2],
'ipnode1' :IPs[0], 'ipnode2' :IPs[1], 'ipnode3' :IPs[2]}
return realsrc.substitute(d)
def ApacheTemplHandler(apachetempl, node, ip):
readingtemplate = open( apachetempl )
realsrc = Template(readingtemplate.read())
d = {'node':node, 'ip':ip}
return realsrc.substitute(d)
###HaprxyTemplHandler('template.txt', '192.168.100.27', 'beta' , 'gamma', 'xxxx', 'yyyy')
###ApacheTemplHandler( 'apachetempl.txt','gamma')