Add project_id to all of the provider objects

This patch adds a project_id field to all of the provider driver data
model objects.

This is useful for drivers to track/associate objects on the backend.

Change-Id: I8f509677da463bc5d0a7649f2f609045cf9b2dd7
This commit is contained in:
Michael Johnson 2019-06-05 16:34:38 -07:00 committed by Carlos Goncalves
parent 2bb2f918ee
commit 45cf2f328f
6 changed files with 54 additions and 17 deletions

View File

@ -412,6 +412,9 @@ contain the following:
+------------------------------+--------+-------------------------------------+
| name | string | Human-readable name of the listener.|
+------------------------------+--------+-------------------------------------+
| project_id | string | ID of the project owning this |
| | | resource. |
+------------------------------+--------+-------------------------------------+
| protocol | string | Protocol type: One of HTTP, HTTPS, |
| | | TCP, or TERMINATED_HTTPS. |
+------------------------------+--------+-------------------------------------+
@ -745,6 +748,8 @@ contain the following:
+-----------------------+--------+------------------------------------------+
| pool_id | string | ID of pool to create. |
+-----------------------+--------+------------------------------------------+
| project_id | string | ID of the project owning this resource. |
+-----------------------+--------+------------------------------------------+
| protocol | string | Protocol type: One of HTTP, HTTPS, |
| | | PROXY, or TCP. |
+-----------------------+--------+------------------------------------------+
@ -933,6 +938,8 @@ contain the following:
+-----------------------+--------+------------------------------------------+
| pool_id | string | ID of pool. |
+-----------------------+--------+------------------------------------------+
| project_id | string | ID of the project owning this resource. |
+-----------------------+--------+------------------------------------------+
| protocol_port | int | The port on which the backend member |
| | | listens for traffic. |
+-----------------------+--------+------------------------------------------+
@ -1164,6 +1171,8 @@ and validated with the following exceptions:
+-----------------------+--------+------------------------------------------+
| pool_id | string | The pool to monitor. |
+-----------------------+--------+------------------------------------------+
| project_id | string | ID of the project owning this resource. |
+-----------------------+--------+------------------------------------------+
| timeout | int | The time, in seconds, after which a |
| | | health check times out. This value must |
| | | be less than the delay value. |
@ -1354,6 +1363,8 @@ contain the following:
| position | int | The position of this policy on the |
| | | listener. Positions start at 1. |
+-----------------------+--------+------------------------------------------+
| project_id | string | ID of the project owning this resource. |
+-----------------------+--------+------------------------------------------+
| redirect_http_code | int | The HTTP status code to be returned on |
| | | a redirect policy. |
+-----------------------+--------+------------------------------------------+
@ -1542,6 +1553,8 @@ contain the following:
+-----------------------+--------+------------------------------------------+
| l7rule_id | string | The ID of the L7 rule. |
+-----------------------+--------+------------------------------------------+
| project_id | string | ID of the project owning this resource. |
+-----------------------+--------+------------------------------------------+
| type | string | The L7 rule type. One of COOKIE, |
| | | FILE_TYPE, HEADER, HOST_NAME, or PATH. |
+-----------------------+--------+------------------------------------------+

View File

@ -72,7 +72,7 @@ munch==2.2.0
netaddr==0.7.19
netifaces==0.10.4
networkx==1.11
octavia-lib==1.1.1
octavia-lib==1.2.0
openstacksdk==0.12.0
os-client-config==1.29.0
os-service-types==1.2.0

View File

@ -177,7 +177,8 @@ def _get_secret_data(cert_manager, project_id, secret_ref):
def listener_dict_to_provider_dict(listener_dict):
new_listener_dict = _base_to_provider_dict(listener_dict)
new_listener_dict = _base_to_provider_dict(listener_dict,
include_project_id=True)
new_listener_dict['listener_id'] = new_listener_dict.pop('id')
if 'load_balancer_id' in new_listener_dict:
new_listener_dict['loadbalancer_id'] = new_listener_dict.pop(
@ -291,7 +292,7 @@ def db_pool_to_provider_pool(db_pool):
def pool_dict_to_provider_dict(pool_dict):
new_pool_dict = _base_to_provider_dict(pool_dict)
new_pool_dict = _base_to_provider_dict(pool_dict, include_project_id=True)
new_pool_dict['pool_id'] = new_pool_dict.pop('id')
# Pull the certs out of the certificate manager to pass to the provider
@ -371,7 +372,8 @@ def db_member_to_provider_member(db_member):
def member_dict_to_provider_dict(member_dict):
new_member_dict = _base_to_provider_dict(member_dict)
new_member_dict = _base_to_provider_dict(member_dict,
include_project_id=True)
new_member_dict['member_id'] = new_member_dict.pop('id')
if 'ip_address' in new_member_dict:
new_member_dict['address'] = new_member_dict.pop('ip_address')
@ -387,7 +389,7 @@ def db_HM_to_provider_HM(db_hm):
def hm_dict_to_provider_dict(hm_dict):
new_hm_dict = _base_to_provider_dict(hm_dict)
new_hm_dict = _base_to_provider_dict(hm_dict, include_project_id=True)
new_hm_dict['healthmonitor_id'] = new_hm_dict.pop('id')
if 'fall_threshold' in new_hm_dict:
new_hm_dict['max_retries_down'] = new_hm_dict.pop('fall_threshold')
@ -418,7 +420,8 @@ def db_l7policy_to_provider_l7policy(db_l7policy):
def l7policy_dict_to_provider_dict(l7policy_dict):
new_l7policy_dict = _base_to_provider_dict(l7policy_dict)
new_l7policy_dict = _base_to_provider_dict(l7policy_dict,
include_project_id=True)
new_l7policy_dict['l7policy_id'] = new_l7policy_dict.pop('id')
# Remove the DB back references
if 'listener' in new_l7policy_dict:
@ -449,7 +452,8 @@ def db_l7rule_to_provider_l7rule(db_l7rule):
def l7rule_dict_to_provider_dict(l7rule_dict):
new_l7rule_dict = _base_to_provider_dict(l7rule_dict)
new_l7rule_dict = _base_to_provider_dict(l7rule_dict,
include_project_id=True)
new_l7rule_dict['l7rule_id'] = new_l7rule_dict.pop('id')
# Remove the DB back references
if 'l7policy' in new_l7rule_dict:

View File

@ -582,12 +582,18 @@ class TestMember(base.BaseAPITest):
mock_driver.name = 'noop_driver'
mock_get_driver.return_value = mock_driver
member1 = {'address': '192.0.2.1', 'protocol_port': 80}
member2 = {'address': '192.0.2.2', 'protocol_port': 80}
member3 = {'address': '192.0.2.3', 'protocol_port': 80}
member4 = {'address': '192.0.2.4', 'protocol_port': 80}
member5 = {'address': '192.0.2.5', 'protocol_port': 80}
member6 = {'address': '192.0.2.6', 'protocol_port': 80}
member1 = {'address': '192.0.2.1', 'protocol_port': 80,
'project_id': self.project_id}
member2 = {'address': '192.0.2.2', 'protocol_port': 80,
'project_id': self.project_id}
member3 = {'address': '192.0.2.3', 'protocol_port': 80,
'project_id': self.project_id}
member4 = {'address': '192.0.2.4', 'protocol_port': 80,
'project_id': self.project_id}
member5 = {'address': '192.0.2.5', 'protocol_port': 80,
'project_id': self.project_id}
member6 = {'address': '192.0.2.6', 'protocol_port': 80,
'project_id': self.project_id}
members = [member1, member2, member3, member4]
for m in members:
self.create_member(pool_id=self.pool_id, **m)
@ -724,8 +730,10 @@ class TestMember(base.BaseAPITest):
mock_driver.name = 'noop_driver'
mock_get_driver.return_value = mock_driver
member1 = {'address': '192.0.2.1', 'protocol_port': 80}
member2 = {'address': '192.0.2.2', 'protocol_port': 80}
member1 = {'address': '192.0.2.1', 'protocol_port': 80,
'project_id': self.project_id}
member2 = {'address': '192.0.2.2', 'protocol_port': 80,
'project_id': self.project_id}
members = [member1, member2]
for m in members:
self.create_member(pool_id=self.pool_id, **m)

View File

@ -74,7 +74,8 @@ class SampleDriverDataModels(object):
'rise_threshold': 2, 'http_method': 'GET',
'url_path': '/', 'expected_codes': '200',
'name': 'hm1', 'pool_id': self.pool1_id,
'http_version': 1.0, 'domain_name': None}
'http_version': 1.0, 'domain_name': None,
'project_id': self.project_id}
self.test_hm1_dict.update(self._common_test_dict)
@ -95,6 +96,7 @@ class SampleDriverDataModels(object):
'max_retries_down': 1,
'name': 'hm1',
'pool_id': self.pool1_id,
'project_id': self.project_id,
'timeout': 3,
'type': constants.HEALTH_MONITOR_PING,
'url_path': '/',
@ -118,6 +120,7 @@ class SampleDriverDataModels(object):
'backup': False,
'subnet_id': self.subnet_id,
'pool': None,
'project_id': self.project_id,
'name': 'member1',
'monitor_address': '192.0.2.26',
'monitor_port': 81}
@ -164,6 +167,7 @@ class SampleDriverDataModels(object):
'monitor_port': 81,
'name': 'member1',
'pool_id': self.pool1_id,
'project_id': self.project_id,
'protocol_port': 80,
'subnet_id': self.subnet_id,
'weight': 0,
@ -209,6 +213,7 @@ class SampleDriverDataModels(object):
self.test_pool1_dict = {'id': self.pool1_id,
'name': 'pool1', 'description': 'Pool 1',
'load_balancer_id': self.lb_id,
'project_id': self.project_id,
'protocol': 'avian',
'lb_algorithm': 'round_robin',
'members': self.test_pool1_members_dict,
@ -258,6 +263,7 @@ class SampleDriverDataModels(object):
'members': self.provider_pool1_members_dict,
'name': 'pool1',
'pool_id': self.pool1_id,
'project_id': self.project_id,
'protocol': 'avian',
'session_persistence': {'type': 'SOURCE'},
'tls_container_ref': self.pool_sni_container_ref,
@ -298,6 +304,7 @@ class SampleDriverDataModels(object):
'compare_type': 'fake_type',
'key': 'fake_key',
'value': 'fake_value',
'project_id': self.project_id,
'l7policy': None,
'invert': False}
@ -320,6 +327,7 @@ class SampleDriverDataModels(object):
'l7policy_id': self.l7policy1_id,
'l7rule_id': self.l7rule1_id,
'type': 'o',
'project_id': self.project_id,
'value': 'fake_value'}
self.provider_l7rule2_dict = copy.deepcopy(self.provider_l7rule1_dict)
@ -341,6 +349,7 @@ class SampleDriverDataModels(object):
'redirect_pool_id': self.pool1_id,
'redirect_url': '/index.html',
'redirect_prefix': 'https://example.com/',
'project_id': self.project_id,
'position': 1,
'listener': None,
'redirect_pool': None,
@ -372,6 +381,7 @@ class SampleDriverDataModels(object):
'listener_id': self.listener1_id,
'name': 'l7policy_1',
'position': 1,
'project_id': self.project_id,
'redirect_pool_id': self.pool1_id,
'redirect_url': '/index.html',
'redirect_prefix': 'https://example.com/',
@ -405,6 +415,7 @@ class SampleDriverDataModels(object):
'description': 'Listener 1',
'default_pool_id': self.pool1_id,
'load_balancer_id': self.lb_id,
'project_id': self.project_id,
'protocol': 'avian',
'protocol_port': 90,
'connection_limit': 10000,
@ -473,6 +484,7 @@ class SampleDriverDataModels(object):
'listener_id': self.listener1_id,
'loadbalancer_id': self.lb_id,
'name': 'listener_1',
'project_id': self.project_id,
'protocol': 'avian',
'protocol_port': 90,
'sni_container_data': [cert2.to_dict(), cert3.to_dict()],

View File

@ -45,7 +45,7 @@ tenacity>=4.9.0 # Apache-2.0
distro>=1.2.0 # Apache-2.0
jsonschema>=2.6.0 # MIT
debtcollector>=1.19.0 # Apache-2.0
octavia-lib>=1.1.1 # Apache-2.0
octavia-lib>=1.2.0 # Apache-2.0
#for the amphora api
Flask!=0.11,>=0.10 # BSD