xentaur

view configuration_templates.py @ 67:6c145935ece5

Fixed path scripts and configuration templates moved to a single file.
author Igor Chubin <igor@chub.in>
date Mon Jan 11 13:01:35 2010 +0200 (2010-01-11)
parents
children
line source
1 #-----------------------------------------------------------------------
2 # CONFIGURATION TEMPLATES
4 cisco_fa01_up="""
5 ena
6 conf t
7 int fa0/0
8 duplex half
9 no shutdown
10 exit
11 int fa1/0
12 duplex half
13 no shutdown
14 exit
15 exit
16 exit
17 """
19 cisco_set_ip_on_int="""
20 interface fa%s/0
21 no ip address
22 ip address %s 255.255.255.0
23 exit
24 """
28 def configure_ip_addresses(doms=domains):
30 cisco_set_ip_on_int="""
31 int fa%s/0
32 duplex full
33 no ip address
34 ip address %s 255.255.255.0
35 no shutdown
36 exit
37 """
39 quagga_set_ip_on_int="""
40 int eth%s
41 no ip address
42 ip address %s/24
43 no shutdown
44 exit
45 """
47 linux_set_ip_on_int="""
48 ifconfig eth%s %s netmask 255.255.255.0
49 """
51 for dom in doms:
52 i=domains.index(dom)+1
53 if domain_types[domains.index(dom)] == 'quagga':
54 command = quagga_set_ip_on_int
55 write_to(i,"conf t\n")
56 j=0
57 for br in vbridges_table[dom]:
58 write_to(i,command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i)))
59 j+=1
60 write_to(i,"end\n")
61 elif domain_types[domains.index(dom)] == 'linux':
62 command = linux_set_ip_on_int
63 j=0
64 for br in vbridges_table[dom]:
65 #write_to(i, command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i)) )
66 print i, command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i))
67 j+=1
68 else:
69 command = cisco_set_ip_on_int
70 write_to(i,"ena\nconf t\n")
71 j=0
72 for br in vbridges_table[dom]:
73 write_to(i,command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i)))
74 j+=1
75 write_to(i,"end\n")
76 return 0
78 def configure_no_ip_addresses(doms=domains):
79 cisco_set_ip_on_int="""
80 int fa%s/0
81 no ip address %s 255.255.255.0
82 exit
83 """
84 quagga_set_ip_on_int="""
85 int eth%s
86 no ip address %s/24
87 exit
88 """
89 for dom in doms:
90 i=domains.index(dom)+1
91 if domain_types[domains.index(dom)] == 'quagga':
92 command = quagga_set_ip_on_int
93 write_to(i,"\nconf t\n")
94 j=0
95 for br in vbridges_table[dom]:
96 write_to(i,command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i)))
97 j+=1
98 write_to(i,"\nend\n")
99 else:
100 command = cisco_set_ip_on_int
101 write_to(i,"\n\n\nena\nconf t\n")
102 j=0
103 for br in vbridges_table[dom]:
104 write_to(i,command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i)))
105 j+=1
106 write_to(i,"\nend\n")
107 return 0
109 def configure_ospf(doms=domains):
110 for dom in doms:
111 if domain_types[domains.index(dom)] == 'quagga':
112 write_to(dom,"\n\nconf t\nrouter ospf\nnetwork 192.168.0.0/16 area 0\nend\n")
113 else:
114 write_to(dom,"\n\nena\nconf t\nrouter ospf 1\nnetwork 192.168.0.0 0.0.255.255 area 0\nend\n")
115 return 0
117 def configure_hostname(doms=domains):
118 for dom in doms:
119 if domain_types[domains.index(dom)] == 'quagga':
120 write_to(dom,"\n\nconf t\nhostname %s\nend\n" % dom)
121 else:
122 write_to(dom,"\n\nena\nconf t\nhostname %s\nend\n" % dom)
123 return 0
125 def configure_logging_synchronous(doms=domains):
126 for dom in domains:
127 if domain_types[domains.index(dom)] == 'quagga':
128 0
129 else:
130 write_to(dom,"\n\nena\nconf t\nline console 0\nlogging synchronous\nend\n")
131 return 0
133 def configure_exec_timeout_0(doms=domains):
134 for dom in domains:
135 if domain_types[domains.index(dom)] == 'quagga':
136 0
137 else:
138 write_to(dom,"\n\nena\nconf t\nline console 0\nexec-timeout 0\nend\n")
139 return 0
141 def configure_no_cdp_log_mismatch_duplex(doms=domains):
142 for dom in filter_by_type(domains,'dynamips'):
143 write_to(dom,"\n\nena\nconf t\nno cdp log mismatch duplex\nend\n")
145 def configure_save(doms=domains):
146 write_to(doms,"\nwr\n")
148 def configure_root(doms=domains):
149 write_to(doms,"root\n")