Adds tags support for Octavia (load_balancer)
This patch adds "tags" support to the Octavia (load_balancer) objects. It adds the "redirect_prefix" to L7 policy. It corrects the "flavor" load balancer field that never existed, to be "flavor_id". Finally, it adds unit testing for the query parameters. Change-Id: I5271183e2838eac9e943b488af5e6795e1ece4d0
This commit is contained in:
parent
e740da6088
commit
2327519e67
@ -13,7 +13,7 @@
|
||||
from openstack import resource
|
||||
|
||||
|
||||
class HealthMonitor(resource.Resource):
|
||||
class HealthMonitor(resource.Resource, resource.TagMixin):
|
||||
resource_key = 'healthmonitor'
|
||||
resources_key = 'healthmonitors'
|
||||
base_path = '/lbaas/healthmonitors'
|
||||
@ -30,6 +30,7 @@ class HealthMonitor(resource.Resource):
|
||||
'http_method', 'max_retries', 'max_retries_down', 'pool_id',
|
||||
'provisioning_status', 'operating_status', 'timeout',
|
||||
'project_id', 'type', 'url_path', is_admin_state_up='admin_state_up',
|
||||
**resource.TagMixin._tag_query_parameters
|
||||
)
|
||||
|
||||
#: Properties
|
||||
|
@ -13,7 +13,7 @@
|
||||
from openstack import resource
|
||||
|
||||
|
||||
class L7Policy(resource.Resource):
|
||||
class L7Policy(resource.Resource, resource.TagMixin):
|
||||
resource_key = 'l7policy'
|
||||
resources_key = 'l7policies'
|
||||
base_path = '/lbaas/l7policies'
|
||||
@ -28,7 +28,9 @@ class L7Policy(resource.Resource):
|
||||
_query_mapping = resource.QueryParameters(
|
||||
'action', 'description', 'listener_id', 'name', 'position',
|
||||
'redirect_pool_id', 'redirect_url', 'provisioning_status',
|
||||
'operating_status', is_admin_state_up='admin_state_up',
|
||||
'operating_status', 'redirect_prefix', 'project_id',
|
||||
is_admin_state_up='admin_state_up',
|
||||
**resource.TagMixin._tag_query_parameters
|
||||
)
|
||||
|
||||
#: Properties
|
||||
@ -54,6 +56,8 @@ class L7Policy(resource.Resource):
|
||||
provisioning_status = resource.Body('provisioning_status')
|
||||
#: The ID of the pool to which the requests will be redirected
|
||||
redirect_pool_id = resource.Body('redirect_pool_id')
|
||||
#: The URL prefix to which the requests should be redirected
|
||||
redirect_prefix = resource.Body('redirect_prefix')
|
||||
#: The URL to which the requests should be redirected
|
||||
redirect_url = resource.Body('redirect_url')
|
||||
#: The list of L7Rules associated with the l7policy
|
||||
|
@ -13,7 +13,7 @@
|
||||
from openstack import resource
|
||||
|
||||
|
||||
class L7Rule(resource.Resource):
|
||||
class L7Rule(resource.Resource, resource.TagMixin):
|
||||
resource_key = 'rule'
|
||||
resources_key = 'rules'
|
||||
base_path = '/lbaas/l7policies/%(l7policy_id)s/rules'
|
||||
@ -29,7 +29,7 @@ class L7Rule(resource.Resource):
|
||||
'compare_type', 'created_at', 'invert', 'key', 'project_id',
|
||||
'provisioning_status', 'type', 'updated_at', 'rule_value',
|
||||
'operating_status', is_admin_state_up='admin_state_up',
|
||||
l7_policy_id='l7policy_id',
|
||||
l7_policy_id='l7policy_id', **resource.TagMixin._tag_query_parameters
|
||||
)
|
||||
|
||||
#: Properties
|
||||
|
@ -13,7 +13,7 @@
|
||||
from openstack import resource
|
||||
|
||||
|
||||
class Listener(resource.Resource):
|
||||
class Listener(resource.Resource, resource.TagMixin):
|
||||
resource_key = 'listener'
|
||||
resources_key = 'listeners'
|
||||
base_path = '/lbaas/listeners'
|
||||
@ -33,6 +33,7 @@ class Listener(resource.Resource):
|
||||
'timeout_client_data', 'timeout_member_connect',
|
||||
'timeout_member_data', 'timeout_tcp_inspect',
|
||||
is_admin_state_up='admin_state_up',
|
||||
**resource.TagMixin._tag_query_parameters
|
||||
)
|
||||
|
||||
# Properties
|
||||
|
@ -13,7 +13,7 @@
|
||||
from openstack import resource
|
||||
|
||||
|
||||
class LoadBalancer(resource.Resource):
|
||||
class LoadBalancer(resource.Resource, resource.TagMixin):
|
||||
resource_key = 'loadbalancer'
|
||||
resources_key = 'loadbalancers'
|
||||
base_path = '/lbaas/loadbalancers'
|
||||
@ -26,10 +26,11 @@ class LoadBalancer(resource.Resource):
|
||||
allow_list = True
|
||||
|
||||
_query_mapping = resource.QueryParameters(
|
||||
'description', 'flavor', 'name', 'project_id', 'provider',
|
||||
'description', 'flavor_id', 'name', 'project_id', 'provider',
|
||||
'vip_address', 'vip_network_id', 'vip_port_id', 'vip_subnet_id',
|
||||
'vip_qos_policy_id', 'provisioning_status', 'operating_status',
|
||||
is_admin_state_up='admin_state_up'
|
||||
is_admin_state_up='admin_state_up',
|
||||
**resource.TagMixin._tag_query_parameters
|
||||
)
|
||||
|
||||
#: Properties
|
||||
@ -39,8 +40,8 @@ class LoadBalancer(resource.Resource):
|
||||
created_at = resource.Body('created_at')
|
||||
#: The load balancer description
|
||||
description = resource.Body('description')
|
||||
#: The load balancer flavor
|
||||
flavor = resource.Body('flavor')
|
||||
#: The load balancer flavor ID
|
||||
flavor_id = resource.Body('flavor_id')
|
||||
#: List of listeners associated with this load balancer
|
||||
listeners = resource.Body('listeners', type=list)
|
||||
#: The load balancer name
|
||||
|
@ -13,7 +13,7 @@
|
||||
from openstack import resource
|
||||
|
||||
|
||||
class Member(resource.Resource):
|
||||
class Member(resource.Resource, resource.TagMixin):
|
||||
resource_key = 'member'
|
||||
resources_key = 'members'
|
||||
base_path = '/lbaas/pools/%(pool_id)s/members'
|
||||
@ -30,6 +30,7 @@ class Member(resource.Resource):
|
||||
'created_at', 'updated_at', 'provisioning_status', 'operating_status',
|
||||
'project_id', 'monitor_address', 'monitor_port', 'backup',
|
||||
is_admin_state_up='admin_state_up',
|
||||
**resource.TagMixin._tag_query_parameters
|
||||
)
|
||||
|
||||
# Properties
|
||||
|
@ -13,7 +13,7 @@
|
||||
from openstack import resource
|
||||
|
||||
|
||||
class Pool(resource.Resource):
|
||||
class Pool(resource.Resource, resource.TagMixin):
|
||||
resource_key = 'pool'
|
||||
resources_key = 'pools'
|
||||
base_path = '/lbaas/pools'
|
||||
@ -29,7 +29,8 @@ class Pool(resource.Resource):
|
||||
'health_monitor_id', 'lb_algorithm', 'listener_id', 'loadbalancer_id',
|
||||
'description', 'name', 'project_id', 'protocol',
|
||||
'created_at', 'updated_at', 'provisioning_status', 'operating_status',
|
||||
is_admin_state_up='admin_state_up'
|
||||
is_admin_state_up='admin_state_up',
|
||||
**resource.TagMixin._tag_query_parameters
|
||||
)
|
||||
|
||||
#: Properties
|
||||
|
@ -72,3 +72,30 @@ class TestPoolHealthMonitor(base.TestCase):
|
||||
self.assertEqual(EXAMPLE['type'], test_hm.type)
|
||||
self.assertEqual(EXAMPLE['updated_at'], test_hm.updated_at)
|
||||
self.assertEqual(EXAMPLE['url_path'], test_hm.url_path)
|
||||
|
||||
self.assertDictEqual(
|
||||
{'limit': 'limit',
|
||||
'marker': 'marker',
|
||||
'created_at': 'created_at',
|
||||
'updated_at': 'updated_at',
|
||||
'name': 'name',
|
||||
'project_id': 'project_id',
|
||||
'tags': 'tags',
|
||||
'any_tags': 'tags-any',
|
||||
'not_tags': 'not-tags',
|
||||
'not_any_tags': 'not-tags-any',
|
||||
'operating_status': 'operating_status',
|
||||
'provisioning_status': 'provisioning_status',
|
||||
'is_admin_state_up': 'admin_state_up',
|
||||
|
||||
'delay': 'delay',
|
||||
'expected_codes': 'expected_codes',
|
||||
'http_method': 'http_method',
|
||||
'max_retries': 'max_retries',
|
||||
'max_retries_down': 'max_retries_down',
|
||||
'pool_id': 'pool_id',
|
||||
'timeout': 'timeout',
|
||||
'type': 'type',
|
||||
'url_path': 'url_path'
|
||||
},
|
||||
test_hm._query_mapping._mapping)
|
||||
|
@ -28,6 +28,7 @@ EXAMPLE = {
|
||||
'project_id': uuid.uuid4(),
|
||||
'provisioning_status': 'ACTIVE',
|
||||
'redirect_pool_id': uuid.uuid4(),
|
||||
'redirect_prefix': 'https://www.example.com',
|
||||
'redirect_url': '/test_url',
|
||||
'rules': [{'id': uuid.uuid4()}],
|
||||
'updated_at': '2017-07-17T12:16:57.233772',
|
||||
@ -64,6 +65,31 @@ class TestL7Policy(base.TestCase):
|
||||
test_l7_policy.provisioning_status)
|
||||
self.assertEqual(EXAMPLE['redirect_pool_id'],
|
||||
test_l7_policy.redirect_pool_id)
|
||||
self.assertEqual(EXAMPLE['redirect_prefix'],
|
||||
test_l7_policy.redirect_prefix)
|
||||
self.assertEqual(EXAMPLE['redirect_url'], test_l7_policy.redirect_url)
|
||||
self.assertEqual(EXAMPLE['rules'], test_l7_policy.rules)
|
||||
self.assertEqual(EXAMPLE['updated_at'], test_l7_policy.updated_at)
|
||||
|
||||
self.assertDictEqual(
|
||||
{'limit': 'limit',
|
||||
'marker': 'marker',
|
||||
'name': 'name',
|
||||
'description': 'description',
|
||||
'project_id': 'project_id',
|
||||
'tags': 'tags',
|
||||
'any_tags': 'tags-any',
|
||||
'not_tags': 'not-tags',
|
||||
'not_any_tags': 'not-tags-any',
|
||||
'operating_status': 'operating_status',
|
||||
'provisioning_status': 'provisioning_status',
|
||||
'is_admin_state_up': 'admin_state_up',
|
||||
|
||||
'action': 'action',
|
||||
'listener_id': 'listener_id',
|
||||
'position': 'position',
|
||||
'redirect_pool_id': 'redirect_pool_id',
|
||||
'redirect_url': 'redirect_url',
|
||||
'redirect_prefix': 'redirect_prefix'
|
||||
},
|
||||
test_l7_policy._query_mapping._mapping)
|
||||
|
@ -63,3 +63,26 @@ class TestL7Rule(base.TestCase):
|
||||
self.assertEqual(EXAMPLE['type'], test_l7rule.type)
|
||||
self.assertEqual(EXAMPLE['updated_at'], test_l7rule.updated_at)
|
||||
self.assertEqual(EXAMPLE['value'], test_l7rule.rule_value)
|
||||
|
||||
self.assertDictEqual(
|
||||
{'limit': 'limit',
|
||||
'marker': 'marker',
|
||||
'created_at': 'created_at',
|
||||
'updated_at': 'updated_at',
|
||||
'project_id': 'project_id',
|
||||
'tags': 'tags',
|
||||
'any_tags': 'tags-any',
|
||||
'not_tags': 'not-tags',
|
||||
'not_any_tags': 'not-tags-any',
|
||||
'operating_status': 'operating_status',
|
||||
'provisioning_status': 'provisioning_status',
|
||||
'is_admin_state_up': 'admin_state_up',
|
||||
|
||||
'compare_type': 'compare_type',
|
||||
'invert': 'invert',
|
||||
'key': 'key',
|
||||
'type': 'type',
|
||||
'rule_value': 'rule_value',
|
||||
'l7_policy_id': 'l7policy_id'
|
||||
},
|
||||
test_l7rule._query_mapping._mapping)
|
||||
|
@ -93,3 +93,34 @@ class TestListener(base.TestCase):
|
||||
test_listener.timeout_member_data)
|
||||
self.assertEqual(EXAMPLE['timeout_tcp_inspect'],
|
||||
test_listener.timeout_tcp_inspect)
|
||||
|
||||
self.assertDictEqual(
|
||||
{'limit': 'limit',
|
||||
'marker': 'marker',
|
||||
'created_at': 'created_at',
|
||||
'updated_at': 'updated_at',
|
||||
'description': 'description',
|
||||
'name': 'name',
|
||||
'project_id': 'project_id',
|
||||
'tags': 'tags',
|
||||
'any_tags': 'tags-any',
|
||||
'not_tags': 'not-tags',
|
||||
'not_any_tags': 'not-tags-any',
|
||||
'operating_status': 'operating_status',
|
||||
'provisioning_status': 'provisioning_status',
|
||||
'is_admin_state_up': 'admin_state_up',
|
||||
|
||||
'connection_limit': 'connection_limit',
|
||||
'default_pool_id': 'default_pool_id',
|
||||
'default_tls_container_ref': 'default_tls_container_ref',
|
||||
'sni_container_refs': 'sni_container_refs',
|
||||
'insert_headers': 'insert_headers',
|
||||
'load_balancer_id': 'load_balancer_id',
|
||||
'protocol': 'protocol',
|
||||
'protocol_port': 'protocol_port',
|
||||
'timeout_client_data': 'timeout_client_data',
|
||||
'timeout_member_connect': 'timeout_member_connect',
|
||||
'timeout_member_data': 'timeout_member_data',
|
||||
'timeout_tcp_inspect': 'timeout_tcp_inspect',
|
||||
},
|
||||
test_listener._query_mapping._mapping)
|
||||
|
@ -21,7 +21,7 @@ EXAMPLE = {
|
||||
'admin_state_up': True,
|
||||
'created_at': '2017-07-17T12:14:57.233772',
|
||||
'description': 'fake_description',
|
||||
'flavor': uuid.uuid4(),
|
||||
'flavor_id': uuid.uuid4(),
|
||||
'id': IDENTIFIER,
|
||||
'listeners': [{'id', uuid.uuid4()}],
|
||||
'name': 'test_load_balancer',
|
||||
@ -59,7 +59,7 @@ class TestLoadBalancer(base.TestCase):
|
||||
self.assertEqual(EXAMPLE['created_at'], test_load_balancer.created_at),
|
||||
self.assertEqual(EXAMPLE['description'],
|
||||
test_load_balancer.description)
|
||||
self.assertEqual(EXAMPLE['flavor'], test_load_balancer.flavor)
|
||||
self.assertEqual(EXAMPLE['flavor_id'], test_load_balancer.flavor_id)
|
||||
self.assertEqual(EXAMPLE['id'], test_load_balancer.id)
|
||||
self.assertEqual(EXAMPLE['listeners'], test_load_balancer.listeners)
|
||||
self.assertEqual(EXAMPLE['name'], test_load_balancer.name)
|
||||
@ -82,6 +82,29 @@ class TestLoadBalancer(base.TestCase):
|
||||
self.assertEqual(EXAMPLE['vip_qos_policy_id'],
|
||||
test_load_balancer.vip_qos_policy_id)
|
||||
|
||||
self.assertDictEqual(
|
||||
{'limit': 'limit',
|
||||
'marker': 'marker',
|
||||
'description': 'description',
|
||||
'flavor_id': 'flavor_id',
|
||||
'name': 'name',
|
||||
'project_id': 'project_id',
|
||||
'provider': 'provider',
|
||||
'operating_status': 'operating_status',
|
||||
'provisioning_status': 'provisioning_status',
|
||||
'is_admin_state_up': 'admin_state_up',
|
||||
'vip_address': 'vip_address',
|
||||
'vip_network_id': 'vip_network_id',
|
||||
'vip_port_id': 'vip_port_id',
|
||||
'vip_subnet_id': 'vip_subnet_id',
|
||||
'vip_qos_policy_id': 'vip_qos_policy_id',
|
||||
'tags': 'tags',
|
||||
'any_tags': 'tags-any',
|
||||
'not_tags': 'not-tags',
|
||||
'not_any_tags': 'not-tags-any',
|
||||
},
|
||||
test_load_balancer._query_mapping._mapping)
|
||||
|
||||
def test_delete_non_cascade(self):
|
||||
sess = mock.Mock()
|
||||
resp = mock.Mock()
|
||||
|
@ -61,3 +61,28 @@ class TestPoolMember(base.TestCase):
|
||||
self.assertEqual(EXAMPLE['subnet_id'], test_member.subnet_id)
|
||||
self.assertEqual(EXAMPLE['weight'], test_member.weight)
|
||||
self.assertFalse(test_member.backup)
|
||||
|
||||
self.assertDictEqual(
|
||||
{'limit': 'limit',
|
||||
'marker': 'marker',
|
||||
'created_at': 'created_at',
|
||||
'updated_at': 'updated_at',
|
||||
'name': 'name',
|
||||
'project_id': 'project_id',
|
||||
'tags': 'tags',
|
||||
'any_tags': 'tags-any',
|
||||
'not_tags': 'not-tags',
|
||||
'not_any_tags': 'not-tags-any',
|
||||
'operating_status': 'operating_status',
|
||||
'provisioning_status': 'provisioning_status',
|
||||
'is_admin_state_up': 'admin_state_up',
|
||||
|
||||
'address': 'address',
|
||||
'protocol_port': 'protocol_port',
|
||||
'subnet_id': 'subnet_id',
|
||||
'weight': 'weight',
|
||||
'monitor_address': 'monitor_address',
|
||||
'monitor_port': 'monitor_port',
|
||||
'backup': 'backup'
|
||||
},
|
||||
test_member._query_mapping._mapping)
|
||||
|
@ -81,3 +81,27 @@ class TestPool(base.TestCase):
|
||||
self.assertEqual(EXAMPLE['health_monitor_id'],
|
||||
test_pool.health_monitor_id)
|
||||
self.assertEqual(EXAMPLE['members'], test_pool.members)
|
||||
|
||||
self.assertDictEqual(
|
||||
{'limit': 'limit',
|
||||
'marker': 'marker',
|
||||
'created_at': 'created_at',
|
||||
'updated_at': 'updated_at',
|
||||
'description': 'description',
|
||||
'name': 'name',
|
||||
'project_id': 'project_id',
|
||||
'tags': 'tags',
|
||||
'any_tags': 'tags-any',
|
||||
'not_tags': 'not-tags',
|
||||
'not_any_tags': 'not-tags-any',
|
||||
'operating_status': 'operating_status',
|
||||
'provisioning_status': 'provisioning_status',
|
||||
'is_admin_state_up': 'admin_state_up',
|
||||
|
||||
'health_monitor_id': 'health_monitor_id',
|
||||
'lb_algorithm': 'lb_algorithm',
|
||||
'listener_id': 'listener_id',
|
||||
'loadbalancer_id': 'loadbalancer_id',
|
||||
'protocol': 'protocol',
|
||||
},
|
||||
test_pool._query_mapping._mapping)
|
||||
|
@ -0,0 +1,10 @@
|
||||
---
|
||||
features:
|
||||
- Add tags support for the Octavia (load_balancer) objects.
|
||||
- |
|
||||
Added support for the Octavia (load_balancer) L7 Policy "redirect_prefix"
|
||||
capability.
|
||||
fixes:
|
||||
- |
|
||||
Fixed the Octavia (load_balancer) load balancer objects to have
|
||||
"flavor_id" instead of the nonexistent "flavor" field.
|
Loading…
Reference in New Issue
Block a user