From 5cdfd8d8b97546c2c67d8ff0c2fe8b4a87b2f677 Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Tue, 10 Mar 2020 23:11:37 -0700 Subject: [PATCH] updated NodeTypes to be used directly --- daemon/core/api/grpc/grpcutils.py | 6 +----- daemon/core/api/tlv/dataconversion.py | 2 +- daemon/core/emane/nodes.py | 2 +- daemon/core/nodes/base.py | 2 +- daemon/core/nodes/docker.py | 2 +- daemon/core/nodes/lxd.py | 2 +- daemon/core/nodes/network.py | 8 ++++---- daemon/core/nodes/physical.py | 2 +- daemon/core/xml/corexml.py | 2 +- 9 files changed, 12 insertions(+), 16 deletions(-) diff --git a/daemon/core/api/grpc/grpcutils.py b/daemon/core/api/grpc/grpcutils.py index d765f4bc..6de7c0bd 100644 --- a/daemon/core/api/grpc/grpcutils.py +++ b/daemon/core/api/grpc/grpcutils.py @@ -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 diff --git a/daemon/core/api/tlv/dataconversion.py b/daemon/core/api/tlv/dataconversion.py index 8d47613d..f2378115 100644 --- a/daemon/core/api/tlv/dataconversion.py +++ b/daemon/core/api/tlv/dataconversion.py @@ -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), diff --git a/daemon/core/emane/nodes.py b/daemon/core/emane/nodes.py index 99045c07..b522a7e2 100644 --- a/daemon/core/emane/nodes.py +++ b/daemon/core/emane/nodes.py @@ -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 diff --git a/daemon/core/nodes/base.py b/daemon/core/nodes/base.py index 9b72df72..9a5da63d 100644 --- a/daemon/core/nodes/base.py +++ b/daemon/core/nodes/base.py @@ -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__( diff --git a/daemon/core/nodes/docker.py b/daemon/core/nodes/docker.py index 4622f4f5..60adfe32 100644 --- a/daemon/core/nodes/docker.py +++ b/daemon/core/nodes/docker.py @@ -72,7 +72,7 @@ class DockerClient: class DockerNode(CoreNode): - apitype = NodeTypes.DOCKER.value + apitype = NodeTypes.DOCKER def __init__( self, diff --git a/daemon/core/nodes/lxd.py b/daemon/core/nodes/lxd.py index b64c0206..3ca399b5 100644 --- a/daemon/core/nodes/lxd.py +++ b/daemon/core/nodes/lxd.py @@ -66,7 +66,7 @@ class LxdClient: class LxcNode(CoreNode): - apitype = NodeTypes.LXC.value + apitype = NodeTypes.LXC def __init__( self, diff --git a/daemon/core/nodes/network.py b/daemon/core/nodes/network.py index fdfa87f1..f9bbd7d3 100644 --- a/daemon/core/nodes/network.py +++ b/daemon/core/nodes/network.py @@ -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" diff --git a/daemon/core/nodes/physical.py b/daemon/core/nodes/physical.py index 8959fda1..299f1ebb 100644 --- a/daemon/core/nodes/physical.py +++ b/daemon/core/nodes/physical.py @@ -264,7 +264,7 @@ class Rj45Node(CoreNodeBase, CoreInterface): network. """ - apitype = NodeTypes.RJ45.value + apitype = NodeTypes.RJ45 type = "rj45" def __init__( diff --git a/daemon/core/xml/corexml.py b/daemon/core/xml/corexml.py index 074a6913..64e20674 100644 --- a/daemon/core/xml/corexml.py +++ b/daemon/core/xml/corexml.py @@ -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)