summaryrefslogtreecommitdiffstats
path: root/netman.py
diff options
context:
space:
mode:
authorChris Austen <austenc@us.ibm.com>2016-02-01 18:18:21 -0600
committerChris Austen <austenc@us.ibm.com>2016-02-01 18:18:21 -0600
commitb13a3cd1b41bb867a54dd7a37322dc8af902454d (patch)
tree106ae5b2eb9528300871696035d937260c8893b0 /netman.py
parenta657afc9cc76dc6678edb8de9df569f92dd108e1 (diff)
downloadphosphor-networkd-b13a3cd1b41bb867a54dd7a37322dc8af902454d.tar.gz
phosphor-networkd-b13a3cd1b41bb867a54dd7a37322dc8af902454d.zip
AddAddress4 not setting the new IP
Just a few changes to make it work... 1) Ensure the .network file is a known name. It must be deleted before the new .network file is added since the other file also had the same interface and priority level 2) I got on the systemd channel because restarting the systemd service does not change the ip address. You needed to flush the ip instead. Notes on the networkd subject from the IRC channel... From the systemd-networkd manpage... "Network configurations applied before networkd is started are not removed" I also learned from the IRC to use the 'ip addr flush <device>' to force the network cleanup. ... <causten__> danderson, so if I setup a server on one subnet, rebooted, then wanted to change the ip I couldn't do it without rebooting? <causten__> is there a workaround? I mean switching ips in a lab to a different subnet is common <danderson> either that, or manually clean up the interface configuration before restarting networkd <danderson> i.e. `ip addr del 1.2.3.4 dev eno1` or whatever <danderson> alternatively, you may want to just use a different network configuration manager (e.g. arch's netctl, or network-manager), if your use case is more complex <danderson> networkd is by design aimed at one-time configuration on startup, and minor maintenance like keeping DHCP going
Diffstat (limited to 'netman.py')
-rwxr-xr-xnetman.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/netman.py b/netman.py
index c63921f..9544d07 100755
--- a/netman.py
+++ b/netman.py
@@ -54,7 +54,7 @@ class NetMan (dbus.service.Object):
def setNetworkProvider(self, provider):
self.provider = provider
- def _setAddr (self, op, device, ipaddr, netmask, family, flags, scope, gateway):
+ def _setAddr (self, op, device, ipaddr, netmask, family, flags, scope, ateway):
netprov = network_providers [self.provider]
bus_name = netprov ['bus_name']
obj_path = netprov ['ip_object_name']
@@ -63,10 +63,10 @@ class NetMan (dbus.service.Object):
obj = self.bus.get_object(bus_name, obj_path)
intf = dbus.Interface(obj, intf_name)
if (op == "add"):
- return intf.AddAddress (device, ipaddr, netmask, family, flags, scope, gateway)
+ return intf.AddAddress (device, ipaddr, netmask, family, flags, cope, gateway)
if (op == "del"):
- return intf.DelAddress (device, ipaddr, netmask, family, flags, scope, gateway)
+ return intf.DelAddress (device, ipaddr, netmask, family, flags, cope, gateway)
def _getAddr (self, target, device):
netprov = network_providers [self.provider]
@@ -97,9 +97,7 @@ class NetMan (dbus.service.Object):
@dbus.service.method(DBUS_NAME, "ssss", "x")
def AddAddress4 (self, device, ipaddr, netmask, gateway):
prefixLen = getPrefixLen (netmask)
- confFile = "/etc/systemd/network/10-bmc-" + device + "-" + ipaddr + '_' + str(prefixLen) + ".network"
- if os.path.exists(confFile):
- return 0
+ confFile = "/etc/systemd/network/10-bmc-" + device + ".network"
print("Making .network file...")
networkconf = open (confFile, "w+")
@@ -108,16 +106,17 @@ class NetMan (dbus.service.Object):
networkconf.write ('[Network]' + '\n')
networkconf.write ('Address=' + ipaddr + '/' + str(prefixLen) + '\n')
networkconf.write ('Gateway=' + gateway + '\n')
+ networkconf.close()
print("Restarting networkd service...")
- call(["systemctl", "restart", "systemd-networkd.service"])
+ call(["ip", "addr", "flush", device])
return 0
- #return self._setAddr ("add", device, ipaddr, netmask, 2, 0, 253, gateway)
+ #return self._setAddr ("add", device, ipaddr, netmask, 2, 0, 253, gateway
@dbus.service.method(DBUS_NAME, "ssss", "x")
def DelAddress4 (self, device, ipaddr, netmask, gateway):
prefixLen = getPrefixLen (netmask)
- confFile = "/etc/systemd/network/10-bmc-" + device + "-" + ipaddr + '_' + str(prefixLen) + ".network"
+ confFile = "/etc/systemd/network/10-bmc-" + device + ".network"
if not (os.path.exists(confFile)):
return 1
@@ -144,4 +143,4 @@ def main():
mainloop.run()
if __name__ == '__main__':
- sys.exit(main())
+ sys.exit(main()) \ No newline at end of file
OpenPOWER on IntegriCloud