small refactoring on how node maps are used, added logic to switch to using a map based on bsd nodes using previous logic

This commit is contained in:
Blake J. Harnden 2017-08-09 10:03:43 -07:00
parent eb5dd3780c
commit 463618ddf8
16 changed files with 46 additions and 36 deletions

View file

@ -206,3 +206,15 @@ class TunnelNode(NetgraphNet):
nghooks = "upper lower"
apitype = NodeTypes.TUNNEL.value
policy = "ACCEPT"
BSD_NODES = {
NodeTypes.DEFAULT: CoreNode,
NodeTypes.SWITCH: SwitchNode,
NodeTypes.HUB: HubNode,
NodeTypes.WIRELESS_LAN: WlanNode,
NodeTypes.RJ45: RJ45Node,
NodeTypes.TUNNEL: TunnelNode,
NodeTypes.PEER_TO_PEER: PtpNet,
NodeTypes.CONTROL_NET: None
}

View file

@ -6,13 +6,12 @@ from core.emane.nodes import EmaneNet
from core.emane.nodes import EmaneNode
from core.enumerations import NodeTypes
from core.netns import nodes
from core.netns import openvswitch
from core.netns.vnet import GreTapBridge
from core.phys import pnodes
from core.xen import xen
# legacy core nodes, that leverage linux bridges
CLASSIC_NODES = {
NODES = {
NodeTypes.DEFAULT: nodes.CoreNode,
NodeTypes.PHYSICAL: pnodes.PhysicalNode,
NodeTypes.XEN: xen.XenNode,
@ -29,22 +28,3 @@ CLASSIC_NODES = {
NodeTypes.PEER_TO_PEER: nodes.PtpNet,
NodeTypes.CONTROL_NET: nodes.CtrlNet
}
# ovs nodes, that depend on ovs to leverage ovs based bridges
OVS_NODES = {
NodeTypes.DEFAULT: nodes.CoreNode,
NodeTypes.PHYSICAL: pnodes.PhysicalNode,
NodeTypes.XEN: xen.XenNode,
NodeTypes.TBD: None,
NodeTypes.SWITCH: openvswitch.OvsSwitchNode,
NodeTypes.HUB: openvswitch.OvsHubNode,
NodeTypes.WIRELESS_LAN: openvswitch.OvsWlanNode,
NodeTypes.RJ45: nodes.RJ45Node,
NodeTypes.TUNNEL: openvswitch.OvsTunnelNode,
NodeTypes.KTUNNEL: None,
NodeTypes.EMANE: EmaneNode,
NodeTypes.EMANE_NET: EmaneNet,
NodeTypes.TAP_BRIDGE: openvswitch.OvsGreTapBridge,
NodeTypes.PEER_TO_PEER: openvswitch.OvsPtpNet,
NodeTypes.CONTROL_NET: openvswitch.OvsCtrlNet
}

View file

@ -737,3 +737,14 @@ class OvsGreTapBridge(OvsNet):
prior to instantiating the GreTap device (before addrconfig).
"""
self.grekey = key
OVS_NODES = {
NodeTypes.SWITCH: OvsSwitchNode,
NodeTypes.HUB: OvsHubNode,
NodeTypes.WIRELESS_LAN: OvsWlanNode,
NodeTypes.TUNNEL: OvsTunnelNode,
NodeTypes.TAP_BRIDGE: OvsGreTapBridge,
NodeTypes.PEER_TO_PEER: OvsPtpNet,
NodeTypes.CONTROL_NET: OvsCtrlNet
}

View file

@ -109,7 +109,7 @@ def main():
if __name__ == "__main__":
# configure nodes to use
node_map = nodemaps.CLASSIC_NODES
node_map = nodemaps.NODES
nodeutils.set_node_map(node_map)
main()

View file

@ -188,7 +188,7 @@ def main():
if __name__ == "__main__" or __name__ == "__builtin__":
# configure nodes to use
node_map = nodemaps.CLASSIC_NODES
node_map = nodemaps.NODES
nodeutils.set_node_map(node_map)
main()

View file

@ -125,7 +125,7 @@ def main():
if __name__ == "__main__" or __name__ == "__builtin__":
# configure nodes to use
node_map = nodemaps.CLASSIC_NODES
node_map = nodemaps.NODES
nodeutils.set_node_map(node_map)
main()

View file

@ -101,7 +101,7 @@ def main():
if __name__ == "__main__" or __name__ == "__builtin__":
# configure nodes to use
node_map = nodemaps.CLASSIC_NODES
node_map = nodemaps.NODES
nodeutils.set_node_map(node_map)
main()

View file

@ -207,7 +207,7 @@ def main():
if __name__ == "__main__":
# configure nodes to use
node_map = nodemaps.CLASSIC_NODES
node_map = nodemaps.NODES
nodeutils.set_node_map(node_map)
main()

View file

@ -101,7 +101,7 @@ def main():
if __name__ == "__main__" or __name__ == "__builtin__":
# configure nodes to use
node_map = nodemaps.CLASSIC_NODES
node_map = nodemaps.NODES
nodeutils.set_node_map(node_map)
main()

View file

@ -603,7 +603,7 @@ def main():
if __name__ == "__main__":
# configure nodes to use
node_map = nodemaps.CLASSIC_NODES
node_map = nodemaps.NODES
nodeutils.set_node_map(node_map)
me = main()

View file

@ -74,7 +74,7 @@ def main():
if __name__ == "__main__" or __name__ == "__builtin__":
# configure nodes to use
node_map = nodemaps.CLASSIC_NODES
node_map = nodemaps.NODES
nodeutils.set_node_map(node_map)
main()

View file

@ -102,7 +102,7 @@ def main():
if __name__ == "__main__":
# configure nodes to use
node_map = nodemaps.CLASSIC_NODES
node_map = nodemaps.NODES
nodeutils.set_node_map(node_map)
main()

View file

@ -852,7 +852,7 @@ def main():
if __name__ == "__main__":
# configure nodes to use
node_map = nodemaps.CLASSIC_NODES
node_map = nodemaps.NODES
nodeutils.set_node_map(node_map)
main()

View file

@ -100,7 +100,7 @@ def main():
if __name__ == "__main__":
# configure nodes to use
node_map = nodemaps.CLASSIC_NODES
node_map = nodemaps.NODES
nodeutils.set_node_map(node_map)
main()

View file

@ -336,9 +336,16 @@ def main():
if __name__ == "__main__":
# configure nodes to use
node_map = nodemaps.CLASSIC_NODES
node_map = nodemaps.NODES
if len(sys.argv) == 2 and sys.argv[1] == "ovs":
node_map = nodemaps.OVS_NODES
from core.netns.openvswitch import OVS_NODES
node_map.update(OVS_NODES)
# update with BSD based nodes
if os.uname()[0] == "FreeBSD":
from core.bsd.nodes import BSD_NODES
node_map.update(BSD_NODES)
nodeutils.set_node_map(node_map)
# load default services

View file

@ -245,7 +245,7 @@ class Core(object):
class CoreServerTest(object):
def __init__(self):
# setup nodes
node_map = nodemaps.CLASSIC_NODES
node_map = nodemaps.NODES
nodeutils.set_node_map(node_map)
# load emane services
@ -321,7 +321,7 @@ class CoreServerTest(object):
@pytest.fixture()
def session():
# configure default nodes
node_map = nodemaps.CLASSIC_NODES
node_map = nodemaps.NODES
nodeutils.set_node_map(node_map)
# create and return session