Merge "Implement Zun client plugin"

This commit is contained in:
Jenkins 2017-04-26 08:36:18 +00:00 committed by Gerrit Code Review
commit e9679344c9
5 changed files with 76 additions and 0 deletions

View 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 zunclient import exceptions as zc_exc
from zunclient.v1 import client as zun_client
from heat.engine.clients import client_plugin
CLIENT_NAME = 'zun'
class ZunClientPlugin(client_plugin.ClientPlugin):
service_types = [CONTAINER] = ['container']
def _create(self):
interface = self._get_client_option(CLIENT_NAME, 'endpoint_type')
args = {
'interface': interface,
'service_type': self.CONTAINER,
'session': self.context.keystone_session,
'region_name': self._get_region_name()
}
client = zun_client.Client(**args)
return client
def is_not_found(self, ex):
return isinstance(ex, zc_exc.NotFound)
def is_over_limit(self, ex):
return isinstance(ex, zc_exc.RequestEntityTooLarge)
def is_conflict(self, ex):
return isinstance(ex, zc_exc.Conflict)

View File

@ -0,0 +1,24 @@
# 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 heat.tests import common
from heat.tests import utils
class ZunClientPluginTest(common.HeatTestCase):
def test_create(self):
context = utils.dummy_context()
plugin = context.clients.client_plugin('zun')
client = plugin.client()
self.assertEqual('http://server.test:5000/v3',
client.containers.api.session.auth.endpoint)

View File

@ -0,0 +1,5 @@
---
other:
- |
Introduce a Zun client plugin module that will be used by the
Zun's resources that are under development.

View File

@ -51,6 +51,7 @@ python-senlinclient>=1.1.0 # Apache-2.0
python-swiftclient>=3.2.0 # Apache-2.0
python-troveclient>=2.2.0 # Apache-2.0
python-zaqarclient>=1.0.0 # Apache-2.0
python-zunclient>=0.1.0 # Apache-2.0
pytz>=2013.6 # MIT
PyYAML>=3.10.0 # MIT
requests!=2.12.2,!=2.13.0,>=2.10.0 # Apache-2.0

View File

@ -78,6 +78,7 @@ heat.clients =
swift = heat.engine.clients.os.swift:SwiftClientPlugin
trove = heat.engine.clients.os.trove:TroveClientPlugin
zaqar = heat.engine.clients.os.zaqar:ZaqarClientPlugin
zun = heat.engine.clients.os.zun:ZunClientPlugin
heat.constraints =
# common constraints