add XpRunner

organisation and start for xp

Signed-off-by: Benjamin Hesmans <benjamin.hesmans@uclouvain.be>
This commit is contained in:
Benjamin Hesmans 2015-01-08 12:04:42 +01:00
parent 9f2ce22e96
commit 7e373bbad5
4 changed files with 75 additions and 27 deletions

9
src/conf/xp/0_iperf_1 Normal file
View File

@ -0,0 +1,9 @@
#option to dvlp are commented but already there.
#kCommit:aaaa
#pmCommit:bbb
#sysctl:mem,x y z
#sysctl:rmem,x y z
#sysctl:wmem,x y z
xpType:iperf
size:10M

View File

@ -1,21 +1,21 @@
#!/usr/bin/python
import sys, getopt
from mpParamTopo import MpParamTopo
from mpMultiInterfaceTopo import MpMultiInterfaceTopo
from mpMultiInterfaceConfig import MpMultiInterfaceConfig
from mpMininetBuilder import MpMininetBuilder
from mpXpRunner import MpXpRunner
from mpTopo import MpTopo
topoParamFile = None
topoType = "mininet"
xpParamFile = None
topoBuilder = "mininet"
def printHelp():
print("Help Menu")
def parseArgs(argv):
global topoParamFile
global xpParamFile
try:
opts, args = getopt.getopt(argv, "hf:", ["topoParam="])
opts, args = getopt.getopt(argv, "ht:x:", ["topoParam=","xp="])
except getopt.GetoptError:
printHelp()
sys.exit(1)
@ -23,28 +23,16 @@ def parseArgs(argv):
if opt == "-h":
printHelp()
sys.exit(1)
elif opt in ("-f","--topoParam"):
print("hllo", arg);
elif opt in ("-x","--xp"):
xpParamFile = arg
elif opt in ("-t","--topoParam"):
print("hey")
topoParamFile = arg
if topoParamFile is None:
print("Missing the topo...")
printHelp()
sys.exit(1)
if __name__ == '__main__':
parseArgs(sys.argv[1:])
if topoParamFile is None:
print("Use command line param")
else:
param = MpParamTopo(topoParamFile)
if topoType == "mininet":
if param.getParam('topoType') == "MultiIf":
mpTopo = MpMultiInterfaceTopo(MpMininetBuilder(), param)
mpConfig = MpMultiInterfaceConfig(mpTopo, param)
mpTopo.startNetwork()
mpConfig.configureNetwork()
mpConfig.pingAllFromClient()
mpTopo.getCLI()
mpTopo.stopNetwork()
else:
print("Unrecognized topo type")
print(mpTopo)
MpXpRunner(MpTopo.mininetBuilder, topoParamFile, xpParamFile)

View File

@ -1,4 +1,7 @@
class MpTopo:
mininetBuilder = "mininet"
multiIfTopo = "MultiIf"
topoAttr = "topoType"
switchNamePrefix = "s"
clientName = "Client"
serverName = "Server"

48
src/mpXpRunner.py Normal file
View File

@ -0,0 +1,48 @@
from mpTopo import MpTopo
from mpParamTopo import MpParamTopo
from mpMultiInterfaceTopo import MpMultiInterfaceTopo
from mpMultiInterfaceConfig import MpMultiInterfaceConfig
from mpMininetBuilder import MpMininetBuilder
class MpXpRunner:
def __init__(self, builderType, topoParamFile, xpParamFile):
self.topoParam = MpParamTopo(topoParamFile)
self.defBuilder(builderType)
self.defTopo()
self.defConfig()
self.startTopo()
self.runXp(xpParamFile)
self.stopTopo()
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)
else:
raise Exception("Unfound Topo" + t)
print(self.mpTopo)
def defConfig(self):
self.mpTopoConfig = MpMultiInterfaceConfig(self.mpTopo,
self.topoParam)
def startTopo(self):
self.mpTopo.startNetwork()
self.mpTopoConfig.configureNetwork()
def runXp(self, xpParamFile):
if xpParamFile is None:
self.mpTopoConfig.pingAllFromClient()
self.mpTopo.getCLI()
else:
raise Exception("TODO")
def stopTopo(self):
self.mpTopo.stopNetwork()