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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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