def get_wifi_networks(): interfaces = {} manager = connman.get_manager_interface() for entry in manager.GetServices(): path = entry[0] dbus_properties = entry[1] if path.startswith(WIFI_PATH): wifi_settings = { 'path': str(path), 'Strength': int(dbus_properties['Strength']), 'State': str(dbus_properties['State']) } security_props = dbus_properties['Security'] if len(security_props) > 0: wifi_settings['Security'] = str(security_props[0]) if 'hidden' not in path: wifi_settings['SSID'] = dbus_properties['Name'].encode('UTF-8') else: wifi_settings[ 'SSID'] = '< Hidden (' + wifi_settings['Security'] + ') >' if not str(dbus_properties['State']) == 'idle' and not str( dbus_properties['State']) == 'failure': settings = extract_network_properties(dbus_properties) if settings: wifi_settings.update(settings) # get Interface name and address eth_props = dbus_properties['Ethernet'] wifi_settings['Interface'] = str(eth_props['Interface']) address = str(eth_props['Address']) wifi_settings['AdapterAddress'] = address if address not in interfaces: interfaces[address] = {} interfaces[address][wifi_settings['SSID']] = wifi_settings return interfaces
def get_ethernet_settings(): manager = connman.get_manager_interface() for entry in manager.GetServices(): eth_settings = None path = entry[0] dbus_properties = entry[1] if path.startswith(ETHERNET_PATH): settings = extract_network_properties(dbus_properties) if settings: eth_settings = {'path': path} eth_settings.update(settings) return eth_settings # if we are here we have not detected a ethernet connection check for NFS ip_value = get_nfs_ip_cmdline_value() if ip_value: if ip_value == 'dhcp': nfs_settings = get_non_connman_connection_details() nfs_settings['Method'] = 'nfs_dhcp' else: nfs_settings = split_nfs_static_cmdlline(ip_value) nfs_settings['Method'] = 'nfs_manual' nfs_settings['Interface'] = 'eth0 (NFS)' nfs_settings['State'] = 'online' nfs_settings['path'] = 'nfs' if not check_MS_NCSI_response(): nfs_settings['State'] = 'ready' return nfs_settings return None
def get_ethernet_settings(): manager = connman.get_manager_interface() for entry in manager.GetServices(): eth_settings = None path = entry[0] dbus_properties = entry[1] if path.startswith(ETHERNET_PATH): settings = extract_network_properties(dbus_properties) if settings: eth_settings = {'path': path } eth_settings.update(settings) return eth_settings # if we are here we have not detected a ethernet connection check for NFS ip_value = get_nfs_ip_cmdline_value() if ip_value: if ip_value == 'dhcp': nfs_settings = get_non_connman_connection_details() nfs_settings['Method'] = 'nfs_dhcp' else: nfs_settings = split_nfs_static_cmdlline(ip_value) nfs_settings['Method'] = 'nfs_manual' nfs_settings['Interface'] = 'eth0 (NFS)' nfs_settings['State'] = 'online' nfs_settings['path'] = 'nfs' if not check_MS_NCSI_response(): nfs_settings['State'] = 'ready' return nfs_settings return None
def get_wifi_networks(): interfaces = {} manager = connman.get_manager_interface() for entry in manager.GetServices(): path = entry[0] dbus_properties = entry[1] if path.startswith(WIFI_PATH): wifi_settings = {'path': str(path), 'Strength': int(dbus_properties['Strength']), 'State' : str(dbus_properties['State'])} security_props = dbus_properties['Security'] if len(security_props) > 0: wifi_settings['Security'] = str(security_props[0]) if 'hidden' not in path: wifi_settings['SSID'] = dbus_properties['Name'].encode('UTF-8') else: wifi_settings['SSID'] = '< Hidden (' + wifi_settings['Security'] + ') >' if not str(dbus_properties['State']) == 'idle' and not str(dbus_properties['State']) == 'failure': settings = extract_network_properties(dbus_properties) if settings: wifi_settings.update(settings) # get Interface name and address eth_props = dbus_properties['Ethernet'] wifi_settings['Interface'] = str(eth_props['Interface']) address = str(eth_props['Address']) wifi_settings['AdapterAddress'] = address if address not in interfaces: interfaces[address] = {} interfaces[address][wifi_settings['SSID']] = wifi_settings return interfaces
def get_wifi_networks(): interfaces = {} manager = connman.get_manager_interface() for entry in manager.GetServices(): path = str(entry[0]) dbus_properties = entry[1] if path.startswith(WIFI_PATH): wifi_settings = { "path": str(path), "Strength": int(dbus_properties["Strength"]), "State": str(dbus_properties["State"]), } security_props = dbus_properties["Security"] if len(security_props) > 0: wifi_settings["Security"] = str(security_props[0]) if "hidden" not in path: wifi_settings["SSID"] = dbus_properties["Name"].encode("UTF-8") else: wifi_settings["SSID"] = "< Hidden (" + wifi_settings["Security"] + ") >" if not str(dbus_properties["State"]) == "idle": settings = extract_network_properties(dbus_properties) if settings: wifi_settings.update(settings) # get Interface name and address eth_props = dbus_properties["Ethernet"] wifi_settings["Interface"] = str(eth_props["Interface"]) address = str(eth_props["Address"]) wifi_settings["AdapterAddress"] = address if address not in interfaces: interfaces[address] = {} interfaces[address][wifi_settings["SSID"]] = wifi_settings return interfaces
def get_wifi_networks(): wifis = {} manager = connman.get_manager_interface() for entry in manager.GetServices(): path = entry[0] dbus_properties = entry[1] if path.startswith(WIFI_PATH) and 'hidden' not in path: wifi_settings = {'path': str(path), 'SSID': dbus_properties['Name'].encode('UTF-8'), 'Strength': int(dbus_properties['Strength']), 'State' : str(dbus_properties['State'])} security_props = dbus_properties['Security'] if len(security_props) > 0: wifi_settings['Security'] = str(security_props[0]) if not str(dbus_properties['State']) == 'idle' and not str(dbus_properties['State']) == 'failure': settings = extract_network_properties(dbus_properties) if settings: wifi_settings.update(settings) wifis[wifi_settings['SSID']] = wifi_settings return wifis
def get_ethernet_settings(): manager = connman.get_manager_interface() for entry in manager.GetServices(): eth_settings = None path = str(entry[0]) dbus_properties = entry[1] if path.startswith(ETHERNET_PATH): settings = extract_network_properties(dbus_properties) if settings: eth_settings = {"path": path} eth_settings.update(settings) return eth_settings # if we are here we have not detected a ethernet connection check for NFS ip_value = get_nfs_ip_cmdline_value() if ip_value: if ip_value == "dhcp": nfs_settings = get_non_connman_connection_details() protocol = "IPV4" if "IPV6" in nfs_settings: protocol = "IPV6" nfs_settings[protocol]["Method"] = "nfs_dhcp" else: nfs_settings = split_nfs_static_cmdlline(ip_value) protocol = "IPV4" if "IPV6" in nfs_settings: protocol = "IPV6" nfs_settings[protocol]["Method"] = "nfs_manual" nfs_settings["Interface"] = "eth0 (NFS)" nfs_settings["State"] = "online" nfs_settings["path"] = "nfs" if not check_MS_NCSI_response(): nfs_settings["State"] = "ready" return nfs_settings return None
import os import os.path WIRELESS_AGENT = '/usr/bin/preseed-agent' ETHERNET_PATH = '/net/connman/service/ethernet' WIFI_PATH = '/net/connman/service/wifi' # this is wher we read NFS network info from this is the current running config RUNNING_NETWORK_DETAILS_FILE = '/proc/cmdline' # but we want to update here - this gets copied to /proc/ as part og boot UPDATE_NETWORK_DETAILS_FILE = '/boot/cmdline' PREESEED_TEMP_LOCATION = '/tmp/preseed.tmp' PREESEED_LOCATION = '/boot/preseed.cfg' manager = connman.get_manager_interface() def is_ethernet_enabled(): return connman.is_technology_enabled('ethernet') def toggle_ethernet_state(state): connman.toggle_technology_state('ethernet', state) def get_ethernet_settings(): for entry in manager.GetServices(): path = entry[0] dbus_properties = entry[1] if path.startswith(ETHERNET_PATH):
WIRELESS_AGENT = '/usr/bin/preseed-agent' ETHERNET_PATH = '/net/connman/service/ethernet' WIFI_PATH = '/net/connman/service/wifi' # this is where we read NFS network info from this is the current running config RUNNING_NETWORK_DETAILS_FILE = '/proc/cmdline' # but we want to update here - this gets copied to /proc/ as part of boot UPDATE_NETWORK_DETAILS_FILE = '/boot/cmdline.txt' PREESEED_TEMP_LOCATION = '/tmp/preseed.tmp' PREESEED_LOCATION = '/boot/preseed.cfg' WAIT_FOR_NETWORK_SERVICE = 'connman-wait-for-network.service' manager = connman.get_manager_interface() def is_ethernet_enabled(): return connman.is_technology_enabled('ethernet') or not get_nfs_ip_cmdline_value() == None def toggle_ethernet_state(state): connman.toggle_technology_state('ethernet', state) def get_ethernet_settings(): for entry in manager.GetServices(): eth_settings = None path = entry[0] dbus_properties = entry[1]