Remove white spaces...

for f in `ls *.py`; do sed -i -e 's/\s\+$//' $f; done
This commit is contained in:
Benjamin Hesmans 2015-02-26 17:43:45 +01:00
parent 8b5134bfd1
commit ff8d8c5537
14 changed files with 52 additions and 52 deletions

View File

@ -1,5 +1,5 @@
class MpConfig:
PING_OUTPUT = "ping.log"
def __init__(self, topo, param):
@ -63,7 +63,7 @@ class MpConfig:
s = "ip route add default via " + via
print(s)
return s
def pingCommand(self, fromIP, toIP, n=5):
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
" >> " + MpConfig.PING_OUTPUT

View File

@ -24,23 +24,23 @@ class MpECMPSingleInterfaceConfig(MpConfig):
cmd = self.getIpRuleCmd(i)
self.topo.commandTo(self.client, cmd)
self.topo.commandTo(self.server, cmd)
cmd = self.getDefaultRouteCmd(self.getRouterIPClient(i),
i)
self.topo.commandTo(self.client, cmd)
cmd = self.getDefaultRouteCmd(self.getRouterIPServer(i),
i)
self.topo.commandTo(self.server, cmd)
i = i + 1
###
cmd = self.addRouteDefaultSimple(self.getRouterIPServer(0))
self.topo.commandTo(self.server, cmd)
cmd = self.addRouteDefaultSimple(self.getRouterIPClient(0))
self.topo.commandTo(self.client, cmd)
self.topo.commandTo(self.client, "ip route flush cache")
self.topo.commandTo(self.server, "ip route flush cache")
@ -63,7 +63,7 @@ class MpECMPSingleInterfaceConfig(MpConfig):
'" -j MARK --set-mark ' + str(id + 1)
print (s)
return s
def getIptableRuleTCPPortServer(self, mask, id):
s = 'iptables -t mangle -A OUTPUT -m u32 --u32 ' + \
'"6&0xFF=0x6 && ' + \
@ -98,7 +98,7 @@ class MpECMPSingleInterfaceConfig(MpConfig):
self.getRouterInterfaceLSwitch(i),
self.getRouterIPClient(i), netmask)
self.topo.commandTo(self.routers[-1] , cmd)
cmd = self.interfaceUpCommand(
self.getRouterInterfaceRSwitch(i),
self.getRouterIPServer(i), netmask)
@ -109,7 +109,7 @@ class MpECMPSingleInterfaceConfig(MpConfig):
cmd = self.interfaceUpCommand(self.getClientInterface(0),
self.getClientIP(0), netmask)
self.topo.commandTo(self.client, cmd)
cmd = self.interfaceUpCommand(self.getServerInterface(),
self.getServerIP(), netmask)
self.topo.commandTo(self.server, cmd)
@ -133,7 +133,7 @@ class MpECMPSingleInterfaceConfig(MpConfig):
rSubnet = self.param.getParam(MpParamTopo.RSUBNET)
routerIP = rSubnet + "0." + str(id + 2)
return routerIP
def getServerIP(self):
rSubnet = self.param.getParam(MpParamTopo.RSUBNET)
serverIP = rSubnet + "0.1"
@ -150,7 +150,7 @@ class MpECMPSingleInterfaceConfig(MpConfig):
def getClientInterface(self, interfaceID):
return MpTopo.clientName + "-eth" + str(interfaceID)
def getServerInterface(self):
return MpTopo.serverName + "-eth0"

View File

@ -3,14 +3,14 @@ from mpTopo import MpTopo
class MpECMPSingleInterfaceTopo(MpTopo):
def __init__(self, topoBuilder, parameterFile):
MpTopo.__init__(self,topoBuilder, parameterFile)
print("Hello ECMP topo")
self.client = self.addHost(MpTopo.clientName)
self.server = self.addHost(MpTopo.serverName)
self.lswitch = self.addSwitch(MpTopo.switchNamePrefix + "0")
self.rswitch = self.addSwitch(MpTopo.switchNamePrefix + "1")
self.addLink( self.client, self.lswitch)
self.addLink( self.server, self.rswitch)

View File

@ -8,12 +8,12 @@ class MpExperience:
self.mpTopo = mpTopo
self.mpConfig = mpConfig
print(self.xpParam)
def classicRun(self):
self.prepare()
self.run()
self.clean()
def prepare(self):
self.setupSysctl()
self.runUserspacePM()

View File

@ -2,7 +2,7 @@ from mpExperience import MpExperience
from mpParamXp import MpParamXp
from mpPvAt import MpPvAt
class MpExperienceNCPV(MpExperience):
class MpExperienceNCPV(MpExperience):
"""
NC PV : NetCat and Pipe Viewer
"""
@ -15,7 +15,7 @@ class MpExperienceNCPV(MpExperience):
MpExperience.__init__(self, xpParamFile, mpTopo, mpConfig)
self.loadParam()
MpExperience.classicRun(self)
def loadParam(self):
self.pvg = self.xpParam.getParam(MpParamXp.PVG)
self.pvz = self.xpParam.getParam(MpParamXp.PVZ)
@ -50,8 +50,8 @@ class MpExperienceNCPV(MpExperience):
o = MpPvAt(float(tab[0]), tab[1])
self.addPvAt(o)
else:
print("pv wrong line : " + n)
print("pv wrong line : " + n)
def addPvAt(self, p):
if len(self.changePvAt) == 0 :
p.delta = p.at
@ -119,19 +119,19 @@ class MpExperienceNCPV(MpExperience):
for i in range(0, len(self.ncClientPort)):
cmd = self.getNCServerCmd(i)
self.mpTopo.commandTo(self.mpConfig.server, cmd)
cmd = self.getNCClientCmd(i)
self.mpConfig.client.sendCmd(cmd)
cmd = self.getPvPidCmd()
self.pvPid = self.mpTopo.commandTo(self.mpConfig.server, cmd)[:-1]
cmd = self.getPvChangeCmd()
print(cmd)
self.mpTopo.commandTo(self.mpConfig.server, cmd)
self.mpConfig.client.waitOutput()
self.mpTopo.commandTo(self.mpConfig.client, "sleep 1")

View File

@ -1,16 +1,16 @@
from mpExperience import MpExperience
from mpParamXp import MpParamXp
class MpExperiencePing(MpExperience):
class MpExperiencePing(MpExperience):
PING_OUTPUT = "ping.log"
def __init__(self, xpParamFile, mpTopo, mpConfig):
MpExperience.__init__(self, xpParamFile, mpTopo, mpConfig)
MpExperience.classicRun(self)
MpExperience.classicRun(self)
def prepapre(self):
MpExperience.prepare(self)
def clean(self):
MpExperience.clean(self)

View File

@ -25,13 +25,13 @@ class MpLinkCharacteristics:
print("Do not take into account " + n.__str__() + \
"because ooo !")
pass
def buildNetemCmd(self, ifname):
cmd = ""
for n in self.netemAt:
cmd = cmd + "sleep " + str(n.delta)
cmd = cmd + " && "
cmd = cmd + " tc qdisc change dev " + ifname + " "
cmd = cmd + " tc qdisc change dev " + ifname + " "
cmd = cmd + " parent " + MpLinkCharacteristics.tcNetemParent
cmd = cmd + " handle " + MpLinkCharacteristics.tcNetemHandle
cmd = cmd + " netem " + n.cmd + " && "
@ -53,4 +53,4 @@ class MpLinkCharacteristics:
for l in self.netemAt:
s = s + "\t" + l.__str__() + "\n"
return s

View File

@ -8,7 +8,7 @@ class MpMininetBuilder(Topo):
def __init__(self):
Topo.__init__( self )
self.net = None
def commandTo(self, who, cmd):
return who.cmd(cmd)
@ -18,7 +18,7 @@ class MpMininetBuilder(Topo):
if stderr:
return "Error"
return stdout
def startNetwork(self):
self.net = Mininet(topo=self,link=TCLink)
self.net.start()
@ -35,7 +35,7 @@ class MpMininetBuilder(Topo):
raise Exception("Network not ready");
else:
return self.net.getNodeByName(who)
def stopNetwork(self):
if self.net is None:
print("Could not stop network... Nothing to stop)")

View File

@ -12,7 +12,7 @@ class MpMultiInterfaceConfig(MpConfig):
for l in self.topo.switch:
cmd = self.addRouteTableCommand(self.getClientIP(i), i)
self.topo.commandTo(self.client, cmd)
cmd = self.addRouteScopeLinkCommand(
self.getClientSubnet(i),
self.getClientInterface(i), i)
@ -22,7 +22,7 @@ class MpMultiInterfaceConfig(MpConfig):
i)
self.topo.commandTo(self.client, cmd)
i = i + 1
cmd = self.addRouteDefaultGlobalCommand(self.getRouterIPSwitch(0),
self.getClientInterface(0))
self.topo.commandTo(self.client, cmd)
@ -30,7 +30,7 @@ class MpMultiInterfaceConfig(MpConfig):
cmd = self.addRouteDefaultSimple(self.getRouterIPServer())
self.topo.commandTo(self.server, cmd)
def configureInterfaces(self):
print("Configure interfaces for multi inf")
self.client = self.topo.getHost(MpTopo.clientName)
@ -43,17 +43,17 @@ class MpMultiInterfaceConfig(MpConfig):
self.getClientInterface(i),
self.getClientIP(i), netmask)
self.topo.commandTo(self.client, cmd)
cmd = self.interfaceUpCommand(
self.getRouterInterfaceSwitch(i),
self.getRouterIPSwitch(i), netmask)
self.topo.commandTo(self.router, cmd)
i = i + 1
cmd = self.interfaceUpCommand(self.getRouterInterfaceServer(),
self.getRouterIPServer(), netmask)
self.topo.commandTo(self.router, cmd)
cmd = self.interfaceUpCommand(self.getServerInterface(),
self.getServerIP(), netmask)
self.topo.commandTo(self.server, cmd)
@ -77,7 +77,7 @@ class MpMultiInterfaceConfig(MpConfig):
rSubnet = self.param.getParam(MpParamTopo.RSUBNET)
routerIP = rSubnet + "0.2"
return routerIP
def getServerIP(self):
rSubnet = self.param.getParam(MpParamTopo.RSUBNET)
serverIP = rSubnet + "0.1"
@ -94,7 +94,7 @@ class MpMultiInterfaceConfig(MpConfig):
def getRouterInterfaceSwitch(self, interfaceID):
return MpTopo.routerName + "-eth" + str(interfaceID)
def getServerInterface(self):
return MpTopo.serverName + "-eth0"
@ -103,7 +103,7 @@ class MpMultiInterfaceConfig(MpConfig):
def getMidRightName(self, id):
return MpTopo.routerName
def getMidL2RInterface(self, id):
return self.getMidLeftName(id) + "-eth2"

View File

@ -7,7 +7,7 @@ class MpParam:
print("default param...")
else:
self.loadParamFile(paramFile)
def loadParamFile(self, paramFile):
f = open(paramFile)
i = 0

View File

@ -31,7 +31,7 @@ class MpParamTopo(MpParam):
val = []
val.append(tmp)
self.loadNetemAtList(i, val)
def loadNetemAtList(self, id, nlist):
for n in nlist:
tab = n.split(",")
@ -44,9 +44,9 @@ class MpParamTopo(MpParam):
else:
print("Netem wrong line : " + n)
print(self.linkCharacteristics[id].netemAt)
def loadLinkCharacteristics(self):
i = 0
i = 0
for k in sorted(self.paramDic):
if k.startswith("path"):
tab = self.paramDic[k].split(",")

View File

@ -64,7 +64,7 @@ class MpParamXp(MpParam):
def __init__(self, paramFile):
MpParam.__init__(self, paramFile)
def getParam(self, key):
val = MpParam.getParam(self, key)
if val is None:

View File

@ -50,7 +50,7 @@ class MpTopo:
def startNetwork(self):
self.topoBuilder.startNetwork()
def closeLogFile(self):
self.logFile.close()

View File

@ -20,7 +20,7 @@ class MpXpRunner:
self.startTopo()
self.runXp()
self.stopTopo()
def defParamXp(self, xpParamFile):
self.xpParam = MpParamXp(xpParamFile)
@ -28,7 +28,7 @@ class MpXpRunner:
if builderType == MpTopo.mininetBuilder:
self.topoBuilder = MpMininetBuilder()
else:
raise Exception("I can not find the builder " +
raise Exception("I can not find the builder " +
builderType)
def defTopo(self):
t = self.topoParam.getParam(MpTopo.topoAttr)
@ -53,7 +53,7 @@ class MpXpRunner:
self.mpTopo,
self.topoParam)
else:
raise Exception("Unfound Topo" + t)
raise Exception("Unfound Topo" + t)
def startTopo(self):
self.mpTopo.startNetwork()
@ -71,6 +71,6 @@ class MpXpRunner:
self.mpTopo.getCLI()
else:
print("Unfound xp type..." + xp)
def stopTopo(self):
self.mpTopo.stopNetwork()