summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@linux.intel.com>2013-02-19 10:45:01 +0200
committerPatrik Flykt <patrik.flykt@linux.intel.com>2013-02-19 14:29:32 +0200
commit62e83d4e282330b87d1c7a5748344e887881c00a (patch)
tree8bfcde79bc9110d0566e5d11be5f5151369a8851
parent0c2bdeabdea59c3d83f2f76a2331fe99b6fe3cdd (diff)
downloadconnman-62e83d4e282330b87d1c7a5748344e887881c00a.tar.gz
connman-62e83d4e282330b87d1c7a5748344e887881c00a.tar.bz2
connman-62e83d4e282330b87d1c7a5748344e887881c00a.zip
test: Script for getting, setting and clearing VPN properties
-rwxr-xr-xtest/vpn-property66
1 files changed, 66 insertions, 0 deletions
diff --git a/test/vpn-property b/test/vpn-property
new file mode 100755
index 00000000..2bafa1ad
--- /dev/null
+++ b/test/vpn-property
@@ -0,0 +1,66 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+
+def make_variant(string):
+ return dbus.String(string, variant_level=1)
+
+def extract_values(values):
+ val = "{"
+ for key in values.keys():
+ val += " " + key + "="
+ if key in ["Servers", "Excludes"]:
+ val += extract_list(values[key])
+ else:
+ val += str(values[key])
+ val += " }"
+ return val
+
+def extract_list(list):
+ val = "["
+ for i in list:
+ if type(i).__name__ == 'Dictionary':
+ val += extract_values(i)
+ elif type(i).__name__ == 'Struct':
+ val += extract_list(i)
+ else:
+ val += " " + str(i)
+ val += "]"
+ return val
+
+argc = len(sys.argv)
+
+if (argc < 2):
+ print "Usage: %s <VPN connection id> [<property name>] [<property values>]" % (sys.argv[0])
+ sys.exit(1)
+
+bus = dbus.SystemBus()
+
+manager = dbus.Interface(bus.get_object("net.connman.vpn", "/"),
+ "net.connman.vpn.Manager")
+
+connections = manager.GetConnections()
+
+path = "/net/connman/vpn/connection/" + sys.argv[1]
+
+print "Attempting to connect VPN %s" % (path)
+
+connection = dbus.Interface(bus.get_object("net.connman.vpn", path),
+ "net.connman.vpn.Connection")
+
+if (argc < 3):
+ properties = connection.GetProperties()
+ for key in properties.keys():
+ if key in ["IPv4", "IPv6" ]:
+ val = extract_values(properties[key])
+ elif key in ["Nameservers","ServerRoutes","UserRoutes"]:
+ val = extract_list(properties[key])
+ else:
+ val = str(properties[key])
+ print " %s = %s" % (key, val)
+
+elif (argc < 4):
+ connection.ClearProperty(sys.argv[2])
+else:
+ connection.SetProperty(sys.argv[2], sys.argv[3])