From 4e909e6a065e96f07d03c2a24cf6bf662ab2fc79 Mon Sep 17 00:00:00 2001 From: Natalie Gaston Date: Wed, 2 Oct 2024 11:01:17 -0700 Subject: [PATCH 1/5] Rename Update to NodeUpdate --- inbm-lib/inbm_common_lib/constants.py | 2 +- inbm/cloudadapter-agent/cloudadapter/client.py | 5 ++--- .../cloudadapter/cloud/adapters/adapter.py | 4 ++-- .../cloudadapter/cloud/client/cloud_client.py | 12 ++++++------ .../cloud/client/inbs_cloud_client.py | 6 +++--- .../cloudadapter/cloud/cloud_builders.py | 10 +++++----- .../cloudadapter/cloud/cloud_publisher.py | 4 ++-- .../cloudadapter/constants.py | 4 ++-- .../unit/cloud/client/test_cloud_client.py | 4 ++-- .../cloud/client/test_inbs_cloud_client.py | 13 ++++++------- .../tests/unit/cloud/test_cloud_builders.py | 12 ++++++------ .../tests/unit/cloud/test_cloud_publisher.py | 18 +++++++++--------- .../dispatcher/aota/aota_command.py | 2 +- .../dispatcher/dispatcher_broker.py | 6 +++--- 14 files changed, 50 insertions(+), 52 deletions(-) diff --git a/inbm-lib/inbm_common_lib/constants.py b/inbm-lib/inbm_common_lib/constants.py index 5c483bd9a..65a76afdc 100644 --- a/inbm-lib/inbm_common_lib/constants.py +++ b/inbm-lib/inbm_common_lib/constants.py @@ -21,7 +21,7 @@ EVENT_CHANNEL = 'manageability/event' TELEMETRY_CHANNEL = 'manageability/telemetry' # Used for Node updates to be sent to UDM -UPDATE_CHANNEL = 'manageability/update' +NODE_UPDATE_CHANNEL = 'manageability/nodeUpdate' CONFIG_CHANNEL = 'ma/configuration/update/' # Request constants diff --git a/inbm/cloudadapter-agent/cloudadapter/client.py b/inbm/cloudadapter-agent/cloudadapter/client.py index 0800b1fdc..56b35004b 100644 --- a/inbm/cloudadapter-agent/cloudadapter/client.py +++ b/inbm/cloudadapter-agent/cloudadapter/client.py @@ -63,8 +63,8 @@ def _bind_agent_to_cloud(self) -> None: lambda _, payload: self._cloud_publisher.publish_event(payload) ) self._broker.bind_callback( - TC_TOPIC.UPDATE, - lambda _, payload: self._cloud_publisher.publish_update(payload) + TC_TOPIC.NODE_UPDATE, + lambda _, payload: self._cloud_publisher.publish_node_update(payload) ) def _bind_ucc_to_agent(self) -> None: @@ -167,7 +167,6 @@ def stop(self) -> None: logger.debug("Stopping cloudadapter client") self._broker.stop() self._cloud_publisher.publish_event("Disconnected") - self._cloud_publisher.publish_update("Disconnected") try: logger.debug("Calling disconnect on adapter") self._adapter.disconnect() diff --git a/inbm/cloudadapter-agent/cloudadapter/cloud/adapters/adapter.py b/inbm/cloudadapter-agent/cloudadapter/cloud/adapters/adapter.py index e70520b31..621d94060 100644 --- a/inbm/cloudadapter-agent/cloudadapter/cloud/adapters/adapter.py +++ b/inbm/cloudadapter-agent/cloudadapter/cloud/adapters/adapter.py @@ -53,13 +53,13 @@ def bind_callback(self, name: str, callback: Callable) -> None: """ pass - def publish_update(self, message: str) -> None: + def publish_node_update(self, message: str) -> None: """Publishes an update to the cloud @param message: (str) The update message to send @exception PublishError: If publish fails """ - self._client.publish_update("update", message) + self._client.publish_node_update("update", message) def publish_event(self, message: str) -> None: """Publishes an event to the cloud diff --git a/inbm/cloudadapter-agent/cloudadapter/cloud/client/cloud_client.py b/inbm/cloudadapter-agent/cloudadapter/cloud/client/cloud_client.py index 362d2fe58..02b74d5b4 100644 --- a/inbm/cloudadapter-agent/cloudadapter/cloud/client/cloud_client.py +++ b/inbm/cloudadapter-agent/cloudadapter/cloud/client/cloud_client.py @@ -15,21 +15,21 @@ class CloudClient: def __init__(self, connection: MQTTConnection, telemetry: OneWayMessenger, event: OneWayMessenger, - update: OneWayMessenger | None, attribute: OneWayMessenger, + node_update: OneWayMessenger | None, attribute: OneWayMessenger, handler: ReceiveRespondHandler) -> None: """Constructor for CloudClient @param connection: Connection associated with this CloudClient @param telemetry: Messenger to send telemetry @param event: Messenger to send events - @param update: Messenger to send updates + @param node_update: Messenger to send node updates @param attribute: Messenger to send attributes @param handler: Handler to deal with cloud method calls """ self._connection = connection self._telemetry = telemetry self._event = event - self._update: OneWayMessenger | None = update + self._node_update: OneWayMessenger | None = node_update self._attribute = attribute self._handler = handler @@ -57,18 +57,18 @@ def publish_telemetry(self, key: str, value: str, time: datetime) -> None: """ return self._telemetry.publish(key, value, time) - def publish_update(self, key: str, value: str) -> None: + def publish_node_update(self, key: str, value: str) -> None: """Publishes an update to the cloud @param key: key to publish @param value: update to publish @exception PublishError: If publish fails """ - if self._update is None: + if self._node_update is None: logger.error("Received update publish request but no update messenger is configured") return None else: - return self._update.publish(key, value) + return self._node_update.publish(key, value) def publish_event(self, key: str, value: str) -> None: """Publishes an event to the cloud diff --git a/inbm/cloudadapter-agent/cloudadapter/cloud/client/inbs_cloud_client.py b/inbm/cloudadapter-agent/cloudadapter/cloud/client/inbs_cloud_client.py index cdd7d4739..689d3ef99 100644 --- a/inbm/cloudadapter-agent/cloudadapter/cloud/client/inbs_cloud_client.py +++ b/inbm/cloudadapter-agent/cloudadapter/cloud/client/inbs_cloud_client.py @@ -114,14 +114,14 @@ def publish_telemetry(self, key: str, value: str, time: datetime) -> None: pass # INBS is not yet ready to receive telemetry - def publish_update(self, key: str, value: str) -> None: - """Publishes an update to the cloud + def publish_node_update(self, key: str, value: str) -> None: + """Publishes a node update to the cloud @param message: node update message to publish @exception PublishError: If publish fails """ if self._grpc_channel is None: - raise PublishError("gRPC channel not set up before calling InbsCloudClient.publish_update") + raise PublishError("gRPC channel not set up before calling InbsCloudClient.publish_node_update") # Turn the message into a dict logger.debug(f"Received node update: key={key}, value={value}") diff --git a/inbm/cloudadapter-agent/cloudadapter/cloud/cloud_builders.py b/inbm/cloudadapter-agent/cloudadapter/cloud/cloud_builders.py index 1f18d8fb6..aecb7d09e 100644 --- a/inbm/cloudadapter-agent/cloudadapter/cloud/cloud_builders.py +++ b/inbm/cloudadapter-agent/cloudadapter/cloud/cloud_builders.py @@ -143,7 +143,7 @@ def build_messenger_with_config(config: Dict[str, Any]): telemetry = config.get("telemetry") attribute = config.get("attribute") event = config.get("event") - update = config.get("update") + node_update = config.get("node_update") if telemetry: telemetry = build_messenger_with_config(telemetry) @@ -155,10 +155,10 @@ def build_messenger_with_config(config: Dict[str, Any]): else: raise ClientBuildError( "Missing 'attribute' MQTT config information while setting up cloud connection.") - if update: - update = build_messenger_with_config(update) + if node_update: + node_update = build_messenger_with_config(node_update) else: - logger.debug("Missing 'update' MQTT config information while setting up cloud connection. TODO: figure out why this doesn't happen for INBS, but does happen for other clouds.") + logger.debug("Missing 'node_update' MQTT config information while setting up cloud connection. TODO: figure out why this doesn't happen for INBS, but does happen for other clouds.") if event: event = build_messenger_with_config(event) else: @@ -205,6 +205,6 @@ def build_messenger_with_config(config: Dict[str, Any]): connection=connection, telemetry=telemetry, event=event, - update=update, + update=node_update, attribute=attribute, handler=handler) diff --git a/inbm/cloudadapter-agent/cloudadapter/cloud/cloud_publisher.py b/inbm/cloudadapter-agent/cloudadapter/cloud/cloud_publisher.py index 19193c57e..3ce0d8548 100644 --- a/inbm/cloudadapter-agent/cloudadapter/cloud/cloud_publisher.py +++ b/inbm/cloudadapter-agent/cloudadapter/cloud/cloud_publisher.py @@ -73,13 +73,13 @@ def publish_telemetry(self, message: str) -> None: except PublishError as e: logger.error(str(e)) - def publish_update(self, message: str) -> None: + def publish_node_update(self, message: str) -> None: """Send node update to UDM @param message: (str) JSON formatted SendNodeUpdateRequest """ logger.debug(f"Received node update: {message}") try: - self._adapter.publish_update(message) + self._adapter.publish_node_update(message) except PublishError as e: logger.error(str(e)) diff --git a/inbm/cloudadapter-agent/cloudadapter/constants.py b/inbm/cloudadapter-agent/cloudadapter/constants.py index a31319bfd..900d4d26b 100644 --- a/inbm/cloudadapter-agent/cloudadapter/constants.py +++ b/inbm/cloudadapter-agent/cloudadapter/constants.py @@ -5,7 +5,7 @@ SPDX-License-Identifier: Apache-2.0 """ -from inbm_common_lib.constants import UPDATE_CHANNEL, TELEMETRY_CHANNEL, RESPONSE_CHANNEL, EVENT_CHANNEL +from inbm_common_lib.constants import NODE_UPDATE_CHANNEL, TELEMETRY_CHANNEL, RESPONSE_CHANNEL, EVENT_CHANNEL from inbm_lib.constants import DOCKER_STATS from inbm_lib.path_prefixes import INTEL_MANAGEABILITY_ETC_PATH_PREFIX from inbm_lib.path_prefixes import INTEL_MANAGEABILITY_SHARE_PATH_PREFIX, BROKER_ETC_PATH @@ -39,7 +39,7 @@ class TC_TOPIC: STATE = tuple([STATE_CHANNEL]) TELEMETRY = tuple([TELEMETRY_CHANNEL]) # Shared by TC and UCC EVENT = tuple([EVENT_CHANNEL, RESPONSE_CHANNEL]) # TODO: What's up with response? - UPDATE = tuple([UPDATE_CHANNEL]) # Used for Node updates to be sent to UDM + NODE_UPDATE = tuple([NODE_UPDATE_CHANNEL]) # Used for Node updates to be sent to UDM # ========== Publishing channels diff --git a/inbm/cloudadapter-agent/tests/unit/cloud/client/test_cloud_client.py b/inbm/cloudadapter-agent/tests/unit/cloud/client/test_cloud_client.py index d72f6ecca..1895fc81d 100644 --- a/inbm/cloudadapter-agent/tests/unit/cloud/client/test_cloud_client.py +++ b/inbm/cloudadapter-agent/tests/unit/cloud/client/test_cloud_client.py @@ -47,9 +47,9 @@ def test_publish_attribute_succeeds(self) -> None: self.cloud_client.publish_attribute(*args) assert self.mock_attribute.publish.call_count == 1 - def test_publish_update_succeeds(self) -> None: + def test_publish_node_update_succeeds(self) -> None: args = ("key", "value") - self.cloud_client.publish_update(*args) + self.cloud_client.publish_node_update(*args) assert self.mock_update.publish.call_count == 1 def test_publish_event_succeeds(self) -> None: diff --git a/inbm/cloudadapter-agent/tests/unit/cloud/client/test_inbs_cloud_client.py b/inbm/cloudadapter-agent/tests/unit/cloud/client/test_inbs_cloud_client.py index dce7bdd3d..298808e9d 100644 --- a/inbm/cloudadapter-agent/tests/unit/cloud/client/test_inbs_cloud_client.py +++ b/inbm/cloudadapter-agent/tests/unit/cloud/client/test_inbs_cloud_client.py @@ -1,4 +1,3 @@ -import threading import pytest from mock import MagicMock, Mock, patch import queue @@ -52,7 +51,7 @@ def test_publish_telemetry(self, inbs_client: InbsCloudClient) -> None: key="example_key", value="example_value", time=datetime.now() ) - def test_publish_update(self, inbs_client: InbsCloudClient) -> None: + def test_publish_node_update(self, inbs_client: InbsCloudClient) -> None: mock_channel = MagicMock() mock_channel.SendNodeUpdateRequest.return_value = "MockResponse" inbs_client._grpc_channel = mock_channel @@ -60,13 +59,13 @@ def test_publish_update(self, inbs_client: InbsCloudClient) -> None: key = 'test-key' value = '{"job_id": "12345", "status": 200, "message": "Update successful"}' - # Call the publish_update method - inbs_client.publish_update(key, value) + # Call the publish_node_update method + inbs_client.publish_node_update(key, value) # Assert that the gRPC channel's SendNodeUpdate method was called mock_channel.SendNodeUpdate.assert_called_once() - def test_publish_update_failure_no_grpc_channel(self, inbs_client: InbsCloudClient): + def test_publish_node_update_failure_no_grpc_channel(self, inbs_client: InbsCloudClient): # Ensure that _grpc_channel is None to simulate the channel not being set up inbs_client._grpc_channel = None @@ -74,9 +73,9 @@ def test_publish_update_failure_no_grpc_channel(self, inbs_client: InbsCloudClie key = 'test-key' value = '{"job_id": "12345", "status": 200, "message": "Update successful"}' - # Call the publish_update method and expect a PublishError + # Call the publish_node_update method and expect a PublishError with pytest.raises(PublishError): - inbs_client.publish_update(key, value) + inbs_client.publish_node_update(key, value) def test_publish_event(self, inbs_client: InbsCloudClient) -> None: # this is not expected to do anything yet diff --git a/inbm/cloudadapter-agent/tests/unit/cloud/test_cloud_builders.py b/inbm/cloudadapter-agent/tests/unit/cloud/test_cloud_builders.py index 0e0ea175a..b9b4ed703 100644 --- a/inbm/cloudadapter-agent/tests/unit/cloud/test_cloud_builders.py +++ b/inbm/cloudadapter-agent/tests/unit/cloud/test_cloud_builders.py @@ -34,9 +34,9 @@ def setUp(self) -> None: "pub": "event_pub", "format": "event_format" }, - "update": { - "pub": "update_pub", - "format": "update_format" + "node_update": { + "pub": "node_update_pub", + "format": "node_update_format" }, "telemetry": { "pub": "telemetry_pub", @@ -93,9 +93,9 @@ def setUp(self) -> None: "pub": "event_pub", "format": "event_format" }, - "update": { - "pub": "update_pub", - "format": "update_format" + "node_update": { + "pub": "node_update_pub", + "format": "node_update_format" }, "command": { "pub": "manageability/request/command", diff --git a/inbm/cloudadapter-agent/tests/unit/cloud/test_cloud_publisher.py b/inbm/cloudadapter-agent/tests/unit/cloud/test_cloud_publisher.py index b9e61b6f1..77754fb8f 100644 --- a/inbm/cloudadapter-agent/tests/unit/cloud/test_cloud_publisher.py +++ b/inbm/cloudadapter-agent/tests/unit/cloud/test_cloud_publisher.py @@ -24,23 +24,23 @@ def setUp(self, MockedAdapter, mock_logger) -> None: self.MockedAdapter = MockedAdapter self.cloud_publisher = CloudPublisher(self.MockedAdapter("config")) - def test_publish_update_succeed(self) -> None: + def test_publish_node_update_succeed(self) -> None: update = "update" - self.cloud_publisher.publish_update(update) + self.cloud_publisher.publish_node_update(update) mocked = self.MockedAdapter.return_value - mocked.publish_update.assert_called_once_with(update) + mocked.publish_node_update.assert_called_once_with(update) @mock.patch("cloudadapter.cloud.cloud_publisher.logger") - def test_publish_update_with_adapter__succeeds(self, mock_logger) -> None: - self.MockedAdapter.return_value.publish_update.return_value = None - self.cloud_publisher.publish_update('{"status": 200, "message": "COMMAND SUCCESSFUL", "job_id": "swupd-0cdce9d5-523b-43d9-8673-d54fd61498fe"}') + def test_publish_node_update_with_adapter__succeeds(self, mock_logger) -> None: + self.MockedAdapter.return_value.publish_node_update.return_value = None + self.cloud_publisher.publish_node_update('{"status": 200, "message": "COMMAND SUCCESSFUL", "job_id": "swupd-0cdce9d5-523b-43d9-8673-d54fd61498fe"}') assert mock_logger.error.call_count == 0 @mock.patch("cloudadapter.cloud.cloud_publisher.logger") - def test_publish_update_with_adapter_fails(self, mock_logger) -> None: - self.MockedAdapter.return_value.publish_update.side_effect = PublishError("Error!") - self.cloud_publisher.publish_update('{"status": 200, "message": "COMMAND SUCCESSFUL", "job_id": "swupd-0cdce9d5-523b-43d9-8673-d54fd61498fe"}') + def test_publish_node_update_with_adapter_fails(self, mock_logger) -> None: + self.MockedAdapter.return_value.publish_node_update.side_effect = PublishError("Error!") + self.cloud_publisher.publish_node_update('{"status": 200, "message": "COMMAND SUCCESSFUL", "job_id": "swupd-0cdce9d5-523b-43d9-8673-d54fd61498fe"}') assert mock_logger.error.call_count == 1 def test_publish_event_succeed(self) -> None: diff --git a/inbm/dispatcher-agent/dispatcher/aota/aota_command.py b/inbm/dispatcher-agent/dispatcher/aota/aota_command.py index 9ae6cf9f6..fca57f78c 100644 --- a/inbm/dispatcher-agent/dispatcher/aota/aota_command.py +++ b/inbm/dispatcher-agent/dispatcher/aota/aota_command.py @@ -19,7 +19,7 @@ from dispatcher.common.result_constants import INSTALL_FAILURE, CODE_OK from dispatcher.config_dbs import ConfigDbs -from dispatcher.constants import TELEMETRY_UPDATE_CHANNEL, UMASK_OTA +from dispatcher.constants import UMASK_OTA from dispatcher.packageinstaller.package_installer import TrtlContainer from dispatcher.packagemanager.local_repo import DirectoryRepo from dispatcher.packagemanager.package_manager import get diff --git a/inbm/dispatcher-agent/dispatcher/dispatcher_broker.py b/inbm/dispatcher-agent/dispatcher/dispatcher_broker.py index 3e4005fbd..8a5874f5d 100644 --- a/inbm/dispatcher-agent/dispatcher/dispatcher_broker.py +++ b/inbm/dispatcher-agent/dispatcher/dispatcher_broker.py @@ -16,7 +16,7 @@ from inbm_lib.mqttclient.config import DEFAULT_MQTT_HOST, DEFAULT_MQTT_PORT, MQTT_KEEPALIVE_INTERVAL from inbm_lib.mqttclient.mqtt import MQTT -from inbm_common_lib.constants import RESPONSE_CHANNEL, EVENT_CHANNEL, UPDATE_CHANNEL +from inbm_common_lib.constants import RESPONSE_CHANNEL, EVENT_CHANNEL, NODE_UPDATE_CHANNEL logger = logging.getLogger(__name__) @@ -46,8 +46,8 @@ def send_update(self, message: str) -> None: @param message: message to be published to cloud @param job_id: Job ID used to track the request in both UDM and TC """ - logger.debug(f"Sending node update for to {UPDATE_CHANNEL} with message: {message}") - self.mqtt_publish(topic=UPDATE_CHANNEL, payload=message) + logger.debug(f"Sending node update for to {NODE_UPDATE_CHANNEL} with message: {message}") + self.mqtt_publish(topic=NODE_UPDATE_CHANNEL, payload=message) def _check_db_for_started_job(self) -> Optional[Schedule]: sqliteMgr = SqliteManager() From 75fb2f555770b216636718167b3c1bee138369b4 Mon Sep 17 00:00:00 2001 From: Natalie Gaston Date: Thu, 3 Oct 2024 16:31:09 -0700 Subject: [PATCH 2/5] fix --- inbm/cloudadapter-agent/cloudadapter/cloud/cloud_builders.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inbm/cloudadapter-agent/cloudadapter/cloud/cloud_builders.py b/inbm/cloudadapter-agent/cloudadapter/cloud/cloud_builders.py index aecb7d09e..b8857f1e3 100644 --- a/inbm/cloudadapter-agent/cloudadapter/cloud/cloud_builders.py +++ b/inbm/cloudadapter-agent/cloudadapter/cloud/cloud_builders.py @@ -205,6 +205,6 @@ def build_messenger_with_config(config: Dict[str, Any]): connection=connection, telemetry=telemetry, event=event, - update=node_update, + node_update=node_update, attribute=attribute, handler=handler) From 4abcac0cfaedefc669e172d2292e1ac1982955cc Mon Sep 17 00:00:00 2001 From: Natalie Gaston Date: Thu, 3 Oct 2024 16:38:13 -0700 Subject: [PATCH 3/5] fix tests --- .../tests/unit/cloud/client/test_cloud_client.py | 6 +++--- .../tests/unit/cloud/client/test_inbs_cloud_client.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/inbm/cloudadapter-agent/tests/unit/cloud/client/test_cloud_client.py b/inbm/cloudadapter-agent/tests/unit/cloud/client/test_cloud_client.py index 1895fc81d..1eb0f2d55 100644 --- a/inbm/cloudadapter-agent/tests/unit/cloud/client/test_cloud_client.py +++ b/inbm/cloudadapter-agent/tests/unit/cloud/client/test_cloud_client.py @@ -25,14 +25,14 @@ def setUp(self) -> None: self.mock_telemetry = mock.create_autospec(Messenger) self.mock_attribute = mock.create_autospec(Messenger) self.mock_event = mock.create_autospec(Messenger) - self.mock_update = mock.create_autospec(Messenger) + self.mock_node_update = mock.create_autospec(Messenger) self.mock_handler = mock.create_autospec(Handler) self.cloud_client = CloudClient( connection=self.mock_connection, telemetry=self.mock_telemetry, event=self.mock_event, - update=self.mock_update, + node_update=self.mock_node_update, attribute=self.mock_attribute, handler=self.mock_handler ) @@ -50,7 +50,7 @@ def test_publish_attribute_succeeds(self) -> None: def test_publish_node_update_succeeds(self) -> None: args = ("key", "value") self.cloud_client.publish_node_update(*args) - assert self.mock_update.publish.call_count == 1 + assert self.mock_node_update.publish.call_count == 1 def test_publish_event_succeeds(self) -> None: args = ("key", "value") diff --git a/inbm/cloudadapter-agent/tests/unit/cloud/client/test_inbs_cloud_client.py b/inbm/cloudadapter-agent/tests/unit/cloud/client/test_inbs_cloud_client.py index a41a02297..aa98eb7c2 100644 --- a/inbm/cloudadapter-agent/tests/unit/cloud/client/test_inbs_cloud_client.py +++ b/inbm/cloudadapter-agent/tests/unit/cloud/client/test_inbs_cloud_client.py @@ -61,7 +61,7 @@ def test_publish_node_update(self, inbs_client: InbsCloudClient) -> None: # Call the publish_update method with patch('cloudadapter.cloud.client.inbs_cloud_client.is_valid_json_structure', return_value=True): - inbs_client.publish_update(key, value) + inbs_client.publish_node_update(key, value) # Assert that the gRPC channel's SendNodeUpdate method was called mock_channel.SendNodeUpdate.assert_called_once() From 95fe081055af25207042d921a358afb85d798f5f Mon Sep 17 00:00:00 2001 From: Natalie Gaston Date: Fri, 4 Oct 2024 09:47:01 -0700 Subject: [PATCH 4/5] fixes connection issue --- inbm-lib/inbm_common_lib/constants.py | 2 +- .../cloudadapter/cloud/client/inbs_cloud_client.py | 6 +++--- .../etc/intel-manageability/public/mqtt-broker/acl.file | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/inbm-lib/inbm_common_lib/constants.py b/inbm-lib/inbm_common_lib/constants.py index 855f24073..4ccbea7ae 100644 --- a/inbm-lib/inbm_common_lib/constants.py +++ b/inbm-lib/inbm_common_lib/constants.py @@ -21,7 +21,7 @@ EVENT_CHANNEL = 'manageability/event' TELEMETRY_CHANNEL = 'manageability/telemetry' # Used for Node updates to be sent to UDM -NODE_UPDATE_CHANNEL = 'manageability/nodeUpdate' +NODE_UPDATE_CHANNEL = 'manageability/nodeupdate' CONFIG_CHANNEL = 'ma/configuration/update/' # Request constants diff --git a/inbm/cloudadapter-agent/cloudadapter/cloud/client/inbs_cloud_client.py b/inbm/cloudadapter-agent/cloudadapter/cloud/client/inbs_cloud_client.py index 81f27ceb8..a1574dac2 100644 --- a/inbm/cloudadapter-agent/cloudadapter/cloud/client/inbs_cloud_client.py +++ b/inbm/cloudadapter-agent/cloudadapter/cloud/client/inbs_cloud_client.py @@ -9,6 +9,7 @@ import random import logging import threading +import uuid from google.protobuf.timestamp_pb2 import Timestamp from typing import Callable, Optional from datetime import datetime @@ -26,6 +27,7 @@ import grpc # type: ignore from .cloud_client import CloudClient + logger = logging.getLogger(__name__) @@ -156,10 +158,9 @@ def publish_node_update(self, key: str, value: str) -> None: actual_end_time=timestamp, job_state=job_state ) - request = inbs_sb_pb2.SendNodeUpdateRequest( - request_id="notused", + request_id=str(uuid.uuid4()), job_update=job, ) logger.debug(f"Sending node update to INBS: request={request}") @@ -234,7 +235,6 @@ def _handle_inbm_command_request( ) continue - if command_type: if command_type == "update_scheduled_operations": # Convert operations to Dispatcher's ScheduleRequest diff --git a/inbm/fpm/mqtt/template/etc/intel-manageability/public/mqtt-broker/acl.file b/inbm/fpm/mqtt/template/etc/intel-manageability/public/mqtt-broker/acl.file index 962842ab3..a85920a22 100644 --- a/inbm/fpm/mqtt/template/etc/intel-manageability/public/mqtt-broker/acl.file +++ b/inbm/fpm/mqtt/template/etc/intel-manageability/public/mqtt-broker/acl.file @@ -12,7 +12,7 @@ topic write manageability/event topic write manageability/cmd/+ topic write manageability/response topic write manageability/response/+ -topic write manageability/update +topic write manageability/nodeupdate topic write ma/configuration/update/+ topic write dispatcher/query @@ -23,7 +23,7 @@ topic read manageability/response topic read manageability/response/+ topic read manageability/telemetry topic read manageability/event -topic read manageability/update +topic read manageability/nodeupdate user inbc-program topic write manageability/request/# From bf2cdcd667f962ad622ed2de1d1fe179228b04b6 Mon Sep 17 00:00:00 2001 From: Natalie Gaston Date: Fri, 4 Oct 2024 10:24:54 -0700 Subject: [PATCH 5/5] update documentation --- inbm/cloudadapter-agent/README.md | 2 +- inbm/dispatcher-agent/README.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/inbm/cloudadapter-agent/README.md b/inbm/cloudadapter-agent/README.md index 99e80295a..0e61406c8 100644 --- a/inbm/cloudadapter-agent/README.md +++ b/inbm/cloudadapter-agent/README.md @@ -49,7 +49,7 @@ The agent subscribes to the following topics: - Agent events: `manageability/event` - Responses: `manageability/response` - Device telemetry: `manageability/telemetry` - - Update from scheduled requests: `manageability/update` + - Update from scheduled requests: `manageability/nodeupdate` ❗`+` is a wild-card indicating single level thus matching `diagnostic/state` or `/state` diff --git a/inbm/dispatcher-agent/README.md b/inbm/dispatcher-agent/README.md index 296047e0b..18a1c97d1 100644 --- a/inbm/dispatcher-agent/README.md +++ b/inbm/dispatcher-agent/README.md @@ -43,6 +43,7 @@ The agent publishes to the following topics: - Dynamic telemetry updates: `telemetry/update` - Informs diagnostic-agent remediation manager to remove a specific container: `remediation/container` - Informs diagnostic-agent remediation manager to remove a specific image:`remediation/image` + - Sends the result of a scheduled request received from UDMScheduled node update. This result is actually sent as a request to cloudadapter: `manageability/nodeupdate` - dispatcher-agent state: dispatcher/state` when dead/running