mininet-sample/src/mpXpRunner.py

111 lines
3.5 KiB
Python
Raw Normal View History

from mpTopo import MpTopo
from mpParamTopo import MpParamTopo
from mpParamXp import MpParamXp
from mpMultiInterfaceTopo import MpMultiInterfaceTopo
from mpMultiInterfaceConfig import MpMultiInterfaceConfig
from mpECMPSingleInterfaceConfig import MpECMPSingleInterfaceConfig
from mpMininetBuilder import MpMininetBuilder
from mpExperiencePing import MpExperiencePing
from mpExperienceNCPV import MpExperienceNCPV
from mpExperienceNC import MpExperienceNC
from mpExperienceHTTPS import MpExperienceHTTPS
2015-12-01 16:48:32 +00:00
from mpExperienceHTTP import MpExperienceHTTP
from mpExperienceSendFile import MpExperienceSendFile
from mpExperienceEpload import MpExperienceEpload
2015-12-02 09:22:57 +00:00
from mpExperienceNetperf import MpExperienceNetperf
2015-12-02 14:22:51 +00:00
from mpExperienceAb import MpExperienceAb
2016-04-14 14:01:39 +00:00
from mpExperienceSiri import MpExperienceSiri
from mpExperienceNone import MpExperienceNone
from mpExperience import MpExperience
from mpECMPSingleInterfaceTopo import MpECMPSingleInterfaceTopo
class MpXpRunner:
def __init__(self, builderType, topoParamFile, xpParamFile):
self.defParamXp(xpParamFile)
self.topoParam = MpParamTopo(topoParamFile)
self.defBuilder(builderType)
self.defTopo()
self.defConfig()
self.startTopo()
self.runXp()
self.stopTopo()
def defParamXp(self, xpParamFile):
self.xpParam = MpParamXp(xpParamFile)
def defBuilder(self, builderType):
if builderType == MpTopo.mininetBuilder:
self.topoBuilder = MpMininetBuilder()
else:
raise Exception("I can not find the builder " +
builderType)
def defTopo(self):
t = self.topoParam.getParam(MpTopo.topoAttr)
if t == MpTopo.multiIfTopo:
self.mpTopo = MpMultiInterfaceTopo(self.topoBuilder,
self.topoParam)
elif t == MpTopo.ECMPLikeTopo:
self.mpTopo = MpECMPSingleInterfaceTopo(
self.topoBuilder,
self.topoParam)
else:
raise Exception("Unfound Topo" + t)
print(self.mpTopo)
def defConfig(self):
t = self.topoParam.getParam(MpTopo.topoAttr)
if t == MpTopo.multiIfTopo:
self.mpTopoConfig = MpMultiInterfaceConfig(self.mpTopo,
self.topoParam)
elif t == MpTopo.ECMPLikeTopo:
self.mpTopoConfig = MpECMPSingleInterfaceConfig(
self.mpTopo,
self.topoParam)
else:
raise Exception("Unfound Topo" + t)
def startTopo(self):
self.mpTopo.startNetwork()
self.mpTopoConfig.configureNetwork()
def runXp(self):
xp = self.xpParam.getParam(MpParamXp.XPTYPE)
if xp == MpExperience.PING:
MpExperiencePing(self.xpParam, self.mpTopo,
self.mpTopoConfig)
elif xp == MpExperience.NCPV:
MpExperienceNCPV(self.xpParam, self.mpTopo,
self.mpTopoConfig)
elif xp == MpExperience.NC:
MpExperienceNC(self.xpParam, self.mpTopo,
self.mpTopoConfig)
elif xp == MpExperience.NONE:
MpExperienceNone(self.xpParam, self.mpTopo,
self.mpTopoConfig)
elif xp == MpExperience.HTTPS:
MpExperienceHTTPS(self.xpParam, self.mpTopo,
self.mpTopoConfig)
2015-12-01 16:48:32 +00:00
elif xp == MpExperience.HTTP:
MpExperienceHTTP(self.xpParam, self.mpTopo,
self.mpTopoConfig)
elif xp == MpExperience.EPLOAD:
MpExperienceEpload(self.xpParam, self.mpTopo,
self.mpTopoConfig)
2015-12-02 09:22:57 +00:00
elif xp == MpExperience.NETPERF:
MpExperienceNetperf(self.xpParam, self.mpTopo,
self.mpTopoConfig)
2015-12-02 14:22:51 +00:00
elif xp == MpExperience.AB:
MpExperienceAb(self.xpParam, self.mpTopo,
self.mpTopoConfig)
2016-04-14 14:01:39 +00:00
elif xp == MpExperience.SIRI:
MpExperienceSiri(self.xpParam, self.mpTopo,
self.mpTopoConfig)
elif xp == MpExperience.SENDFILE:
MpExperienceSendFile(self.xpParam, self.mpTopo,
self.mpTopoConfig)
else:
print("Unfound xp type..." + xp)
def stopTopo(self):
self.mpTopo.stopNetwork()