mirror of
https://github.com/ivan-usov-org/bec.git
synced 2025-04-22 02:20:02 +02:00
minor changes to config handler
This commit is contained in:
parent
18da7987fa
commit
38f3036a94
@ -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"]:
|
||||
|
@ -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"]},
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user