From 3e33abe0a6c5b97e53b37f0f2285a04c971beae6 Mon Sep 17 00:00:00 2001 From: brent s Date: Sat, 30 Nov 2019 01:22:28 -0500 Subject: [PATCH] forgot to add wifi settings --- aif.xsd | 5 +++-- aif/network/net.py | 4 ++-- aif/network/netctl.py | 26 ++++++++++++++++++++++++++ aif/network/networkd.py | 1 + docs/MANUAL.adoc | 2 +- 5 files changed, 33 insertions(+), 5 deletions(-) diff --git a/aif.xsd b/aif.xsd index 54dd294..f8257b1 100644 --- a/aif.xsd +++ b/aif.xsd @@ -244,7 +244,7 @@ - + @@ -465,6 +465,7 @@ + @@ -887,7 +888,7 @@ - + diff --git a/aif/network/net.py b/aif/network/net.py index 622162b..8580b6f 100644 --- a/aif/network/net.py +++ b/aif/network/net.py @@ -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: diff --git a/aif/network/netctl.py b/aif/network/netctl.py index 11cd01a..9fd8d84 100644 --- a/aif/network/netctl.py +++ b/aif/network/netctl.py @@ -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() diff --git a/aif/network/networkd.py b/aif/network/networkd.py index 0c1bb62..2b5dd8a 100644 --- a/aif/network/networkd.py +++ b/aif/network/networkd.py @@ -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 + diff --git a/docs/MANUAL.adoc b/docs/MANUAL.adoc index 32f1e31..9f27b88 100644 --- a/docs/MANUAL.adoc +++ b/docs/MANUAL.adoc @@ -589,7 +589,7 @@ This is going to be highly unpredictable based on the networking provider you ch === "I'm using netctl as my network provider, and-" I'ma let you finish, but netctl is a *really* simple network provider. I mean REALLY simple. As such, a lot of things (like mixing auto DNS and non-auto addressing) don't work at all feasibly, and probably might not ever. It's great for simple and flat configurations (i.e. all static everything, all automatic everything, etc.) and I even use it on my own machines where I can, but it just simply doesn't make allowances for more complex setups. (This is why init scripts were replaced by systemd for init, remember? Script-and-shell-based utilities, such as netctl -- seriously, the entire thing's written in Bash -- just can't handle more complex jobs reliably.) -If you need more advanced functionality but don't want a lot of cruft or bloat, I recommend `systemd` as your network provider. It requires no extra packages (other than wpa_supplicant, if you're using wireless) because it's part of the systemd package (which is part of the most basic install of Arch) and handles more advanced configurations a lot more reliably. +If you need more advanced functionality but don't want a lot of cruft or bloat, I recommend `networkd` as your network provider. It requires no extra packages (other than wpa_supplicant, if you're using wireless) because it's part of the systemd package (which is part of the most basic install of Arch) and handles more advanced configurations a lot more reliably. === "How do I specify WEP for a wireless network?" You can't. WEP's pretty broken. I understand some legacy networks may still use it, but I'm incredibly uncomfortable supporting it.