forgot to add wifi settings

This commit is contained in:
2019-11-30 01:22:28 -05:00
parent 3a2eca4b98
commit 3e33abe0a6
5 changed files with 33 additions and 5 deletions

View File

@@ -5,13 +5,13 @@ class Network(object):
def __init__(self, network_xml):
self.xml = network_xml
self.hostname = self.xml.attrib['hostname'].strip()
self.provider = self.xml.attrib.get('provider', 'systemd').strip()
self.provider = self.xml.attrib.get('provider', 'networkd').strip()
handler = None
if self.provider == 'netctl':
import aif.network.netctl as handler
elif self.provider == 'nm':
import aif.network.networkmanager as handler
elif self.provider == 'systemd':
elif self.provider == 'networkd':
import aif.network.networkd as handler
self.provider = handler
if not self.provider:

View File

@@ -275,3 +275,29 @@ class Wireless(Connection):
super().__init__(iface_xml)
self.connection_type = 'wireless'
self._initCfg()
self._initConnCfg()
def _initConnCfg(self):
self._cfg['BASE']['ESSID'] = "'{0}'".format(self.xml.attrib['essid'])
hidden = aif.utils.xmlBool(self.xml.attrib.get('hidden', 'false'))
if hidden:
self._cfg['BASE']['Hidden'] = 'yes'
try:
bssid = self.xml.attrib.get('bssid').strip()
except AttributeError:
bssid = None
if bssid:
bssid = aif.network._common.canonizeEUI(bssid)
self._cfg['BASE']['AP'] = bssid
crypto = self.xml.find('encryption')
if crypto:
self.packages.add('wpa_supplicant')
crypto = aif.network._common.convertWifiCrypto(crypto)
# if crypto['type'] in ('wpa', 'wpa2', 'wpa3'):
if crypto['type'] in ('wpa', 'wpa2'):
# TODO: WPA2 enterprise
self._cfg['BASE']['Security'] = 'wpa'
# if crypto['type'] in ('wep', 'wpa', 'wpa2', 'wpa3'):
if crypto['type'] in ('wpa', 'wpa2'):
self._cfg['BASE']['Key'] = crypto['auth']['psk']
return()

View File

@@ -5,3 +5,4 @@ import socket
# (https://stackoverflow.com/a/38286559/733214), there's no way to *write* an INI with them using configparser.
# So we use Jinja2 logic.
import jinja2