2 # vim: set et sw=4 sts=4 :
8 for c in line.split('\t'):
9 r.append(c.strip('"\n'))
16 if line.startswith('"tabla de ruteo de '):
20 hosts[host]['ifaces'] = []
21 while line and line.strip() <> '"red"\t"ip"\t"mascara"\t"gateway"\t"interfaz"\t"metrica"':
22 if line.startswith('"'):
23 (iface, ip, mascara, broadcast) = get_campos(line)[:4]
24 hosts[host]['ifaces'].append({
28 'broadcast': broadcast,
32 hosts[host]['rutas'] = []
33 while line and line.strip() <> '"--"':
34 if line.startswith('"'):
35 (red, ip, mascara, gateway, iface, metrica) = get_campos(line)
36 if not metrica: metrica = "1"
37 hosts[host]['rutas'].append({
50 hosts = parse(sys.stdin)
51 for iface in hosts[host]['ifaces']:
52 if not iface['iface'].startswith('ppp'):
53 print 'ifconfig %(iface)s %(ip)s broadcast %(broadcast)s netmask %(mascara)s' % iface
54 for ruta in hosts[host]['rutas']:
55 if ruta['metrica'] <> "0":
56 print 'route add -net %(ip)s gw %(gateway)s netmask %(mascara)s dev %(iface)s metric %(metrica)s' % ruta
59 hosts = parse(sys.stdin)
60 for iface in hosts[host]['ifaces']:
61 if not iface['iface'].startswith('ppp'):
62 print 'ifconfig %(iface)s down' % iface
64 if __name__ == '__main__':
65 if sys.argv[1] == 'up':
67 elif sys.argv[1] == 'down':