assigned specific xml element types to network nested devices (switches and hubs) instead of the generic 'host' type
This commit is contained in:
parent
af885e156e
commit
e8cf15fb64
1 changed files with 9 additions and 7 deletions
|
@ -23,7 +23,7 @@ def enum(**enums):
|
||||||
return type('Enum', (), enums)
|
return type('Enum', (), enums)
|
||||||
|
|
||||||
class Attrib(object):
|
class Attrib(object):
|
||||||
''' scenario plan attribute constants
|
''' NMF scenario plan attribute constants
|
||||||
'''
|
'''
|
||||||
NetType = enum(WIRELESS = 'wireless', ETHERNET = 'ethernet',
|
NetType = enum(WIRELESS = 'wireless', ETHERNET = 'ethernet',
|
||||||
PTP_WIRED = 'point-to-point-wired',
|
PTP_WIRED = 'point-to-point-wired',
|
||||||
|
@ -33,8 +33,11 @@ class Attrib(object):
|
||||||
NETWORK = "network")
|
NETWORK = "network")
|
||||||
DevType = enum(HOST = 'host', ROUTER = 'router', SWITCH = 'switch',
|
DevType = enum(HOST = 'host', ROUTER = 'router', SWITCH = 'switch',
|
||||||
HUB = 'hub')
|
HUB = 'hub')
|
||||||
|
''' Node types in CORE
|
||||||
|
'''
|
||||||
NodeType = enum(ROUTER = 'router', HOST = 'host', MDR = 'mdr',
|
NodeType = enum(ROUTER = 'router', HOST = 'host', MDR = 'mdr',
|
||||||
PC = 'PC', RJ45 = 'rj45')
|
PC = 'PC', RJ45 = 'rj45', SWITCH = 'lanswitch',
|
||||||
|
HUB = 'hub')
|
||||||
Alias = enum(ID = "COREID")
|
Alias = enum(ID = "COREID")
|
||||||
|
|
||||||
''' A link endpoint in CORE
|
''' A link endpoint in CORE
|
||||||
|
@ -570,15 +573,14 @@ class DeviceElement(NamedXmlElement):
|
||||||
elif devObj.type == Attrib.NodeType.RJ45:
|
elif devObj.type == Attrib.NodeType.RJ45:
|
||||||
devType = Attrib.DevType.HOST
|
devType = Attrib.DevType.HOST
|
||||||
nodeId = "EMULATOR-HOST"
|
nodeId = "EMULATOR-HOST"
|
||||||
|
elif devObj.type == Attrib.NodeType.HUB:
|
||||||
|
devType = Attrib.DevType.HUB
|
||||||
|
elif devObj.type == Attrib.NodeType.SWITCH:
|
||||||
|
devType = Attrib.DevType.SWITCH
|
||||||
else:
|
else:
|
||||||
# Default custom types (defined in ~/.core/nodes.conf) to HOST
|
# Default custom types (defined in ~/.core/nodes.conf) to HOST
|
||||||
devType = Attrib.DevType.HOST
|
devType = Attrib.DevType.HOST
|
||||||
|
|
||||||
if devType is None:
|
|
||||||
if isinstance(devObj, nodes.HubNode):
|
|
||||||
devType = Attrib.DevType.HUB
|
|
||||||
elif isinstance(devObj, nodes.SwitchNode):
|
|
||||||
devType = Attrib.DevType.SWITCH
|
|
||||||
|
|
||||||
if devType is None:
|
if devType is None:
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
Loading…
Reference in a new issue