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 _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 _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)
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 _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 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