From 752428421637d40833ff68647cdbbe58809a643f Mon Sep 17 00:00:00 2001 From: Jaime Caamaño Ruiz Date: Thu, 22 Mar 2018 08:31:09 +0100 Subject: Fix tacker resource collection request MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Looks like using tacker_client.get to request a resource collection causes connection drops and subsequent requests to fail, probably because of incomplete pagination handling. Use tacker_client.list instead. Change-Id: I79ba39759b61f57774e65b5e49686edb6bf05c13 Signed-off-by: Jaime Caamaño Ruiz --- sfc/lib/openstack_utils.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sfc/lib/openstack_utils.py b/sfc/lib/openstack_utils.py index e127e8d2..fb63de9e 100644 --- a/sfc/lib/openstack_utils.py +++ b/sfc/lib/openstack_utils.py @@ -245,12 +245,12 @@ def get_tacker_client(other_creds={}): def get_id_from_name(tacker_client, resource_type, resource_name): try: - req_params = {'fields': 'id', 'name': resource_name} - endpoint = '/{0}s'.format(resource_type) - resp = tacker_client.get(endpoint, params=req_params) - endpoint = endpoint.replace('-', '_') - return resp[endpoint[1:]][0]['id'] - except Exception, e: + params = {'fields': 'id', 'name': resource_name} + collection = resource_type + 's' + path = '/' + collection + resp = tacker_client.list(collection, path, **params) + return resp[collection][0]['id'] + except Exception as e: logger.error("Error [get_id_from_name(tacker_client, " "resource_type, resource_name)]: %s" % e) return None -- cgit 1.2.3-korg