~cyphermox/ubuntu/natty/connman/release-0.64

« back to all changes in this revision

Viewing changes to test/set-address

  • Committer: Mathieu Trudel-Lapierre
  • Date: 2010-11-30 15:51:10 UTC
  • mfrom: (1.1.13 upstream)
  • Revision ID: mathieu.trudel-lapierre@canonical.com-20101130155110-32g0usyc4jbl131x
New upstream release 0.64.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
import dbus
5
5
 
6
6
if (len(sys.argv) < 3):
7
 
        print "Usage: %s <address> <netmask> <gateway>" % (sys.argv[0])
 
7
        print "Usage: %s <address> <netmask | prefix length> <gateway> [version]" % (sys.argv[0])
8
8
        sys.exit(1)
9
9
 
10
10
bus = dbus.SystemBus()
11
11
 
12
 
manager = dbus.Interface(bus.get_object('org.moblin.connman', "/"),
13
 
                                        'org.moblin.connman.Manager')
 
12
manager = dbus.Interface(bus.get_object('net.connman', "/"),
 
13
                                        'net.connman.Manager')
14
14
 
15
15
properties = manager.GetProperties()
16
16
 
17
17
for path in properties["Services"]:
18
 
        service = dbus.Interface(bus.get_object('org.moblin.connman', path),
19
 
                                                'org.moblin.connman.Service')
 
18
        service = dbus.Interface(bus.get_object('net.connman', path),
 
19
                                                'net.connman.Service')
20
20
 
21
21
        properties = service.GetProperties()
22
22
 
23
 
        print "Setting address %s for %s" % (sys.argv[1], path)
24
 
 
25
 
        service.SetProperty("IPv4.Configuration",
26
 
                { "Method": "manual", "Address": sys.argv[1],
27
 
                        "Netmask": sys.argv[2], "Gateway": sys.argv[3]})
 
23
 
 
24
 
 
25
        if (len(sys.argv) == 5 and sys.argv[4] == "ipv6"):
 
26
                ipv = 6
 
27
        else:
 
28
                ipv = 4
 
29
 
 
30
        print "Setting IPv%d address %s for %s" % (ipv, sys.argv[1], path)
 
31
 
 
32
        if (ipv == 4):
 
33
                service.SetProperty("IPv4.Configuration",
 
34
                                        { "Method": "manual",
 
35
                                                "Address": sys.argv[1],
 
36
                                                "Netmask": sys.argv[2],
 
37
                                                        "Gateway": sys.argv[3]})
 
38
        else:
 
39
                service.SetProperty("IPv6.Configuration",
 
40
                                        { "Method": "manual",
 
41
                                                "Address": sys.argv[1],
 
42
                                                "PrefixLength": sys.argv[2],
 
43
                                                        "Gateway": sys.argv[3]})
28
44
 
29
45
        print