Merge "Move manila resources in-tree"

This commit is contained in:
Jenkins 2015-06-09 03:12:03 +00:00 committed by Gerrit Code Review
commit f8aabd3c18
14 changed files with 75 additions and 89 deletions

View File

@ -1,18 +0,0 @@
Manila plugin for OpenStack Heat
================================
This plugin enables using Manila resources in a Heat template.
### 1. Install the Manila 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 newly installed
plugin.

View File

@ -1 +0,0 @@
python-manilaclient>=1.0.3

View File

@ -1,34 +0,0 @@
[metadata]
name = heat-contrib-manila
summary = Heat resources for Manila
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]
packages =
heat_manila
# Copy to /usr/lib/heat for plugin loading
data_files =
lib/heat/manila = heat_manila/resources/*
[entry_points]
heat.clients =
manila = heat_manila.client:ManilaClientPlugin
[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

@ -22,6 +22,10 @@ manila_client = importutils.try_import('manilaclient.v1.client')
class ManilaClientPlugin(client_plugin.ClientPlugin):
@staticmethod
def is_available():
return manila_client is not None
def _create(self):
endpoint_type = self._get_client_option('manila', 'endpoint_type')
endpoint = self.url_for(service_type='share',

View File

@ -12,6 +12,7 @@
# under the License.
from heat.common.i18n import _
from heat.engine import clients
from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource
@ -109,3 +110,10 @@ def resource_mapping():
return {
'OS::Manila::SecurityService': SecurityService
}
def available_resource_mapping():
if not clients.has_client('manila'):
return {}
return resource_mapping()

View File

@ -0,0 +1,31 @@
#
# 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 oslo_utils import importutils
import testtools
from heat.tests import common
from heat.tests import utils
manila_client = importutils.try_import('manilaclient.v1.client')
class ManilaClientPluginTests(common.HeatTestCase):
@testtools.skipIf(manila_client is None, 'Tests the manila client')
def test_create(self):
context = utils.dummy_context()
plugin = context.clients.client_plugin('manila')
client = plugin.client()
self.assertIsNotNone(client.security_services)
self.assertEqual('http://server.test:5000/v3', client.client.base_url)

View File

@ -12,17 +12,22 @@
# under the License.
import mock
from oslo_utils import importutils
import six
import testtools
from heat.common import exception
from heat.common import template_format
from heat.engine import resource
from heat.engine import resources
from heat.engine.resources.openstack.manila import security_service
from heat.engine import scheduler
from heat.engine import stack as stack_parser
from heat.engine import template
from heat.tests import common
from heat.tests import utils
from ..resources import security_service # noqa
manila_client = importutils.try_import('manilaclient.v1.client')
stack_template = '''
heat_template_version: 2013-05-23
@ -71,10 +76,11 @@ resources:
'''
class SecurityServiceTest(common.HeatTestCase):
class ManilaSecurityServiceTest(common.HeatTestCase):
def setUp(self):
super(SecurityServiceTest, self).setUp()
super(ManilaSecurityServiceTest, self).setUp()
resources.initialise()
utils.setup_dummy_db()
self.ctx = utils.dummy_context()
@ -168,3 +174,10 @@ class SecurityServiceTest(common.HeatTestCase):
scheduler.TaskRunner(ss.update, new_ss))
msg = 'The Resource security_service requires replacement.'
self.assertEqual(msg, six.text_type(err))
@testtools.skipIf(manila_client is not None,
'Tests manila client not installed')
def test_no_client(self):
tmpl = template.Template((template_format.parse(stack_template)))
stack = stack_parser.Stack(utils.dummy_context(), 'foo', tmpl)
self.assertRaises(exception.ResourceTypeNotFound, stack.validate)

View File

@ -14,16 +14,21 @@
import copy
import mock
from oslo_utils import importutils
import testtools
from heat.common import exception
from heat.common import template_format
from heat.engine import resource
from heat.engine import resources
from heat.engine.resources.openstack.manila import share_type as mshare_type
from heat.engine import rsrc_defn
from heat.engine import scheduler
from heat.engine import stack as stack_parser
from heat.engine import template
from heat.tests import common
from heat.tests import utils
from ..resources import share_type as mshare_type # noqa
manila_client = importutils.try_import('manilaclient.v1.client')
manila_template = """
heat_template_version: 2013-05-23
@ -42,10 +47,9 @@ class ManilaShareTypeTest(common.HeatTestCase):
def setUp(self):
super(ManilaShareTypeTest, self).setUp()
resources.initialise()
utils.setup_dummy_db()
self.ctx = utils.dummy_context()
resource._register_class("OS::Manila::ShareType",
mshare_type.ManilaShareType)
def _init_share(self, stack_name, share_type_name="test_share_type"):
# parse stack
@ -114,3 +118,10 @@ class ManilaShareTypeTest(common.HeatTestCase):
fake_share_type.unset_keys.assert_called_once_with({"test": "test"})
fake_share_type.set_keys.assert_called_with(
updated_props[mshare_type.ManilaShareType.EXTRA_SPECS])
@testtools.skipIf(manila_client is not None,
'Tests manila client not installed')
def test_no_client(self):
tmpl = template.Template((template_format.parse(manila_template)))
stack = stack_parser.Stack(utils.dummy_context(), 'foo', tmpl)
self.assertRaises(exception.ResourceTypeNotFound, stack.validate)

View File

@ -52,6 +52,7 @@ heat.clients =
glance = heat.engine.clients.os.glance:GlanceClientPlugin
heat = heat.engine.clients.os.heat_plugin:HeatClientPlugin
keystone = heat.engine.clients.os.keystone:KeystoneClientPlugin
manila = heat.engine.clients.os.manila:ManilaClientPlugin
nova = heat.engine.clients.os.nova:NovaClientPlugin
neutron = heat.engine.clients.os.neutron:NeutronClientPlugin
swift = heat.engine.clients.os.swift:SwiftClientPlugin