diff --git a/src/device/service/DeviceServiceServicerImpl.py b/src/device/service/DeviceServiceServicerImpl.py index 6674ef13427fcaf3a9b274f268323a541d9c9851..179b7795b541801afb1db63f1ab532253a8cc851 100644 --- a/src/device/service/DeviceServiceServicerImpl.py +++ b/src/device/service/DeviceServiceServicerImpl.py @@ -58,6 +58,7 @@ class DeviceServiceServicerImpl(DeviceServiceServicer): device.device_type = request.device_type device.device_operational_status = DeviceOperationalStatusEnum.DEVICEOPERATIONALSTATUS_UNDEFINED device.device_drivers.extend(request.device_drivers) # pylint: disable=no-member + device.device_config.CopyFrom(request.device_config) # pylint: disable=no-member device_id = context_client.SetDevice(device) device = get_device(context_client, device_id.device_uuid.uuid, rw_copy=True) diff --git a/src/device/service/Tools.py b/src/device/service/Tools.py index d2cd0b48104857ac8a4525feb28a4ca480e0aec1..c86838c62cf06c74b7860908c55e5d464eeef709 100644 --- a/src/device/service/Tools.py +++ b/src/device/service/Tools.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import json +import json, logging from typing import Any, Dict, List, Tuple, Union from common.Constants import DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME from common.method_wrappers.ServiceExceptions import InvalidArgumentException @@ -26,6 +26,8 @@ from .Errors import ( ERROR_BAD_ENDPOINT, ERROR_DELETE, ERROR_GET, ERROR_GET_INIT, ERROR_MISSING_KPI, ERROR_SAMPLETYPE, ERROR_SET, ERROR_SUBSCRIBE, ERROR_UNSUBSCRIBE) +LOGGER = logging.getLogger(__name__) + def check_connect_rules(device_config : DeviceConfig) -> Dict[str, Any]: connection_config_rules = dict() unexpected_config_rules = list() @@ -77,10 +79,14 @@ def populate_endpoints(device : Device, driver : _Driver, monitoring_loops : Mon device_uuid = device.device_id.device_uuid.uuid resources_to_get = [RESOURCE_ENDPOINTS] + LOGGER.warning('resources_to_get = {:s}'.format(str(resources_to_get))) results_getconfig = driver.GetConfig(resources_to_get) + LOGGER.warning('results_getconfig = {:s}'.format(str(results_getconfig))) errors : List[str] = list() for endpoint in results_getconfig: + LOGGER.warning('endpoint = {:s}'.format(str(endpoint))) + if len(endpoint) != 2: errors.append(ERROR_BAD_ENDPOINT.format(device_uuid, str(endpoint))) continue @@ -90,6 +96,8 @@ def populate_endpoints(device : Device, driver : _Driver, monitoring_loops : Mon errors.append(ERROR_GET.format(device_uuid, str(resource_key), str(resource_value))) continue + LOGGER.warning('resource_value = {:s}'.format(str(resource_value))) + endpoint_uuid = resource_value.get('uuid') device_endpoint = device.device_endpoints.add() @@ -104,6 +112,8 @@ def populate_endpoints(device : Device, driver : _Driver, monitoring_loops : Mon device_endpoint.kpi_sample_types.append(kpi_sample_type) monitoring_loops.add_resource_key(device_uuid, endpoint_uuid, kpi_sample_type, monitor_resource_key) + LOGGER.warning('device.device_endpoints = {:s}'.format(str(device.device_endpoints))) + LOGGER.warning('errors = {:s}'.format(str(errors))) return errors def _raw_config_rules_to_grpc( diff --git a/src/device/service/driver_api/DriverInstanceCache.py b/src/device/service/driver_api/DriverInstanceCache.py index 29fecf36ff00031de393b30b3d9f6eef3b0c5343..7bddd70aa47eb5ac5e45c473819a9a58c5fd31b4 100644 --- a/src/device/service/driver_api/DriverInstanceCache.py +++ b/src/device/service/driver_api/DriverInstanceCache.py @@ -84,7 +84,7 @@ def get_driver(driver_instance_cache : DriverInstanceCache, device : Device) -> driver_filter_fields = get_device_driver_filter_fields(device) connect_rules = get_connect_rules(device.device_config) - #LOGGER.info('[get_driver] connect_rules = {:s}'.format(str(connect_rules))) + LOGGER.info('[get_driver] connect_rules = {:s}'.format(str(connect_rules))) address = connect_rules.get('address', '127.0.0.1') port = connect_rules.get('port', '0') settings = connect_rules.get('settings', '{}')