376 lines
13 KiB
Python
Raw Normal View History

# Copyright 2012 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#
# Copyright 2012 Nebula, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from __future__ import absolute_import
Widget to expose the metadata catalog from glance In Juno, Glance is providing a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes both simple tags and key / value pairs (properties, specs, etc). This widget will get the metadata definitions from Glance and will let the user add the metadata to the resource being edited. It provides value validation as well as description information about the metadata. An implementation for Images is included in this patch. Additional patches will be made for other resource types. This patch also removes Edit Image Custom Properties screen as new widget provides the same functionality. To avoid regressions owner property is added to Image Detail screen. ********************** TESTING ************************** You can test this code with Glance patches by following the instructions at the bottom of this etherpad: Go to: https://etherpad.openstack.org/p/j3-glance-patches ********************************************************* [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Implements: blueprint tagging DocImpact Co-Authored-By: Santiago Baldassin <santiago.b.baldassin@intel.com> Co-Authored-By: Pawel Skowron <pawel.skowron@intel.com> Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Szymon Wroblewski <szymon.wroblewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Heather Whisenhunt <heather.whisenhunt@hp.com> Change-Id: I335d4708f5ce8afe58fb88dbe9efd79e2c04fc9e
2014-09-11 19:10:41 +02:00
import collections
import itertools
Widget to expose the metadata catalog from glance In Juno, Glance is providing a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes both simple tags and key / value pairs (properties, specs, etc). This widget will get the metadata definitions from Glance and will let the user add the metadata to the resource being edited. It provides value validation as well as description information about the metadata. An implementation for Images is included in this patch. Additional patches will be made for other resource types. This patch also removes Edit Image Custom Properties screen as new widget provides the same functionality. To avoid regressions owner property is added to Image Detail screen. ********************** TESTING ************************** You can test this code with Glance patches by following the instructions at the bottom of this etherpad: Go to: https://etherpad.openstack.org/p/j3-glance-patches ********************************************************* [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Implements: blueprint tagging DocImpact Co-Authored-By: Santiago Baldassin <santiago.b.baldassin@intel.com> Co-Authored-By: Pawel Skowron <pawel.skowron@intel.com> Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Szymon Wroblewski <szymon.wroblewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Heather Whisenhunt <heather.whisenhunt@hp.com> Change-Id: I335d4708f5ce8afe58fb88dbe9efd79e2c04fc9e
2014-09-11 19:10:41 +02:00
import json
import logging
import os
Widget to expose the metadata catalog from glance In Juno, Glance is providing a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes both simple tags and key / value pairs (properties, specs, etc). This widget will get the metadata definitions from Glance and will let the user add the metadata to the resource being edited. It provides value validation as well as description information about the metadata. An implementation for Images is included in this patch. Additional patches will be made for other resource types. This patch also removes Edit Image Custom Properties screen as new widget provides the same functionality. To avoid regressions owner property is added to Image Detail screen. ********************** TESTING ************************** You can test this code with Glance patches by following the instructions at the bottom of this etherpad: Go to: https://etherpad.openstack.org/p/j3-glance-patches ********************************************************* [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Implements: blueprint tagging DocImpact Co-Authored-By: Santiago Baldassin <santiago.b.baldassin@intel.com> Co-Authored-By: Pawel Skowron <pawel.skowron@intel.com> Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Szymon Wroblewski <szymon.wroblewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Heather Whisenhunt <heather.whisenhunt@hp.com> Change-Id: I335d4708f5ce8afe58fb88dbe9efd79e2c04fc9e
2014-09-11 19:10:41 +02:00
from django.conf import settings
from django.core.files.uploadedfile import InMemoryUploadedFile
from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.files.uploadedfile import TemporaryUploadedFile
import glanceclient as glance_client
from six.moves import _thread as thread
from horizon.utils import functions as utils
from horizon.utils.memoized import memoized # noqa
from openstack_dashboard.api import base
LOG = logging.getLogger(__name__)
Base Glance Metadata Definitions Admin UI Provide a base admin UI for viewing, importing, and associating the metadata definitions that can be used with various resource types such as flavors, images, and host aggregates. In Juno, Glance provided a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes key / value pairs such as properties, extra specs, etc. Horizon landed several patches that read these properties. You can view the functionality in the "update metadata" action on Flavors, Images, and Host Aggregates. This specific patch is to bring in the Admin UI for the basic coarse grained actions on the definitions in the catalog. This includes creating (importing) a namespace, viewing the overview details about it, deleting the namespace, and associating the namespace for use with specific resource types. Future blueprints will be registered for: - CRUD on individual metadata definitions within the namespace For example, editing the default value of an individual property. [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Santiago Baldassin<santiago.b.baldassin@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> DocImpact: Concept awareness Change-Id: Ie34007f73af7e0941631a52f03841068e509a72c Implements: blueprint glance-metadata-definitions-base-admin-ui
2014-09-12 13:54:01 +02:00
VERSIONS = base.APIVersionManager("image", preferred_version=2)
try:
from glanceclient.v2 import client as glance_client_v2
VERSIONS.load_supported_version(2, {"client": glance_client_v2,
"version": 2})
except ImportError:
pass
try:
from glanceclient.v1 import client as glance_client_v1
VERSIONS.load_supported_version(1, {"client": glance_client_v1,
"version": 1})
except ImportError:
pass
@memoized
def glanceclient(request, version='1'):
url = base.url_for(request, 'image')
insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False)
cacert = getattr(settings, 'OPENSTACK_SSL_CACERT', None)
return glance_client.Client(version, url, token=request.user.token.id,
insecure=insecure, cacert=cacert)
def image_delete(request, image_id):
return glanceclient(request).images.delete(image_id)
def image_get(request, image_id):
"""Returns an Image object populated with metadata for image
Fixes LP Bug#862664 - Improper calls to get_image The glance.client.Client.get_image() call returns a tuple of (metadata, image_iterator). Unfortunately, Horizon's glance API calls get_image() when it means to call get_image_meta(). Because the call to get_image() simply ignores the image iterator returned from get_image(), when the image iterator is garbage-collected, this causes the connection to Glance to be closed, however by that time the socket bound to the iterator has been switched out by eventlet. The result is lots of these in the Glance API log: 2011-09-28 17:46:12 DEBUG [glance.store.filesystem] Found image at /opt/stack/glance/images/3. Returning in ChunkedFile. 2011-09-28 17:46:12 DEBUG [eventlet.wsgi.server] Traceback (most recent call last): File "/usr/lib/pymodules/python2.7/eventlet/wsgi.py", line 351, in handle_one_response write(''.join(towrite)) File "/usr/lib/pymodules/python2.7/eventlet/wsgi.py", line 301, in write _writelines(towrite) File "/usr/lib/python2.7/socket.py", line 334, in writelines self.flush() File "/usr/lib/python2.7/socket.py", line 303, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) File "/usr/lib/pymodules/python2.7/eventlet/greenio.py", line 283, in sendall tail = self.send(data, flags) File "/usr/lib/pymodules/python2.7/eventlet/greenio.py", line 269, in send total_sent += fd.send(data[total_sent:], flags) error: [Errno 104] Connection reset by peer This patch fixes the improper calls to get_image() by replacing them with appropriate calls to get_image_meta(). Change-Id: I741a207ba0e222820492aeb48bab9464d17539ab
2011-12-06 12:27:19 -05:00
with supplied identifier.
"""
image = glanceclient(request).images.get(image_id)
if not hasattr(image, 'name'):
image.name = None
return image
def image_list_detailed(request, marker=None, sort_dir='desc',
sort_key='created_at', filters=None, paginate=False):
limit = getattr(settings, 'API_RESULT_LIMIT', 1000)
page_size = utils.get_page_size(request)
if paginate:
request_size = page_size + 1
else:
request_size = limit
kwargs = {'filters': filters or {}}
if marker:
kwargs['marker'] = marker
kwargs['sort_dir'] = sort_dir
kwargs['sort_key'] = sort_key
images_iter = glanceclient(request).images.list(page_size=request_size,
limit=limit,
**kwargs)
has_prev_data = False
has_more_data = False
if paginate:
images = list(itertools.islice(images_iter, request_size))
# first and middle page condition
if len(images) > page_size:
images.pop(-1)
has_more_data = True
# middle page condition
if marker is not None:
has_prev_data = True
# first page condition when reached via prev back
elif sort_dir == 'asc' and marker is not None:
has_more_data = True
# last page condition
elif marker is not None:
has_prev_data = True
else:
images = list(images_iter)
return (images, has_more_data, has_prev_data)
def image_update(request, image_id, **kwargs):
image_data = kwargs.get('data', None)
try:
return glanceclient(request).images.update(image_id, **kwargs)
finally:
if image_data:
try:
os.remove(image_data.file.name)
except Exception as e:
filename = str(image_data.file)
if hasattr(image_data.file, 'name'):
filename = image_data.file.name
msg = (('Failed to remove temporary image file '
'%(file)s (%(e)s)') %
dict(file=filename, e=str(e)))
LOG.warning(msg)
def image_create(request, **kwargs):
"""Create image.
:param kwargs:
* copy_from: URL from which Glance server should immediately copy
the data and store it in its configured image store.
* data: Form data posted from client.
* location: URL where the data for this image already resides.
In the case of 'copy_from' and 'location', the Glance server
will give us a immediate response from create and handle the data
asynchronously.
In the case of 'data' the process of uploading the data may take
some time and is handed off to a separate thread.
"""
data = kwargs.pop('data', None)
image = glanceclient(request).images.create(**kwargs)
if data:
if isinstance(data, TemporaryUploadedFile):
# Hack to fool Django, so we can keep file open in the new thread.
data.file.close_called = True
if isinstance(data, InMemoryUploadedFile):
# Clone a new file for InMemeoryUploadedFile.
# Because the old one will be closed by Django.
data = SimpleUploadedFile(data.name,
data.read(),
data.content_type)
thread.start_new_thread(image_update,
(request, image.id),
{'data': data,
'purge_props': False})
return image
Widget to expose the metadata catalog from glance In Juno, Glance is providing a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes both simple tags and key / value pairs (properties, specs, etc). This widget will get the metadata definitions from Glance and will let the user add the metadata to the resource being edited. It provides value validation as well as description information about the metadata. An implementation for Images is included in this patch. Additional patches will be made for other resource types. This patch also removes Edit Image Custom Properties screen as new widget provides the same functionality. To avoid regressions owner property is added to Image Detail screen. ********************** TESTING ************************** You can test this code with Glance patches by following the instructions at the bottom of this etherpad: Go to: https://etherpad.openstack.org/p/j3-glance-patches ********************************************************* [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Implements: blueprint tagging DocImpact Co-Authored-By: Santiago Baldassin <santiago.b.baldassin@intel.com> Co-Authored-By: Pawel Skowron <pawel.skowron@intel.com> Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Szymon Wroblewski <szymon.wroblewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Heather Whisenhunt <heather.whisenhunt@hp.com> Change-Id: I335d4708f5ce8afe58fb88dbe9efd79e2c04fc9e
2014-09-11 19:10:41 +02:00
def image_update_properties(request, image_id, remove_props=None, **kwargs):
"""Add or update a custom property of an image."""
Widget to expose the metadata catalog from glance In Juno, Glance is providing a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes both simple tags and key / value pairs (properties, specs, etc). This widget will get the metadata definitions from Glance and will let the user add the metadata to the resource being edited. It provides value validation as well as description information about the metadata. An implementation for Images is included in this patch. Additional patches will be made for other resource types. This patch also removes Edit Image Custom Properties screen as new widget provides the same functionality. To avoid regressions owner property is added to Image Detail screen. ********************** TESTING ************************** You can test this code with Glance patches by following the instructions at the bottom of this etherpad: Go to: https://etherpad.openstack.org/p/j3-glance-patches ********************************************************* [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Implements: blueprint tagging DocImpact Co-Authored-By: Santiago Baldassin <santiago.b.baldassin@intel.com> Co-Authored-By: Pawel Skowron <pawel.skowron@intel.com> Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Szymon Wroblewski <szymon.wroblewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Heather Whisenhunt <heather.whisenhunt@hp.com> Change-Id: I335d4708f5ce8afe58fb88dbe9efd79e2c04fc9e
2014-09-11 19:10:41 +02:00
return glanceclient(request, '2').images.update(image_id,
remove_props,
**kwargs)
def image_delete_properties(request, image_id, keys):
"""Delete custom properties for an image."""
return glanceclient(request, '2').images.update(image_id, keys)
Widget to expose the metadata catalog from glance In Juno, Glance is providing a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes both simple tags and key / value pairs (properties, specs, etc). This widget will get the metadata definitions from Glance and will let the user add the metadata to the resource being edited. It provides value validation as well as description information about the metadata. An implementation for Images is included in this patch. Additional patches will be made for other resource types. This patch also removes Edit Image Custom Properties screen as new widget provides the same functionality. To avoid regressions owner property is added to Image Detail screen. ********************** TESTING ************************** You can test this code with Glance patches by following the instructions at the bottom of this etherpad: Go to: https://etherpad.openstack.org/p/j3-glance-patches ********************************************************* [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Implements: blueprint tagging DocImpact Co-Authored-By: Santiago Baldassin <santiago.b.baldassin@intel.com> Co-Authored-By: Pawel Skowron <pawel.skowron@intel.com> Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Szymon Wroblewski <szymon.wroblewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Heather Whisenhunt <heather.whisenhunt@hp.com> Change-Id: I335d4708f5ce8afe58fb88dbe9efd79e2c04fc9e
2014-09-11 19:10:41 +02:00
class BaseGlanceMetadefAPIResourceWrapper(base.APIResourceWrapper):
@property
def description(self):
return (getattr(self._apiresource, 'description', None) or
getattr(self._apiresource, 'display_name', None))
def as_json(self, indent=4):
result = collections.OrderedDict()
for attr in self._attrs:
if hasattr(self, attr):
result[attr] = getattr(self, attr)
return json.dumps(result, indent=indent)
def to_dict(self):
return self._apiresource
Widget to expose the metadata catalog from glance In Juno, Glance is providing a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes both simple tags and key / value pairs (properties, specs, etc). This widget will get the metadata definitions from Glance and will let the user add the metadata to the resource being edited. It provides value validation as well as description information about the metadata. An implementation for Images is included in this patch. Additional patches will be made for other resource types. This patch also removes Edit Image Custom Properties screen as new widget provides the same functionality. To avoid regressions owner property is added to Image Detail screen. ********************** TESTING ************************** You can test this code with Glance patches by following the instructions at the bottom of this etherpad: Go to: https://etherpad.openstack.org/p/j3-glance-patches ********************************************************* [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Implements: blueprint tagging DocImpact Co-Authored-By: Santiago Baldassin <santiago.b.baldassin@intel.com> Co-Authored-By: Pawel Skowron <pawel.skowron@intel.com> Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Szymon Wroblewski <szymon.wroblewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Heather Whisenhunt <heather.whisenhunt@hp.com> Change-Id: I335d4708f5ce8afe58fb88dbe9efd79e2c04fc9e
2014-09-11 19:10:41 +02:00
class Namespace(BaseGlanceMetadefAPIResourceWrapper):
_attrs = ['namespace', 'display_name', 'description',
'resource_type_associations', 'visibility', 'protected',
'created_at', 'updated_at', 'properties', 'objects']
@property
Base Glance Metadata Definitions Admin UI Provide a base admin UI for viewing, importing, and associating the metadata definitions that can be used with various resource types such as flavors, images, and host aggregates. In Juno, Glance provided a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes key / value pairs such as properties, extra specs, etc. Horizon landed several patches that read these properties. You can view the functionality in the "update metadata" action on Flavors, Images, and Host Aggregates. This specific patch is to bring in the Admin UI for the basic coarse grained actions on the definitions in the catalog. This includes creating (importing) a namespace, viewing the overview details about it, deleting the namespace, and associating the namespace for use with specific resource types. Future blueprints will be registered for: - CRUD on individual metadata definitions within the namespace For example, editing the default value of an individual property. [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Santiago Baldassin<santiago.b.baldassin@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> DocImpact: Concept awareness Change-Id: Ie34007f73af7e0941631a52f03841068e509a72c Implements: blueprint glance-metadata-definitions-base-admin-ui
2014-09-12 13:54:01 +02:00
def resource_type_names(self):
Widget to expose the metadata catalog from glance In Juno, Glance is providing a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes both simple tags and key / value pairs (properties, specs, etc). This widget will get the metadata definitions from Glance and will let the user add the metadata to the resource being edited. It provides value validation as well as description information about the metadata. An implementation for Images is included in this patch. Additional patches will be made for other resource types. This patch also removes Edit Image Custom Properties screen as new widget provides the same functionality. To avoid regressions owner property is added to Image Detail screen. ********************** TESTING ************************** You can test this code with Glance patches by following the instructions at the bottom of this etherpad: Go to: https://etherpad.openstack.org/p/j3-glance-patches ********************************************************* [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Implements: blueprint tagging DocImpact Co-Authored-By: Santiago Baldassin <santiago.b.baldassin@intel.com> Co-Authored-By: Pawel Skowron <pawel.skowron@intel.com> Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Szymon Wroblewski <szymon.wroblewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Heather Whisenhunt <heather.whisenhunt@hp.com> Change-Id: I335d4708f5ce8afe58fb88dbe9efd79e2c04fc9e
2014-09-11 19:10:41 +02:00
result = [resource_type['name'] for resource_type in
getattr(self._apiresource, 'resource_type_associations')]
Base Glance Metadata Definitions Admin UI Provide a base admin UI for viewing, importing, and associating the metadata definitions that can be used with various resource types such as flavors, images, and host aggregates. In Juno, Glance provided a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes key / value pairs such as properties, extra specs, etc. Horizon landed several patches that read these properties. You can view the functionality in the "update metadata" action on Flavors, Images, and Host Aggregates. This specific patch is to bring in the Admin UI for the basic coarse grained actions on the definitions in the catalog. This includes creating (importing) a namespace, viewing the overview details about it, deleting the namespace, and associating the namespace for use with specific resource types. Future blueprints will be registered for: - CRUD on individual metadata definitions within the namespace For example, editing the default value of an individual property. [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Santiago Baldassin<santiago.b.baldassin@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> DocImpact: Concept awareness Change-Id: Ie34007f73af7e0941631a52f03841068e509a72c Implements: blueprint glance-metadata-definitions-base-admin-ui
2014-09-12 13:54:01 +02:00
return sorted(result)
Widget to expose the metadata catalog from glance In Juno, Glance is providing a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes both simple tags and key / value pairs (properties, specs, etc). This widget will get the metadata definitions from Glance and will let the user add the metadata to the resource being edited. It provides value validation as well as description information about the metadata. An implementation for Images is included in this patch. Additional patches will be made for other resource types. This patch also removes Edit Image Custom Properties screen as new widget provides the same functionality. To avoid regressions owner property is added to Image Detail screen. ********************** TESTING ************************** You can test this code with Glance patches by following the instructions at the bottom of this etherpad: Go to: https://etherpad.openstack.org/p/j3-glance-patches ********************************************************* [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Implements: blueprint tagging DocImpact Co-Authored-By: Santiago Baldassin <santiago.b.baldassin@intel.com> Co-Authored-By: Pawel Skowron <pawel.skowron@intel.com> Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Szymon Wroblewski <szymon.wroblewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Heather Whisenhunt <heather.whisenhunt@hp.com> Change-Id: I335d4708f5ce8afe58fb88dbe9efd79e2c04fc9e
2014-09-11 19:10:41 +02:00
@property
def public(self):
if getattr(self._apiresource, 'visibility') == 'public':
return True
else:
return False
@memoized
Widget to expose the metadata catalog from glance In Juno, Glance is providing a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes both simple tags and key / value pairs (properties, specs, etc). This widget will get the metadata definitions from Glance and will let the user add the metadata to the resource being edited. It provides value validation as well as description information about the metadata. An implementation for Images is included in this patch. Additional patches will be made for other resource types. This patch also removes Edit Image Custom Properties screen as new widget provides the same functionality. To avoid regressions owner property is added to Image Detail screen. ********************** TESTING ************************** You can test this code with Glance patches by following the instructions at the bottom of this etherpad: Go to: https://etherpad.openstack.org/p/j3-glance-patches ********************************************************* [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Implements: blueprint tagging DocImpact Co-Authored-By: Santiago Baldassin <santiago.b.baldassin@intel.com> Co-Authored-By: Pawel Skowron <pawel.skowron@intel.com> Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Szymon Wroblewski <szymon.wroblewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Heather Whisenhunt <heather.whisenhunt@hp.com> Change-Id: I335d4708f5ce8afe58fb88dbe9efd79e2c04fc9e
2014-09-11 19:10:41 +02:00
def metadefs_namespace_get(request, namespace, resource_type=None, wrap=False):
namespace = glanceclient(request, '2').\
metadefs_namespace.get(namespace, resource_type=resource_type)
# There were problems with using the wrapper class in
# nested json serialization. So sometimes, it is not desirable
Widget to expose the metadata catalog from glance In Juno, Glance is providing a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes both simple tags and key / value pairs (properties, specs, etc). This widget will get the metadata definitions from Glance and will let the user add the metadata to the resource being edited. It provides value validation as well as description information about the metadata. An implementation for Images is included in this patch. Additional patches will be made for other resource types. This patch also removes Edit Image Custom Properties screen as new widget provides the same functionality. To avoid regressions owner property is added to Image Detail screen. ********************** TESTING ************************** You can test this code with Glance patches by following the instructions at the bottom of this etherpad: Go to: https://etherpad.openstack.org/p/j3-glance-patches ********************************************************* [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Implements: blueprint tagging DocImpact Co-Authored-By: Santiago Baldassin <santiago.b.baldassin@intel.com> Co-Authored-By: Pawel Skowron <pawel.skowron@intel.com> Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Szymon Wroblewski <szymon.wroblewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Heather Whisenhunt <heather.whisenhunt@hp.com> Change-Id: I335d4708f5ce8afe58fb88dbe9efd79e2c04fc9e
2014-09-11 19:10:41 +02:00
# to wrap.
if wrap:
return Namespace(namespace)
else:
return namespace
def metadefs_namespace_list(request,
filters=None,
Base Glance Metadata Definitions Admin UI Provide a base admin UI for viewing, importing, and associating the metadata definitions that can be used with various resource types such as flavors, images, and host aggregates. In Juno, Glance provided a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes key / value pairs such as properties, extra specs, etc. Horizon landed several patches that read these properties. You can view the functionality in the "update metadata" action on Flavors, Images, and Host Aggregates. This specific patch is to bring in the Admin UI for the basic coarse grained actions on the definitions in the catalog. This includes creating (importing) a namespace, viewing the overview details about it, deleting the namespace, and associating the namespace for use with specific resource types. Future blueprints will be registered for: - CRUD on individual metadata definitions within the namespace For example, editing the default value of an individual property. [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Santiago Baldassin<santiago.b.baldassin@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> DocImpact: Concept awareness Change-Id: Ie34007f73af7e0941631a52f03841068e509a72c Implements: blueprint glance-metadata-definitions-base-admin-ui
2014-09-12 13:54:01 +02:00
sort_dir='asc',
sort_key='namespace',
Widget to expose the metadata catalog from glance In Juno, Glance is providing a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes both simple tags and key / value pairs (properties, specs, etc). This widget will get the metadata definitions from Glance and will let the user add the metadata to the resource being edited. It provides value validation as well as description information about the metadata. An implementation for Images is included in this patch. Additional patches will be made for other resource types. This patch also removes Edit Image Custom Properties screen as new widget provides the same functionality. To avoid regressions owner property is added to Image Detail screen. ********************** TESTING ************************** You can test this code with Glance patches by following the instructions at the bottom of this etherpad: Go to: https://etherpad.openstack.org/p/j3-glance-patches ********************************************************* [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Implements: blueprint tagging DocImpact Co-Authored-By: Santiago Baldassin <santiago.b.baldassin@intel.com> Co-Authored-By: Pawel Skowron <pawel.skowron@intel.com> Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Szymon Wroblewski <szymon.wroblewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Heather Whisenhunt <heather.whisenhunt@hp.com> Change-Id: I335d4708f5ce8afe58fb88dbe9efd79e2c04fc9e
2014-09-11 19:10:41 +02:00
marker=None,
paginate=False):
Base Glance Metadata Definitions Admin UI Provide a base admin UI for viewing, importing, and associating the metadata definitions that can be used with various resource types such as flavors, images, and host aggregates. In Juno, Glance provided a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes key / value pairs such as properties, extra specs, etc. Horizon landed several patches that read these properties. You can view the functionality in the "update metadata" action on Flavors, Images, and Host Aggregates. This specific patch is to bring in the Admin UI for the basic coarse grained actions on the definitions in the catalog. This includes creating (importing) a namespace, viewing the overview details about it, deleting the namespace, and associating the namespace for use with specific resource types. Future blueprints will be registered for: - CRUD on individual metadata definitions within the namespace For example, editing the default value of an individual property. [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Santiago Baldassin<santiago.b.baldassin@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> DocImpact: Concept awareness Change-Id: Ie34007f73af7e0941631a52f03841068e509a72c Implements: blueprint glance-metadata-definitions-base-admin-ui
2014-09-12 13:54:01 +02:00
"""Retrieve a listing of Namespaces
Base Glance Metadata Definitions Admin UI Provide a base admin UI for viewing, importing, and associating the metadata definitions that can be used with various resource types such as flavors, images, and host aggregates. In Juno, Glance provided a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes key / value pairs such as properties, extra specs, etc. Horizon landed several patches that read these properties. You can view the functionality in the "update metadata" action on Flavors, Images, and Host Aggregates. This specific patch is to bring in the Admin UI for the basic coarse grained actions on the definitions in the catalog. This includes creating (importing) a namespace, viewing the overview details about it, deleting the namespace, and associating the namespace for use with specific resource types. Future blueprints will be registered for: - CRUD on individual metadata definitions within the namespace For example, editing the default value of an individual property. [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Santiago Baldassin<santiago.b.baldassin@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> DocImpact: Concept awareness Change-Id: Ie34007f73af7e0941631a52f03841068e509a72c Implements: blueprint glance-metadata-definitions-base-admin-ui
2014-09-12 13:54:01 +02:00
:param paginate: If true will perform pagination based on settings.
:param marker: Specifies the namespace of the last-seen namespace.
The typical pattern of limit and marker is to make an
initial limited request and then to use the last
namespace from the response as the marker parameter
in a subsequent limited request. With paginate, limit
is automatically set.
:param sort_dir: The sort direction ('asc' or 'desc').
:param sort_key: The field to sort on (for example, 'created_at'). Default
is namespace. The way base namespaces are loaded into glance
typically at first deployment is done in a single transaction
giving them a potentially unpredictable sort result when using
create_at.
:param filters: specifies addition fields to filter on such as
resource_types.
Base Glance Metadata Definitions Admin UI Provide a base admin UI for viewing, importing, and associating the metadata definitions that can be used with various resource types such as flavors, images, and host aggregates. In Juno, Glance provided a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes key / value pairs such as properties, extra specs, etc. Horizon landed several patches that read these properties. You can view the functionality in the "update metadata" action on Flavors, Images, and Host Aggregates. This specific patch is to bring in the Admin UI for the basic coarse grained actions on the definitions in the catalog. This includes creating (importing) a namespace, viewing the overview details about it, deleting the namespace, and associating the namespace for use with specific resource types. Future blueprints will be registered for: - CRUD on individual metadata definitions within the namespace For example, editing the default value of an individual property. [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Santiago Baldassin<santiago.b.baldassin@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> DocImpact: Concept awareness Change-Id: Ie34007f73af7e0941631a52f03841068e509a72c Implements: blueprint glance-metadata-definitions-base-admin-ui
2014-09-12 13:54:01 +02:00
:returns A tuple of three values:
1) Current page results
2) A boolean of whether or not there are previous page(s).
3) A boolean of whether or not there are more page(s).
Base Glance Metadata Definitions Admin UI Provide a base admin UI for viewing, importing, and associating the metadata definitions that can be used with various resource types such as flavors, images, and host aggregates. In Juno, Glance provided a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes key / value pairs such as properties, extra specs, etc. Horizon landed several patches that read these properties. You can view the functionality in the "update metadata" action on Flavors, Images, and Host Aggregates. This specific patch is to bring in the Admin UI for the basic coarse grained actions on the definitions in the catalog. This includes creating (importing) a namespace, viewing the overview details about it, deleting the namespace, and associating the namespace for use with specific resource types. Future blueprints will be registered for: - CRUD on individual metadata definitions within the namespace For example, editing the default value of an individual property. [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Santiago Baldassin<santiago.b.baldassin@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> DocImpact: Concept awareness Change-Id: Ie34007f73af7e0941631a52f03841068e509a72c Implements: blueprint glance-metadata-definitions-base-admin-ui
2014-09-12 13:54:01 +02:00
"""
# Listing namespaces requires the v2 API. If not supported we return an
# empty array so callers don't need to worry about version checking.
if get_version() < 2:
return [], False, False
if filters is None:
filters = {}
Widget to expose the metadata catalog from glance In Juno, Glance is providing a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes both simple tags and key / value pairs (properties, specs, etc). This widget will get the metadata definitions from Glance and will let the user add the metadata to the resource being edited. It provides value validation as well as description information about the metadata. An implementation for Images is included in this patch. Additional patches will be made for other resource types. This patch also removes Edit Image Custom Properties screen as new widget provides the same functionality. To avoid regressions owner property is added to Image Detail screen. ********************** TESTING ************************** You can test this code with Glance patches by following the instructions at the bottom of this etherpad: Go to: https://etherpad.openstack.org/p/j3-glance-patches ********************************************************* [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Implements: blueprint tagging DocImpact Co-Authored-By: Santiago Baldassin <santiago.b.baldassin@intel.com> Co-Authored-By: Pawel Skowron <pawel.skowron@intel.com> Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Szymon Wroblewski <szymon.wroblewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Heather Whisenhunt <heather.whisenhunt@hp.com> Change-Id: I335d4708f5ce8afe58fb88dbe9efd79e2c04fc9e
2014-09-11 19:10:41 +02:00
limit = getattr(settings, 'API_RESULT_LIMIT', 1000)
page_size = utils.get_page_size(request)
if paginate:
request_size = page_size + 1
else:
request_size = limit
kwargs = {'filters': filters}
if marker:
kwargs['marker'] = marker
kwargs['sort_dir'] = sort_dir
kwargs['sort_key'] = sort_key
namespaces_iter = glanceclient(request, '2').metadefs_namespace.list(
page_size=request_size, limit=limit, **kwargs)
has_prev_data = False
has_more_data = False
if paginate:
namespaces = list(itertools.islice(namespaces_iter, request_size))
# first and middle page condition
if len(namespaces) > page_size:
namespaces.pop(-1)
has_more_data = True
# middle page condition
if marker is not None:
has_prev_data = True
# first page condition when reached via prev back
Base Glance Metadata Definitions Admin UI Provide a base admin UI for viewing, importing, and associating the metadata definitions that can be used with various resource types such as flavors, images, and host aggregates. In Juno, Glance provided a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes key / value pairs such as properties, extra specs, etc. Horizon landed several patches that read these properties. You can view the functionality in the "update metadata" action on Flavors, Images, and Host Aggregates. This specific patch is to bring in the Admin UI for the basic coarse grained actions on the definitions in the catalog. This includes creating (importing) a namespace, viewing the overview details about it, deleting the namespace, and associating the namespace for use with specific resource types. Future blueprints will be registered for: - CRUD on individual metadata definitions within the namespace For example, editing the default value of an individual property. [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Santiago Baldassin<santiago.b.baldassin@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> DocImpact: Concept awareness Change-Id: Ie34007f73af7e0941631a52f03841068e509a72c Implements: blueprint glance-metadata-definitions-base-admin-ui
2014-09-12 13:54:01 +02:00
elif sort_dir == 'desc' and marker is not None:
Widget to expose the metadata catalog from glance In Juno, Glance is providing a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes both simple tags and key / value pairs (properties, specs, etc). This widget will get the metadata definitions from Glance and will let the user add the metadata to the resource being edited. It provides value validation as well as description information about the metadata. An implementation for Images is included in this patch. Additional patches will be made for other resource types. This patch also removes Edit Image Custom Properties screen as new widget provides the same functionality. To avoid regressions owner property is added to Image Detail screen. ********************** TESTING ************************** You can test this code with Glance patches by following the instructions at the bottom of this etherpad: Go to: https://etherpad.openstack.org/p/j3-glance-patches ********************************************************* [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Implements: blueprint tagging DocImpact Co-Authored-By: Santiago Baldassin <santiago.b.baldassin@intel.com> Co-Authored-By: Pawel Skowron <pawel.skowron@intel.com> Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Szymon Wroblewski <szymon.wroblewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Heather Whisenhunt <heather.whisenhunt@hp.com> Change-Id: I335d4708f5ce8afe58fb88dbe9efd79e2c04fc9e
2014-09-11 19:10:41 +02:00
has_more_data = True
# last page condition
elif marker is not None:
has_prev_data = True
else:
namespaces = list(namespaces_iter)
namespaces = [Namespace(namespace) for namespace in namespaces]
return namespaces, has_more_data, has_prev_data
Base Glance Metadata Definitions Admin UI Provide a base admin UI for viewing, importing, and associating the metadata definitions that can be used with various resource types such as flavors, images, and host aggregates. In Juno, Glance provided a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes key / value pairs such as properties, extra specs, etc. Horizon landed several patches that read these properties. You can view the functionality in the "update metadata" action on Flavors, Images, and Host Aggregates. This specific patch is to bring in the Admin UI for the basic coarse grained actions on the definitions in the catalog. This includes creating (importing) a namespace, viewing the overview details about it, deleting the namespace, and associating the namespace for use with specific resource types. Future blueprints will be registered for: - CRUD on individual metadata definitions within the namespace For example, editing the default value of an individual property. [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Santiago Baldassin<santiago.b.baldassin@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> DocImpact: Concept awareness Change-Id: Ie34007f73af7e0941631a52f03841068e509a72c Implements: blueprint glance-metadata-definitions-base-admin-ui
2014-09-12 13:54:01 +02:00
def metadefs_namespace_full_list(request, resource_type, filters=None,
*args, **kwargs):
filters = filters or {}
filters['resource_types'] = [resource_type]
namespaces, has_more_data, has_prev_data = metadefs_namespace_list(
request, filters, *args, **kwargs
)
return [
metadefs_namespace_get(request, x.namespace, resource_type)
for x in namespaces
], has_more_data, has_prev_data
Base Glance Metadata Definitions Admin UI Provide a base admin UI for viewing, importing, and associating the metadata definitions that can be used with various resource types such as flavors, images, and host aggregates. In Juno, Glance provided a metadata definitions catalog[1][2] where users can register the available metadata definitions that can be used on different types of resources (images, artifacts, volumes, flavors, aggregates, etc). This includes key / value pairs such as properties, extra specs, etc. Horizon landed several patches that read these properties. You can view the functionality in the "update metadata" action on Flavors, Images, and Host Aggregates. This specific patch is to bring in the Admin UI for the basic coarse grained actions on the definitions in the catalog. This includes creating (importing) a namespace, viewing the overview details about it, deleting the namespace, and associating the namespace for use with specific resource types. Future blueprints will be registered for: - CRUD on individual metadata definitions within the namespace For example, editing the default value of an individual property. [1] Approved Glance Juno Spec: https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst [2] Glance PTL Juno Feature Overview: https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Santiago Baldassin<santiago.b.baldassin@intel.com> Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com> Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com> Co-Authored-By: Michal Dulko <michal.dulko@intel.com> DocImpact: Concept awareness Change-Id: Ie34007f73af7e0941631a52f03841068e509a72c Implements: blueprint glance-metadata-definitions-base-admin-ui
2014-09-12 13:54:01 +02:00
def metadefs_namespace_create(request, namespace):
return glanceclient(request, '2').metadefs_namespace.create(**namespace)
def metadefs_namespace_update(request, namespace_name, **properties):
return glanceclient(request, '2').metadefs_namespace.update(
namespace_name,
**properties)
def metadefs_namespace_delete(request, namespace_name):
return glanceclient(request, '2').metadefs_namespace.delete(namespace_name)
def metadefs_resource_types_list(request):
return glanceclient(request, '2').metadefs_resource_type.list()
def metadefs_namespace_resource_types(request, namespace_name):
resource_types = glanceclient(request, '2').metadefs_resource_type.get(
namespace_name)
# metadefs_resource_type.get() returns generator, converting it to list
return list(resource_types)
def metadefs_namespace_add_resource_type(request,
namespace_name,
resource_type):
return glanceclient(request, '2').metadefs_resource_type.associate(
namespace_name, **resource_type)
def metadefs_namespace_remove_resource_type(request,
namespace_name,
resource_type_name):
glanceclient(request, '2').metadefs_resource_type.deassociate(
namespace_name, resource_type_name)
def get_version():
return VERSIONS.active