Beispiel #1
0
    def _configure_network_interface(self, data):
        devname = data
        ndata = network.ksdata_from_ifcfg(devname)
        if not ndata:
            # There is no ifcfg file for the device.
            # Make sure there is just one connection for the device.
            try:
                nm.nm_device_setting_value(devname, "connection", "uuid")
            except nm.SettingsNotFoundError:
                log.debug("can't find any connection for %s", devname)
                return
            except nm.MultipleSettingsFoundError:
                log.debug("multiple non-ifcfg connections found for %s",
                          devname)
                return

            log.debug("dumping ifcfg file for in-memory connection %s",
                      devname)
            nm.nm_update_settings_of_device(
                devname, [['connection', 'id', devname, None]])
            ndata = network.ksdata_from_ifcfg(devname)

        new_spoke = ConfigureNetworkSpoke(self.data, self.storage,
                                          self.payload, self.instclass, ndata)
        ScreenHandler.push_screen_modal(new_spoke)
        self.redraw()

        if ndata.ip == "dhcp":
            ndata.bootProto = "dhcp"
            ndata.ip = ""
        else:
            ndata.bootProto = "static"
            if not ndata.netmask:
                self.errors.append(
                    _("Configuration not saved: netmask missing in static configuration"
                      ))
                return

        if ndata.ipv6 == "ignore":
            ndata.noipv6 = True
            ndata.ipv6 = ""
        else:
            ndata.noipv6 = False

        uuid = network.update_settings_with_ksdata(devname, ndata)
        network.update_onboot_value(devname,
                                    ndata.onboot,
                                    ksdata=None,
                                    root_path="")
        network.logIfcfgFiles("settings of %s updated in tui" % devname)

        if new_spoke.apply_configuration:
            self._apply = True
            try:
                nm.nm_activate_device_connection(devname, uuid)
            except (nm.UnmanagedDeviceError, nm.UnknownConnectionError):
                self.errors.append(
                    _("Can't apply configuration, device activation failed."))

        self.apply()
Beispiel #2
0
 def setNetworkOnbootDefault(self, ksdata):
     if ksdata.method.method not in ("url", "nfs"):
         return
     if network.has_some_wired_autoconnect_device():
         return
     dev = network.default_route_device()
     if not dev:
         return
     if nm.nm_device_type_is_wifi(dev):
         return
     network.update_onboot_value(dev, "yes", ksdata)
Beispiel #3
0
 def setNetworkOnbootDefault(self, ksdata):
     if any(nd.onboot for nd in ksdata.network.network if nd.device):
         return
     # choose the device used during installation
     # (ie for majority of cases the one having the default route)
     dev = network.default_route_device() or network.default_route_device(family="inet6")
     if not dev:
         return
     # ignore wireless (its ifcfgs would need to be handled differently)
     if nm.nm_device_type_is_wifi(dev):
         return
     network.update_onboot_value(dev, True, ksdata=ksdata)
Beispiel #4
0
 def setNetworkOnbootDefault(self, ksdata):
     if any(nd.onboot for nd in ksdata.network.network if nd.device):
         return
     # choose the device used during installation
     # (ie for majority of cases the one having the default route)
     dev = network.default_route_device() or network.default_route_device(family="inet6")
     if not dev:
         return
     # ignore wireless (its ifcfgs would need to be handled differently)
     if nm.nm_device_type_is_wifi(dev):
         return
     network.update_onboot_value(dev, True, ksdata=ksdata)
Beispiel #5
0
 def setNetworkOnbootDefault(self, ksdata):
     if network.has_some_wired_autoconnect_device():
         return
     # choose the device used during installation
     # (ie for majority of cases the one having the default route)
     dev = network.default_route_device() \
           or network.default_route_device(family="inet6")
     if not dev:
         return
     # ignore wireless (its ifcfgs would need to be handled differently)
     if nm.nm_device_type_is_wifi(dev):
         return
     network.update_onboot_value(dev, "yes", ksdata)
Beispiel #6
0
 def setNetworkOnbootDefault(self, ksdata):
     if network.has_some_wired_autoconnect_device():
         return
     # choose the device used during installation
     # (ie for majority of cases the one having the default route)
     dev = network.default_route_device() \
           or network.default_route_device(family="inet6")
     if not dev:
         return
     # ignore wireless (its ifcfgs would need to be handled differently)
     if nm.nm_device_type_is_wifi(dev):
         return
     network.update_onboot_value(dev, "yes", ksdata)
Beispiel #7
0
    def _configure_network_interface(self, data):
        devname = data
        ndata = network.ksdata_from_ifcfg(devname)
        if not ndata:
            # There is no ifcfg file for the device.
            # Make sure there is just one connection for the device.
            try:
                nm.nm_device_setting_value(devname, "connection", "uuid")
            except nm.SettingsNotFoundError:
                log.debug("can't find any connection for %s", devname)
                return
            except nm.MultipleSettingsFoundError:
                log.debug("multiple non-ifcfg connections found for %s", devname)
                return

            log.debug("dumping ifcfg file for in-memory connection %s", devname)
            nm.nm_update_settings_of_device(devname, [['connection', 'id', devname, None]])
            ndata = network.ksdata_from_ifcfg(devname)

        new_spoke = ConfigureNetworkSpoke(self.data, self.storage,
                                          self.payload, self.instclass, ndata)
        ScreenHandler.push_screen_modal(new_spoke)
        self.redraw()

        if ndata.ip == "dhcp":
            ndata.bootProto = "dhcp"
            ndata.ip = ""
        else:
            ndata.bootProto = "static"
            if not ndata.netmask:
                self.errors.append(_("Configuration not saved: netmask missing in static configuration"))
                return

        if ndata.ipv6 == "ignore":
            ndata.noipv6 = True
            ndata.ipv6 = ""
        else:
            ndata.noipv6 = False

        uuid = network.update_settings_with_ksdata(devname, ndata)
        network.update_onboot_value(devname, ndata.onboot, ksdata=None, root_path="")
        network.logIfcfgFiles("settings of %s updated in tui" % devname)

        if ndata._apply:
            self._apply = True
            try:
                nm.nm_activate_device_connection(devname, uuid)
            except (nm.UnmanagedDeviceError, nm.UnknownConnectionError):
                self.errors.append(_("Can't apply configuration, device activation failed."))

        self.apply()
Beispiel #8
0
 def setNetworkOnbootDefault(self, ksdata):
     if any(nd.onboot for nd in ksdata.network.network if nd.device):
         return
     # choose first wired device having link
     for dev in nm.nm_devices():
         if nm.nm_device_type_is_wifi(dev):
             continue
         try:
             link_up = nm.nm_device_carrier(dev)
         except (nm.UnknownDeviceError, nm.PropertyNotFoundError):
             continue
         if link_up:
             network.update_onboot_value(dev, True, ksdata=ksdata)
             break
Beispiel #9
0
 def setNetworkOnbootDefault(self, ksdata):
     if network.has_some_wired_autoconnect_device():
         return
     # choose first wired device having link
     for dev in nm.nm_devices():
         if nm.nm_device_type_is_wifi(dev):
             continue
         try:
             link_up = nm.nm_device_carrier(dev)
         except (nm.UnknownDeviceError, nm.PropertyNotFoundError):
             continue
         if link_up:
             network.update_onboot_value(dev, "yes", ksdata)
             break
Beispiel #10
0
 def setNetworkOnbootDefault(self, ksdata):
     if any(nd.onboot for nd in ksdata.network.network if nd.device):
         return
     # choose first wired device having link
     for dev in nm.nm_devices():
         if nm.nm_device_type_is_wifi(dev):
             continue
         try:
             link_up = nm.nm_device_carrier(dev)
         except (nm.UnknownDeviceError, nm.PropertyNotFoundError):
             continue
         if link_up:
             network.update_onboot_value(dev, True, ksdata=ksdata)
             break
Beispiel #11
0
 def setNetworkOnbootDefault(self, ksdata):
     if network.has_some_wired_autoconnect_device():
         return
     # choose first wired device having link
     for dev in nm.nm_devices():
         if nm.nm_device_type_is_wifi(dev):
             continue
         try:
             link_up = nm.nm_device_carrier(dev)
         except (nm.UnknownDeviceError, nm.PropertyNotFoundError):
             continue
         if link_up:
             network.update_onboot_value(dev, "yes", ksdata)
             break
Beispiel #12
0
    def input(self, args, key):
        """ Handle the input. """
        try:
            num = int(key)
        except ValueError:
            return super(NetworkSpoke, self).input(args, key)

        if num == 1:
            # set hostname
            self.app.switch_screen_modal(self.hostname_dialog, Entry(_("Host Name"),
                                "hostname", re.compile(".*$"), True))
            self.apply()
            return INPUT_PROCESSED
        elif 2 <= num <= len(self.supported_devices) + 1:
            # configure device
            devname = self.supported_devices[num-2]
            ndata = network.ksdata_from_ifcfg(devname)
            if not ndata:
                try:
                    nm.nm_device_setting_value(devname, "connection", "uuid")
                except nm.SettingsNotFoundError:
                    pass
                else:
                    log.debug("network: dumping ifcfg file for in-memory connection %s", devname)
                    nm.nm_update_settings_of_device(devname, [['connection', 'id', devname, None]])
                    ndata = network.ksdata_from_ifcfg(devname)

            if not ndata:
                log.debug("network: can't find any connection for %s", devname)
                self.errors.append(_("Configuration of device not found"))
                return INPUT_PROCESSED

            newspoke = ConfigureNetworkSpoke(self.app, self.data, self.storage,
                                    self.payload, self.instclass, ndata)
            self.app.switch_screen_modal(newspoke)

            if ndata.ip == "dhcp":
                ndata.bootProto = "dhcp"
                ndata.ip = ""
            else:
                ndata.bootProto = "static"
                if not ndata.netmask:
                    self.errors.append(_("Configuration not saved: netmask missing in static configuration"))
                    return INPUT_PROCESSED

            if ndata.ipv6 == "ignore":
                ndata.noipv6 = True
                ndata.ipv6 = ""
            else:
                ndata.noipv6 = False

            network.update_settings_with_ksdata(devname, ndata)
            network.update_onboot_value(devname, ndata.onboot, ksdata=None, root_path="")

            if ndata._apply:
                self._apply = True
                uuid = nm.nm_device_setting_value(devname, "connection", "uuid")
                try:
                    nm.nm_activate_device_connection(devname, uuid)
                except (nm.UnmanagedDeviceError, nm.UnknownConnectionError):
                    self.errors.append(_("Can't apply configuration, device activation failed."))

            self.apply()
            return INPUT_PROCESSED
        else:
            return key
Beispiel #13
0
    def input(self, args, key):
        """ Handle the input. """
        try:
            num = int(key)
        except ValueError:
            return super(NetworkSpoke, self).input(args, key)

        if num == 1:
            # set hostname
            self.app.switch_screen_modal(
                self.hostname_dialog,
                Entry(_("Host Name"), "hostname", re.compile(".*$"), True))
            self.apply()
            return INPUT_PROCESSED
        elif 2 <= num <= len(self.supported_devices) + 1:
            # configure device
            devname = self.supported_devices[num - 2]
            ndata = network.ksdata_from_ifcfg(devname)
            if not ndata:
                try:
                    nm.nm_device_setting_value(devname, "connection", "uuid")
                except nm.SettingsNotFoundError:
                    pass
                else:
                    log.debug(
                        "network: dumping ifcfg file for in-memory connection %s",
                        devname)
                    nm.nm_update_settings_of_device(
                        devname, [['connection', 'id', devname, None]])
                    ndata = network.ksdata_from_ifcfg(devname)

            if not ndata:
                log.debug("network: can't find any connection for %s", devname)
                self.errors.append(_("Configuration of device not found"))
                return INPUT_PROCESSED

            newspoke = ConfigureNetworkSpoke(self.app, self.data, self.storage,
                                             self.payload, self.instclass,
                                             ndata)
            self.app.switch_screen_modal(newspoke)

            if ndata.ip == "dhcp":
                ndata.bootProto = "dhcp"
                ndata.ip = ""
            else:
                ndata.bootProto = "static"
                if not ndata.netmask:
                    self.errors.append(
                        _("Configuration not saved: netmask missing in static configuration"
                          ))
                    return INPUT_PROCESSED

            if ndata.ipv6 == "ignore":
                ndata.noipv6 = True
                ndata.ipv6 = ""
            else:
                ndata.noipv6 = False

            network.update_settings_with_ksdata(devname, ndata)
            network.update_onboot_value(devname,
                                        ndata.onboot,
                                        ksdata=None,
                                        root_path="")

            if ndata._apply:
                self._apply = True
                uuid = nm.nm_device_setting_value(devname, "connection",
                                                  "uuid")
                try:
                    nm.nm_activate_device_connection(devname, uuid)
                except (nm.UnmanagedDeviceError, nm.UnknownConnectionError):
                    self.errors.append(
                        _("Can't apply configuration, device activation failed."
                          ))

            self.apply()
            return INPUT_PROCESSED
        else:
            return key