Example #1
0
    def on_cancel_interface(self, *args):

        self.hardwarelist.rollback()
        devicelist = NCDeviceList.getDeviceList()
        devicelist.rollback()
        self.toplevel.destroy()
        gtk.main_quit()
    def getConf(self):
        PROGNAME = 'system-config-network'
        import netconfpkg
        from netconfpkg import NC_functions
        NC_functions.prepareRoot(CHROOT)

        from netconfpkg import \
             NCDeviceList, NCProfileList, \
             NCHardwareList, NCIPsecList

        from netconfpkg.NC_functions import log

        NC_functions.setVerboseLevel(0)
        NC_functions.setDebugLevel(0)
        log.set_loglevel(NC_functions.getVerboseLevel())

        devlists = [
            #            NCIPsecList.getIPsecList(),
            NCDeviceList.getDeviceList(),
            NCHardwareList.getHardwareList(),
            NCProfileList.getProfileList(),
        ]

        devstr = ""
        for devlist in devlists:
            devlist.load()
            devstr += str(devlist)
        return devstr
 def on_cancel_interface(self, *args): # pylint: disable-msg=W0613
     hardwarelist = NCHardwareList.getHardwareList()
     hardwarelist.rollback() 
     devicelist = NCDeviceList.getDeviceList()
     devicelist.rollback()   
     self.toplevel.destroy()
     self.canceled = True
     gtk.main_quit()
 def on_raw_ip_activate(self, *args):  # pylint: disable-msg=W0613
     self.xml.get_widget('ipAutomaticRadio').set_active(False)
     self.xml.get_widget('ipStaticRadio').set_active(True)
     self.on_ipBootProto_toggled(\
             self.xml.get_widget('ipAutomaticRadio'))
     self.xml.get_widget('ipAutomaticRadio').set_sensitive(False)
     dialup = self.device.createDialup()
     dialup.EncapMode = 'rawip'
     self.device.Device = getNewDialupDevice(NCDeviceList.getDeviceList(),
                                             self.device)
Example #5
0
 def __init__(self,
              toplevel=None,
              connection_type='Ethernet',
              do_save=1,
              druid=None):
     InterfaceCreator.__init__(self, do_save=do_save)
     self.toplevel = toplevel
     self.topdruid = druid
     self.devicelist = NCDeviceList.getDeviceList()
     self.device = NCPluginDevADSL.DevADSL()
     self.profilelist = NCProfileList.getProfileList()
     self.toplevel = toplevel
     self.connection_type = connection_type
     self.druids = []
     self.xml = None
     self.druid = None
    def on_finish_page_finish(self, druid_page,
                              druid):  # pylint: disable-msg=W0613
        self.device.Device = getNewDialupDevice(NCDeviceList.getDeviceList(),
                                                self.device)
        hardwarelist = NCHardwareList.getHardwareList()

        hardwarelist.commit()
        self.devicelist.append(self.device)
        self.device.commit()
        for prof in self.profilelist:
            if prof.Active == False:
                continue
            prof.ActiveDevices.append(self.device.DeviceId)
            break
        self.profilelist.commit()
        self.devicelist.commit()

        self.save()
        self.toplevel.destroy()
        gtk.main_quit()
Example #7
0
    def on_okButton_clicked(self, button):  # pylint: disable-msg=W0613
        try:
            self.dehydrate()
        except ValueError as e:
            generic_error_dialog(e, self.dialog)
            self.dialog.run()
        devicelist = NCDeviceList.getDeviceList()
        ipseclist = NCIPsecList.getIPsecList()
        dup = None
        for dev in devicelist:
            if dev == self.device:
                continue
            if dev.DeviceId == self.device.DeviceId:
                dup = 1
                break
        else:
            for ipsec in ipseclist:
                if ipsec.IPsecId == self.device.DeviceId:
                    dup = 1
                    break

        if dup:
            generic_error_dialog(
                _("Nickname %s is already in use!\nPlease choose another one.\n"
                  ) % (self.device.DeviceId))
            duplicate = True
            num = 0
            while duplicate:
                devname = self.device.DeviceId + '_' + str(num)
                duplicate = False
                for dev in devicelist:
                    if dev.DeviceId == devname:
                        duplicate = True
                        break
                for ipsec in ipseclist:
                    if ipsec.IPsecId == devname:
                        duplicate = True
                        break
                num = num + 1
            self.device.DeviceId = devname
        return True
    def loadprof(self, pr, profdir):

        devicelist = NCDeviceList.getDeviceList()
        ipseclist = NCIPsecList.getIPsecList()

        prof = Profile()
        self.append(prof)
        prof.ProfileName = pr

        if pr == self.curr_prof:
            prof.Active = True
        else:
            prof.Active = False

        devlist = []

        if profdir:
            devlist = ConfDevices(profdir)

        if not devlist:
            devlist = ConfDevices(getRoot() + OLDSYSCONFDEVICEDIR)

        for dev in devlist:
            for d in devicelist:
                if d.DeviceId == dev:
                    #print >> sys.stderr, "Appending ", d.DeviceId, dev
                    prof.ActiveDevices.append(dev)
                    break

        for ipsec in devlist:
            for d in ipseclist:
                if d.IPsecId == ipsec:
                    prof.ActiveIPsecs.append(ipsec)
                    break

        # CHECK: [198898] new backend for /etc/hosts
        if profdir:
            try:
                prof.HostsList.load(filename=profdir + '/hosts')
            except ValueError, e:
                self.error = str(e)
Example #9
0
    def __init__(self,
                 toplevel=None,
                 connection_type=TOKENRING,
                 do_save=1,
                 druid=None):
        InterfaceCreator.__init__(self, do_save=do_save)
        self.toplevel = toplevel
        self.topdruid = druid
        self.xml = None
        self.devicelist = NCDeviceList.getDeviceList()
        self.device = NCPluginDevTokenRing.DevTokenRing()
        self.device.Type = connection_type
        self.device.OnBoot = True
        self.device.AllowUser = False
        self.device.IPv6Init = False

        self.profilelist = NCProfileList.getProfileList()
        self.toplevel = toplevel
        self.connection_type = connection_type
        self.hw_sel = 0
        self.hwPage = False
        self.druids = []
        self.devlist = []
    def __init__(self,
                 toplevel=None,
                 connection_type=ISDN,
                 do_save=1,
                 druid=None):
        InterfaceCreator.__init__(self, do_save=do_save)

        self.connection_type = connection_type
        df = NCDeviceFactory.getDeviceFactory()
        self.device = df.getDeviceClass(connection_type)()
        self.toplevel = toplevel
        self.druids = []
        self.country = ""
        self.city = ""
        self.name = ""
        self.provider = None
        self.device.BootProto = 'dialup'
        self.device.AutoDNS = True

        self.devicelist = NCDeviceList.getDeviceList()
        self.profilelist = NCProfileList.getProfileList()
        self.xml = None
        self.druid = druid
        self.dbtree = None
Example #11
0
    def dehydrate(self):
        self.device.DeviceId = self.xml.get_widget(
            'providerNameEntry').get_text()
        self.device.DeviceId = re.sub('-', '_', self.device.DeviceId)

        self.device.Type = 'xDSL'
        self.device.BootProto = 'dialup'
        self.device.AllowUser = True
        self.device.IPv6Init = False
        self.device.AutoDNS = True
        dialup = self.device.createDialup()
        hw = self.xml.get_widget("ethernetDeviceEntry").get_text()
        fields = hw.split()
        hw = fields[0]
        dialup.EthDevice = hw
        dialup.ProviderName = self.xml.get_widget(
            "providerNameEntry").get_text()
        dialup.Login = self.xml.get_widget("loginNameEntry").get_text()
        dialup.Password = self.xml.get_widget("passwordEntry").get_text()
        dialup.SyncPPP = False
        self.device.Device = getNewDialupDevice(NCDeviceList.getDeviceList(),
                                                self.device)
        dialup.DefRoute = True
        self.device.AutoDNS = True
        return True


def Usage():
    # FIXME: change string
    print _("system-config-network - network configuration tool\n\n"
            "Usage: system-config-network -v --verbose -d --debug")


if __name__ == '__main__':
    # make ctrl-C work
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    if os.getuid() == 0:
        NCProfileList.updateNetworkScripts()
        NCDeviceList.updateNetworkScripts()
    import getopt

    class BadUsage(Exception):
        pass

    try:
        __opts, __args = getopt.getopt(cmdline, "v?d",
                                       ["verbose", "debug", "help", "root="])
        for __opt, __val in __opts:
            if __opt == '-v' or __opt == '--verbose':
                NC_functions.setVerboseLevel(NC_functions.getVerboseLevel() +
                                             1)
                continue

            if __opt == '-d' or __opt == '--debug':
Example #13
0
 def saveDevices(self):
     from netconfpkg import NCDeviceList
     devicelist = NCDeviceList.getDeviceList()
     devicelist.save()
     devicelist.setunmodified()
    def test(self):
        error = None
        for prof in self:
            try:
                prof.HostsList.test()
            except ValueError, e:
                if not error:
                    error = "Profile: %s \n%s" % (prof.ProfileName, e)
                else:
                    error += str(e)
        if error:
            raise ValueError(error)
        #return
        # Keep that test for later versions
        devmap = {}
        devicelist = NCDeviceList.getDeviceList()

        for prof in self:
            if not prof.Active:
                continue
            for devId in prof.ActiveDevices:
                for dev in devicelist:
                    if dev.DeviceId == devId:
                        device = dev
                        break
                else:
                    continue

                if devmap.has_key(device.Device) and \
                       device.Alias == devmap[device.Device].Alias:
                    msg = (_('Device %s uses the same Hardware Device '
Example #15
0
 def __init__(self):
     self.activedevicelist = []
     self.devicelist = NCDeviceList.getDeviceList()
     self.load()