except AttributeError:
pass
- print "self.ifaces:", self.ifaces
+ #print "self.ifaces:", self.ifaces
self.loadNetworkConfig()
#self.writeNetworkConfig()
#print ord(' ')
fp = popen("ifconfig " + iface)
result = fp.readlines()
fp.close()
- data = { 'up': False, 'dhcp': False }
+ data = { 'up': False, 'dhcp': False, 'preup' : False, 'postdown' : False }
for line in result:
ip = self.regExpMatch(ipPattern, self.regExpMatch(ipLinePattern, line))
netmask = self.regExpMatch(ipPattern, self.regExpMatch(netmaskLinePattern, line))
if iface['up'] == True:
fp.write("auto " + ifacename + "\n")
self.configuredInterfaces.append(ifacename)
- if iface['dhcp'] == True and iface['up'] == True:
+ if iface['dhcp'] == True:
fp.write("iface "+ ifacename +" inet dhcp\n")
- if iface['dhcp'] == False and iface['up'] == True:
+ if iface['dhcp'] == False:
fp.write("iface "+ ifacename +" inet static\n")
if iface.has_key('ip'):
print tuple(iface['ip'])
fp.write(" gateway %d.%d.%d.%d\n" % tuple(iface['gateway']))
if iface.has_key("configStrings"):
fp.write("\n" + iface["configStrings"] + "\n")
+ if iface["preup"] is not False and not iface.has_key("configStrings"):
+ fp.write(iface["preup"])
+ fp.write(iface["postdown"])
fp.write("\n")
fp.close()
self.writeNameserverConfig()
ifaces[currif]["netmask"] = map(int, split[1].split('.'))
if (split[0] == "gateway"):
ifaces[currif]["gateway"] = map(int, split[1].split('.'))
-
- #self.configuredInterfaces = ifaces
+ if (split[0] == "pre-up"):
+ self.ifaces[currif]["preup"] = i
+ if (split[0] == "post-down"):
+ self.ifaces[currif]["postdown"] = i
+
print "read interfaces:", ifaces
for ifacename, iface in ifaces.items():
if self.ifaces.has_key(ifacename):
self.ifaces[ifacename]["dhcp"] = iface["dhcp"]
-
print "self.ifaces after loading:", self.ifaces
def loadNameserverConfig(self):
def ok(self):
iNetwork.setAdapterAttribute(self.iface, "up", self.activateInterfaceEntry.value)
- if self.activateInterfaceEntry.value is True:
- iNetwork.setAdapterAttribute(self.iface, "dhcp", self.dhcpConfigEntry.value)
- iNetwork.setAdapterAttribute(self.iface, "ip", self.ipConfigEntry.value)
- iNetwork.setAdapterAttribute(self.iface, "netmask", self.netmaskConfigEntry.value)
- if self.hasGatewayConfigEntry.value:
- iNetwork.setAdapterAttribute(self.iface, "gateway", self.gatewayConfigEntry.value)
- else:
- iNetwork.removeAdapterAttribute(self.iface, "gateway")
- if self.extended is not None and self.configStrings is not None:
- iNetwork.setAdapterAttribute(self.iface, "configStrings", self.configStrings(self.iface))
- self.ws.writeConfig()
+ #if self.activateInterfaceEntry.value is True:
+ iNetwork.setAdapterAttribute(self.iface, "dhcp", self.dhcpConfigEntry.value)
+ iNetwork.setAdapterAttribute(self.iface, "ip", self.ipConfigEntry.value)
+ iNetwork.setAdapterAttribute(self.iface, "netmask", self.netmaskConfigEntry.value)
+ if self.hasGatewayConfigEntry.value:
+ iNetwork.setAdapterAttribute(self.iface, "gateway", self.gatewayConfigEntry.value)
else:
- iNetwork.removeAdapterAttribute(self.iface, "ip")
- iNetwork.removeAdapterAttribute(self.iface, "netmask")
iNetwork.removeAdapterAttribute(self.iface, "gateway")
+ if self.extended is not None and self.configStrings is not None:
+ iNetwork.setAdapterAttribute(self.iface, "configStrings", self.configStrings(self.iface))
+ self.ws.writeConfig()
+ #else:
+ # iNetwork.removeAdapterAttribute(self.iface, "ip")
+ # iNetwork.removeAdapterAttribute(self.iface, "netmask")
+ # iNetwork.removeAdapterAttribute(self.iface, "gateway")
+ # iNetwork.deactivateInterface(self.iface)
+ if self.activateInterfaceEntry.value is False:
iNetwork.deactivateInterface(self.iface)
-
iNetwork.deactivateNetworkConfig()
iNetwork.writeNetworkConfig()
iNetwork.activateNetworkConfig()