summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2014-10-08 18:15:23 -0400
committerDan Winship <danw@gnome.org>2014-10-19 09:27:48 -0400
commitba900f2a44f978300cac768c75384b54e3be61bc (patch)
treee400e2899d432eafadde7fad15ccc443e2e0c0af
parente06bd1ef17bacf38d5a1f06ff827971a5969da53 (diff)
tools: add a bit of support for VLANs to test-networkmanager-service.py
-rwxr-xr-xtools/test-networkmanager-service.py46
1 files changed, 40 insertions, 6 deletions
diff --git a/tools/test-networkmanager-service.py b/tools/test-networkmanager-service.py
index c3e251e49b..064336fa39 100755
--- a/tools/test-networkmanager-service.py
+++ b/tools/test-networkmanager-service.py
@@ -226,6 +226,34 @@ class WiredDevice(Device):
pass
###################################################################
+IFACE_VLAN = 'org.freedesktop.NetworkManager.Device.Vlan'
+
+PV_HW_ADDRESS = "HwAddress"
+PV_CARRIER = "Carrier"
+PV_VLAN_ID = "VlanId"
+
+class VlanDevice(Device):
+ def __init__(self, bus, iface):
+ Device.__init__(self, bus, iface, NM_DEVICE_TYPE_VLAN)
+ self.add_dbus_interface(IFACE_VLAN, self.__get_props)
+
+ self.mac = random_mac()
+ self.carrier = False
+ self.vlan_id = 1
+
+ # Properties interface
+ def __get_props(self):
+ props = {}
+ props[PV_HW_ADDRESS] = self.mac
+ props[PV_CARRIER] = self.carrier
+ props[PV_VLAN_ID] = self.vlan_id
+ return props
+
+ @dbus.service.signal(IFACE_VLAN, signature='a{sv}')
+ def PropertiesChanged(self, changed):
+ pass
+
+###################################################################
IFACE_WIFI_AP = 'org.freedesktop.NetworkManager.AccessPoint'
PP_FLAGS = "Flags"
@@ -653,21 +681,27 @@ class NetworkManager(ExportedObj):
@dbus.service.method(dbus_interface=IFACE_NM, in_signature='ooo', out_signature='o')
def ActivateConnection(self, conpath, devpath, specific_object):
+ try:
+ connection = settings.get_connection(conpath)
+ except Exception as e:
+ raise UnknownConnectionException("Connection not found")
+
+ hash = connection.GetSettings()
+ s_con = hash['connection']
+
device = None
for d in self.devices:
if d.path == devpath:
device = d
break
+ if not device and s_con['type'] == 'vlan':
+ ifname = s_con['interface-name']
+ device = VlanDevice(self._bus, ifname)
+ self.add_device(device)
if not device:
raise UnknownDeviceException("No device found for the requested iface.")
- try:
- connection = settings.get_connection(conpath)
- except Exception as e:
- raise UnknownConnectionException("Connection not found")
-
# See if we need secrets. For the moment, we only support WPA
- hash = connection.GetSettings()
if hash.has_key('802-11-wireless-security'):
s_wsec = hash['802-11-wireless-security']
if (s_wsec['key-mgmt'] == 'wpa-psk' and not s_wsec.has_key('psk')):