def addDeviceType(self, mtype): df = getDeviceFactory() devclass = df.getDeviceClass(mtype) if devclass: newdev = devclass() self.append(newdev) # else: # FIXME: !! # generic_error_dialog() return newdev
def newDevice(self, mscreen): """ Displays the main screen @screen The snack screen instance """ t = snack.TextboxReflowed(25, _("Which device type do you want to add?")) bb = snack.ButtonBar(mscreen, ((_("Add"), "add"), (_("Cancel"), "cancel"))) li = snack.Listbox(5, width=25, returnExit=1) li.append(_("Ethernet"), ETHERNET) machine = os.uname()[4] if machine == 's390' or machine == 's390x': li.append(_("QETH"), QETH) else: li.append(_("Modem"), MODEM) li.append(_("ISDN"), ISDN) g = snack.GridForm(mscreen, _("Network Configuration"), 1, 3) g.add(t, 0, 0) g.add(li, 0, 1) g.add(bb, 0, 2) res = g.run() mscreen.popWindow() if bb.buttonPressed(res) != 'cancel': todo = li.current() df = getDeviceFactory() dev = None devclass = df.getDeviceClass(todo) devlist = getDeviceList() if not devclass: return -1 dev = devclass() if dev: devlist.append(dev) return dev return -2
def load(self): from netconfpkg.NCDevice import ConfDevice updateNetworkScripts() self.__delslice__(0, len(self)) df = getDeviceFactory() devdir = getRoot() + SYSCONFDEVICEDIR devices = [] log.log(5, "Checking %s" % devdir) if os.path.isdir(devdir): devices = ConfDevices() if not devices: log.log(5, "Checking %s" % devdir) devdir = getRoot() + OLDSYSCONFDEVICEDIR devices = ConfDevices(devdir) for dev in devices: log.log(5, "Checking %s" % dev) if dev == 'lo': continue conf = ConfDevice(dev, devdir) mtype = None device = None # take a peek in the config file if conf.has_key("TYPE"): mtype = conf["TYPE"] if conf.has_key("DEVICE"): device = conf["DEVICE"] if conf.has_key("NETTYPE"): if conf["NETTYPE"] == "qeth": mtype = QETH if conf["NETTYPE"] == "lcs": mtype = LCS del conf if mtype == "IPSEC": continue if not mtype or mtype == "" or mtype == _("Unknown"): from netconfpkg import NCHardwareList hwlist = NCHardwareList.getHardwareList() for hw in hwlist: if hw.Name == device: mtype = hw.Type break else: mtype = getDeviceType(device) devclass = df.getDeviceClass(mtype) if devclass: newdev = devclass() newdev.load(dev) self.append(newdev) # try: # newdev.load(dev) # except BaseException, e: # # FIXME: better exception handling # generic_error_dialog (_("Error loading file %s\n%s") # % (devdir + # "/ifcfg-" + dev, str(e)), # dialog_type="error") # else: # self.append(newdev) else: log.log(1, "NO DEVICE CLASS FOUND FOR %s" % dev) d = Device() self.append(d) d.load(dev) self.commit() self.setunmodified() chdev = {} # the initscripts do not like '-' for dev in self: newDeviceId = re.sub('-', '_', dev.DeviceId) if newDeviceId != dev.DeviceId: chdev[dev.DeviceId] = newDeviceId #log.log(4, "%s != %s" % (newDeviceId, dev.DeviceId)) # Fixed change device names in active list of all profiles import netconfpkg.NCProfileList profilelist = netconfpkg.NCProfileList.getProfileList() for prof in profilelist: #log.log(4, str(prof.ActiveDevices)) if dev.DeviceId in prof.ActiveDevices: pos = prof.ActiveDevices.index(dev.DeviceId) prof.ActiveDevices[pos] = newDeviceId #log.log(4, "changed %s" % (prof.ActiveDevices[pos])) #log.log(4, str(prof.ActiveDevices)) prof.commit() dev.DeviceId = newDeviceId dev.commit() dev.setunmodified() if len(chdev.keys()): s = _("Changed the following Nicknames due to the initscripts:\n") for n, d in chdev.items(): s += "%s -> %s\n" % (n, d) generic_longinfo_dialog(_("Nicknames changed"), s)
def __init__(self, parent_dialog = None): self.creator = None glade_file = 'NewInterfaceDruid.glade' if not os.path.isfile(glade_file): glade_file = GUI_functions.GLADEPATH + glade_file if not os.path.isfile(glade_file): glade_file = NETCONFDIR + glade_file self.xml = gtk.glade.XML (glade_file, 'toplevel', domain=GUI_functions.PROGNAME) # get the widgets we need self.toplevel = self.xml.get_widget ('toplevel') self.druid = self.xml.get_widget ('druid') self.start_page = self.xml.get_widget('start_page') self.interface_clist = self.xml.get_widget ('interface_clist') self.description_label = self.xml.get_widget ('description_label') if parent_dialog: self.toplevel.set_transient_for(parent_dialog) self.toplevel.set_position (gtk.WIN_POS_CENTER_ON_PARENT) else: self.toplevel.set_position (gtk.WIN_POS_CENTER) xml_signal_autoconnect (self.xml, { 'on_toplevel_delete_event' : self.on_cancel_interface, 'on_druid_cancel' : self.on_cancel_interface, 'on_start_page_prepare' : self.on_start_page_prepare, 'on_start_page_next' : self.on_start_page_next, 'on_interface_clist_select_row' : \ self.on_interface_clist_select_row, }) load_icon("network.xpm", self.toplevel) # Initialize the clist self.interface_clist.column_titles_passive () self.interface_clist.set_row_height(20) self.interface_clist.clear() interfaces = [] df = getDeviceFactory() dfk = df.keys() dfk.sort() for mtype in dfk: i = df.getDeviceClass(mtype)().getWizard() if i: interfaces.append(i) for iface_creator in interfaces: iface = iface_creator (self.toplevel, do_save = None, druid = self.druid) iftype = iface.get_type() row = self.interface_clist.append ( \ [ iface.get_project_name () ] ) device_pixmap, device_mask = \ GUI_functions.get_device_icon_mask(iftype, self.toplevel) self.interface_clist.set_pixtext (row, 0, iface.get_project_name (), 5, device_pixmap, device_mask) self.interface_clist.set_row_data (row, iface) self.canceled = False self.interface_clist.select_row (0, 0) self.toplevel.show_all () self.on_start_page_prepare (None, None)
def register_plugin(): _df = getDeviceFactory() _df.register(DevEthernet)
def init_gui(self): # pylint: disable-msg=W0201 if self.xml: return glade_file = "sharedtcpip.glade" if not os.path.exists(glade_file): glade_file = GLADEPATH + glade_file if not os.path.exists(glade_file): glade_file = NETCONFDIR + glade_file self.sharedtcpip_xml = gtk.glade.XML(glade_file, None, domain=PROGNAME) glade_file = 'QethInterfaceDruid.glade' if not os.path.exists(glade_file): glade_file = GLADEPATH + glade_file if not os.path.exists(glade_file): glade_file = NETCONFDIR + glade_file self.xml = gtk.glade.XML(glade_file, 'druid', domain=PROGNAME) xml_signal_autoconnect(self.xml, { "on_hostname_config_page_back" : \ self.on_hostname_config_page_back, "on_hostname_config_page_next" : \ self.on_hostname_config_page_next, "on_hostname_config_page_prepare" : \ self.on_hostname_config_page_prepare, "on_hw_config_page_back" : self.on_hw_config_page_back, "on_hw_config_page_next" : self.on_hw_config_page_next, "on_hw_config_page_prepare" : self.on_hw_config_page_prepare, "on_finish_page_finish" : self.on_finish_page_finish, "on_finish_page_prepare" : self.on_finish_page_prepare, "on_finish_page_back" : self.on_finish_page_back } ) #print "EthernetInterface getDeviceList" self.devicelist = getDeviceList() df = getDeviceFactory() devclass = df.getDeviceClass(self.connection_type) if devclass: self.device = devclass() else: self.device = NCPluginDevQeth.DevQeth() self.device.Type = self.connection_type self.device.OnBoot = True self.device.AllowUser = False self.device.IPv6Init = False self.profilelist = NCProfileList.getProfileList() self.hw_sel = 0 self.hwPage = False window = self.sharedtcpip_xml.get_widget('dhcpWindow') frame = self.sharedtcpip_xml.get_widget('dhcpFrame') vbox = self.xml.get_widget('generalVbox') window.remove(frame) vbox.pack_start(frame) sharedtcpip.dhcp_init(self.sharedtcpip_xml, self.device) self.druids = [] self.druid = self.xml.get_widget('druid') for i in self.druid.get_children(): self.druid.remove(i) self.druids.append(i) if self.connection_type == QETH: self.hwDruid = QethHardware(self.toplevel) self.hwDruid.has_ethernet = None self.druids = [self.druids[0]] + self.hwDruid.druids[:]\ + self.druids[1:]
def register_plugin(): __df = getDeviceFactory() __df.register(DevModem, MODEM)
and hw.Card.IoPort1 and hw.Card.IoPort2): os.system( 'SUBSYSTEM="ccw" DEVPATH="bus/ccwgroup/drivers/lcs/%s" /lib/udev/ccw_init' % hw.Card.IoPort) break return DevEthernet.activate(self, dialog) def setDevLcsDialog(dialog): """Set the lcs dialog class""" global _devLcsDialog _devLcsDialog = dialog def setDevLcsWizard(wizard): """Set the lcs wizard class""" global _devLcsWizard _devLcsWizard = wizard import os machine = os.uname()[4] if machine == 's390' or machine == 's390x': _df = getDeviceFactory() _df.register(DevLcs, LCS) del _df __author__ = "Harald Hoyer <*****@*****.**>"
def register_plugin(): __df = getDeviceFactory() __df.register(DevTokenRing, TOKENRING)
def register_plugin(): df = getDeviceFactory() df.register(DevADSL, DSL)
def register_plugin(): __df = getDeviceFactory() __df.register(DevWireless, WIRELESS)