#!/usr/bin/env python
# vim: set et sw=4 sts=4 :
+import sys
+
def get_campos(line):
r = []
for c in line.split('\t'):
line = f.readline()
return hosts
-def main(host):
- import sys, pprint
- #pprint.pprint(parse(sys.stdin))
- #sys.exit(1)
+def up(host):
hosts = parse(sys.stdin)
for iface in hosts[host]['ifaces']:
if not iface['iface'].startswith('ppp'):
if ruta['metrica'] <> "0":
print 'route add -net %(ip)s gw %(gateway)s netmask %(mascara)s dev %(iface)s metric %(metrica)s' % ruta
+def down(host):
+ hosts = parse(sys.stdin)
+ for iface in hosts[host]['ifaces']:
+ if not iface['iface'].startswith('ppp'):
+ print 'ifconfig %(iface)s down' % iface
+
if __name__ == '__main__':
- import sys
- main(sys.argv[1])
+ if sys.argv[1] == 'up':
+ up(sys.argv[2])
+ elif sys.argv[1] == 'down':
+ down(sys.argv[2])