Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue #84 Must deal with unset image names #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions occi_os_api/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,15 @@ def _refresh_os_mixins(self, extras):
LOG.debug(msg)
continue
ctg_term = occify_terms(img['id'])
os_template = os_mixins.OsTemplate(term=ctg_term,
scheme=template_schema,
os_id=img['id'],
related=[infrastructure.
OS_TEMPLATE],
attributes=None,
title='Image: %s' % img['name'],
location='/' + ctg_term + '/')
os_template = os_mixins.OsTemplate(
term=ctg_term,
scheme=template_schema,
os_id=img['id'],
related=[infrastructure.OS_TEMPLATE],
attributes=None,
title='Image: %s' % get_image_name(img),
location='/' + ctg_term + '/'
)

try:
self.registry.get_backend(os_template, extras)
Expand Down Expand Up @@ -270,5 +271,15 @@ def occify_terms(term_name):
'''
Occifies a term_name so that it is compliant with GFD 185.
'''
term = term_name.strip().replace(' ', '_').replace('.', '-').lower()
return term
if term_name:
return term_name.strip().replace(' ', '_').replace('.', '-').lower()

def get_image_name(image):
"""
Return image name if Image name is not None
if Image name is None return Image Id
"""
if image['name']:
return image['name']
else:
return image['id']