Add Magnum client plugin
Change-Id: I0c31b7a9ce79b962c14c9bad59c1bf5ecb35ba82 Implements: partial blueprint magnum-resources
This commit is contained in:
18
contrib/heat_magnum/README.md
Normal file
18
contrib/heat_magnum/README.md
Normal file
@@ -0,0 +1,18 @@
|
||||
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.
|
||||
0
contrib/heat_magnum/heat_magnum/__init__.py
Normal file
0
contrib/heat_magnum/heat_magnum/__init__.py
Normal file
45
contrib/heat_magnum/heat_magnum/client.py
Normal file
45
contrib/heat_magnum/heat_magnum/client.py
Normal file
@@ -0,0 +1,45 @@
|
||||
#
|
||||
# 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
|
||||
|
||||
from heat.engine.clients import client_plugin
|
||||
|
||||
exceptions = importutils.try_import(
|
||||
'magnumclient.openstack.common.apiclient.exceptions')
|
||||
magnum_client = importutils.try_import('magnumclient.v1.client')
|
||||
|
||||
|
||||
class MagnumClientPlugin(client_plugin.ClientPlugin):
|
||||
|
||||
def _create(self):
|
||||
endpoint_type = self._get_client_option('magnum', 'endpoint_type')
|
||||
endpoint = self.url_for(service_type='container',
|
||||
endpoint_type=endpoint_type)
|
||||
|
||||
args = {
|
||||
'magnum_url': endpoint,
|
||||
'input_auth_token': self.auth_token
|
||||
}
|
||||
|
||||
client = magnum_client.Client(**args)
|
||||
return client
|
||||
|
||||
def is_not_found(self, ex):
|
||||
return isinstance(ex, exceptions.NotFound)
|
||||
|
||||
def is_over_limit(self, ex):
|
||||
return isinstance(ex, exceptions.RequestEntityTooLarge)
|
||||
|
||||
def is_conflict(self, ex):
|
||||
return isinstance(ex, exceptions.Conflict)
|
||||
1
contrib/heat_magnum/requirements.txt
Normal file
1
contrib/heat_magnum/requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
python-magnumclient>=0.0.1
|
||||
34
contrib/heat_magnum/setup.cfg
Normal file
34
contrib/heat_magnum/setup.cfg
Normal file
@@ -0,0 +1,34 @@
|
||||
[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
|
||||
29
contrib/heat_magnum/setup.py
Normal file
29
contrib/heat_magnum/setup.py
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/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)
|
||||
Reference in New Issue
Block a user