Adds barbican to osclient
This patch is the foundation for adding Barnican based scenarios. The browbeat project would like to measure the performance of barbican keys, in order to do this we need to add barbican support to rally-openstack. Change-Id: If23299ade2580f5dc76a02cd5b29f94558356c67 Signed-off-by: Chuck Short <chucks@redhat.com>
This commit is contained in:
parent
8ef93aa517
commit
4201363727
@ -485,6 +485,7 @@ class Glance(OSClient):
|
||||
supported_versions=["1"])
|
||||
class Heat(OSClient):
|
||||
"""Wrapper for HeatClient which returns an authenticated native client."""
|
||||
|
||||
def create_client(self, version=None, service_type=None):
|
||||
"""Return heat client."""
|
||||
from heatclient import client as heat
|
||||
@ -553,6 +554,7 @@ class Ceilometer(OSClient):
|
||||
"""Wrapper for CeilometerClient which returns authenticated native client.
|
||||
|
||||
"""
|
||||
|
||||
def create_client(self, version=None, service_type=None):
|
||||
"""Return ceilometer client."""
|
||||
from ceilometerclient import client as ceilometer
|
||||
@ -640,6 +642,7 @@ class Zaqar(OSClient):
|
||||
"""Wrapper for ZaqarClient which returns an authenticated native client.
|
||||
|
||||
"""
|
||||
|
||||
def choose_version(self, version=None):
|
||||
# zaqarclient accepts only int or float obj as version
|
||||
return float(super(Zaqar, self).choose_version(version))
|
||||
@ -660,6 +663,7 @@ class Murano(OSClient):
|
||||
"""Wrapper for MuranoClient which returns an authenticated native client.
|
||||
|
||||
"""
|
||||
|
||||
def create_client(self, version=None, service_type=None):
|
||||
"""Return Murano client."""
|
||||
from muranoclient import client as murano
|
||||
@ -677,6 +681,7 @@ class Designate(OSClient):
|
||||
"""Wrapper for DesignateClient which returns authenticated native client.
|
||||
|
||||
"""
|
||||
|
||||
def create_client(self, version=None, service_type=None):
|
||||
"""Return designate client."""
|
||||
from designateclient import client
|
||||
@ -700,6 +705,7 @@ class Trove(OSClient):
|
||||
"""Wrapper for TroveClient which returns an authenticated native client.
|
||||
|
||||
"""
|
||||
|
||||
def create_client(self, version=None, service_type=None):
|
||||
"""Returns trove client."""
|
||||
from troveclient import client as trove
|
||||
@ -715,6 +721,7 @@ class Mistral(OSClient):
|
||||
"""Wrapper for MistralClient which returns an authenticated native client.
|
||||
|
||||
"""
|
||||
|
||||
def create_client(self, service_type=None):
|
||||
"""Return Mistral client."""
|
||||
from mistralclient.api import client as mistral
|
||||
@ -731,6 +738,7 @@ class Swift(OSClient):
|
||||
"""Wrapper for SwiftClient which returns an authenticated native client.
|
||||
|
||||
"""
|
||||
|
||||
def create_client(self, service_type=None):
|
||||
"""Return swift client."""
|
||||
from swiftclient import client as swift
|
||||
@ -752,6 +760,7 @@ class EC2(OSClient):
|
||||
"""Wrapper for EC2Client which returns an authenticated native client.
|
||||
|
||||
"""
|
||||
|
||||
def create_client(self):
|
||||
"""Return ec2 client."""
|
||||
LOG.warning("rally.osclient.EC2 is deprecated since Rally 0.10.0.")
|
||||
@ -779,6 +788,7 @@ class Monasca(OSClient):
|
||||
"""Wrapper for MonascaClient which returns an authenticated native client.
|
||||
|
||||
"""
|
||||
|
||||
def create_client(self, version=None, service_type=None):
|
||||
"""Return monasca client."""
|
||||
from monascaclient import client as monasca
|
||||
@ -800,6 +810,7 @@ class Senlin(OSClient):
|
||||
"""Wrapper for SenlinClient which returns an authenticated native client.
|
||||
|
||||
"""
|
||||
|
||||
def create_client(self, version=None, service_type=None):
|
||||
"""Return senlin client."""
|
||||
from senlinclient import client as senlin
|
||||
@ -817,6 +828,7 @@ class Magnum(OSClient):
|
||||
"""Wrapper for MagnumClient which returns an authenticated native client.
|
||||
|
||||
"""
|
||||
|
||||
def create_client(self, version=None, service_type=None):
|
||||
"""Return magnum client."""
|
||||
from magnumclient import client as magnum
|
||||
@ -836,6 +848,7 @@ class Watcher(OSClient):
|
||||
"""Wrapper for WatcherClient which returns an authenticated native client.
|
||||
|
||||
"""
|
||||
|
||||
def create_client(self, version=None, service_type=None):
|
||||
"""Return watcher client."""
|
||||
from watcherclient import client as watcher_client
|
||||
@ -848,6 +861,25 @@ class Watcher(OSClient):
|
||||
return client
|
||||
|
||||
|
||||
@configure("barbican", default_version="1", default_service_type="key-manager")
|
||||
class Barbican(OSClient):
|
||||
"""Wrapper for BarbicanClient which returns an authenticated native client.
|
||||
|
||||
"""
|
||||
|
||||
def create_client(self, version=None, service_type=None):
|
||||
"""Return Barbican client."""
|
||||
from barbicanclient import client as barbican_client
|
||||
|
||||
version = "v%s" % self.choose_version(version)
|
||||
|
||||
client = barbican_client.Client(
|
||||
version=self.choose_version(version),
|
||||
session=self.keystone.get_session()[0])
|
||||
|
||||
return client
|
||||
|
||||
|
||||
class Clients(object):
|
||||
"""This class simplify and unify work with OpenStack python clients."""
|
||||
|
||||
|
0
rally_openstack/scenarios/barbican/__init__.py
Normal file
0
rally_openstack/scenarios/barbican/__init__.py
Normal file
@ -1216,7 +1216,7 @@ class FakeNeutronClient(object):
|
||||
pool = setup_dict(data["pool"],
|
||||
required=["lb_method", "protocol", "subnet_id"],
|
||||
defaults={"name": generate_name("pool_"),
|
||||
"admin_state_up": True})
|
||||
"admin_state_up": True})
|
||||
if pool["subnet_id"] not in self.__subnets:
|
||||
raise neutron_exceptions.NeutronClientException
|
||||
pool_id = generate_uuid()
|
||||
@ -1590,6 +1590,12 @@ class FakeWatcherClient(object):
|
||||
self.goal = FakeGoalManager()
|
||||
|
||||
|
||||
class FakeBarbicanClient(object):
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
class FakeClients(object):
|
||||
|
||||
def __init__(self, credential_=None):
|
||||
@ -1612,6 +1618,7 @@ class FakeClients(object):
|
||||
self._ec2 = None
|
||||
self._senlin = None
|
||||
self._watcher = None
|
||||
self._barbican = None
|
||||
self._credential = credential_ or FakeCredential(
|
||||
auth_url="http://fake.example.org:5000/v2.0/",
|
||||
username="fake_username",
|
||||
@ -1716,6 +1723,11 @@ class FakeClients(object):
|
||||
self._watcher = FakeWatcherClient()
|
||||
return self._watcher
|
||||
|
||||
def barbican(self):
|
||||
if not self._barbican:
|
||||
self._barbican = FakeBarbicanClient()
|
||||
return self._barbican
|
||||
|
||||
|
||||
class FakeRunner(object):
|
||||
|
||||
|
0
tests/unit/scenarios/barbican/__init__.py
Normal file
0
tests/unit/scenarios/barbican/__init__.py
Normal file
@ -1042,3 +1042,23 @@ class OSClientsTestCase(test.TestCase):
|
||||
|
||||
mock_watcher.client.Client.assert_called_once_with("1", **kw)
|
||||
self.assertEqual(fake_watcher, self.clients.cache["watcher"])
|
||||
|
||||
@mock.patch("%s.Barbican._get_endpoint" % PATH)
|
||||
def test_barbican(self, mock_barbican__get_endpoint):
|
||||
fake_barbican = fakes.FakeBarbicanClient()
|
||||
mock_barbican = mock.MagicMock()
|
||||
mock_barbican__get_endpoint.return_value = "http://fake.to:2/fake"
|
||||
mock_keystoneauth1 = mock.MagicMock()
|
||||
mock_barbican.client.Client.return_value = fake_barbican
|
||||
with mock.patch.dict("sys.modules",
|
||||
{"barbicanclient": mock_barbican,
|
||||
"keystoneauth1": mock_keystoneauth1}):
|
||||
client = self.clients.barbican()
|
||||
|
||||
self.assertEqual(fake_barbican, client)
|
||||
kw = {
|
||||
"session": mock_keystoneauth1.session.Session(),
|
||||
"version": "v1"
|
||||
}
|
||||
mock_barbican.client.Client.assert_called_once_with(**kw)
|
||||
self.assertEqual(fake_barbican, self.clients.cache["barbican"])
|
||||
|
Loading…
x
Reference in New Issue
Block a user