Move cinder_volume_type resource in-tree

This change relocates the keystone resources from the contrib area into
the main resource tree.

Change-Id: If42555cdfeed69fdc65e15f88053a66dc9c3ae3b
This commit is contained in:
Miguel Grinberg 2015-06-01 14:04:16 -07:00
parent b02805bea5
commit 228824c7e3
8 changed files with 24 additions and 117 deletions

View File

@ -1,49 +0,0 @@
Cinder volume_type plugin for OpenStack Heat
============================================
This plugin enables using Cinder volume_types as resources in a Heat template.
### 1. Install the Cinder volume_type plugin in Heat
NOTE: These instructions assume the value of heat.conf plugin_dirs includes the
default directory /usr/lib/heat.
To install the plugin, from this directory run:
sudo python ./setup.py install
### 2. Restart heat
Only the process "heat-engine" needs to be restarted to load the new installed
plugin.
### Template Format
Here's an example cinder volume_type and cinder volume resources:
```yaml
heat_template_version: 2013-05-23
description: Heat Cinder creation with volume_type example
resources:
my_volume_type:
type: OS::Cinder::VolumeType
properties:
name: volumeBackend
metadata: {volume_backend_name: lvmdriver}
my_volume:
type: OS::Cinder::Volume
properties:
size: 1
volume_type: {get_resource: my_volume_type}
```
### Issues with the Cinder volume_type plugin
By default only users who have the admin role can manage volume
types because of the default policy in
Cinder: ```"volume_extension:types_manage": "rule:admin_api"```
To let the possibility to all users to create volume type, the rule must be
replaced with the following: ```"volume_extension:types_manage": ""```
The following error occurs if the policy has not been correctly set:
ERROR: Policy doesn't allow volume_extension:types_manage to be performed.

View File

@ -1,27 +0,0 @@
[metadata]
name = heat-contrib-cinder-volume-type
summary = Heat resource for managing cinder volume_types
description-file =
README.md
author = OpenStack
author-email = openstack-dev@lists.openstack.org
home-page = http://www.openstack.org/
classifier =
Environment :: OpenStack
Intended Audience :: Information Technology
Intended Audience :: System Administrators
License :: OSI Approved :: Apache Software License
Operating System :: POSIX :: Linux
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 2.6
[files]
# Copy to /usr/lib/heat for plugin loading
data_files =
lib/heat/cinder_volume_type = cinder_volume_type/resources/*
[global]
setup-hooks =
pbr.hooks.setup_hook

View File

@ -1,29 +0,0 @@
#!/usr/bin/env python
#
# 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.
# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT
import setuptools
# In python < 2.7.4, a lazy loading of package `pbr` will break
# setuptools if some other modules registered functions in `atexit`.
# solution from: http://bugs.python.org/issue15881#msg170215
try:
import multiprocessing # noqa
except ImportError:
pass
setuptools.setup(
setup_requires=['pbr'],
pbr=True)

View File

@ -19,11 +19,28 @@ from heat.engine import support
class CinderVolumeType(resource.Resource):
"""
A resource for creating OpenStack virtual hardware templates.
A resource for creating cinder volume types.
Note that default cinder security policy usage of this resource
is limited to being used by administrators only.
Here is an example cinder volume_type and cinder volume resources::
heat_template_version: 2013-05-23
description: Heat Cinder creation with volume_type example
resources:
my_volume_type:
type: OS::Cinder::VolumeType
properties:
name: volumeBackend
metadata: {volume_backend_name: lvmdriver}
my_volume:
type: OS::Cinder::Volume
properties:
size: 1
volume_type: {get_resource: my_volume_type}
"""
support_status = support.SupportStatus(version='2015.1')
PROPERTIES = (

View File

@ -13,15 +13,12 @@
import mock
from heat.engine import resource
from heat.engine.resources.openstack.cinder import cinder_volume_type
from heat.engine import stack
from heat.engine import template
from heat.tests import common
from heat.tests import utils
from ..resources.cinder_volume_type import CinderVolumeType # noqa
from ..resources.cinder_volume_type import resource_mapping # noqa
volume_type_template = {
'heat_template_version': '2013-05-23',
'resources': {
@ -42,10 +39,6 @@ class CinderVolumeTypeTest(common.HeatTestCase):
self.ctx = utils.dummy_context()
# For unit testing purpose. Register resource provider
# explicitly.
resource._register_class('OS::Cinder::VolumeType', CinderVolumeType)
self.stack = stack.Stack(
self.ctx, 'cinder_volume_type_test_stack',
template.Template(volume_type_template)
@ -59,10 +52,12 @@ class CinderVolumeTypeTest(common.HeatTestCase):
self.volume_types = self.cinderclient.volume_types
def test_resource_mapping(self):
mapping = resource_mapping()
mapping = cinder_volume_type.resource_mapping()
self.assertEqual(1, len(mapping))
self.assertEqual(CinderVolumeType, mapping['OS::Cinder::VolumeType'])
self.assertIsInstance(self.my_volume_type, CinderVolumeType)
self.assertEqual(cinder_volume_type.CinderVolumeType,
mapping['OS::Cinder::VolumeType'])
self.assertIsInstance(self.my_volume_type,
cinder_volume_type.CinderVolumeType)
def test_volume_type_handle_create(self):
value = mock.MagicMock()