Пример #1
0
    def test03Profile(self):
        """Test profile removal"""
        self.redirectStd()
        from netconfpkg import NC_functions
        NC_functions.prepareRoot(CHROOT)
        devstr = self.getConf()

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

        from netconfpkg.NC_functions import log
        profilelist = NCProfileList.getProfileList()
        NC_functions.setVerboseLevel(0)
        NC_functions.setDebugLevel(0)
        log.set_loglevel(NC_functions.getVerboseLevel())

        profilelist.remove(profilelist.getActiveProfile())
        profilelist.switchToProfile('default')
        profilelist.commit()
        self.save()
        NC_functions.setVerboseLevel(0)
        NC_functions.setDebugLevel(0)
        devstr = self.getConf()
        self.redirectEnd()
        expect = BASICSETUP
        self.failUnless(expectConf(expect, devstr))
Пример #2
0
    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
Пример #3
0
 def save(self):
     from netconfpkg import NCProfileList
     profilelist = NCProfileList.getProfileList()
     profilelist.fixInterfaces()
     self.saveHardware()
     self.saveDevices()
     self.saveIPsecs()
     self.saveProfiles()
Пример #4
0
    def dehydrate(self):
        profilelist = NCProfileList.getProfileList()

        for prof in profilelist:
            if prof.Active == True:
                index = prof.DNS.SearchList.index(self.Name)
                n = self.xml.get_widget("domainNameEntry").get_text()

                if len(n.strip()) == 0:
                    del prof.DNS.SearchList[index]
                else:
                    prof.DNS.SearchList[index] = n

                self.hydrate()
                prof.DNS.SearchList.commit()
Пример #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
Пример #6
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 = []
Пример #7
0
    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
            return 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
Пример #9
0
    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:]
Пример #10
0
 def saveProfiles(self):
     from netconfpkg import NCProfileList
     profilelist = NCProfileList.getProfileList()
     profilelist.save()
     profilelist.setunmodified()
Пример #11
0
    def test02Profile(self):
        """Test profile creation """
        #self.clearModules()
        self.setupChroot()
        self.redirectStd()
        from netconfpkg import NC_functions
        NC_functions.prepareRoot(CHROOT)
        NC_functions.updateNetworkScripts(True)

        from netconfpkg import NCProfileList
        from netconfpkg.NCProfile import Profile
        profilelist = NCProfileList.getProfileList()

        text = "newprofile"
        prof = Profile()
        profilelist.append(prof)
        prof.apply(profilelist[0])
        prof.ProfileName = text
        prof.commit()
        profilelist.switchToProfile(prof, dochange=True)
        self.save()

        devstr = self.getConf()
        expect = """DeviceList.Ethernet.eth0.AllowUser=False
DeviceList.Ethernet.eth0.AutoDNS=True
DeviceList.Ethernet.eth0.BootProto=dhcp
DeviceList.Ethernet.eth0.Device=eth0
DeviceList.Ethernet.eth0.DeviceId=eth0
DeviceList.Ethernet.eth0.IPv6Init=False
DeviceList.Ethernet.eth0.NMControlled=False
DeviceList.Ethernet.eth0.OnBoot=True
DeviceList.Ethernet.eth0.Type=Ethernet
DeviceList.ISDN.1net4you0.AllowUser=True
DeviceList.ISDN.1net4you0.AutoDNS=True
DeviceList.ISDN.1net4you0.BootProto=dialup
DeviceList.ISDN.1net4you0.Device=ippp0
DeviceList.ISDN.1net4you0.DeviceId=1net4you0
DeviceList.ISDN.1net4you0.Dialup.Authentication=+pap -chap
DeviceList.ISDN.1net4you0.Dialup.ChannelBundling=False
DeviceList.ISDN.1net4you0.Dialup.Compression.AdressControl=False
DeviceList.ISDN.1net4you0.Dialup.Compression.BSD=False
DeviceList.ISDN.1net4you0.Dialup.Compression.CCP=False
DeviceList.ISDN.1net4you0.Dialup.Compression.ProtoField=False
DeviceList.ISDN.1net4you0.Dialup.Compression.VJID=False
DeviceList.ISDN.1net4you0.Dialup.Compression.VJTcpIp=False
DeviceList.ISDN.1net4you0.Dialup.DefRoute=True
DeviceList.ISDN.1net4you0.Dialup.DialMode=manual
DeviceList.ISDN.1net4you0.Dialup.EncapMode=syncppp
DeviceList.ISDN.1net4you0.Dialup.HangupTimeout=600
DeviceList.ISDN.1net4you0.Dialup.Login=web
DeviceList.ISDN.1net4you0.Dialup.Password=
DeviceList.ISDN.1net4you0.Dialup.Persist=False
DeviceList.ISDN.1net4you0.Dialup.PhoneNumber=019256252
DeviceList.ISDN.1net4you0.Dialup.ProviderName=1net4you
DeviceList.ISDN.1net4you0.Dialup.Secure=False
DeviceList.ISDN.1net4you0.IPv6Init=False
DeviceList.ISDN.1net4you0.OnBoot=False
DeviceList.ISDN.1net4you0.Type=ISDN
DeviceList.Modem.1net4you.AllowUser=True
DeviceList.Modem.1net4you.AutoDNS=True
DeviceList.Modem.1net4you.BootProto=dialup
DeviceList.Modem.1net4you.Device=ppp0
DeviceList.Modem.1net4you.DeviceId=1net4you
DeviceList.Modem.1net4you.Dialup.Compression.AdressControl=False
DeviceList.Modem.1net4you.Dialup.Compression.BSD=False
DeviceList.Modem.1net4you.Dialup.Compression.CCP=False
DeviceList.Modem.1net4you.Dialup.Compression.ProtoField=False
DeviceList.Modem.1net4you.Dialup.Compression.VJID=False
DeviceList.Modem.1net4you.Dialup.Compression.VJTcpIp=False
DeviceList.Modem.1net4you.Dialup.DefRoute=True
DeviceList.Modem.1net4you.Dialup.DialMode=manual
DeviceList.Modem.1net4you.Dialup.Inherits=Modem0
DeviceList.Modem.1net4you.Dialup.HangupTimeout=600
DeviceList.Modem.1net4you.Dialup.Login=web
DeviceList.Modem.1net4you.Dialup.Password=web
DeviceList.Modem.1net4you.Dialup.Persist=False
DeviceList.Modem.1net4you.Dialup.PhoneNumber=019256252
DeviceList.Modem.1net4you.Dialup.ProviderName=1net4you
DeviceList.Modem.1net4you.Dialup.StupidMode=True
DeviceList.Modem.1net4you.IPv6Init=False
DeviceList.Modem.1net4you.OnBoot=False
DeviceList.Modem.1net4you.Type=Modem
DeviceList.TokenRing.tr0.AllowUser=False
DeviceList.TokenRing.tr0.AutoDNS=True
DeviceList.TokenRing.tr0.BootProto=dhcp
DeviceList.TokenRing.tr0.Device=tr0
DeviceList.TokenRing.tr0.DeviceId=tr0
DeviceList.TokenRing.tr0.IPv6Init=False
DeviceList.TokenRing.tr0.OnBoot=True
DeviceList.TokenRing.tr0.Type=TokenRing
DeviceList.Wireless.eth3.AllowUser=False
DeviceList.Wireless.eth3.AutoDNS=True
DeviceList.Wireless.eth3.BootProto=dhcp
DeviceList.Wireless.eth3.Device=eth3
DeviceList.Wireless.eth3.DeviceId=eth3
DeviceList.Wireless.eth3.IPv6Init=False
DeviceList.Wireless.eth3.OnBoot=False
DeviceList.Wireless.eth3.Type=Wireless
DeviceList.Wireless.eth3.Wireless.Channel=1
DeviceList.Wireless.eth3.Wireless.EssId=
DeviceList.Wireless.eth3.Wireless.Key=
DeviceList.Wireless.eth3.Wireless.Mode=Auto
DeviceList.Wireless.eth3.Wireless.Rate=auto
HardwareList.Ethernet.eth0.Card.ModuleName=3c501
HardwareList.Ethernet.eth0.Description=3c501
HardwareList.Ethernet.eth0.Name=eth0
HardwareList.Ethernet.eth0.Status=configured
HardwareList.Ethernet.eth0.Type=Ethernet
HardwareList.Ethernet.eth1.Card.ModuleName=3c501
HardwareList.Ethernet.eth1.Description=3c501
HardwareList.Ethernet.eth1.Name=eth1
HardwareList.Ethernet.eth1.Status=configured
HardwareList.Ethernet.eth1.Type=Ethernet
HardwareList.Ethernet.eth2.Card.ModuleName=3c501
HardwareList.Ethernet.eth2.Description=3c501
HardwareList.Ethernet.eth2.Name=eth2
HardwareList.Ethernet.eth2.Status=configured
HardwareList.Ethernet.eth2.Type=Ethernet
HardwareList.Ethernet.eth3.Card.ModuleName=3c501
HardwareList.Ethernet.eth3.Description=3c501
HardwareList.Ethernet.eth3.Name=eth3
HardwareList.Ethernet.eth3.Status=configured
HardwareList.Ethernet.eth3.Type=Ethernet
HardwareList.ISDN.ISDN Card 0.Card.ChannelProtocol=2
HardwareList.ISDN.ISDN Card 0.Card.DeviceId=
HardwareList.ISDN.ISDN Card 0.Card.DriverId=HiSax
HardwareList.ISDN.ISDN Card 0.Card.Firmware=
HardwareList.ISDN.ISDN Card 0.Card.IRQ=5
HardwareList.ISDN.ISDN Card 0.Card.IoPort1=
HardwareList.ISDN.ISDN Card 0.Card.IoPort2=
HardwareList.ISDN.ISDN Card 0.Card.IoPort=0x300
HardwareList.ISDN.ISDN Card 0.Card.Mem=
HardwareList.ISDN.ISDN Card 0.Card.ModuleName=hisax
HardwareList.ISDN.ISDN Card 0.Card.Type=30
HardwareList.ISDN.ISDN Card 0.Card.VendorId=
HardwareList.ISDN.ISDN Card 0.Description=ACER P10
HardwareList.ISDN.ISDN Card 0.Name=ISDN Card 0
HardwareList.ISDN.ISDN Card 0.Status=configured
HardwareList.ISDN.ISDN Card 0.Type=ISDN
HardwareList.Modem.Modem0.Description=Generic Modem
HardwareList.Modem.Modem0.Modem.BaudRate=115200
HardwareList.Modem.Modem0.Modem.DeviceName=/dev/modem
HardwareList.Modem.Modem0.Modem.DialCommand=ATDT
HardwareList.Modem.Modem0.Modem.FlowControl=CRTSCTS
HardwareList.Modem.Modem0.Modem.InitString=ATZ
HardwareList.Modem.Modem0.Modem.ModemVolume=0
HardwareList.Modem.Modem0.Name=Modem0
HardwareList.Modem.Modem0.Status=configured
HardwareList.Modem.Modem0.Type=Modem
HardwareList.TokenRing.tr0.Card.ModuleName=olympic
HardwareList.TokenRing.tr0.Description=olympic
HardwareList.TokenRing.tr0.Name=tr0
HardwareList.TokenRing.tr0.Status=configured
HardwareList.TokenRing.tr0.Type=TokenRing
ProfileList.default.Active=False
ProfileList.default.ActiveDevices.1=1net4you
ProfileList.default.ActiveDevices.2=1net4you0
ProfileList.default.ActiveDevices.3=eth0
ProfileList.default.ActiveDevices.4=eth3
ProfileList.default.ActiveDevices.5=tr0
ProfileList.default.DNS.Domainname=
ProfileList.default.DNS.Hostname=test
ProfileList.default.DNS.PrimaryDNS=1.1.1.1
ProfileList.default.DNS.SearchList.1=home
ProfileList.default.DNS.SecondaryDNS=2.2.2.2
ProfileList.default.DNS.TertiaryDNS=3.3.3.3
ProfileList.default.HostsList.1.AliasList.1=localhost
ProfileList.default.HostsList.1.Hostname=localhost.localdomain
ProfileList.default.HostsList.1.IP=127.0.0.1
ProfileList.default.HostsList.2.AliasList.1=localhost6
ProfileList.default.HostsList.2.Hostname=localhost6.localdomain6
ProfileList.default.HostsList.2.IP=::1
ProfileList.default.HostsList.3.AliasList.1=test1
ProfileList.default.HostsList.3.AliasList.2=test2
ProfileList.default.HostsList.3.Hostname=test
ProfileList.default.HostsList.3.IP=10.1.1.1
ProfileList.default.ProfileName=default
ProfileList.newprofile.Active=True
ProfileList.newprofile.ActiveDevices.1=1net4you
ProfileList.newprofile.ActiveDevices.2=1net4you0
ProfileList.newprofile.ActiveDevices.3=eth0
ProfileList.newprofile.ActiveDevices.4=eth3
ProfileList.newprofile.ActiveDevices.5=tr0
ProfileList.newprofile.DNS.Domainname=
ProfileList.newprofile.DNS.Hostname=test
ProfileList.newprofile.DNS.PrimaryDNS=1.1.1.1
ProfileList.newprofile.DNS.SearchList.1=home
ProfileList.newprofile.DNS.SecondaryDNS=2.2.2.2
ProfileList.newprofile.DNS.TertiaryDNS=3.3.3.3
ProfileList.newprofile.HostsList.1.AliasList.1=localhost
ProfileList.newprofile.HostsList.1.Hostname=localhost.localdomain
ProfileList.newprofile.HostsList.1.IP=127.0.0.1
ProfileList.newprofile.HostsList.2.AliasList.1=localhost6
ProfileList.newprofile.HostsList.2.Hostname=localhost6.localdomain6
ProfileList.newprofile.HostsList.2.IP=::1
ProfileList.newprofile.HostsList.3.AliasList.1=test1
ProfileList.newprofile.HostsList.3.AliasList.2=test2
ProfileList.newprofile.HostsList.3.Hostname=test
ProfileList.newprofile.HostsList.3.IP=10.1.1.1
ProfileList.newprofile.ProfileName=newprofile
"""
        self.redirectEnd()
        self.failUnless(expectConf(devstr, expect))