Raise correct exception when a service doesn't exist
There are heat, cinder, neutron, glance, nova and keystone actions in Mistral. We can call any of them in workflows, but in case of absence of one of the called services, we will get "list index out of range" error. This patch fixes the issue. Closes-Bug: #1422725 Change-Id: I05acb5a27eb82c08b712f9687fc8230b2275ed44
This commit is contained in:
parent
f8bda321b8
commit
ba5b18c5f5
|
@ -67,16 +67,20 @@ def get_endpoint_for_project(service_name=None, service_type=None):
|
|||
service_list = keystone_client.services.list()
|
||||
|
||||
if service_name:
|
||||
service_id = [s.id for s in service_list if s.name == service_name][0]
|
||||
service_ids = [s.id for s in service_list if s.name == service_name]
|
||||
elif service_type:
|
||||
service_id = [s.id for s in service_list if s.type == service_type][0]
|
||||
service_ids = [s.id for s in service_list if s.type == service_type]
|
||||
else:
|
||||
raise Exception(
|
||||
"Either 'service_name' or 'service_type' must be provided."
|
||||
)
|
||||
|
||||
if not service_ids:
|
||||
raise Exception("Either service '%s' or service type "
|
||||
"'%s' doesn't exist!" % (service_name, service_type))
|
||||
|
||||
endpoints = keystone_client.endpoints.list(
|
||||
service=service_id,
|
||||
service=service_ids[0],
|
||||
interface='public'
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue