def setNetworkOnbootDefault(self, ksdata): # if something's already enabled, we can just leave the config alone for devName in nm.nm_devices(): if nm.nm_device_type_is_wifi(devName): continue try: onboot = nm.nm_device_setting_value(devName, "connection", "autoconnect") except nm.DeviceSettingsNotFoundError: continue if not onboot == False: return # the default otherwise: bring up the first wired netdev with link for devName in nm.nm_devices(): if nm.nm_device_type_is_wifi(devName): continue try: link_up = nm.nm_device_carrier(devName) except ValueError: continue if link_up: ifcfg_path = network.find_ifcfg_file_of_device( devName, root_path=ROOT_PATH) if not ifcfg_path: continue ifcfg = network.IfcfgFile(ifcfg_path) ifcfg.read() ifcfg.set(('ONBOOT', 'yes')) ifcfg.write() for nd in ksdata.network.network: if nd.device == devName: nd.onboot = True break break
def setNetworkOnbootDefault(self, ksdata): # if there is no device to be autoactivated after reboot for devName in nm.nm_devices(): if nm.nm_device_type_is_wifi(devName): continue try: onboot = nm.nm_device_setting_value(devName, "connection", "autoconnect") except nm.SettingsNotFoundError: continue if not onboot == False: return # set ONBOOT=yes for the device used during installation # (ie for majority of cases the one having the default route) devName = network.default_route_device() if not devName: return if nm.nm_device_type_is_wifi(devName): return ifcfg_path = network.find_ifcfg_file_of_device(devName, root_path=ROOT_PATH) if not ifcfg_path: return ifcfg = network.IfcfgFile(ifcfg_path) ifcfg.read() ifcfg.set(('ONBOOT', 'yes')) ifcfg.write() for nd in ksdata.network.network: if nd.device == devName: nd.onboot = True break
def get_onboot_from_ifcfg(connection_uuid): ifcfg_path = network.find_ifcfg_file([('UUID', connection_uuid)]) if not ifcfg_path: log.error("can't find ifcfg file of %s", connection_uuid) return False ifcfg = network.IfcfgFile(ifcfg_path) ifcfg.read() return ifcfg.get('ONBOOT') != "no"
def set_onboot_in_ifcfg(connection_uuid, onboot): ifcfg_path = network.find_ifcfg_file([('UUID', connection_uuid)]) if not ifcfg_path: log.error("can't find ifcfg file of %s", connection_uuid) return False ifcfg = network.IfcfgFile(ifcfg_path) ifcfg.read() ifcfg.set(('ONBOOT', "yes" if onboot else "no")) ifcfg.write()