Merge "Adds Octavia to OSClient"
This commit is contained in:
commit
ebaae2415b
@ -396,6 +396,28 @@ class Neutron(OSClient):
|
|||||||
return client
|
return client
|
||||||
|
|
||||||
|
|
||||||
|
@configure("octavia", default_version="2",
|
||||||
|
default_service_type="load-balancer", supported_versions=["2"])
|
||||||
|
class Octavia(OSClient):
|
||||||
|
"""Wrapper for OctaviaClient which returns an authenticated native client.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
def create_client(self, version=None, service_type=None):
|
||||||
|
"""Return octavia client."""
|
||||||
|
from octaviaclient.api.v2 import octavia
|
||||||
|
|
||||||
|
kw_args = {}
|
||||||
|
if self.credential.endpoint_type:
|
||||||
|
kw_args["endpoint_type"] = self.credential.endpoint_type
|
||||||
|
|
||||||
|
client = octavia.OctaviaAPI(
|
||||||
|
endpoint=self._get_endpoint(service_type),
|
||||||
|
session=self.keystone.get_session()[0],
|
||||||
|
**kw_args)
|
||||||
|
return client
|
||||||
|
|
||||||
|
|
||||||
@configure("glance", default_version="2", default_service_type="image",
|
@configure("glance", default_version="2", default_service_type="image",
|
||||||
supported_versions=["1", "2"])
|
supported_versions=["1", "2"])
|
||||||
class Glance(OSClient):
|
class Glance(OSClient):
|
||||||
|
@ -24,6 +24,7 @@ python-muranoclient>=0.8.2 # Apache License, Version
|
|||||||
python-monascaclient>=1.7.0 # Apache Software License
|
python-monascaclient>=1.7.0 # Apache Software License
|
||||||
python-neutronclient>=6.3.0 # Apache Software License
|
python-neutronclient>=6.3.0 # Apache Software License
|
||||||
python-novaclient>=9.1.0 # Apache License, Version 2.0
|
python-novaclient>=9.1.0 # Apache License, Version 2.0
|
||||||
|
python-octaviaclient>=1.4.0 # Apache License, Version 2.0
|
||||||
python-saharaclient>=1.4.0 # Apache License, Version 2.0
|
python-saharaclient>=1.4.0 # Apache License, Version 2.0
|
||||||
python-senlinclient>=1.1.0 # Apache Software License
|
python-senlinclient>=1.1.0 # Apache Software License
|
||||||
python-swiftclient>=3.2.0 # Apache Software License
|
python-swiftclient>=3.2.0 # Apache Software License
|
||||||
|
@ -1490,6 +1490,12 @@ class FakeNeutronClient(object):
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
|
class FakeOctaviaClient(object):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class FakeIronicClient(object):
|
class FakeIronicClient(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -1590,6 +1596,7 @@ class FakeClients(object):
|
|||||||
self._keystone = None
|
self._keystone = None
|
||||||
self._cinder = None
|
self._cinder = None
|
||||||
self._neutron = None
|
self._neutron = None
|
||||||
|
self._octavia = None
|
||||||
self._sahara = None
|
self._sahara = None
|
||||||
self._heat = None
|
self._heat = None
|
||||||
self._designate = None
|
self._designate = None
|
||||||
@ -1637,6 +1644,11 @@ class FakeClients(object):
|
|||||||
self._neutron = FakeNeutronClient()
|
self._neutron = FakeNeutronClient()
|
||||||
return self._neutron
|
return self._neutron
|
||||||
|
|
||||||
|
def octavia(self):
|
||||||
|
if not self._octavia:
|
||||||
|
self._octavia = FakeOctaviaClient()
|
||||||
|
return self._octavia
|
||||||
|
|
||||||
def sahara(self):
|
def sahara(self):
|
||||||
if not self._sahara:
|
if not self._sahara:
|
||||||
self._sahara = FakeSaharaClient()
|
self._sahara = FakeSaharaClient()
|
||||||
|
@ -471,6 +471,24 @@ class OSClientsTestCase(test.TestCase):
|
|||||||
mock_neutron.client.Client.assert_called_once_with("2.0", **kw)
|
mock_neutron.client.Client.assert_called_once_with("2.0", **kw)
|
||||||
self.assertEqual(fake_neutron, self.clients.cache["neutron"])
|
self.assertEqual(fake_neutron, self.clients.cache["neutron"])
|
||||||
|
|
||||||
|
@mock.patch("%s.Octavia._get_endpoint" % PATH)
|
||||||
|
def test_octavia(self, mock_octavia__get_endpoint):
|
||||||
|
fake_octavia = fakes.FakeOctaviaClient()
|
||||||
|
mock_octavia__get_endpoint.return_value = "http://fake.to:2/fake"
|
||||||
|
mock_octavia = mock.MagicMock()
|
||||||
|
mock_keystoneauth1 = mock.MagicMock()
|
||||||
|
mock_octavia.octavia.OctaviaAPI.return_value = fake_octavia
|
||||||
|
self.assertNotIn("octavia", self.clients.cache)
|
||||||
|
with mock.patch.dict("sys.modules",
|
||||||
|
{"octaviaclient.api.v2": mock_octavia,
|
||||||
|
"keystoneauth1": mock_keystoneauth1}):
|
||||||
|
client = self.clients.octavia()
|
||||||
|
self.assertEqual(fake_octavia, client)
|
||||||
|
kw = {"endpoint": mock_octavia__get_endpoint.return_value,
|
||||||
|
"session": mock_keystoneauth1.session.Session()}
|
||||||
|
mock_octavia.octavia.OctaviaAPI.assert_called_once_with(**kw)
|
||||||
|
self.assertEqual(fake_octavia, self.clients.cache["octavia"])
|
||||||
|
|
||||||
@mock.patch("%s.Heat._get_endpoint" % PATH)
|
@mock.patch("%s.Heat._get_endpoint" % PATH)
|
||||||
def test_heat(self, mock_heat__get_endpoint):
|
def test_heat(self, mock_heat__get_endpoint):
|
||||||
fake_heat = fakes.FakeHeatClient()
|
fake_heat = fakes.FakeHeatClient()
|
||||||
|
Loading…
Reference in New Issue
Block a user