X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=net.py;h=16953aae2809cbaba841107cdf8834f7d44ef027;hb=913c1a15c8497f01dbf0b7f7e837cf5ee38481bf;hp=9ba9b3e5f8ecbfd9e8e6fdbb5900d56b214c2a13;hpb=fda8d4da0b665b91cb6c2c4524c15a6a3feb3aad;p=nodemanager.git diff --git a/net.py b/net.py index 9ba9b3e..16953aa 100644 --- a/net.py +++ b/net.py @@ -1,4 +1,5 @@ # +# $Id$ # """network configuration""" @@ -7,6 +8,7 @@ import bwlimit import logger import string import iptables +import os def GetSlivers(plc, data): InitNodeLimit(data) @@ -60,8 +62,22 @@ def InitI2(plc, data): i2nodes = [] i2nodeids = plc.GetNodeGroups(["Internet2"])[0]['node_ids'] for node in plc.GetInterfaces({"node_id": i2nodeids}, ["ip"]): + # Get the IPs i2nodes.append(node['ip']) + # this will create the set if it doesn't already exist + # and add IPs that don't exist in the set rather than + # just recreateing the set. bwlimit.exempt_init('Internet2', i2nodes) + + # set the iptables classification rule if it doesnt exist. + cmd = '-A POSTROUTING -m set --set Internet2 dst -j CLASSIFY --set-class 0001:2000 --add-mark' + rules = [] + ipt = os.popen("/sbin/iptables-save") + for line in ipt.readlines(): rules.append(line.strip(" \n")) + ipt.close() + if cmd not in rules: + logger.verbose("net: Adding iptables rule for Internet2") + os.popen("/sbin/iptables -t mangle " + cmd) def InitNAT(plc, data): # query running network interfaces