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