updates to allow custom nodes to be linked with interfaces

This commit is contained in:
Blake Harnden 2019-11-08 15:43:58 -08:00
parent b0fe5660bd
commit 3306dbbfae

View file

@ -13,8 +13,8 @@ from coretk.interface import Interface, InterfaceManager
from coretk.mobilitynodeconfig import MobilityNodeConfig
from coretk.wlannodeconfig import WlanNodeConfig
NETWORK_NODES = ["switch", "hub", "wlan", "rj45", "tunnel", "emane"]
DEFAULT_NODES = ["router", "host", "PC", "mdr", "prouter"]
NETWORK_NODES = {"switch", "hub", "wlan", "rj45", "tunnel", "emane"}
DEFAULT_NODES = {"router", "host", "PC", "mdr", "prouter"}
class Node:
@ -409,6 +409,9 @@ class CoreClient:
else:
return self.reusable.pop(0)
def is_model_node(self, name):
return name in DEFAULT_NODES or name in self.custom_nodes
def add_graph_node(self, session_id, canvas_id, x, y, name):
"""
Add node, with information filled in, to grpc manager
@ -437,7 +440,7 @@ class CoreClient:
node_type = core_pb2.NodeType.TUNNEL
elif name == "emane":
node_type = core_pb2.NodeType.EMANE
elif name in DEFAULT_NODES or name in self.custom_nodes:
elif self.is_model_node(name):
node_type = core_pb2.NodeType.DEFAULT
node_model = name
else:
@ -606,7 +609,7 @@ class CoreClient:
self.interfaces_manager.new_subnet()
src_node = self.nodes[src_canvas_id]
if src_node.model in DEFAULT_NODES:
if self.is_model_node(src_node.model):
ifid = len(src_node.interfaces)
name = "eth" + str(ifid)
src_interface = Interface(
@ -620,7 +623,7 @@ class CoreClient:
)
dst_node = self.nodes[dst_canvas_id]
if dst_node.model in DEFAULT_NODES:
if self.is_model_node(dst_node.model):
ifid = len(dst_node.interfaces)
name = "eth" + str(ifid)
dst_interface = Interface(