This patch adds support for group types and group specs. This is the first patch to implement the blueprint generic-volume-group. The client side patch is here: https://review.openstack.org/#/c/320157/ Current microversion is 3.11. The following CLI's are supported. cinder --os-volume-api-version 3.11 group-type-create my_test_group cinder --os-volume-api-version 3.11 group-type-list cinder --os-volume-api-version 3.11 group-type-show my_test_group cinder --os-volume-api-version 3.11 group-type-key my_test_group set test_key=test_val cinder --os-volume-api-version 3.11 group-specs-list cinder --os-volume-api-version 3.11 group-type-key my_test_group unset test_key cinder --os-volume-api-version 3.11 group-type-update <group type uuid> --name "new_group" --description "my group type" cinder --os-volume-api-version 3.11 group-type-delete new_group APIImpact DocImpact Change-Id: I38b938782e0c3b2df624f975bd07e0b81684c888 Partial-Implements: blueprint generic-volume-group
44 lines
1.8 KiB
Python
44 lines
1.8 KiB
Python
# Copyright 2016 EMC Corporation
|
|
# All Rights Reserved.
|
|
#
|
|
# 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 cinder.api import common
|
|
|
|
|
|
class ViewBuilder(common.ViewBuilder):
|
|
|
|
def show(self, request, group_type, brief=False):
|
|
"""Trim away extraneous group type attributes."""
|
|
context = request.environ['cinder.context']
|
|
trimmed = dict(id=group_type.get('id'),
|
|
name=group_type.get('name'),
|
|
description=group_type.get('description'),
|
|
is_public=group_type.get('is_public'))
|
|
if common.validate_policy(
|
|
context,
|
|
'group:access_group_types_specs'):
|
|
trimmed['group_specs'] = group_type.get('group_specs')
|
|
return trimmed if brief else dict(group_type=trimmed)
|
|
|
|
def index(self, request, group_types):
|
|
"""Index over trimmed group types."""
|
|
group_types_list = [self.show(request, group_type, True)
|
|
for group_type in group_types]
|
|
group_type_links = self._get_collection_links(request, group_types,
|
|
'group_types')
|
|
group_types_dict = dict(group_types=group_types_list)
|
|
if group_type_links:
|
|
group_types_dict['group_type_links'] = group_type_links
|
|
return group_types_dict
|