Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
e187206e
Commit
e187206e
authored
Jun 04, 2013
by
Georgios D. Tsoukalas
Browse files
common: get_public_endpoint() helper for service URLs
parent
27599fd8
Changes
1
Hide whitespace changes
Inline
Side-by-side
snf-common/synnefo/lib/services.py
View file @
e187206e
...
...
@@ -56,3 +56,26 @@ def filter_public(services):
if
service
.
get
(
'public'
,
False
):
public_services
[
name
]
=
deepcopy
(
service
)
return
public_services
def
get_public_endpoint
(
services
,
service_type
,
version
=
None
):
found_endpoints
=
{}
for
service_name
,
service
in
services
.
iteritems
():
if
service_type
!=
service
[
'type'
]:
continue
for
endpoint
in
service
[
'endpoints'
]:
endpoint_version
=
endpoint
[
'versionId'
]
if
version
is
not
None
:
if
version
!=
endpoint_version
:
continue
found_endpoints
[
endpoint_version
]
=
endpoint
if
not
found_endpoints
:
m
=
"No endpoint found for service type '{0}'"
.
format
(
service_type
)
if
version
is
not
None
:
m
+=
" and version '{0}'"
.
format
(
version
)
raise
ValueError
(
m
)
selected
=
sorted
(
found_endpoints
.
keys
())[
-
1
]
return
found_endpoints
[
selected
][
'publicURL'
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment