def input(self, args, key): """ Handle the input. """ try: num = int(key) except ValueError: return key if num == 1: # set hostname self.app.switch_screen_modal( self.hostname_dialog, Entry(_("Hostname"), "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) 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.gateway or not ndata.netmask: self.errors.append( _("Configuration not saved: gateway or 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) if ndata._apply: 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
def input(self, args, key): """ Handle the input. """ try: num = int(key) except ValueError: return 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) 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.gateway or not ndata.netmask: self.errors.append(_("Configuration not saved: gateway or 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) if ndata._apply: 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
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()
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()
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
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