Add Octavia (load_balancer) provider API support
This patch adds the Octavia (load_balancer) provider API support. Specifically: providers and provider_flavor_capabilities Change-Id: Ieb8e2d2fc592d69eca9c8cf36f726a35db1cda22
This commit is contained in:
parent
41d6d33339
commit
b27f0c579e
@ -96,3 +96,11 @@ L7 Rule Operations
|
||||
.. automethod:: openstack.load_balancer.v2._proxy.Proxy.get_l7_rule
|
||||
.. automethod:: openstack.load_balancer.v2._proxy.Proxy.l7_rules
|
||||
.. automethod:: openstack.load_balancer.v2._proxy.Proxy.update_l7_rule
|
||||
|
||||
Provider Operations
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. autoclass:: openstack.load_balancer.v2._proxy.Proxy
|
||||
|
||||
.. automethod:: openstack.load_balancer.v2._proxy.Proxy.providers
|
||||
.. automethod:: openstack.load_balancer.v2._proxy.Proxy.provider_flavor_capabilities
|
||||
|
@ -11,3 +11,4 @@ Load Balancer Resources
|
||||
v2/health_monitor
|
||||
v2/l7_policy
|
||||
v2/l7_rule
|
||||
v2/provider
|
||||
|
21
doc/source/user/resources/load_balancer/v2/provider.rst
Normal file
21
doc/source/user/resources/load_balancer/v2/provider.rst
Normal file
@ -0,0 +1,21 @@
|
||||
openstack.load_balancer.v2.provider
|
||||
===================================
|
||||
|
||||
.. automodule:: openstack.load_balancer.v2.provider
|
||||
|
||||
The Provider Class
|
||||
------------------
|
||||
|
||||
The ``Provider`` class inherits from :class:`~openstack.resource.Resource`.
|
||||
|
||||
.. autoclass:: openstack.load_balancer.v2.provider.Provider
|
||||
:members:
|
||||
|
||||
The Provider Flavor Capabilities Class
|
||||
--------------------------------------
|
||||
|
||||
The ``ProviderFlavorCapabilities`` class inherits from
|
||||
:class:`~openstack.resource.Resource`.
|
||||
|
||||
.. autoclass:: openstack.load_balancer.v2.provider.ProviderFlavorCapabilities
|
||||
:members:
|
@ -17,6 +17,7 @@ from openstack.load_balancer.v2 import listener as _listener
|
||||
from openstack.load_balancer.v2 import load_balancer as _lb
|
||||
from openstack.load_balancer.v2 import member as _member
|
||||
from openstack.load_balancer.v2 import pool as _pool
|
||||
from openstack.load_balancer.v2 import provider as _provider
|
||||
from openstack.load_balancer.v2 import quota as _quota
|
||||
from openstack import proxy
|
||||
from openstack import resource
|
||||
@ -779,3 +780,18 @@ class Proxy(proxy.Proxy):
|
||||
:returns: ``None``
|
||||
"""
|
||||
self._delete(_quota.Quota, quota, ignore_missing=ignore_missing)
|
||||
|
||||
def providers(self, **query):
|
||||
"""Retrieve a generator of providers
|
||||
|
||||
:returns: A generator of providers instances
|
||||
"""
|
||||
return self._list(_provider.Provider, **query)
|
||||
|
||||
def provider_flavor_capabilities(self, provider, **query):
|
||||
"""Retrieve a generator of provider flavor capabilities
|
||||
|
||||
:returns: A generator of provider flavor capabilities instances
|
||||
"""
|
||||
return self._list(_provider.ProviderFlavorCapabilities,
|
||||
provider=provider, **query)
|
||||
|
57
openstack/load_balancer/v2/provider.py
Normal file
57
openstack/load_balancer/v2/provider.py
Normal file
@ -0,0 +1,57 @@
|
||||
# Copyright 2019 Rackspace, US Inc.
|
||||
#
|
||||
# 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 openstack import resource
|
||||
|
||||
|
||||
class Provider(resource.Resource):
|
||||
resources_key = 'providers'
|
||||
base_path = '/lbaas/providers'
|
||||
|
||||
# capabilities
|
||||
allow_create = False
|
||||
allow_fetch = False
|
||||
allow_commit = False
|
||||
allow_delete = False
|
||||
allow_list = True
|
||||
|
||||
_query_mapping = resource.QueryParameters('description', 'name')
|
||||
|
||||
# Properties
|
||||
#: The provider name.
|
||||
name = resource.Body('name')
|
||||
#: The provider description.
|
||||
description = resource.Body('description')
|
||||
|
||||
|
||||
class ProviderFlavorCapabilities(resource.Resource):
|
||||
resources_key = 'flavor_capabilities'
|
||||
base_path = '/lbaas/providers/%(provider)s/flavor_capabilities'
|
||||
|
||||
# capabilities
|
||||
allow_create = False
|
||||
allow_fetch = False
|
||||
allow_commit = False
|
||||
allow_delete = False
|
||||
allow_list = True
|
||||
|
||||
_query_mapping = resource.QueryParameters('description', 'name')
|
||||
|
||||
# Properties
|
||||
#: The provider name to query.
|
||||
provider = resource.URI('provider')
|
||||
#: The provider name.
|
||||
name = resource.Body('name')
|
||||
#: The provider description.
|
||||
description = resource.Body('description')
|
@ -47,6 +47,7 @@ class TestLoadBalancer(base.BaseFunctionalTest):
|
||||
COMPARE_TYPE = 'CONTAINS'
|
||||
L7RULE_TYPE = 'HOST_NAME'
|
||||
L7RULE_VALUE = 'example'
|
||||
AMPHORA = 'amphora'
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
@ -474,3 +475,16 @@ class TestLoadBalancer(base.BaseFunctionalTest):
|
||||
|
||||
def test_default_quota(self):
|
||||
self.conn.load_balancer.get_quota_default()
|
||||
|
||||
def test_providers(self):
|
||||
providers = self.conn.load_balancer.providers()
|
||||
# Make sure our default provider is in the list
|
||||
self.assertTrue(
|
||||
any(prov['name'] == self.AMPHORA for prov in providers))
|
||||
|
||||
def test_provider_flavor_capabilities(self):
|
||||
capabilities = self.conn.load_balancer.provider_flavor_capabilities(
|
||||
self.AMPHORA)
|
||||
# Make sure a known capability is in the default provider
|
||||
self.assertTrue(any(
|
||||
cap['name'] == 'loadbalancer_topology' for cap in capabilities))
|
||||
|
73
openstack/tests/unit/load_balancer/test_provider.py
Normal file
73
openstack/tests/unit/load_balancer/test_provider.py
Normal file
@ -0,0 +1,73 @@
|
||||
# Copyright 2019 Rackspace, US Inc.
|
||||
#
|
||||
# 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 openstack.tests.unit import base
|
||||
|
||||
from openstack.load_balancer.v2 import provider
|
||||
|
||||
EXAMPLE = {
|
||||
'name': 'best',
|
||||
'description': 'The best provider'
|
||||
}
|
||||
|
||||
|
||||
class TestProvider(base.TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
test_provider = provider.Provider()
|
||||
self.assertEqual('providers', test_provider.resources_key)
|
||||
self.assertEqual('/lbaas/providers', test_provider.base_path)
|
||||
self.assertFalse(test_provider.allow_create)
|
||||
self.assertFalse(test_provider.allow_fetch)
|
||||
self.assertFalse(test_provider.allow_commit)
|
||||
self.assertFalse(test_provider.allow_delete)
|
||||
self.assertTrue(test_provider.allow_list)
|
||||
|
||||
def test_make_it(self):
|
||||
test_provider = provider.Provider(**EXAMPLE)
|
||||
self.assertEqual(EXAMPLE['name'], test_provider.name)
|
||||
self.assertEqual(EXAMPLE['description'], test_provider.description)
|
||||
|
||||
self.assertDictEqual(
|
||||
{'limit': 'limit',
|
||||
'marker': 'marker',
|
||||
'name': 'name',
|
||||
'description': 'description'},
|
||||
test_provider._query_mapping._mapping)
|
||||
|
||||
|
||||
class TestProviderFlavorCapabilities(base.TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
test_flav_cap = provider.ProviderFlavorCapabilities()
|
||||
self.assertEqual('flavor_capabilities', test_flav_cap.resources_key)
|
||||
self.assertEqual('/lbaas/providers/%(provider)s/flavor_capabilities',
|
||||
test_flav_cap.base_path)
|
||||
self.assertFalse(test_flav_cap.allow_create)
|
||||
self.assertFalse(test_flav_cap.allow_fetch)
|
||||
self.assertFalse(test_flav_cap.allow_commit)
|
||||
self.assertFalse(test_flav_cap.allow_delete)
|
||||
self.assertTrue(test_flav_cap.allow_list)
|
||||
|
||||
def test_make_it(self):
|
||||
test_flav_cap = provider.ProviderFlavorCapabilities(**EXAMPLE)
|
||||
self.assertEqual(EXAMPLE['name'], test_flav_cap.name)
|
||||
self.assertEqual(EXAMPLE['description'], test_flav_cap.description)
|
||||
|
||||
self.assertDictEqual(
|
||||
{'limit': 'limit',
|
||||
'marker': 'marker',
|
||||
'name': 'name',
|
||||
'description': 'description'},
|
||||
test_flav_cap._query_mapping._mapping)
|
@ -21,6 +21,7 @@ from openstack.load_balancer.v2 import listener
|
||||
from openstack.load_balancer.v2 import load_balancer as lb
|
||||
from openstack.load_balancer.v2 import member
|
||||
from openstack.load_balancer.v2 import pool
|
||||
from openstack.load_balancer.v2 import provider
|
||||
from openstack.load_balancer.v2 import quota
|
||||
from openstack import proxy as proxy_base
|
||||
from openstack.tests.unit import test_proxy_base
|
||||
@ -32,6 +33,7 @@ class TestLoadBalancerProxy(test_proxy_base.TestProxyBase):
|
||||
LISTENER_ID = uuid.uuid4()
|
||||
POOL_ID = uuid.uuid4()
|
||||
L7_POLICY_ID = uuid.uuid4()
|
||||
AMPHORA = 'amphora'
|
||||
|
||||
def setUp(self):
|
||||
super(TestLoadBalancerProxy, self).setUp()
|
||||
@ -308,3 +310,12 @@ class TestLoadBalancerProxy(test_proxy_base.TestProxyBase):
|
||||
|
||||
def test_quota_delete_ignore(self):
|
||||
self.verify_delete(self.proxy.delete_quota, quota.Quota, True)
|
||||
|
||||
def test_providers(self):
|
||||
self.verify_list(self.proxy.providers, provider.Provider)
|
||||
|
||||
def test_provider_flavor_capabilities(self):
|
||||
self.verify_list(self.proxy.provider_flavor_capabilities,
|
||||
provider.ProviderFlavorCapabilities,
|
||||
method_args=[self.AMPHORA],
|
||||
expected_kwargs={'provider': self.AMPHORA})
|
||||
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Adds Octavia (load_balancer) support for the providers APIs.
|
Loading…
x
Reference in New Issue
Block a user