|
13 |
iface lo inet loopback |
13 |
iface lo inet loopback |
14 |
|
14 |
|
15 |
@!@ |
15 |
@!@ |
|
|
16 |
INTERFACE_TYPES = ['eth', 'br'] |
17 |
devices = [] |
16 |
|
18 |
|
17 |
eth_devices=[] |
19 |
for type in INTERFACE_TYPES: |
|
|
20 |
vars()['%s_devices' % type] = [] |
18 |
|
21 |
|
19 |
for key,value in configRegistry.items(): |
22 |
for key,value in configRegistry.items(): |
20 |
if key.startswith('interfaces/eth'): |
23 |
for type in INTERFACE_TYPES: |
21 |
k = key.split("/")[1:2][0] |
24 |
if key.startswith('interfaces/%s' % type): |
22 |
if k not in eth_devices: |
25 |
k = key.split("/")[1:2][0] |
23 |
eth_devices.append(k) |
26 |
if k not in vars()['%s_devices' % type]: |
|
|
27 |
vars()['%s_devices' % type].append(k) |
24 |
|
28 |
|
25 |
eth_devices.sort() |
29 |
for type in INTERFACE_TYPES: |
|
|
30 |
vars()['%s_devices' % type].sort() |
31 |
devices.extend( vars()['%s_devices' % type] ) |
26 |
|
32 |
|
27 |
def check_gateway (ip, netmask, gateway): |
33 |
def check_gateway (ip, netmask, gateway): |
28 |
if not gateway: |
34 |
if not gateway: |
|
36 |
if samenet == 1: |
42 |
if samenet == 1: |
37 |
return 1 |
43 |
return 1 |
38 |
|
44 |
|
39 |
|
|
|
40 |
gateway=False |
45 |
gateway=False |
41 |
configExists=False |
46 |
configExists=False |
42 |
ifhandler=configRegistry.get('interfaces/handler','ifplugd') |
47 |
ifhandler=configRegistry.get('interfaces/handler','ifplugd') |
43 |
|
48 |
|
44 |
|
49 |
for i in devices: |
45 |
for i in eth_devices: |
|
|
46 |
configExists=False |
50 |
configExists=False |
47 |
iface = i.replace("_", ":") |
51 |
iface = i.replace("_", ":") |
48 |
if configRegistry.has_key('interfaces/%s/type' % i) and configRegistry['interfaces/%s/type' % i] == 'dhcp': |
52 |
if configRegistry.has_key('interfaces/%s/type' % i) and configRegistry['interfaces/%s/type' % i] == 'dhcp': |
|
54 |
print 'auto %s' % iface |
58 |
print 'auto %s' % iface |
55 |
print 'iface %s inet dhcp' % iface |
59 |
print 'iface %s inet dhcp' % iface |
56 |
configExists=True |
60 |
configExists=True |
57 |
elif configRegistry['interfaces/%s/address' % i]: |
61 |
elif configRegistry['interfaces/%s/address' % i]: |
58 |
print 'auto %s' % iface |
62 |
print 'auto %s' % iface |
59 |
print 'iface %s inet static' % iface |
63 |
print 'iface %s inet static' % iface |
60 |
|
64 |
|
|
70 |
print 'gateway '+configRegistry['gateway'] |
74 |
print 'gateway '+configRegistry['gateway'] |
71 |
gateway=True |
75 |
gateway=True |
72 |
configExists=True |
76 |
configExists=True |
|
|
77 |
elif iface.startswith('br') and configRegistry.get('interfaces/%s/type' % i, '') == 'manual': |
78 |
print 'auto %s' % iface |
79 |
print 'iface %s inet %s' % (iface, configRegistry.get('interfaces/%s/type' % i)) |
80 |
configExists=True |
73 |
|
81 |
|
74 |
if configExists: |
82 |
if configExists: |
75 |
for key,value in configRegistry.items(): |
83 |
for key,value in configRegistry.items(): |
|
80 |
for key,value in configRegistry.items(): |
88 |
for key,value in configRegistry.items(): |
81 |
if key.startswith('interfaces/%s/options/' % i): |
89 |
if key.startswith('interfaces/%s/options/' % i): |
82 |
print value |
90 |
print value |
|
|
91 |
if key.startswith('interfaces/%s/bridge/' % i): |
92 |
print 'bridge_%s %s' % (key.split('/')[3], value) |
93 |
|
83 |
if i == "eth0": |
94 |
if i == "eth0": |
84 |
if configRegistry.get('interfaces/eth0/netmask', "") == "255.255.255.255" and configRegistry.get('gateway', False): |
95 |
if configRegistry.get('interfaces/eth0/netmask', "") == "255.255.255.255" and configRegistry.get('gateway', False): |
85 |
print "up ip route add %s/32 dev eth0" % configRegistry["gateway"] |
96 |
print "up ip route add %s/32 dev eth0" % configRegistry["gateway"] |
86 |
print "up route add default gw %s" % configRegistry["gateway"] |
97 |
print "up route add default gw %s" % configRegistry["gateway"] |
87 |
|
|
|
88 |
@!@ |
98 |
@!@ |