1#!/usr/bin/python
2
3import dbus, flimflam, sys
4
5if (len(sys.argv) < 2):
6    print "Usage: %s <address>" % (sys.argv[0])
7    sys.exit(1)
8
9(_, address) = sys.argv
10
11flim = flimflam.FlimFlam(dbus.SystemBus())
12
13for device in flim.GetObjectList("Device"):
14    device_properties = device.GetProperties(utf8_strings = True)
15
16    for path in device_properties["IPConfigs"]:
17        ipconfig = flim.GetObjectInterface("IPConfig", path)
18        ipconfig_properties = ipconfig.GetProperties(utf8_strings = True)
19
20        if ipconfig_properties["Method"] not in ["ipv4","ipv6"]:
21            print "Skip %s; method %s" % (ipconfig.object_path,
22                ipconfig_properties["Method"])
23            continue
24
25        ipconfig.SetProperty("Address", address)
26