stubbing network out

This commit is contained in:
brent s 2019-11-11 21:42:58 -05:00
parent 856d89f231
commit 5371ae2361
7 changed files with 67 additions and 17 deletions

View File

@ -270,6 +270,7 @@
WPA3? WPA3?
EAP, EAP,
eduroam (https://github.com/rst0git/netctl-eduroam-config/blob/master/eduroam), etc. --> 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:complexType name="t_wifi_crypto">
<xs:all> <xs:all>
<xs:element name="type" minOccurs="1" maxOccurs="1" default="wpa2"> <xs:element name="type" minOccurs="1" maxOccurs="1" default="wpa2">

View File

@ -3,14 +3,22 @@ try:
except ImportError: except ImportError:
pass # GI isn't supported, so we don't even use a fallback. 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? # TODO: use DBus interface for systemd but fallback to subprocess?
# http://0pointer.net/blog/the-new-sd-bus-api-of-systemd.html # 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=ZUX9Fx8Rwzg
# https://www.youtube.com/watch?v=lBQgMGPxqNo # https://www.youtube.com/watch?v=lBQgMGPxqNo
# https://github.com/facebookincubator/pystemd has some unit/service examples # https://github.com/facebookincubator/pystemd has some unit/service examples
# try: try:
# from . import networkd from . import networkd
# except ImportError: except ImportError:
# from . import networkd_fallback as networkd from . import networkd_fallback as networkd


from . import netctl
try:
from . import networkmanager
except ImportError:
from . import networkmanager_fallback

from . import net

View File

@ -1,13 +1,3 @@
import gi import gi
gi.require_version('NM', '2.0') gi.require_version('NM', '1.0')
from gi.repository import NM, GLib from gi.repository import GObject, 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))

19
aif/network/net.py Normal file
View File

@ -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

View File

@ -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'

View File

@ -0,0 +1 @@
import subprocess

View File

@ -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. 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 === Necessary
These are needed for using AIF-NG. These are needed for using AIF-NG.