Implement Zun client plugin
Co-Authored-By: Hongbin Lu <hongbin.lu@huawei.com> Partial Implements:blueprint heat-plugin-zun Change-Id: Icedc709222f04d52769bbe95a34a0178c01a44e0
This commit is contained in:
parent
6d570b70f5
commit
f4c213519e
45
heat/engine/clients/os/zun.py
Normal file
45
heat/engine/clients/os/zun.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 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)
|
24
heat/tests/clients/test_zun_client.py
Normal file
24
heat/tests/clients/test_zun_client.py
Normal 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)
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
other:
|
||||
- |
|
||||
Introduce a Zun client plugin module that will be used by the
|
||||
Zun's resources that are under development.
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user