+ def getNumberOfAdapters(self):
+ return len(self.ifaces)
+
+ def getFriendlyAdapterName(self, x):
+ # maybe this needs to be replaced by an external list.
+ friendlyNames = {
+ "eth0": _("Integrated Ethernet"),
+ "wlan0": _("Wireless"),
+ "ath0": _("Integrated Wireless")
+ }
+ return friendlyNames.get(x, x) # when we have no friendly name, use adapter name
+
+ def getAdapterName(self, iface):
+ return iface
+
+ def getAdapterList(self):
+ return self.ifaces.keys()
+
+ def getAdapterAttribute(self, iface, attribute):
+ if self.ifaces.has_key(iface):
+ if self.ifaces[iface].has_key(attribute):
+ return self.ifaces[iface][attribute]
+ return None
+
+ def setAdapterAttribute(self, iface, attribute, value):
+ print "setting for adapter", iface, "attribute", attribute, " to value", value
+ if self.ifaces.has_key(iface):
+ self.ifaces[iface][attribute] = value
+
+ def removeAdapterAttribute(self, iface, attribute):
+ if self.ifaces.has_key(iface):
+ if self.ifaces[iface].has_key(attribute):
+ del self.ifaces[iface][attribute]
+
+ def getNameserverList(self):
+ if len(self.nameservers) == 0:
+ return [[0, 0, 0, 0], [0, 0, 0, 0]]
+ else:
+ return self.nameservers
+
+ def clearNameservers(self):
+ self.nameservers = []
+
+ def addNameserver(self, nameserver):
+ if nameserver not in self.nameservers:
+ self.nameservers.append(nameserver)
+
+ def removeNameserver(self, nameserver):
+ if nameserver in self.nameservers:
+ self.nameservers.remove(nameserver)
+
+ def changeNameserver(self, oldnameserver, newnameserver):
+ if oldnameserver in self.nameservers:
+ for i in range(len(self.nameservers)):
+ if self.nameservers[i] == oldnameserver:
+ self.nameservers[i] = newnameserver
+
+ def resetNetworkConfig(self, mode='lan', callback = None):
+ self.resetNetworkConsole = Console()
+ self.commands = []
+ self.commands.append("/etc/init.d/avahi-daemon stop")
+ for iface in self.ifaces.keys():
+ cmd = "ip addr flush " + iface
+ self.commands.append(cmd)
+ self.commands.append("/etc/init.d/networking stop")
+ self.commands.append("killall -9 udhcpc")
+ self.commands.append("rm /var/run/udhcpc*")
+ self.resetNetworkConsole.eBatch(self.commands, self.resetNetworkFinishedCB, [mode, callback], debug=True)
+
+ def resetNetworkFinishedCB(self, extra_args):
+ (mode, callback) = extra_args
+ if len(self.resetNetworkConsole.appContainers) == 0:
+ self.writeDefaultNetworkConfig(mode, callback)