274e89bb588581d2b6c69e09cd0f64bd016cd9d0
[platform/upstream/connman.git] / test / set-ipv6-method
1 #!/usr/bin/python
2
3 import sys
4 import dbus
5
6 def print_usage():
7         print "Usage: %s <service> off|manual|auto [<address> [prefixlen] [gateway]]" % (sys.argv[0])
8
9 if (len(sys.argv) < 3):
10         print_usage()
11         sys.exit(1)
12
13 bus = dbus.SystemBus()
14 path = "/profile/default/" + sys.argv[1]
15 service = dbus.Interface(bus.get_object('net.connman', path),
16                                         'net.connman.Service')
17
18 properties = service.GetProperties()
19
20 print "Setting method %s for %s" % (sys.argv[2], sys.argv[1])
21
22 ipv6_configuration = { "Method": sys.argv[2] }
23 if (len(sys.argv) > 3):
24         ipv6_configuration["Address"] = sys.argv[3]
25 if (len(sys.argv) > 4):
26         ipv6_configuration["PrefixLength"] = sys.argv[4]
27 if (len(sys.argv) > 5):
28         ipv6_configuration["Gateway"] = sys.argv[5]
29
30 service.SetProperty("IPv6.Configuration", ipv6_configuration)
31 print "New IPv6.Configuration: ", ipv6_configuration
32
33 print