2015-01-06 14:47:15 +00:00
|
|
|
from mpLinkCharacteristics import MpLinkCharacteristics
|
2015-01-08 18:52:45 +00:00
|
|
|
from mpParam import MpParam
|
2015-01-06 14:47:15 +00:00
|
|
|
|
2015-01-08 18:52:45 +00:00
|
|
|
class MpParamTopo(MpParam):
|
2015-01-07 13:44:44 +00:00
|
|
|
LSUBNET = "leftSubnet"
|
|
|
|
RSUBNET = "rightSubnet"
|
|
|
|
defaultValue = {}
|
|
|
|
defaultValue[LSUBNET] = "10.1."
|
|
|
|
defaultValue[RSUBNET] = "10.2."
|
|
|
|
|
2015-01-06 14:47:15 +00:00
|
|
|
def __init__(self, paramFile):
|
2015-01-08 18:52:45 +00:00
|
|
|
MpParam.__init__(self, paramFile)
|
2015-01-06 14:47:15 +00:00
|
|
|
self.linkCharacteristics = []
|
|
|
|
self.loadLinkCharacteristics()
|
|
|
|
|
|
|
|
def loadLinkCharacteristics(self):
|
|
|
|
i = 0
|
2015-01-07 15:00:15 +00:00
|
|
|
for k in sorted(self.paramDic):
|
2015-01-06 14:47:15 +00:00
|
|
|
if k.startswith("path"):
|
|
|
|
tab = self.paramDic[k].split(",")
|
|
|
|
if len(tab) == 3:
|
|
|
|
path = MpLinkCharacteristics(i,tab[0],
|
|
|
|
tab[1], tab[2])
|
|
|
|
self.linkCharacteristics.append(path)
|
2015-01-12 11:26:54 +00:00
|
|
|
i = i + 1
|
2015-01-06 14:47:15 +00:00
|
|
|
else:
|
|
|
|
print("Ignored path :")
|
|
|
|
print(self.paramDic[k])
|
|
|
|
|
|
|
|
def getParam(self, key):
|
2015-01-08 18:52:45 +00:00
|
|
|
val = MpParam.getParam(self, key)
|
|
|
|
if val is None:
|
|
|
|
if key in MpParamTopo.defaultValue:
|
|
|
|
return MpParamTopo[key]
|
|
|
|
else:
|
|
|
|
raise Exception("Param not found " + key)
|
2015-01-06 14:47:15 +00:00
|
|
|
else:
|
2015-01-08 18:52:45 +00:00
|
|
|
return val
|
2015-01-06 14:47:15 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
2015-01-08 18:52:45 +00:00
|
|
|
s = MpParam.__str__(self)
|
2015-01-06 14:47:15 +00:00
|
|
|
s = s + "\n"
|
|
|
|
for p in self.linkCharacteristics[:-1]:
|
|
|
|
s = s + p.__str__() + "\n"
|
|
|
|
s = s + self.linkCharacteristics[-1].__str__()
|
|
|
|
return s
|