diff --git a/src/device/service/Tools.py b/src/device/service/Tools.py index b4dc66dde9562364342dd736405d4d4dcbd9772a..28b5391a7b19b9e64a37504b8a95e61aa6db1d72 100644 --- a/src/device/service/Tools.py +++ b/src/device/service/Tools.py @@ -19,6 +19,7 @@ from common.method_wrappers.ServiceExceptions import InvalidArgumentException from common.proto.context_pb2 import ConfigActionEnum, Device, DeviceConfig from common.proto.device_pb2 import MonitoringSettings from common.proto.kpi_sample_types_pb2 import KpiSampleType +from common.tools.grpc.ConfigRules import update_config_rule_custom from common.tools.grpc.Tools import grpc_message_to_json from .driver_api._Driver import _Driver, RESOURCE_ENDPOINTS from .monitoring.MonitoringLoops import MonitoringLoops @@ -117,11 +118,8 @@ def _raw_config_rules_to_grpc( errors.append(error_template.format(device_uuid, str(resource_key), str(resource_value))) continue - config_rule = device_config.config_rules.add() - config_rule.action = config_action - config_rule.custom.resource_key = resource_key - config_rule.custom.resource_value = \ - resource_value if isinstance(resource_value, str) else json.dumps(resource_value, sort_keys=True) + resource_value = json.loads(resource_value) if isinstance(resource_value, str) else resource_value + update_config_rule_custom(device_config.config_rules, resource_key, resource_value, new_action=config_action) return errors