Commit eb04de62 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Device omponent - IETF Slice Driver:

- Fix discovery of endpoint settings
parent f33df30f
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -138,14 +138,18 @@ class TfsApiClient(RestApiClient):
                .get('device_config', dict())
                .get('config_rules', list())
            )
            config_rule_dict = dict()
            config_rule_dict : Dict[str, Dict] = dict()
            for cr in config_rule_list:
                if cr['action'] != 'CONFIGACTION_SET': continue
                if 'custom' not in cr: continue
                cr_rk : str = cr['custom']['resource_key']
                if not cr_rk.startswith('/endpoints/endpoint['): continue
                settings = json.loads(cr['custom']['resource_value'])
                ep_name = settings['name']
                ep_uuid = settings.get('uuid')
                if ep_uuid is not None:
                    config_rule_dict[ep_uuid] = settings
                ep_name = settings.get('name')
                if ep_name is not None:
                    config_rule_dict[ep_name] = settings

            for json_endpoint in json_device['device_endpoints']:
@@ -158,6 +162,10 @@ class TfsApiClient(RestApiClient):
                    'name': endpoint_name,
                    'type': json_endpoint['endpoint_type'],
                }
                endpoint_settings = config_rule_dict.get(endpoint_uuid)
                if endpoint_settings is not None:
                    endpoint_data['settings'] = endpoint_settings
                else:
                    endpoint_settings = config_rule_dict.get(endpoint_name)
                    if endpoint_settings is not None:
                        endpoint_data['settings'] = endpoint_settings