diff options
author | Jaime Caamaño Ruiz <jcaamano@suse.com> | 2018-03-22 08:31:09 +0100 |
---|---|---|
committer | Jaime Caamaño Ruiz <jcaamano@suse.com> | 2018-03-22 08:31:09 +0100 |
commit | 752428421637d40833ff68647cdbbe58809a643f (patch) | |
tree | 849537ecd2c11ae66fe5d59bbefa565d9bff9f1e | |
parent | abf33b5d34225408fd882e455c86c36e0493c5e5 (diff) |
Fix tacker resource collection request
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 <jcaamano@suse.com>
-rw-r--r-- | sfc/lib/openstack_utils.py | 12 |
1 files 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 |