Skip to content

Commit

Permalink
fix: fixed component management
Browse files Browse the repository at this point in the history
  • Loading branch information
naman108 committed Dec 28, 2024
1 parent 965791b commit f19a20a
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 37 deletions.
10 changes: 4 additions & 6 deletions digitalpy/core/api/blueprints/component_management_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ def GETComponent():
"""TODO"""
try:
# send data to the NetworkInterface
response = BlueprintCommunicator().send_message_sync(
"GETComponent",
"^Component",
response = BlueprintCommunicator().send_flow_sync(
"ComponentManagement_GetComponent",
{
}) # type: ignore
return response.get_value("message"), 200
Expand Down Expand Up @@ -95,9 +94,8 @@ def GETComponentStatus():
"""returns the status of the component or the last error"""
try:
# send data to the NetworkInterface
BlueprintCommunicator().send_message_async(
"GETComponentStatus",
"^ComponentStatus",
BlueprintCommunicator().send_flow_sync(
"ComponentManagement_GetComponentStatus",
{
"ID": request.args.get('ID'),
}) # type: ignore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# pylint: disable=invalid-name

from pathlib import Path
from typing import Union
from digitalpy.core.domain.node import Node

# iterating associations
Expand All @@ -17,10 +19,12 @@ def component_installation_path(self) -> 'str':
return self._component_installation_path

@component_installation_path.setter
def component_installation_path(self, component_installation_path: 'str'):
component_installation_path = str(component_installation_path)
def component_installation_path(self, component_installation_path: Union['str', 'Path']):
if isinstance(component_installation_path, Path):
component_installation_path = str(component_installation_path)

if not isinstance(component_installation_path, str):
raise TypeError("'component_installation_path' must be of type str")
raise TypeError("'component_installation_path' must be of type str or Path")
self._component_installation_path = component_installation_path

@property
Expand Down
2 changes: 1 addition & 1 deletion digitalpy/core/core_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ __class = digitalpy.core.zmanager.impl.routing_worker_pusher.RoutingWorkerPusher
[IntegrationManagerSubscriber]
__class = digitalpy.core.zmanager.impl.integration_manager_subscriber.IntegrationManagerSubscriber
; amount of time to wait for a response from the integration manager, if 0 then it will wait indefinitely, if -1 then it will not wait
timeout = 3000
timeout = -1

; the routing worker configuration
[RoutingWorker]
Expand Down
11 changes: 11 additions & 0 deletions digitalpy/core/core_flows.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ IntegrationManager?updateRoutingWorkers@ROUTING_WORKER?update
Subject?IAMConnection?Connection
??done

; component management flows
[ComponentManagement_GetComponent]
?ComponentManagement_GetComponent?Push
Subject?ComponentManagement__GetComponent?get_component
??done

[ComponentManagement_GetComponentStatus]
?ComponentManagement_GetComponentStatus?Push
Subject?ComponentManagement_GetComponentStatus?GETComponentStatus
??done

; service management flows
[ServiceManagement_GetServiceStatus]
?ServiceManagement_GetReloadSystemHealth?Push
Expand Down
18 changes: 9 additions & 9 deletions digitalpy/core/main/DigitalPy.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from time import sleep
from typing import TYPE_CHECKING

from digitalpy.core.component_management.domain.model.component_management_configuration import ComponentManagementConfiguration
from digitalpy.core.service_management.domain.model.service_configuration import (
ServiceConfiguration,
)
Expand Down Expand Up @@ -259,16 +260,15 @@ def register_app_components(self):
app_blueprints = app_root / "blueprints"

# Set the installation path for components in the configuration
self.configuration.set_value(
"component_installation_path",
str(app_components),
"ComponentManagement",
)
component_management_conf: ComponentManagementConfiguration = SingletonConfigurationFactory.get_configuration_object("ComponentManagementConfiguration")

# Set the blueprint path for components in the configuration
self.configuration.set_value(
"component_blueprint_path", str(app_blueprints), "ComponentManagement"
)
# Set the component installation path if it is not already set
if component_management_conf.component_installation_path is None:
component_management_conf.component_installation_path = app_components

# Set the blueprint path for components in the configuration if it is not already set
if component_management_conf.component_blueprint_path is None:
component_management_conf.component_blueprint_path = app_blueprints

# Retrieve an instance of ComponentManagement
component_management: ComponentManagement = ObjectFactory.get_instance(
Expand Down
15 changes: 0 additions & 15 deletions digitalpy/core/zmanager/impl/integration_manager_subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ def setup(self):
self.subscriber_socket.setsockopt(zmq.SNDHWM, 0)
self.subscriber_socket.setsockopt(zmq.LINGER, 0)

self.set_blocking(True)
self.set_timeout(self.timeout)

def _get_topics(self) -> list[ActionKey]:
topics = []
return topics
Expand Down Expand Up @@ -173,18 +170,6 @@ def _deserialize_request(self, message: bytes) -> Request:
request = self.serializer_container.from_zmanager_message(message)
return request

def set_blocking(self, blocking: bool):
"""Set the blocking mode of the socket"""
if blocking:
self.subscriber_socket.setsockopt(zmq.RCVTIMEO, -1)
else:
self.subscriber_socket.setsockopt(zmq.RCVTIMEO, self.timeout)

def set_timeout(self, timeout: int):
"""Set the timeout for the socket"""
self.timeout = timeout
self.subscriber_socket.setsockopt(zmq.RCVTIMEO, self.timeout)

def __getstate__(self):
state = self.__dict__
if "subscriber_socket" in state:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import pytest

from digitalpy.core.domain.domain.network_client import NetworkClient
from tests.testing_utilities.facade_utilities import (
from digitalpy.testing.facade_utilities import (
initialize_facade,
test_environment,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
ServiceManagement,
)
from pathlib import PurePath
from digitalpy.testinge_utilities import (
from digitalpy.testing.facade_utilities import (
initialize_facade,
test_environment,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_telemetry/test_status_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from digitalpy.core.service_management.domain.model.system_event import SystemEvent
from digitalpy.core.service_management.domain.model.system_health import SystemHealth
from digitalpy.core.service_management.domain.model.system_log import SystemLog
from digitalpy.testinge_utilities import \
from digitalpy.testing.facade_utilities import \
test_environment


Expand Down

0 comments on commit f19a20a

Please sign in to comment.