diff --git a/src/context/service/database/Component.py b/src/context/service/database/Component.py index 8774c0cbf6a57ddb22eabc63669bc618f577b809..17d3cb9fffdc59fc913deaa68ddbaf3e6f4f3976 100644 --- a/src/context/service/database/Component.py +++ b/src/context/service/database/Component.py @@ -1,6 +1,5 @@ - # Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -48,25 +47,27 @@ def compose_components_data( if '/inventory' in resource_key: resource_value_data = json.loads(resource_value) name = resource_value_data.pop('name', None) - type = resource_value_data.pop('class', None) - uuid = resource_value_data.pop('uuid', None) + type_ = resource_value_data.pop('class', None) parent = resource_value_data.pop('parent-component-references', None) - resource_value_data.pop('component-reference', None) + attributes = resource_value_data.pop('attributes', {}) + if len(resource_value_data) > 0: + LOGGER.warning('Discarding Component Leftovers: {:s}'.format(str(resource_value_data))) attributes = { attr_name:json.dumps(attr_value) - for attr_name,attr_value in resource_value_data.items() + for attr_name,attr_value in attributes.items() } component_uuid = get_uuid_from_string(component.custom.resource_key, prefix_for_name=device_uuid) dict_component = { 'component_uuid': component_uuid, 'device_uuid' : device_uuid, 'name' : name, - 'type' : type, + 'type' : type_, 'attributes' : json.dumps(attributes), #Store the remaining fields in 'attributes' 'parent' : parent, 'created_at' : now, 'updated_at' : now, } + LOGGER.debug('dict_component={:s}'.format(str(dict_component))) dict_components.append(dict_component) return dict_components