summaryrefslogtreecommitdiff
path: root/openstackclient/network
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-07-08 17:42:11 +0000
committerGerrit Code Review <review@openstack.org>2014-07-08 17:42:11 +0000
commite7bfabc886f9b132de2d2705f40b746cf052c7dd (patch)
treefe339087f0c22d95363b785763c48e1848905262 /openstackclient/network
parentba15646cf8729b461e54233205f9324abf0fa960 (diff)
parenta065dd09e4e649186710435f93a1ad0734601476 (diff)
downloadpython-openstackclient-e7bfabc886f9b132de2d2705f40b746cf052c7dd.tar.gz
Merge "Allow network find to use alternate name"
Diffstat (limited to 'openstackclient/network')
-rw-r--r--openstackclient/network/common.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/openstackclient/network/common.py b/openstackclient/network/common.py
index 5ba44f7b..bd6203bd 100644
--- a/openstackclient/network/common.py
+++ b/openstackclient/network/common.py
@@ -14,20 +14,22 @@
from openstackclient.common import exceptions
-def find(client, resource, resources, name_or_id):
+def find(client, resource, resources, name_or_id, name_attr='name'):
"""Find a network resource
:param client: network client
:param resource: name of the resource
:param resources: plural name of resource
:param name_or_id: name or id of resource user is looking for
+ :param name_attr: key to the name attribute for the resource
For example:
n = find(netclient, 'network', 'networks', 'matrix')
"""
list_method = getattr(client, "list_%s" % resources)
# Search for by name
- data = list_method(name=name_or_id, fields='id')
+ kwargs = {name_attr: name_or_id, 'fields': 'id'}
+ data = list_method(**kwargs)
info = data[resources]
if len(info) == 1:
return info[0]['id']