Skip to content

Commit

Permalink
Add Get Power Capabilities to Telemetry agent as static telemetry data (
Browse files Browse the repository at this point in the history
  • Loading branch information
nmgaston authored Dec 5, 2024
1 parent 88cdab8 commit 13bc848
Show file tree
Hide file tree
Showing 19 changed files with 548 additions and 210 deletions.
1 change: 1 addition & 0 deletions inbm/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
## Next Release
### Changed
- (NEXMANAGE-513) Record the granular log in download-only mode
- (NEXMANAGE-1022) Adds Power Capabilities to Static Telemetry data. Sends Static Telemetry data to INBS via the INBS Cloud Client in CloudAdapter.

### Added
- (NEXMANAGE-826) Update granular log to support architecture independent package
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def publish_telemetry(self, key: str, value: str, time: datetime) -> None:
@param time: timestamp for this telemetry publish
@exception PublishError: If publish fails
"""

pass # INBS is not yet ready to receive telemetry
pass # INBS is not yet ready to receive events

def publish_node_update(self, key: str, value: str) -> None:
"""Publishes a node update to the cloud
Expand Down Expand Up @@ -161,9 +161,10 @@ def publish_node_update(self, key: str, value: str) -> None:

request = inbs_sb_pb2.SendNodeUpdateRequest(
request_id=str(uuid.uuid4()),
job_update=job,
job_update=job,
static_telemetry=None,
)
logger.debug(f"Sending node update to INBS: request={request}")
logger.debug(f"Sending node update job status to INBS: request={request}")

try:
response = self._grpc_channel.SendNodeUpdate(request, metadata=self._metadata)
Expand All @@ -185,11 +186,35 @@ def publish_attribute(self, key: str, value: str) -> None:
"""Publishes a device attribute to the cloud
@param key: attribute's key
@param value: value to set for the attribute
@param value: attribute's value
@exception PublishError: If publish fails
"""

pass # INBS is not yet ready to receive attributes
logger.debug(f"Received telemetry: key={key}, value={value}")

if self._grpc_channel is None:
raise PublishError("gRPC channel not set up before calling InbsCloudClient.publish_node_update")


static_telemetry=common_pb2.StaticTelemetry(
node_id=self._client_id,
)

static_telemetry.key = key
static_telemetry.value = value

request = inbs_sb_pb2.SendNodeUpdateRequest(
request_id=str(uuid.uuid4()),
job_update=None,
static_telemetry=static_telemetry,
)
logger.debug(f"Sending node update of static telemetry to INBS: request={request}")

try:
response = self._grpc_channel.SendNodeUpdate(request, metadata=self._metadata)
logger.info(f"Received response from gRPC server: {response}")
except grpc.RpcError as e:
logger.error(f"Failed to send node update via gRPC: {e}")

def bind_callback(self, name: str, callback: Callable) -> None:
"""Bind a callback to be triggered by a method called on the cloud
Expand Down
32 changes: 22 additions & 10 deletions inbm/cloudadapter-agent/cloudadapter/pb/common/v1/common_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions inbm/cloudadapter-agent/cloudadapter/pb/common/v1/common_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,27 @@ class PostOperation(google.protobuf.message.Message):

global___PostOperation = PostOperation

@typing.final
class StaticTelemetry(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

NODE_ID_FIELD_NUMBER: builtins.int
KEY_FIELD_NUMBER: builtins.int
VALUE_FIELD_NUMBER: builtins.int
node_id: builtins.str
key: builtins.str
value: builtins.str
def __init__(
self,
*,
node_id: builtins.str = ...,
key: builtins.str = ...,
value: builtins.str = ...,
) -> None: ...
def ClearField(self, field_name: typing.Literal["key", b"key", "node_id", b"node_id", "value", b"value"]) -> None: ...

global___StaticTelemetry = StaticTelemetry

@typing.final
class Job(google.protobuf.message.Message):
"""this message represents a Job and can be used in multiple contexts; see RPC definitions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
import warnings


GRPC_GENERATED_VERSION = '1.67.0'
GRPC_VERSION = grpc.__version__
_version_not_supported = False

try:
from grpc._utilities import first_version_is_lower
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
except ImportError:
_version_not_supported = True

if _version_not_supported:
raise RuntimeError(
f'The grpc package installed is at version {GRPC_VERSION},'
+ f' but the generated code in cloudadapter.pb.common.v1/common_pb2_grpc.py depends on'
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
)
Loading

0 comments on commit 13bc848

Please sign in to comment.