def network_config(self): """Network config is read from initramfs provided files If none is present, then we fall back to fallback configuration. """ if self._network_config == sources.UNSET: # this is v1 self._network_config = cmdline.read_initramfs_config() if not self._network_config: # this is now v2 self._network_config = self.distro.generate_fallback_config() if self.ds_cfg.get('configure_secondary_nics', BUILTIN_DS_CONFIG["configure_secondary_nics"]): try: # Mutate self._network_config to include secondary # VNICs self._add_network_config_from_opc_imds() except Exception: util.logexc( LOG, "Failed to parse secondary network configuration!") # we need to verify that the nic selected is not a netfail over # device and, if it is a netfail master, then we need to avoid # emitting any match by mac _ensure_netfailover_safe(self._network_config) return self._network_config
def network_config(self): """Network config is read from initramfs provided files If none is present, then we fall back to fallback configuration. One thing to note here is that this method is not currently considered at all if there is is kernel/initramfs provided data. In that case, stages considers that the cmdline data overrides datasource provided data and does not consult here. We nonetheless return cmdline provided config if present and fallback to generate fallback.""" if self._network_config == sources.UNSET: # this is v1 self._network_config = cmdline.read_initramfs_config() if not self._network_config: # this is now v2 self._network_config = self.distro.generate_fallback_config() if self.ds_cfg.get('configure_secondary_nics'): try: # Mutate self._network_config to include secondary VNICs _add_network_config_from_opc_imds(self._network_config) except Exception: util.logexc( LOG, "Failed to fetch secondary network configuration!") # we need to verify that the nic selected is not a netfail over # device and, if it is a netfail master, then we need to avoid # emitting any match by mac _ensure_netfailover_safe(self._network_config) return self._network_config
def network_config(self): """Network config is read from initramfs provided files If none is present, then we fall back to fallback configuration. One thing to note here is that this method is not currently considered at all if there is is kernel/initramfs provided data. In that case, stages considers that the cmdline data overrides datasource provided data and does not consult here. We nonetheless return cmdline provided config if present and fallback to generate fallback.""" if self._network_config == sources.UNSET: self._network_config = cmdline.read_initramfs_config() if not self._network_config: self._network_config = self.distro.generate_fallback_config() return self._network_config
def _find_networking_config(self): disable_file = os.path.join( self.paths.get_cpath("data"), "upgraded-network" ) if os.path.exists(disable_file): return (None, disable_file) available_cfgs = { NetworkConfigSource.cmdline: cmdline.read_kernel_cmdline_config(), NetworkConfigSource.initramfs: cmdline.read_initramfs_config(), NetworkConfigSource.ds: None, NetworkConfigSource.system_cfg: self.cfg.get("network"), } if self.datasource and hasattr(self.datasource, "network_config"): available_cfgs[ NetworkConfigSource.ds ] = self.datasource.network_config if self.datasource: order = self.datasource.network_config_sources else: order = sources.DataSource.network_config_sources for cfg_source in order: if not hasattr(NetworkConfigSource, cfg_source): LOG.warning( "data source specifies an invalid network cfg_source: %s", cfg_source, ) continue if cfg_source not in available_cfgs: LOG.warning( "data source specifies an unavailable network" " cfg_source: %s", cfg_source, ) continue ncfg = available_cfgs[cfg_source] if net.is_disabled_cfg(ncfg): LOG.debug("network config disabled by %s", cfg_source) return (None, cfg_source) if ncfg: return (ncfg, cfg_source) return ( self.distro.generate_fallback_config(), NetworkConfigSource.fallback, )
def _find_networking_config(self): disable_file = os.path.join(self.paths.get_cpath("data"), "upgraded-network") if os.path.exists(disable_file): return (None, disable_file) available_cfgs = { NetworkConfigSource.CMD_LINE: cmdline.read_kernel_cmdline_config(), NetworkConfigSource.INITRAMFS: cmdline.read_initramfs_config(), NetworkConfigSource.DS: None, NetworkConfigSource.SYSTEM_CFG: self.cfg.get("network"), } if self.datasource and hasattr(self.datasource, "network_config"): available_cfgs[ NetworkConfigSource.DS] = self.datasource.network_config if self.datasource: order = self.datasource.network_config_sources else: order = sources.DataSource.network_config_sources for cfg_source in order: if not isinstance(cfg_source, NetworkConfigSource): LOG.warning( "data source specifies an invalid network cfg_source: %s", cfg_source, ) continue if cfg_source not in available_cfgs: LOG.warning( "data source specifies an unavailable network" " cfg_source: %s", cfg_source, ) continue ncfg = self._remove_top_level_network_key( available_cfgs[cfg_source]) if net.is_disabled_cfg(ncfg): LOG.debug("network config disabled by %s", cfg_source) return (None, cfg_source) if ncfg: return (ncfg, cfg_source) return ( self.distro.generate_fallback_config(), NetworkConfigSource.FALLBACK, )
def _is_iscsi_root(): return bool(cmdline.read_initramfs_config())