updated NodeTypes to be used directly

This commit is contained in:
Blake Harnden 2020-03-10 23:11:37 -07:00
parent f277e96c9a
commit 5cdfd8d8b9
9 changed files with 12 additions and 16 deletions

View file

@ -26,11 +26,7 @@ def add_node_data(node_proto: core_pb2.Node) -> Tuple[NodeTypes, int, NodeOption
:return: node type, id, and options
"""
_id = node_proto.id
_type = node_proto.type
if _type is None:
_type = NodeTypes.DEFAULT.value
_type = NodeTypes(_type)
_type = NodeTypes(node_proto.type)
options = NodeOptions(name=node_proto.name, model=node_proto.model)
options.icon = node_proto.icon
options.opaque = node_proto.opaque

View file

@ -17,7 +17,7 @@ def convert_node(node_data):
coreapi.CoreNodeTlv,
[
(NodeTlvs.NUMBER, node_data.id),
(NodeTlvs.TYPE, node_data.node_type),
(NodeTlvs.TYPE, node_data.node_type.value),
(NodeTlvs.NAME, node_data.name),
(NodeTlvs.IP_ADDRESS, node_data.ip_address),
(NodeTlvs.MAC_ADDRESS, node_data.mac_address),

View file

@ -33,7 +33,7 @@ class EmaneNet(CoreNetworkBase):
Emane controller object that exists in a session.
"""
apitype = NodeTypes.EMANE.value
apitype = NodeTypes.EMANE
linktype = LinkTypes.WIRED
type = "wlan"
is_emane = True

View file

@ -472,7 +472,7 @@ class CoreNode(CoreNodeBase):
Provides standard core node logic.
"""
apitype = NodeTypes.DEFAULT.value
apitype = NodeTypes.DEFAULT
valid_address_types = {"inet", "inet6", "inet6link"}
def __init__(

View file

@ -72,7 +72,7 @@ class DockerClient:
class DockerNode(CoreNode):
apitype = NodeTypes.DOCKER.value
apitype = NodeTypes.DOCKER
def __init__(
self,

View file

@ -66,7 +66,7 @@ class LxdClient:
class LxcNode(CoreNode):
apitype = NodeTypes.LXC.value
apitype = NodeTypes.LXC
def __init__(
self,

View file

@ -999,7 +999,7 @@ class SwitchNode(CoreNetwork):
Provides switch functionality within a core node.
"""
apitype = NodeTypes.SWITCH.value
apitype = NodeTypes.SWITCH
policy = "ACCEPT"
type = "lanswitch"
@ -1010,7 +1010,7 @@ class HubNode(CoreNetwork):
ports by turning off MAC address learning.
"""
apitype = NodeTypes.HUB.value
apitype = NodeTypes.HUB
policy = "ACCEPT"
type = "hub"
@ -1029,7 +1029,7 @@ class WlanNode(CoreNetwork):
Provides wireless lan functionality within a core node.
"""
apitype = NodeTypes.WIRELESS_LAN.value
apitype = NodeTypes.WIRELESS_LAN
linktype = LinkTypes.WIRED
policy = "DROP"
type = "wlan"
@ -1140,6 +1140,6 @@ class TunnelNode(GreTapBridge):
Provides tunnel functionality in a core node.
"""
apitype = NodeTypes.TUNNEL.value
apitype = NodeTypes.TUNNEL
policy = "ACCEPT"
type = "tunnel"

View file

@ -264,7 +264,7 @@ class Rj45Node(CoreNodeBase, CoreInterface):
network.
"""
apitype = NodeTypes.RJ45.value
apitype = NodeTypes.RJ45
type = "rj45"
def __init__(

View file

@ -260,7 +260,7 @@ class NetworkElement(NodeElement):
def add_type(self) -> None:
if self.node.apitype:
node_type = NodeTypes(self.node.apitype).name
node_type = self.node.apitype.name
else:
node_type = self.node.__class__.__name__
add_attribute(self.element, "type", node_type)