예제 #1
0
    def _update_network_data(self):
        hostname = self.data.network.hostname

        self.data.network.network = []
        for i, name in enumerate(nm.nm_devices()):
            if network.is_ibft_configured_device(name):
                continue
            nd = network.ksdata_from_ifcfg(name)
            if not nd:
                continue
            if name in nm.nm_activated_devices():
                nd.activate = True
            else:
                # First network command defaults to --activate so we must
                # use --no-activate explicitly to prevent the default
                if i == 0:
                    nd.activate = False
            self.data.network.network.append(nd)

        (valid, error) = network.sanityCheckHostname(self.hostname_dialog.value)
        if valid:
            hostname = self.hostname_dialog.value
        else:
            self.errors.append(_("Host name is not valid: %s") % error)
            self.hostname_dialog.value = hostname
        network.update_hostname_data(self.data, hostname)
    def _add_server(self, server):
        """
        Checks if a given server is a valid hostname and if yes, adds it
        to the list of servers.

        :param server: string containing hostname

        """

        (valid, error) = network.sanityCheckHostname(server)
        if not valid:
            log.error("'%s' is not a valid hostname: %s" % (server, error))
            return

        for row in self._serversStore:
            if row[0] == server:
                #do not add duplicate items
                return

        itr = self._serversStore.append([server, SERVER_QUERY, True])

        if "pool" in server:
            self._poolsNote.set_text(_(POOL_SERVERS_NOTE))

        #do not block UI while starting thread (may take some time)
        self._refresh_server_working(itr)
예제 #3
0
    def _update_network_data(self):
        hostname = self._network_module.proxy.Hostname

        self.data.network.network = []
        for i, name in enumerate(nm.nm_devices()):
            if network.is_ibft_configured_device(name):
                continue
            nd = network.ksdata_from_ifcfg(name)
            if not nd:
                continue
            if name in nm.nm_activated_devices():
                nd.activate = True
            else:
                # First network command defaults to --activate so we must
                # use --no-activate explicitly to prevent the default
                if i == 0:
                    nd.activate = False
            self.data.network.network.append(nd)

        (valid, error) = network.sanityCheckHostname(self._value)
        if valid:
            hostname = self._value
        else:
            self.errors.append(_("Host name is not valid: %s") % error)
            self._value = hostname
        network.update_hostname_data(self.data, hostname)
예제 #4
0
    def _add_server(self, server):
        """
        Checks if a given server is a valid hostname and if yes, adds it
        to the list of servers.

        :param server: string containing hostname

        """

        (valid, error) = network.sanityCheckHostname(server)
        if not valid:
            log.error("'%s' is not a valid hostname: %s" % (server, error))
            return

        for row in self._serversStore:
            if row[0] == server:
                #do not add duplicate items
                return

        itr = self._serversStore.append([server, SERVER_QUERY, True])

        if "pool" in server:
            self._poolsNote.set_text(_(POOL_SERVERS_NOTE))

        #do not block UI while starting thread (may take some time)
        self._refresh_server_working(itr)
예제 #5
0
    def getNext(self):
        hostname = string.strip(self.hostnameEntry.get_text())
        herrors = network.sanityCheckHostname(hostname)

        if not hostname:
            self.intf.messageWindow(
                _("Error with Hostname"),
                _("You must enter a valid hostname for this "
                  "computer."),
                custom_icon="error")
            self.hostnameError()

        if herrors is not None:
            self.intf.messageWindow(_("Error with Hostname"),
                                    _("The hostname \"%(hostname)s\" is not "
                                      "valid for the following reason:\n\n"
                                      "%(herrors)s") % {
                                          'hostname': hostname,
                                          'herrors': herrors
                                      },
                                    custom_icon="error")
            self.hostnameError()

        self.anaconda.network.setHostname(hostname)
        return None
예제 #6
0
    def _validateServer(self, inputcheck):
        server = self.get_input(inputcheck.input_obj)

        # If not set, fail the check to keep the button insensitive, but don't
        # display an error
        if not server:
            return InputCheck.CHECK_SILENT

        (valid, error) = network.sanityCheckHostname(server)
        if not valid:
            return "'%s' is not a valid hostname: %s" % (server, error)
        else:
            return InputCheck.CHECK_OK
예제 #7
0
    def _validateServer(self, inputcheck):
        server = self.get_input(inputcheck.input_obj)

        # If not set, fail the check to keep the button insensitive, but don't
        # display an error
        if not server:
            return InputCheck.CHECK_SILENT

        (valid, error) = network.sanityCheckHostname(server)
        if not valid:
            return "'%s' is not a valid hostname: %s" % (server, error)
        else:
            return InputCheck.CHECK_OK
    def on_server_edited(self, renderer, path, new_text, *args):
        if not path:
            return

        (valid, error) = network.sanityCheckHostname(new_text)
        if not valid:
            log.error("'%s' is not a valid hostname: %s" % (new_text, error))
            return

        itr = self._serversStore.get_iter(path)

        if self._serversStore[itr][0] == new_text:
            return

        self._serversStore.set_value(itr, 0, new_text)
        self._serversStore.set_value(itr, 1, SERVER_QUERY)

        self._refresh_server_working(itr)
예제 #9
0
    def on_server_edited(self, renderer, path, new_text, *args):
        if not path:
            return

        (valid, error) = network.sanityCheckHostname(new_text)
        if not valid:
            log.error("'%s' is not a valid hostname: %s", new_text, error)
            return

        itr = self._serversStore.get_iter(path)

        if self._serversStore[itr][SERVER_HOSTNAME] == new_text:
            return

        self._serversStore.set_value(itr, SERVER_HOSTNAME, new_text)
        self._serversStore.set_value(itr, SERVER_WORKING, SERVER_QUERY)

        self._refresh_server_working(itr)
예제 #10
0
    def _update_network_data(self):
        hostname = self.data.network.hostname

        self.data.network.network = []
        for name in nm.nm_devices():
            nd = network.ksdata_from_ifcfg(name)
            if not nd:
                continue
            if name in nm.nm_activated_devices():
                nd.activate = True
            self.data.network.network.append(nd)

        (valid, error) = network.sanityCheckHostname(self.hostname_dialog.value)
        if valid:
            hostname = self.hostname_dialog.value
        else:
            self.errors.append(_("Host name is not valid: %s") % error)
            self.hostname_dialog.value = hostname
        network.update_hostname_data(self.data, hostname)
예제 #11
0
파일: network.py 프로젝트: tyll/anaconda
    def _update_network_data(self):
        hostname = self.data.network.hostname

        self.data.network.network = []
        for name in nm.nm_devices():
            nd = network.ksdata_from_ifcfg(name)
            if not nd:
                continue
            if name in nm.nm_activated_devices():
                nd.activate = True
            self.data.network.network.append(nd)

        (valid, error) = network.sanityCheckHostname(self.hostname_dialog.value)
        if valid:
            hostname = self.hostname_dialog.value
        else:
            self.errors.append(_("Host name is not valid: %s") % error)
            self.hostname_dialog.value = hostname
        network.update_hostname_data(self.data, hostname)
    def getNext(self):
        hostname = string.strip(self.hostnameEntry.get_text())
        herrors = network.sanityCheckHostname(hostname)

        if not hostname:
            self.intf.messageWindow(_("Error with Hostname"),
                                    _("You must enter a valid hostname for this "
                                      "computer."), custom_icon="error")
            self.hostnameError()

        if herrors is not None:
            self.intf.messageWindow(_("Error with Hostname"),
                                    _("The hostname \"%(hostname)s\" is not "
                                      "valid for the following reason:\n\n"
                                      "%(herrors)s")
                                    % {'hostname': hostname,
                                       'herrors': herrors},
                                    custom_icon="error")
            self.hostnameError()

        self.anaconda.network.setHostname(hostname)
        return None
예제 #13
0
    def sanityCheckHostname_test(self):

        self.assertFalse(network.sanityCheckHostname("")[0])
        self.assertFalse(network.sanityCheckHostname(None)[0])

        # section length < 64
        self.assertTrue(network.sanityCheckHostname("h" * 63)[0])
        self.assertFalse(network.sanityCheckHostname("h" * 64)[0])

        # length < 256
        self.assertTrue(
            network.sanityCheckHostname("section." * 31 + "section")[0])
        self.assertFalse(
            network.sanityCheckHostname("section." * 31 + "sectionx")[0])

        self.assertFalse(
            network.sanityCheckHostname("section.must.be..nonempty.")[0])
        self.assertFalse(
            network.sanityCheckHostname(".section.must.be.nonempty.")[0])
        self.assertTrue(
            network.sanityCheckHostname(
                "section.can.contain.only.alphanums.012.or.hyp-hens")[0])
        self.assertFalse(
            network.sanityCheckHostname(
                "section.can.contain.only.alphanums.012.or.hyp-hens!!!")[0])
        self.assertFalse(
            network.sanityCheckHostname("section.may.not.start.with.-hyphen")
            [0])
        self.assertFalse(
            network.sanityCheckHostname("section.may.not.end.with.hyphen-")[0])

        self.assertTrue(network.sanityCheckHostname("0-0.")[0])
        self.assertTrue(network.sanityCheckHostname("0.")[0])

        self.assertFalse(network.sanityCheckHostname("Lennart's Laptop")[0])
예제 #14
0
    def sanityCheckHostname_test(self):

        self.assertFalse(network.sanityCheckHostname("")[0])
        self.assertFalse(network.sanityCheckHostname(None)[0])

        # section length < 64
        self.assertTrue(network.sanityCheckHostname("h"*63)[0])
        self.assertFalse(network.sanityCheckHostname("h"*64)[0])

        # length < 256
        self.assertTrue(network.sanityCheckHostname("section." * 31+"section")[0])
        self.assertFalse(network.sanityCheckHostname("section." * 31+"sectionx")[0])

        self.assertFalse(network.sanityCheckHostname(
            "section.must.be..nonempty.")[0])
        self.assertFalse(network.sanityCheckHostname(
            ".section.must.be.nonempty.")[0])
        self.assertTrue(network.sanityCheckHostname(
            "section.can.contain.only.alphanums.012.or.hyp-hens")[0])
        self.assertFalse(network.sanityCheckHostname(
            "section.can.contain.only.alphanums.012.or.hyp-hens!!!")[0])
        self.assertFalse(network.sanityCheckHostname(
            "section.may.not.start.with.-hyphen")[0])
        self.assertFalse(network.sanityCheckHostname(
            "section.may.not.end.with.hyphen-")[0])

        self.assertTrue(network.sanityCheckHostname("0-0.")[0])
        self.assertTrue(network.sanityCheckHostname("0.")[0])

        self.assertFalse(network.sanityCheckHostname("Lennart's Laptop")[0])