blob: f8efa9d925d00e33bb40ea5715b8ac8d4cc6d798 [file] [log] [blame]
#!/usr/bin/env python3
# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from __future__ import print_function
import sys
import dbus
import flimflam
if len(sys.argv) < 2:
print('Usage: %s <address>' % (sys.argv[0]))
sys.exit(1)
(_, address) = sys.argv
flim = flimflam.FlimFlam(dbus.SystemBus())
for device in flim.GetObjectList('Device'):
device_properties = device.GetProperties()
for path in device_properties['IPConfigs']:
ipconfig = flim.GetObjectInterface('IPConfig', path)
ipconfig_properties = ipconfig.GetProperties()
if ipconfig_properties['Method'] not in ['ipv4', 'ipv6']:
print('Skip %s; method %s' % (ipconfig.object_path,
ipconfig_properties['Method']))
continue
ipconfig.SetProperty('Address', address)