Add script to set IP configuration method
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Thu, 18 Feb 2010 11:16:59 +0000 (09:16 -0200)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 18 Feb 2010 17:14:22 +0000 (09:14 -0800)
This script is used to set IPv4.Configuration property of a service,
allowing to change among dhcp and manual methods.

Makefile.am
test/set-ip-method [new file with mode: 0755]

index 37d5ef8..b10b1bb 100644 (file)
@@ -141,7 +141,7 @@ test_scripts = test/get-state test/list-profiles test/list-services \
                test/simple-agent test/show-introspection test/test-compat \
                test/test-manager test/test-connman test/monitor-connman \
                test/connect-vpn test/disconnect-vpn test/list-providers \
-               test/monitor-manager test/test-counter
+               test/monitor-manager test/test-counter test/set-ip-method
 
 if TEST
 testdir = $(pkglibdir)/test
diff --git a/test/set-ip-method b/test/set-ip-method
new file mode 100755 (executable)
index 0000000..0d08e4d
--- /dev/null
@@ -0,0 +1,33 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+
+def print_usage():
+       print "Usage: %s <service> [off|dhcp|manual <address> [netmask]]" % (sys.argv[0])
+
+
+if (len(sys.argv) < 3):
+       print_usage()
+       sys.exit(1)
+
+bus = dbus.SystemBus()
+path = "/profile/default/" + sys.argv[1]
+service = dbus.Interface(bus.get_object('org.moblin.connman', path),
+                                       'org.moblin.connman.Service')
+
+properties = service.GetProperties()
+
+print "Setting method %s for %s" % (sys.argv[2], sys.argv[1])
+
+ipv4_configuration = { "Method": sys.argv[2] }
+if (len(sys.argv) > 3):
+       ipv4_configuration["Address"] = sys.argv[3]
+if (len(sys.argv) > 4):
+       ipv4_configuration["Netmask"] = sys.argv[4]
+
+
+service.SetProperty("IPv4.Configuration", ipv4_configuration)
+print "New IPv4.Configuration: ", ipv4_configuration
+
+print