diff options
Diffstat (limited to 'docker/dockerplugin/discovery.py')
-rw-r--r-- | docker/dockerplugin/discovery.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/docker/dockerplugin/discovery.py b/docker/dockerplugin/discovery.py index 8361c13..563693c 100644 --- a/docker/dockerplugin/discovery.py +++ b/docker/dockerplugin/discovery.py @@ -2,6 +2,7 @@ # org.onap.dcae # ================================================================================ # Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. +# Copyright (c) 2019 Pantheon.tech. All rights reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -187,7 +188,7 @@ def is_healthy(consul_host, instance): def add_to_entry(conn, key, add_name, add_value): """ - Find 'key' in consul. + Find 'key' in consul. Treat its value as a JSON string representing a dict. Extend the dict by adding an entry with key 'add_name' and value 'add_value'. Turn the resulting extended dict into a JSON string. @@ -223,12 +224,9 @@ def add_to_entry(conn, key, add_name, add_value): def _find_matching_services(services, name_search, tags): """Find matching services given search criteria""" - def is_match(service): - srv_name, srv_tags = service - return name_search in srv_name and \ - all(map(lambda tag: tag in srv_tags, tags)) - - return [ srv[0] for srv in services.items() if is_match(srv) ] + tags = set(tags) + return [srv_name for srv_name in services + if name_search in srv_name and tags <= set(services[srv_name])] def search_services(conn, name_search, tags): """Search for services that match criteria |