From 7467ff44131c0ac0924fd897e014be2e9d832625 Mon Sep 17 00:00:00 2001 From: Faiyaz Ahmed Date: Fri, 19 Sep 2008 19:06:20 +0000 Subject: [PATCH] Check for the existence of the Internet2 clique iptables rule and add if absent. --- README | 2 +- net.py | 17 +++++++++++++++++ nm.py | 10 ++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/README b/README index aa62ab0..d049d21 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ # $Id$ # $HeadURL$ -The PlanetLab Node Manager manages all aspects of PlanetLab node and slice management once the node has been initialized and configured by the Boot Manager. It periodically contacts its management authority for configuration updates. It provides an XML-RPC API for performing local operations on slices. +The PlanetLab NodeManager manages all aspects of PlanetLab node and slice management once the node has been initialized and configured by the Boot Manager. It periodically contacts its management authority for configuration updates. It provides an XML-RPC API for performing local operations on slices. Copyright 2008 Princeton University http://www.planet-lab.org diff --git a/net.py b/net.py index 088f9a3..e0f9c12 100644 --- a/net.py +++ b/net.py @@ -1,5 +1,7 @@ # +# $Id$ # + """network configuration""" import sioc @@ -7,6 +9,7 @@ import bwlimit import logger import string import iptables +import os def GetSlivers(plc, data): InitNodeLimit(data) @@ -60,8 +63,22 @@ def InitI2(plc, data): i2nodes = [] i2nodeids = plc.GetNodeGroups(["Internet2"])[0]['node_ids'] for node in plc.GetNodeNetworks({"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 diff --git a/nm.py b/nm.py index a2b6a4d..bb0a2ab 100755 --- a/nm.py +++ b/nm.py @@ -1,4 +1,13 @@ #!/usr/bin/python + +# +# Useful information can be found at https://svn.planet-lab.org/wiki/NodeManager +# + +# Faiyaz Ahmed +# Copyright (C) 2008 The Trustees of Princeton University + + """Node Manager""" import optparse @@ -36,6 +45,7 @@ parser.add_option('-m', '--module', action='store', dest='module', default='', h modules = [] def GetSlivers(plc): + '''Run call backs defined in modules''' try: logger.log("Syncing w/ PLC") data = plc.GetSlivers() -- 2.43.0