summaryrefslogtreecommitdiff
path: root/openstackclient/identity
diff options
context:
space:
mode:
authorzhiyuan_cai <luckyvega.g@gmail.com>2015-01-04 11:26:18 +0800
committerzhiyuan_cai <luckyvega.g@gmail.com>2015-01-04 11:26:18 +0800
commit369ae3f9f06c90e8d57b71befa6bc22a843c2f7d (patch)
treefbde9519581762b92cf6c8e11454be9e7e528d06 /openstackclient/identity
parentcbb26724fccdbbb76913a8f2994768dea3046480 (diff)
downloadpython-openstackclient-369ae3f9f06c90e8d57b71befa6bc22a843c2f7d.tar.gz
Check if service.name available before access
Currently v3 endpoint commands access service.name directly, while name is not a required attribute of service. So if we associate an endpoint to a service without name, we will get an AttributeError executing v3 endpoint commands later. This patch addresses this issue by checking if service.name is available before accessing it. Change-Id: I3dd686ef02a2e21e2049a49cb55634385c2ecfaf Closes-Bug: #1406737
Diffstat (limited to 'openstackclient/identity')
-rw-r--r--openstackclient/identity/v3/endpoint.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/openstackclient/identity/v3/endpoint.py b/openstackclient/identity/v3/endpoint.py
index 0c077c5a..eba7ca14 100644
--- a/openstackclient/identity/v3/endpoint.py
+++ b/openstackclient/identity/v3/endpoint.py
@@ -27,6 +27,13 @@ from openstackclient.common import utils
from openstackclient.identity import common
+def get_service_name(service):
+ if hasattr(service, 'name'):
+ return service.name
+ else:
+ return ''
+
+
class CreateEndpoint(show.ShowOne):
"""Create endpoint command"""
@@ -83,7 +90,7 @@ class CreateEndpoint(show.ShowOne):
info = {}
endpoint._info.pop('links')
info.update(endpoint._info)
- info['service_name'] = service.name
+ info['service_name'] = get_service_name(service)
info['service_type'] = service.type
return zip(*sorted(six.iteritems(info)))
@@ -150,7 +157,7 @@ class ListEndpoint(lister.Lister):
for ep in data:
service = common.find_service(identity_client, ep.service_id)
- ep.service_name = service.name
+ ep.service_name = get_service_name(service)
ep.service_type = service.type
return (columns,
(utils.get_item_properties(
@@ -261,6 +268,6 @@ class ShowEndpoint(show.ShowOne):
info = {}
endpoint._info.pop('links')
info.update(endpoint._info)
- info['service_name'] = service.name
+ info['service_name'] = get_service_name(service)
info['service_type'] = service.type
return zip(*sorted(six.iteritems(info)))