Antoni Segura Puimedon has uploaded a new change for review. Change subject: iproute2: Add static and autoconf ipv6 support ......................................................................
iproute2: Add static and autoconf ipv6 support This patch enables the users of the iproute2 configurator to set ipv6 static addresses or change the ipv6 autoconf status of the an interface. Change-Id: I372212dd9abc1dbb2ce4d966ef25726a439ac166 Signed-off-by: Antoni S. Puimedon <[email protected]> --- M lib/vdsm/ipwrapper.py M vdsm/network/configurators/iproute2.py 2 files changed, 25 insertions(+), 9 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/89/27189/1 diff --git a/lib/vdsm/ipwrapper.py b/lib/vdsm/ipwrapper.py index f51166c..6c1e4b5 100644 --- a/lib/vdsm/ipwrapper.py +++ b/lib/vdsm/ipwrapper.py @@ -1,4 +1,4 @@ -# Copyright 2013 Red Hat, Inc. +# Copyright 2013-2014 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -509,9 +509,11 @@ return _execCmd(command) -def routeAdd(route): - command = [_IP_BINARY.cmd, 'route', 'add'] +def routeAdd(route, version=4, dev=None): + command = [_IP_BINARY.cmd, '-%s' % version, 'route', 'add'] command += route + if dev is not None: + command += ['dev', dev] _execCmd(command) @@ -577,14 +579,17 @@ return _execCmd(command) -def addrAdd(dev, ipaddr, netmask): - command = [_IP_BINARY.cmd, 'addr', 'add', 'dev', dev, '%s/%s' % - (ipaddr, netmask)] +def addrAdd(dev, ipaddr, netmask, version=4): + command = [_IP_BINARY.cmd, '-%s' % version, 'addr', 'add', 'dev', dev, + '%s/%s' % (ipaddr, netmask)] _execCmd(command) -def addrFlush(dev): - command = [_IP_BINARY.cmd, 'addr', 'flush', 'dev', dev] +def addrFlush(dev, version=None): + command = [_IP_BINARY.cmd] + if version is not None: + command.append('-%s' % version) + command += ['addr', 'flush', 'dev', dev] _execCmd(command) diff --git a/vdsm/network/configurators/iproute2.py b/vdsm/network/configurators/iproute2.py index a4a1c0e..cc7f036 100644 --- a/vdsm/network/configurators/iproute2.py +++ b/vdsm/network/configurators/iproute2.py @@ -196,12 +196,23 @@ def _setIpConfig(self, iface): ipConfig = iface.ipConfig - if ipConfig.ipaddr: + if ipConfig.ipaddr or ipConfig.ipv6addr: self.removeIpConfig(iface) + if ipConfig.ipaddr: ipwrapper.addrAdd(iface.name, ipConfig.ipaddr, ipConfig.netmask) if ipConfig.gateway and ipConfig.defaultRoute: ipwrapper.routeAdd(['default', 'via', ipConfig.gateway]) + if ipConfig.ipv6addr: + ipv6addr, ipv6netmask = ipConfig.ipv6addr.split('/') + ipwrapper.addrAdd(iface.name, ipv6addr, ipv6netmask, version=6) + if ipConfig.ipv6gateway: + ipwrapper.routeAdd(['default', 'via', ipConfig.ipv6gateway], + dev=iface.name, version=6) + if ipConfig.ipv6autoconf is not None: + with open('/proc/sys/net/ipv6/conf/%s/autoconf' % iface.name, + 'w') as ipv6_autoconf: + ipv6_autoconf.write('1' if ipConfig.ipv6autoconf else '0') def removeIpConfig(self, iface): ipwrapper.addrFlush(iface.name) -- To view, visit http://gerrit.ovirt.org/27189 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I372212dd9abc1dbb2ce4d966ef25726a439ac166 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Antoni Segura Puimedon <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
