From 6bcc8a373d4b9e7e697c5b6738da41ae041f627c Mon Sep 17 00:00:00 2001 From: Robert Pothier Date: Tue, 2 Jun 2015 13:27:58 -0400 Subject: [PATCH] Move Magnum client into main tree This moves the magnum client plugin out of contrib into the main tree. Change-Id: Ie520bcb27530394af0afef8335e3d57d7dc26121 Implements: partial blueprint magnum-resources --- contrib/heat_magnum/README.md | 18 ---------- contrib/heat_magnum/heat_magnum/__init__.py | 0 contrib/heat_magnum/requirements.txt | 1 - contrib/heat_magnum/setup.cfg | 34 ------------------- contrib/heat_magnum/setup.py | 29 ---------------- .../engine/clients/os/magnum.py | 5 ++- heat/tests/test_magnum_client.py | 31 +++++++++++++++++ setup.cfg | 1 + 8 files changed, 36 insertions(+), 83 deletions(-) delete mode 100644 contrib/heat_magnum/README.md delete mode 100644 contrib/heat_magnum/heat_magnum/__init__.py delete mode 100644 contrib/heat_magnum/requirements.txt delete mode 100644 contrib/heat_magnum/setup.cfg delete mode 100644 contrib/heat_magnum/setup.py rename contrib/heat_magnum/heat_magnum/client.py => heat/engine/clients/os/magnum.py (95%) create mode 100644 heat/tests/test_magnum_client.py diff --git a/contrib/heat_magnum/README.md b/contrib/heat_magnum/README.md deleted file mode 100644 index 77ea70184c..0000000000 --- a/contrib/heat_magnum/README.md +++ /dev/null @@ -1,18 +0,0 @@ -Magnum plugin for OpenStack Heat -================================ - -This plugin enables using Magnum resources in a Heat template. - - -### 1. Install the Magnum 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. diff --git a/contrib/heat_magnum/heat_magnum/__init__.py b/contrib/heat_magnum/heat_magnum/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/contrib/heat_magnum/requirements.txt b/contrib/heat_magnum/requirements.txt deleted file mode 100644 index e34f132625..0000000000 --- a/contrib/heat_magnum/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -python-magnumclient>=0.0.1 diff --git a/contrib/heat_magnum/setup.cfg b/contrib/heat_magnum/setup.cfg deleted file mode 100644 index d4a3de855d..0000000000 --- a/contrib/heat_magnum/setup.cfg +++ /dev/null @@ -1,34 +0,0 @@ -[metadata] -name = heat-contrib-magnum -summary = Heat resources for Magnum -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_magnum - -# Copy to /usr/lib/heat for plugin loading -data_files = - lib/heat/magnum = heat_magnum/resources/* - -[entry_points] -heat.clients = - magnum = heat_magnum.client:MagnumClientPlugin - -[global] -setup-hooks = - pbr.hooks.setup_hook diff --git a/contrib/heat_magnum/setup.py b/contrib/heat_magnum/setup.py deleted file mode 100644 index 62f38a592f..0000000000 --- a/contrib/heat_magnum/setup.py +++ /dev/null @@ -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) diff --git a/contrib/heat_magnum/heat_magnum/client.py b/heat/engine/clients/os/magnum.py similarity index 95% rename from contrib/heat_magnum/heat_magnum/client.py rename to heat/engine/clients/os/magnum.py index da458e6b89..dd3e552a84 100644 --- a/contrib/heat_magnum/heat_magnum/client.py +++ b/heat/engine/clients/os/magnum.py @@ -24,6 +24,10 @@ class MagnumClientPlugin(client_plugin.ClientPlugin): service_types = ['container'] + @staticmethod + def is_available(): + return magnum_client is not None + def _create(self): endpoint_type = self._get_client_option('magnum', 'endpoint_type') endpoint = self.url_for(service_type=self.service_types[0], @@ -33,7 +37,6 @@ class MagnumClientPlugin(client_plugin.ClientPlugin): 'magnum_url': endpoint, 'input_auth_token': self.auth_token } - client = magnum_client.Client(**args) return client diff --git a/heat/tests/test_magnum_client.py b/heat/tests/test_magnum_client.py new file mode 100644 index 0000000000..f6fd7d6308 --- /dev/null +++ b/heat/tests/test_magnum_client.py @@ -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 + +magnum_client = importutils.try_import('magnumclient.v1.client') + + +class MagnumClientPluginTests(common.HeatTestCase): + + @testtools.skipIf(magnum_client is None, 'Tests the magnum client') + def test_create(self): + context = utils.dummy_context() + plugin = context.clients.client_plugin('magnum') + client = plugin.client() + self.assertEqual('http://server.test:5000/v3', + client.baymodels.api.endpoint) diff --git a/setup.cfg b/setup.cfg index 9bb144b46e..c652ff5057 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 + magnum = heat.engine.clients.os.magnum:MagnumClientPlugin manila = heat.engine.clients.os.manila:ManilaClientPlugin mistral = heat.engine.clients.os.mistral:MistralClientPlugin nova = heat.engine.clients.os.nova:NovaClientPlugin