diff --git a/glance/parallax/controllers.py b/glance/parallax/controllers.py index 3926cb82a7..0043c17154 100644 --- a/glance/parallax/controllers.py +++ b/glance/parallax/controllers.py @@ -132,8 +132,7 @@ def _make_image_dict(image): def _fetch_attrs(d, attrs): return dict([(a, d[a]) for a in attrs]) - file_attrs = db.BASE_MODEL_ATTRS | set(['location', 'size']) - files = [_fetch_attrs(f, file_attrs) for f in image['files']] + files = [_fetch_attrs(f, db.IMAGE_FILE_ATTRS) for f in image['files']] # TODO(sirp): should this be a dict, or a list of dicts? # A plain dict is more convenient, but list of dicts would provide @@ -141,8 +140,7 @@ def _fetch_attrs(d, attrs): metadata = dict((m['key'], m['value']) for m in image['metadata'] if not m['deleted']) - image_attrs = db.BASE_MODEL_ATTRS | set(['name', 'image_type', 'status', 'is_public']) - image_dict = _fetch_attrs(image, image_attrs) + image_dict = _fetch_attrs(image, db.IMAGE_ATTRS) image_dict['files'] = files image_dict['metadata'] = metadata diff --git a/glance/parallax/db/__init__.py b/glance/parallax/db/__init__.py index 09fd774ef4..d32d0affbb 100644 --- a/glance/parallax/db/__init__.py +++ b/glance/parallax/db/__init__.py @@ -25,3 +25,8 @@ # attributes common to all models BASE_MODEL_ATTRS = set(['id', 'created_at', 'updated_at', 'deleted_at', 'deleted']) + +IMAGE_FILE_ATTRS = BASE_MODEL_ATTRS | set(['location', 'size']) + +IMAGE_ATTRS = BASE_MODEL_ATTRS | set(['name', 'image_type', 'status', + 'is_public'])