minor changes to config handler

This commit is contained in:
wakonig_k 2022-09-10 11:59:00 +02:00
parent 18da7987fa
commit 38f3036a94
2 changed files with 9 additions and 4 deletions

View File

@ -218,6 +218,11 @@ class DeviceManagerBase:
self._start_connectors(bootstrap_server)
self._get_config_from_DB()
@property
def scibec(self):
"""SciBec instance"""
return self._scibec
def load_config_from_disk(self, config_path) -> dict:
"""
load config from disk and send request
@ -435,7 +440,7 @@ class DeviceManagerBase:
# pylint: disable=protected-access
self.devices._add_device(dev.get("name"), obj)
def _check_request_validity(self, msg: DeviceConfigMessage) -> None:
def check_request_validity(self, msg: DeviceConfigMessage) -> None:
if msg.content["action"] not in ["update", "add", "remove", "reload"]:
raise DeviceConfigError("Action must be either add, remove, update, or reload.")
if msg.content["action"] in ["update", "add", "remove"] and not msg.content["config"]:

View File

@ -27,7 +27,7 @@ class ConfigHandler:
"""
try:
self.device_manager._check_request_validity(msg)
self.device_manager.check_request_validity(msg)
if msg.content["action"] != "update":
return
updated = False
@ -74,7 +74,7 @@ class ConfigHandler:
DeviceConfigError: Raised if the db update fails.
"""
logger.debug("updating in DB")
success = self.device_manager._scibec.patch_device_config(
success = self.device_manager.scibec.patch_device_config(
self.device_manager.devices[device_name].config["id"],
{"enabled": self.device_manager.devices[device_name].enabled},
)
@ -91,7 +91,7 @@ class ConfigHandler:
DeviceConfigError: Raised if the db update fails.
"""
logger.debug("updating in DB")
success = self.device_manager._scibec.patch_device_config(
success = self.device_manager.scibec.patch_device_config(
self.device_manager.devices[device_name].config["id"],
{"deviceConfig": self.device_manager.devices[device_name].config["deviceConfig"]},
)