Merge "Add Blazar client plugin to Heat"
This commit is contained in:
commit
158636e94f
|
@ -62,3 +62,4 @@ We have integration with
|
||||||
* https://git.openstack.org/cgit/openstack/python-zaqarclient (messaging service)
|
* https://git.openstack.org/cgit/openstack/python-zaqarclient (messaging service)
|
||||||
* https://git.openstack.org/cgit/openstack/python-monascaclient (monitoring service)
|
* https://git.openstack.org/cgit/openstack/python-monascaclient (monitoring service)
|
||||||
* https://git.openstack.org/cgit/openstack/python-zunclient (container management service)
|
* https://git.openstack.org/cgit/openstack/python-zunclient (container management service)
|
||||||
|
* https://git.openstack.org/cgit/openstack/python-blazarclient (reservation service)
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
#
|
||||||
|
# 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 blazarclient import client as blazar_client
|
||||||
|
from keystoneauth1.exceptions import http as ks_exc
|
||||||
|
|
||||||
|
from heat.engine.clients import client_plugin
|
||||||
|
|
||||||
|
CLIENT_NAME = 'blazar'
|
||||||
|
|
||||||
|
|
||||||
|
class BlazarClientPlugin(client_plugin.ClientPlugin):
|
||||||
|
|
||||||
|
service_types = [RESERVATION] = ['reservation']
|
||||||
|
|
||||||
|
def _create(self, version=None):
|
||||||
|
interface = self._get_client_option(CLIENT_NAME, 'endpoint_type')
|
||||||
|
args = {
|
||||||
|
'session': self.context.keystone_session,
|
||||||
|
'service_type': self.RESERVATION,
|
||||||
|
'interface': interface,
|
||||||
|
'region_name': self._get_region_name(),
|
||||||
|
}
|
||||||
|
|
||||||
|
client = blazar_client.Client(**args)
|
||||||
|
return client
|
||||||
|
|
||||||
|
def is_not_found(self, exc):
|
||||||
|
return isinstance(exc, ks_exc.NotFound)
|
||||||
|
|
||||||
|
def has_host(self):
|
||||||
|
return True if self.client().host.list() else False
|
|
@ -0,0 +1,42 @@
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
import mock
|
||||||
|
|
||||||
|
|
||||||
|
class BlazarClientPluginTest(common.HeatTestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(BlazarClientPluginTest, self).setUp()
|
||||||
|
self.blazar_client = mock.MagicMock()
|
||||||
|
context = utils.dummy_context()
|
||||||
|
self.blazar_client_plugin = context.clients.client_plugin('blazar')
|
||||||
|
|
||||||
|
def _stub_client(self):
|
||||||
|
self.blazar_client_plugin.client = lambda: self.blazar_client
|
||||||
|
|
||||||
|
def test_create(self):
|
||||||
|
client = self.blazar_client_plugin.client()
|
||||||
|
self.assertEqual(None, client.blazar_url)
|
||||||
|
|
||||||
|
def test_has_host_pass(self):
|
||||||
|
self._stub_client()
|
||||||
|
self.blazar_client.host.list.return_value = ['hosta']
|
||||||
|
self.assertEqual(True, self.blazar_client_plugin.has_host())
|
||||||
|
|
||||||
|
def test_has_host_fail(self):
|
||||||
|
self._stub_client()
|
||||||
|
self.blazar_client.host.list.return_value = []
|
||||||
|
self.assertEqual(False, self.blazar_client_plugin.has_host())
|
|
@ -101,6 +101,7 @@ pyOpenSSL==17.5.0
|
||||||
pyparsing==2.2.0
|
pyparsing==2.2.0
|
||||||
pyperclip==1.6.0
|
pyperclip==1.6.0
|
||||||
python-barbicanclient==4.5.2
|
python-barbicanclient==4.5.2
|
||||||
|
python-blazarclient===1.0.0
|
||||||
python-ceilometerclient==2.5.0
|
python-ceilometerclient==2.5.0
|
||||||
python-cinderclient==3.3.0
|
python-cinderclient==3.3.0
|
||||||
python-dateutil==2.7.0
|
python-dateutil==2.7.0
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
other:
|
||||||
|
- |
|
||||||
|
Introduce a Blazar client plugin module that will be used by Blazar resources.
|
|
@ -31,6 +31,7 @@ oslo.versionedobjects>=1.31.2 # Apache-2.0
|
||||||
PasteDeploy>=1.5.0 # MIT
|
PasteDeploy>=1.5.0 # MIT
|
||||||
aodhclient>=0.9.0 # Apache-2.0
|
aodhclient>=0.9.0 # Apache-2.0
|
||||||
python-barbicanclient>=4.5.2 # Apache-2.0
|
python-barbicanclient>=4.5.2 # Apache-2.0
|
||||||
|
python-blazarclient>=1.0.0 # Apache-2.0
|
||||||
python-ceilometerclient>=2.5.0 # Apache-2.0
|
python-ceilometerclient>=2.5.0 # Apache-2.0
|
||||||
python-cinderclient>=3.3.0 # Apache-2.0
|
python-cinderclient>=3.3.0 # Apache-2.0
|
||||||
python-designateclient>=2.7.0 # Apache-2.0
|
python-designateclient>=2.7.0 # Apache-2.0
|
||||||
|
|
|
@ -65,6 +65,7 @@ oslo.policy.policies =
|
||||||
heat.clients =
|
heat.clients =
|
||||||
aodh = heat.engine.clients.os.aodh:AodhClientPlugin
|
aodh = heat.engine.clients.os.aodh:AodhClientPlugin
|
||||||
barbican = heat.engine.clients.os.barbican:BarbicanClientPlugin
|
barbican = heat.engine.clients.os.barbican:BarbicanClientPlugin
|
||||||
|
blazar = heat.engine.clients.os.blazar:BlazarClientPlugin
|
||||||
ceilometer = heat.engine.clients.os.ceilometer:CeilometerClientPlugin
|
ceilometer = heat.engine.clients.os.ceilometer:CeilometerClientPlugin
|
||||||
cinder = heat.engine.clients.os.cinder:CinderClientPlugin
|
cinder = heat.engine.clients.os.cinder:CinderClientPlugin
|
||||||
designate = heat.engine.clients.os.designate:DesignateClientPlugin
|
designate = heat.engine.clients.os.designate:DesignateClientPlugin
|
||||||
|
|
Loading…
Reference in New Issue