example:
where = PluginDescriptor.WHERE_NETWORKSETUP, fnc={"ifaceSupported": callFunction, "configStrings": configStrings}
with
def PluginFunction(session, iface):
session.open(<MainPlugin>, iface)
def callFunction(iface):
if <iface is supported by plugin>:
return PluginFunction
else:
return None
def configSrings(iface):
return "# would add this to adapter iface into /etc/networking/interfaces"
fp.write(" netmask %d.%d.%d.%d\n" % tuple(iface['netmask']))
if iface.has_key('gateway'):
fp.write(" gateway %d.%d.%d.%d\n" % tuple(iface['gateway']))
fp.write(" netmask %d.%d.%d.%d\n" % tuple(iface['netmask']))
if iface.has_key('gateway'):
fp.write(" gateway %d.%d.%d.%d\n" % tuple(iface['gateway']))
+
+ if iface.has_key("configStrings"):
+ fp.write("\n" + iface["configStrings"] + "\n")
fp.write("\n")
fp.close()
self.writeNameserverConfig()
fp.write("\n")
fp.close()
self.writeNameserverConfig()
return None
def setAdapterAttribute(self, iface, attribute, value):
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
if self.ifaces.has_key(iface):
self.ifaces[iface][attribute] = value
self.extended = None
for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
self.extended = None
for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
- callFnc = p.__call__(self.iface)
+ callFnc = p.__call__["ifaceSupported"](self.iface)
if callFnc is not None:
self.extended = callFnc
if callFnc is not None:
self.extended = callFnc
+ print p.__call__
+ if p.__call__.has_key("configStrings"):
+ self.configStrings = p.__call__["configStrings"]
+ else:
+ self.configStrings = None
self.extendedSetup = getConfigListEntry(_('Extended Setup...'), NoSave(ConfigNothing()))
self.list.append(self.extendedSetup)
self.extendedSetup = getConfigListEntry(_('Extended Setup...'), NoSave(ConfigNothing()))
self.list.append(self.extendedSetup)
iNetwork.setAdapterAttribute(self.iface, "gateway", self.gatewayConfigEntry.value)
else:
iNetwork.removeAdapterAttribute(self.iface, "gateway")
iNetwork.setAdapterAttribute(self.iface, "gateway", self.gatewayConfigEntry.value)
else:
iNetwork.removeAdapterAttribute(self.iface, "gateway")
+
+ print "self.extended:", self.extended
+ print "self.configStrings:", self.configStrings
+ if self.extended is not None and self.configStrings is not None:
+ iNetwork.setAdapterAttribute(self.iface, "configStrings", self.configStrings(self.iface))
+
iNetwork.deactivateNetworkConfig()
iNetwork.writeNetworkConfig()
iNetwork.activateNetworkConfig()
iNetwork.deactivateNetworkConfig()
iNetwork.writeNetworkConfig()
iNetwork.activateNetworkConfig()