From 72189a5c28fe86b9978c29bdf684d28153b49506 Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Wed, 1 Apr 2020 10:56:09 -0700 Subject: [PATCH] fix configdata issue, since most corehandler code did not account for using flags directly --- daemon/core/api/tlv/corehandlers.py | 2 +- daemon/core/api/tlv/dataconversion.py | 10 ++++++++-- daemon/core/emulator/data.py | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/daemon/core/api/tlv/corehandlers.py b/daemon/core/api/tlv/corehandlers.py index 4a5e02db..95ee5e9c 100644 --- a/daemon/core/api/tlv/corehandlers.py +++ b/daemon/core/api/tlv/corehandlers.py @@ -1892,7 +1892,7 @@ class CoreHandler(socketserver.BaseRequestHandler): node = self.session.get_node(node_id) values = ServiceShim.tovaluelist(node, service) config_data = ConfigData( - message_type=MessageFlags.NONE, + message_type=0, node=node_id, object=self.session.services.name, type=ConfigFlags.UPDATE.value, diff --git a/daemon/core/api/tlv/dataconversion.py b/daemon/core/api/tlv/dataconversion.py index 2689a1e9..876e72a5 100644 --- a/daemon/core/api/tlv/dataconversion.py +++ b/daemon/core/api/tlv/dataconversion.py @@ -18,6 +18,9 @@ def convert_node(node_data): :param core.emulator.data.NodeData node_data: node data to convert :return: packed node message """ + session = None + if node_data.session is not None: + session = str(node_data.session) services = None if node_data.services is not None: services = "|".join([x for x in node_data.services]) @@ -33,7 +36,7 @@ def convert_node(node_data): (NodeTlvs.MODEL, node_data.model), (NodeTlvs.EMULATION_ID, node_data.emulation_id), (NodeTlvs.EMULATION_SERVER, node_data.server), - (NodeTlvs.SESSION, str(node_data.session)), + (NodeTlvs.SESSION, session), (NodeTlvs.X_POSITION, int(node_data.x_position)), (NodeTlvs.Y_POSITION, int(node_data.y_position)), (NodeTlvs.CANVAS, node_data.canvas), @@ -56,6 +59,9 @@ def convert_config(config_data): :param core.emulator.data.ConfigData config_data: config data to convert :return: packed message """ + session = None + if config_data.session is not None: + session = str(config_data.session) tlv_data = structutils.pack_values( coreapi.CoreConfigTlv, [ @@ -68,7 +74,7 @@ def convert_config(config_data): (ConfigTlvs.BITMAP, config_data.bitmap), (ConfigTlvs.POSSIBLE_VALUES, config_data.possible_values), (ConfigTlvs.GROUPS, config_data.groups), - (ConfigTlvs.SESSION, str(config_data.session)), + (ConfigTlvs.SESSION, session), (ConfigTlvs.INTERFACE_NUMBER, config_data.interface_number), (ConfigTlvs.NETWORK_ID, config_data.network_id), (ConfigTlvs.OPAQUE, config_data.opaque), diff --git a/daemon/core/emulator/data.py b/daemon/core/emulator/data.py index a7d4c9df..c7141541 100644 --- a/daemon/core/emulator/data.py +++ b/daemon/core/emulator/data.py @@ -16,7 +16,7 @@ from core.emulator.enumerations import ( @dataclass class ConfigData: - message_type: MessageFlags = None + message_type: int = None node: int = None object: str = None type: int = None