2015-01-20 10:04:36 +00:00
|
|
|
from mpParamTopo import MpParamTopo
|
|
|
|
|
2015-01-06 14:47:15 +00:00
|
|
|
class MpTopo:
|
2015-01-08 11:04:42 +00:00
|
|
|
mininetBuilder = "mininet"
|
|
|
|
multiIfTopo = "MultiIf"
|
2015-01-12 11:26:54 +00:00
|
|
|
ECMPLikeTopo = "ECMPLike"
|
2015-01-08 11:04:42 +00:00
|
|
|
topoAttr = "topoType"
|
2015-01-07 13:44:44 +00:00
|
|
|
switchNamePrefix = "s"
|
2015-01-12 11:26:54 +00:00
|
|
|
routerNamePrefix = "r"
|
2015-01-07 13:44:44 +00:00
|
|
|
clientName = "Client"
|
|
|
|
serverName = "Server"
|
|
|
|
routerName = "Router"
|
2015-01-14 10:46:33 +00:00
|
|
|
cmdLog = "command.log"
|
2015-01-07 13:44:44 +00:00
|
|
|
|
2015-01-06 14:47:15 +00:00
|
|
|
"""Simple MpTopo"""
|
|
|
|
def __init__(self, topoBuilder, topoParam):
|
|
|
|
self.topoBuilder = topoBuilder
|
2015-01-08 18:52:45 +00:00
|
|
|
self.topoParam = topoParam
|
2015-01-20 10:04:36 +00:00
|
|
|
self.changeNetem = topoParam.getParam(MpParamTopo.changeNetem)
|
2015-01-14 10:46:33 +00:00
|
|
|
self.logFile = open(MpTopo.cmdLog, 'w')
|
2015-01-20 10:04:36 +00:00
|
|
|
|
|
|
|
def getLinkCharacteristics(self):
|
|
|
|
return topoParam.linkCharacteristics()
|
|
|
|
|
2015-01-06 14:47:15 +00:00
|
|
|
def commandTo(self, who, cmd):
|
2015-01-14 10:46:33 +00:00
|
|
|
self.logFile.write(who.__str__() + " : " + cmd + "\n")
|
2015-01-07 13:44:44 +00:00
|
|
|
self.topoBuilder.commandTo(who, cmd)
|
2015-01-06 14:47:15 +00:00
|
|
|
|
2015-01-14 14:19:39 +00:00
|
|
|
def notNSCommand(self, cmd):
|
|
|
|
"""
|
|
|
|
mainly use for not namespace sysctl.
|
|
|
|
"""
|
|
|
|
self.logFile.write("Not_NS" + " : " + cmd + "\n")
|
|
|
|
return self.topoBuilder.notNSCommand(cmd)
|
|
|
|
|
2015-01-06 14:47:15 +00:00
|
|
|
def getHost(self, who):
|
2015-01-07 13:44:44 +00:00
|
|
|
return self.topoBuilder.getHost(who)
|
2015-01-06 14:47:15 +00:00
|
|
|
|
|
|
|
def addHost(self, host):
|
2015-01-07 13:44:44 +00:00
|
|
|
return self.topoBuilder.addHost(host)
|
2015-01-06 14:47:15 +00:00
|
|
|
|
|
|
|
def addSwitch(self, switch):
|
2015-01-07 13:44:44 +00:00
|
|
|
return self.topoBuilder.addSwitch(switch)
|
2015-01-06 14:47:15 +00:00
|
|
|
|
|
|
|
def addLink(self, fromA, toB, **kwargs):
|
|
|
|
self.topoBuilder.addLink(fromA,toB,**kwargs)
|
|
|
|
|
2015-01-07 13:44:44 +00:00
|
|
|
def getCLI(self):
|
|
|
|
self.topoBuilder.getCLI()
|
|
|
|
|
|
|
|
def startNetwork(self):
|
|
|
|
self.topoBuilder.startNetwork()
|
2015-01-14 10:46:33 +00:00
|
|
|
|
|
|
|
def closeLogFile(self):
|
|
|
|
self.logFile.close()
|
2015-01-07 13:44:44 +00:00
|
|
|
|
|
|
|
def stopNetwork(self):
|
|
|
|
self.topoBuilder.stopNetwork()
|