summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrent s <r00t@square-r00t.net>2019-11-11 21:42:58 -0500
committerbrent s <r00t@square-r00t.net>2019-11-11 21:42:58 -0500
commit5371ae2361bed672938bf927ea5257bcf49cc453 (patch)
tree440b38a8355bf9d1d24f1026510e287d1c1563c3
parent856d89f231b5ee303ff0390d4e974a7cbd1df98b (diff)
downloadAIF-NG-5371ae2361bed672938bf927ea5257bcf49cc453.tar.xz
stubbing network out
-rw-r--r--aif.xsd1
-rw-r--r--aif/network/__init__.py18
-rw-r--r--aif/network/_common.py14
-rw-r--r--aif/network/net.py19
-rw-r--r--aif/network/networkmanager.py23
-rw-r--r--aif/network/networkmanager_fallback.py1
-rw-r--r--docs/MANUAL.adoc8
7 files changed, 67 insertions, 17 deletions
diff --git a/aif.xsd b/aif.xsd
index bba465d..2024912 100644
--- a/aif.xsd
+++ b/aif.xsd
@@ -270,6 +270,7 @@
WPA3?
EAP,
eduroam (https://github.com/rst0git/netctl-eduroam-config/blob/master/eduroam), etc. -->
+ <!-- wep64, wep128, wpa-psk:tkip, wpa-psk:aes, wpa2-psk:tkip, wpa2-psk:aes, wpa2-psk:tkip/aes -->
<xs:complexType name="t_wifi_crypto">
<xs:all>
<xs:element name="type" minOccurs="1" maxOccurs="1" default="wpa2">
diff --git a/aif/network/__init__.py b/aif/network/__init__.py
index 20a8caa..4ebacdd 100644
--- a/aif/network/__init__.py
+++ b/aif/network/__init__.py
@@ -3,14 +3,22 @@ try:
except ImportError:
pass # GI isn't supported, so we don't even use a fallback.
+from . import netctl
+
# TODO: use DBus interface for systemd but fallback to subprocess?
# http://0pointer.net/blog/the-new-sd-bus-api-of-systemd.html
# https://www.youtube.com/watch?v=ZUX9Fx8Rwzg
# https://www.youtube.com/watch?v=lBQgMGPxqNo
# https://github.com/facebookincubator/pystemd has some unit/service examples
-# try:
-# from . import networkd
-# except ImportError:
-# from . import networkd_fallback as networkd
+try:
+ from . import networkd
+except ImportError:
+ from . import networkd_fallback as networkd
-from . import netctl
+
+try:
+ from . import networkmanager
+except ImportError:
+ from . import networkmanager_fallback
+
+from . import net
diff --git a/aif/network/_common.py b/aif/network/_common.py
index a8686f5..bcacaa5 100644
--- a/aif/network/_common.py
+++ b/aif/network/_common.py
@@ -1,13 +1,3 @@
import gi
-gi.require_version('NM', '2.0')
-from gi.repository import NM, GLib
-
-NM.ensure_init([None])
-
-
-def addBDPlugin(plugin_name):
- plugins = NM.get_available_plugin_names()
- plugins.append(plugin_name)
- plugins = list(set(plugins)) # Deduplicate
- spec = NM.plugin_specs_from_names(plugins)
- return(NM.ensure_init(spec))
+gi.require_version('NM', '1.0')
+from gi.repository import GObject, NM, GLib
diff --git a/aif/network/net.py b/aif/network/net.py
new file mode 100644
index 0000000..cadfe6f
--- /dev/null
+++ b/aif/network/net.py
@@ -0,0 +1,19 @@
+class Network(object):
+ def __init__(self, network_xml):
+ self.xml = network_xml
+ self.hostname = self.xml.attrib['hostname']
+ self.provider = self.xml.attrib.get('provider', 'netctl')
+ handler = None
+ if self.provider == 'netctl':
+ from . import netctl as handler
+ elif self.provider == 'nm':
+ from . import networkmanager as handler
+ elif self.provider == 'systemd':
+ from . import networkd as handler
+ self.provider = handler
+ if not self.provider:
+ raise RuntimeError('Could not determine handler')
+ self.connections = []
+
+ def _initConns(self):
+ pass
diff --git a/aif/network/networkmanager.py b/aif/network/networkmanager.py
index e69de29..23a8350 100644
--- a/aif/network/networkmanager.py
+++ b/aif/network/networkmanager.py
@@ -0,0 +1,23 @@
+from . import _common
+
+_NM = _common.NM
+
+
+class Connection(object):
+ def __init__(self, iface_xml):
+ self.xml = iface_xml
+ self.connection_type = None
+ self.provider_type = 'NetworkManager'
+ self.client = _NM.Client.new()
+
+
+class Ethernet(Connection):
+ def __init__(self, iface_xml):
+ super().__init__(iface_xml)
+ self.connection_type = 'ethernet'
+
+
+class Wireless(Connection):
+ def __init__(self, iface_xml):
+ super().__init__(iface_xml)
+ self.connection_type = 'wireless'
diff --git a/aif/network/networkmanager_fallback.py b/aif/network/networkmanager_fallback.py
index e69de29..2933cb5 100644
--- a/aif/network/networkmanager_fallback.py
+++ b/aif/network/networkmanager_fallback.py
@@ -0,0 +1 @@
+import subprocess
diff --git a/docs/MANUAL.adoc b/docs/MANUAL.adoc
index f7d85d5..2ed63ed 100644
--- a/docs/MANUAL.adoc
+++ b/docs/MANUAL.adoc
@@ -85,6 +85,14 @@ TIP: Your distro's package manager should have most if not all of these availabl
NOTE: Some versions may be higher than actually needed.
+////
+Need to revamp. Recommended vs. fallback plus required for both
+
+Recommended:
+pygobject-introspection
+libblockdev
+libnm
+////
=== Necessary
These are needed for using AIF-NG.