[Magnum] Add Magnum client to Rally
Change-Id: I9553590ae7d35c0a9a4da2af4ddda3647215d1e4 Partially-Implements: bp benchmark-scenarios-for-magnum
This commit is contained in:
parent
38d54ec730
commit
4c524c5390
@ -4,3 +4,4 @@ python-muranoclient>=0.5.5
|
|||||||
python-monascaclient>=1.0.22
|
python-monascaclient>=1.0.22
|
||||||
python-cueclient>=1.0.0
|
python-cueclient>=1.0.0
|
||||||
python-senlinclient>=0.3.0 # Apache-2.0
|
python-senlinclient>=0.3.0 # Apache-2.0
|
||||||
|
python-magnumclient>=2.0.0 # Apache-2.0
|
||||||
|
@ -112,6 +112,7 @@ class _Service(utils.ImmutableMixin, utils.EnumMixin):
|
|||||||
MURANO = "murano"
|
MURANO = "murano"
|
||||||
IRONIC = "ironic"
|
IRONIC = "ironic"
|
||||||
GNOCCHI = "gnocchi"
|
GNOCCHI = "gnocchi"
|
||||||
|
MAGNUM = "magnum"
|
||||||
|
|
||||||
|
|
||||||
class _ServiceType(utils.ImmutableMixin, utils.EnumMixin):
|
class _ServiceType(utils.ImmutableMixin, utils.EnumMixin):
|
||||||
@ -139,6 +140,7 @@ class _ServiceType(utils.ImmutableMixin, utils.EnumMixin):
|
|||||||
APPLICATION_CATALOG = "application-catalog"
|
APPLICATION_CATALOG = "application-catalog"
|
||||||
BARE_METAL = "baremetal"
|
BARE_METAL = "baremetal"
|
||||||
METRIC = "metric"
|
METRIC = "metric"
|
||||||
|
CONTAINER = "container"
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.__names = {
|
self.__names = {
|
||||||
@ -164,6 +166,7 @@ class _ServiceType(utils.ImmutableMixin, utils.EnumMixin):
|
|||||||
self.APPLICATION_CATALOG: _Service.MURANO,
|
self.APPLICATION_CATALOG: _Service.MURANO,
|
||||||
self.BARE_METAL: _Service.IRONIC,
|
self.BARE_METAL: _Service.IRONIC,
|
||||||
self.METRIC: _Service.GNOCCHI,
|
self.METRIC: _Service.GNOCCHI,
|
||||||
|
self.CONTAINER: _Service.MAGNUM,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __getitem__(self, service_type):
|
def __getitem__(self, service_type):
|
||||||
|
@ -735,6 +735,19 @@ class Senlin(OSClient):
|
|||||||
**self._get_auth_info(project_name_key="project_name"))
|
**self._get_auth_info(project_name_key="project_name"))
|
||||||
|
|
||||||
|
|
||||||
|
@configure("magnum", default_version="1", default_service_type="container",)
|
||||||
|
class Magnum(OSClient):
|
||||||
|
def create_client(self, version=None, service_type=None):
|
||||||
|
"""Return magnum client."""
|
||||||
|
from magnumclient import client as magnum
|
||||||
|
|
||||||
|
api_url = self._get_endpoint(service_type)
|
||||||
|
session = self._get_session(endpoint=api_url)
|
||||||
|
endpoint_type = self.credential.endpoint_type,
|
||||||
|
|
||||||
|
return magnum.Client(session=session, interface=endpoint_type[0])
|
||||||
|
|
||||||
|
|
||||||
class Clients(object):
|
class Clients(object):
|
||||||
"""This class simplify and unify work with OpenStack python clients."""
|
"""This class simplify and unify work with OpenStack python clients."""
|
||||||
|
|
||||||
|
@ -1487,6 +1487,12 @@ class FakeSenlinClient(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class FakeMagnumClient(object):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class FakeClients(object):
|
class FakeClients(object):
|
||||||
|
|
||||||
def __init__(self, credential_=None):
|
def __init__(self, credential_=None):
|
||||||
|
@ -817,3 +817,28 @@ class OSClientsTestCase(test.TestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
mock_senlin.client.Client.return_value,
|
mock_senlin.client.Client.return_value,
|
||||||
self.clients.cache["senlin"])
|
self.clients.cache["senlin"])
|
||||||
|
|
||||||
|
@mock.patch("rally.osclients.Magnum._get_session")
|
||||||
|
def test_magnum(self, mock_magnum__get_session):
|
||||||
|
fake_magnum = fakes.FakeMagnumClient()
|
||||||
|
mock_magnum = mock.MagicMock()
|
||||||
|
mock_magnum.client.Client.return_value = fake_magnum
|
||||||
|
|
||||||
|
mock_magnum__get_session.return_value = self.fake_keystone.session
|
||||||
|
|
||||||
|
self.assertNotIn("magnum", self.clients.cache)
|
||||||
|
with mock.patch.dict("sys.modules", {"magnumclient": mock_magnum}):
|
||||||
|
client = self.clients.magnum()
|
||||||
|
|
||||||
|
self.assertEqual(fake_magnum, client)
|
||||||
|
|
||||||
|
self.service_catalog.url_for.assert_called_once_with(
|
||||||
|
service_type="container",
|
||||||
|
endpoint_type=consts.EndpointType.PUBLIC,
|
||||||
|
region_name=self.credential.region_name)
|
||||||
|
|
||||||
|
mock_magnum.client.Client.assert_called_once_with(
|
||||||
|
interface=consts.EndpointType.PUBLIC,
|
||||||
|
session=self.fake_keystone.session)
|
||||||
|
|
||||||
|
self.assertEqual(fake_magnum, self.clients.cache["magnum"])
|
||||||
|
Loading…
Reference in New Issue
Block a user