xentaur
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/configuration_templates.py Mon Jan 11 13:01:35 2010 +0200 1.3 @@ -0,0 +1,151 @@ 1.4 +#----------------------------------------------------------------------- 1.5 +# CONFIGURATION TEMPLATES 1.6 + 1.7 +cisco_fa01_up=""" 1.8 +ena 1.9 +conf t 1.10 +int fa0/0 1.11 +duplex half 1.12 +no shutdown 1.13 +exit 1.14 +int fa1/0 1.15 +duplex half 1.16 +no shutdown 1.17 +exit 1.18 +exit 1.19 +exit 1.20 +""" 1.21 + 1.22 +cisco_set_ip_on_int=""" 1.23 +interface fa%s/0 1.24 +no ip address 1.25 +ip address %s 255.255.255.0 1.26 +exit 1.27 +""" 1.28 + 1.29 + 1.30 + 1.31 +def configure_ip_addresses(doms=domains): 1.32 + 1.33 + cisco_set_ip_on_int=""" 1.34 +int fa%s/0 1.35 +duplex full 1.36 +no ip address 1.37 +ip address %s 255.255.255.0 1.38 +no shutdown 1.39 +exit 1.40 +""" 1.41 + 1.42 + quagga_set_ip_on_int=""" 1.43 +int eth%s 1.44 +no ip address 1.45 +ip address %s/24 1.46 +no shutdown 1.47 +exit 1.48 +""" 1.49 + 1.50 + linux_set_ip_on_int=""" 1.51 +ifconfig eth%s %s netmask 255.255.255.0 1.52 +""" 1.53 + 1.54 + for dom in doms: 1.55 + i=domains.index(dom)+1 1.56 + if domain_types[domains.index(dom)] == 'quagga': 1.57 + command = quagga_set_ip_on_int 1.58 + write_to(i,"conf t\n") 1.59 + j=0 1.60 + for br in vbridges_table[dom]: 1.61 + write_to(i,command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i))) 1.62 + j+=1 1.63 + write_to(i,"end\n") 1.64 + elif domain_types[domains.index(dom)] == 'linux': 1.65 + command = linux_set_ip_on_int 1.66 + j=0 1.67 + for br in vbridges_table[dom]: 1.68 + #write_to(i, command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i)) ) 1.69 + print i, command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i)) 1.70 + j+=1 1.71 + else: 1.72 + command = cisco_set_ip_on_int 1.73 + write_to(i,"ena\nconf t\n") 1.74 + j=0 1.75 + for br in vbridges_table[dom]: 1.76 + write_to(i,command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i))) 1.77 + j+=1 1.78 + write_to(i,"end\n") 1.79 + return 0 1.80 + 1.81 +def configure_no_ip_addresses(doms=domains): 1.82 + cisco_set_ip_on_int=""" 1.83 +int fa%s/0 1.84 +no ip address %s 255.255.255.0 1.85 +exit 1.86 +""" 1.87 + quagga_set_ip_on_int=""" 1.88 +int eth%s 1.89 +no ip address %s/24 1.90 +exit 1.91 +""" 1.92 + for dom in doms: 1.93 + i=domains.index(dom)+1 1.94 + if domain_types[domains.index(dom)] == 'quagga': 1.95 + command = quagga_set_ip_on_int 1.96 + write_to(i,"\nconf t\n") 1.97 + j=0 1.98 + for br in vbridges_table[dom]: 1.99 + write_to(i,command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i))) 1.100 + j+=1 1.101 + write_to(i,"\nend\n") 1.102 + else: 1.103 + command = cisco_set_ip_on_int 1.104 + write_to(i,"\n\n\nena\nconf t\n") 1.105 + j=0 1.106 + for br in vbridges_table[dom]: 1.107 + write_to(i,command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i))) 1.108 + j+=1 1.109 + write_to(i,"\nend\n") 1.110 + return 0 1.111 + 1.112 +def configure_ospf(doms=domains): 1.113 + for dom in doms: 1.114 + if domain_types[domains.index(dom)] == 'quagga': 1.115 + write_to(dom,"\n\nconf t\nrouter ospf\nnetwork 192.168.0.0/16 area 0\nend\n") 1.116 + else: 1.117 + write_to(dom,"\n\nena\nconf t\nrouter ospf 1\nnetwork 192.168.0.0 0.0.255.255 area 0\nend\n") 1.118 + return 0 1.119 + 1.120 +def configure_hostname(doms=domains): 1.121 + for dom in doms: 1.122 + if domain_types[domains.index(dom)] == 'quagga': 1.123 + write_to(dom,"\n\nconf t\nhostname %s\nend\n" % dom) 1.124 + else: 1.125 + write_to(dom,"\n\nena\nconf t\nhostname %s\nend\n" % dom) 1.126 + return 0 1.127 + 1.128 +def configure_logging_synchronous(doms=domains): 1.129 + for dom in domains: 1.130 + if domain_types[domains.index(dom)] == 'quagga': 1.131 + 0 1.132 + else: 1.133 + write_to(dom,"\n\nena\nconf t\nline console 0\nlogging synchronous\nend\n") 1.134 + return 0 1.135 + 1.136 +def configure_exec_timeout_0(doms=domains): 1.137 + for dom in domains: 1.138 + if domain_types[domains.index(dom)] == 'quagga': 1.139 + 0 1.140 + else: 1.141 + write_to(dom,"\n\nena\nconf t\nline console 0\nexec-timeout 0\nend\n") 1.142 + return 0 1.143 + 1.144 +def configure_no_cdp_log_mismatch_duplex(doms=domains): 1.145 + for dom in filter_by_type(domains,'dynamips'): 1.146 + write_to(dom,"\n\nena\nconf t\nno cdp log mismatch duplex\nend\n") 1.147 + 1.148 +def configure_save(doms=domains): 1.149 + write_to(doms,"\nwr\n") 1.150 + 1.151 +def configure_root(doms=domains): 1.152 + write_to(doms,"root\n") 1.153 + 1.154 +