Browse Source

Merge "Move to using octavia-lib constants"

changes/63/672463/11
Zuul 1 week ago
parent
commit
6b4dad2b87

+ 63
- 46
octavia/common/constants.py View File

@@ -284,76 +284,93 @@ DOMAIN_NAME_REGEX = (
284 284
 SUPPORTED_TASKFLOW_ENGINE_TYPES = ['serial', 'parallel']
285 285
 
286 286
 # Task/Flow constants
287
+ACTIVE_CONNECTIONS = 'active_connections'
288
+ADDED_PORTS = 'added_ports'
289
+AMP_DATA = 'amp_data'
287 290
 AMPHORA = 'amphora'
288
-FAILED_AMPHORA = 'failed_amphora'
289
-FAILOVER_AMPHORA = 'failover_amphora'
290
-AMPHORAE = 'amphorae'
291 291
 AMPHORA_ID = 'amphora_id'
292 292
 AMPHORA_INDEX = 'amphora_index'
293
-FAILOVER_AMPHORA_ID = 'failover_amphora_id'
293
+AMPHORA_NETWORK_CONFIG = 'amphora_network_config'
294
+AMPHORAE = 'amphorae'
295
+AMPHORAE_NETWORK_CONFIG = 'amphorae_network_config'
296
+AMPS_DATA = 'amps_data'
297
+ANTI_AFFINITY = 'anti-affinity'
298
+BYTES_IN = 'bytes_in'
299
+BYTES_OUT = 'bytes_out'
300
+CA_TLS_CERTIFICATE_ID = 'ca_tls_certificate_id'
301
+CLIENT_CA_TLS_CERTIFICATE_ID = 'client_ca_tls_certificate_id'
302
+CLIENT_CRL_CONTAINER_ID = 'client_crl_container_id'
303
+COMPUTE_ID = 'compute_id'
304
+COMPUTE_OBJ = 'compute_obj'
305
+CONN_MAX_RETRIES = 'conn_max_retries'
306
+CONN_RETRY_INTERVAL = 'conn_retry_interval'
307
+CREATED_AT = 'created_at'
308
+CRL_CONTAINER_ID = 'crl_container_id'
294 309
 DELTA = 'delta'
295 310
 DELTAS = 'deltas'
311
+ENABLED = 'enabled'
312
+FAILED_AMPHORA = 'failed_amphora'
313
+FAILOVER_AMPHORA = 'failover_amphora'
314
+FAILOVER_AMPHORA_ID = 'failover_amphora_id'
315
+FLAVOR_ID = 'flavor_id'
296 316
 HEALTH_MON = 'health_mon'
297 317
 HEALTH_MONITOR = 'health_monitor'
318
+HEALTH_MONITOR_ID = 'health_monitor_id'
319
+HEALTH_MONITOR_UPDATES = 'health_monitor_updates'
320
+IP_ADDRESS = 'ip_address'
321
+L7POLICY = 'l7policy'
322
+L7POLICY_ID = 'l7policy_id'
323
+L7POLICY_UPDATES = 'l7policy_updates'
324
+L7RULE = 'l7rule'
325
+L7RULE_ID = 'l7rule_id'
326
+L7RULE_UPDATES = 'l7rule_updates'
298 327
 LISTENER = 'listener'
299 328
 LISTENER_ID = 'listener_id'
329
+LISTENER_UPDATES = 'listener_updates'
300 330
 LOADBALANCER = 'loadbalancer'
301 331
 LOADBALANCER_ID = 'loadbalancer_id'
302 332
 LOAD_BALANCER_ID = 'load_balancer_id'
303
-SERVER_GROUP_ID = 'server_group_id'
304
-ANTI_AFFINITY = 'anti-affinity'
305
-SOFT_ANTI_AFFINITY = 'soft-anti-affinity'
333
+LOAD_BALANCER_UPDATES = 'load_balancer_updates'
306 334
 MEMBER = 'member'
307 335
 MEMBER_ID = 'member_id'
308
-COMPUTE_ID = 'compute_id'
309
-COMPUTE_OBJ = 'compute_obj'
310
-AMP_DATA = 'amp_data'
311
-AMPS_DATA = 'amps_data'
336
+MEMBER_PORTS = 'member_ports'
337
+MEMBER_UPDATES = 'member_updates'
338
+NAME = 'name'
339
+NETWORK_ID = 'network_id'
312 340
 NICS = 'nics'
313
-VIP = 'vip'
341
+OBJECT = 'object'
342
+PEER_PORT = 'peer_port'
314 343
 POOL = 'pool'
315 344
 POOL_CHILD_COUNT = 'pool_child_count'
316 345
 POOL_ID = 'pool_id'
317
-L7POLICY = 'l7policy'
318
-L7RULE = 'l7rule'
319
-OBJECT = 'object'
320
-SERVER_PEM = 'server_pem'
321
-UPDATE_DICT = 'update_dict'
322
-VIP_NETWORK = 'vip_network'
323
-AMPHORA_NETWORK_CONFIG = 'amphora_network_config'
324
-AMPHORAE_NETWORK_CONFIG = 'amphorae_network_config'
325
-ADDED_PORTS = 'added_ports'
326
-PORTS = 'ports'
327
-MEMBER_PORTS = 'member_ports'
328
-TOPOLOGY = 'topology'
329
-HEALTH_MONITOR_ID = 'health_monitor_id'
330
-L7POLICY_ID = 'l7policy_id'
331
-L7RULE_ID = 'l7rule_id'
332
-LOAD_BALANCER_UPDATES = 'load_balancer_updates'
333
-LISTENER_UPDATES = 'listener_updates'
334 346
 POOL_UPDATES = 'pool_updates'
335
-MEMBER_UPDATES = 'member_updates'
336
-HEALTH_MONITOR_UPDATES = 'health_monitor_updates'
337
-L7POLICY_UPDATES = 'l7policy_updates'
338
-L7RULE_UPDATES = 'l7rule_updates'
339
-TIMEOUT_DICT = 'timeout_dict'
347
+PORT_ID = 'port_id'
348
+PORTS = 'ports'
349
+PROVIDER = 'provider'
350
+PROVIDER_NAME = 'provider_name'
351
+QOS_POLICY_ID = 'qos_policy_id'
352
+REDIRECT_POOL = 'redirect_pool'
340 353
 REQ_CONN_TIMEOUT = 'req_conn_timeout'
341 354
 REQ_READ_TIMEOUT = 'req_read_timeout'
342
-CONN_MAX_RETRIES = 'conn_max_retries'
343
-CONN_RETRY_INTERVAL = 'conn_retry_interval'
344
-SUBNET = 'subnet'
345
-AMP_DATA = 'amp_data'
346
-ACTIVE_CONNECTIONS = 'active_connections'
347
-BYTES_IN = 'bytes_in'
348
-BYTES_OUT = 'bytes_out'
349 355
 REQUEST_ERRORS = 'request_errors'
350
-TOTAL_CONNECTIONS = 'total_connections'
351
-NAME = 'name'
352
-PROVIDER_NAME = 'provider_name'
353
-
354
-# Database fields
356
+SERVER_GROUP_ID = 'server_group_id'
357
+SERVER_PEM = 'server_pem'
355 358
 SNI_CONTAINERS = 'sni_containers'
359
+SOFT_ANTI_AFFINITY = 'soft-anti-affinity'
360
+SUBNET = 'subnet'
361
+TAGS = 'tags'
362
+TIMEOUT_DICT = 'timeout_dict'
363
+TLS_CERTIFICATE_ID = 'tls_certificate_id'
364
+TLS_CONTAINER_ID = 'tls_container_id'
365
+TOPOLOGY = 'topology'
366
+TOTAL_CONNECTIONS = 'total_connections'
367
+UPDATED_AT = 'updated_at'
368
+UPDATE_DICT = 'update_dict'
369
+VIP = 'vip'
370
+VIP_NETWORK = 'vip_network'
371
+VRRP_GROUP = 'vrrp_group'
356 372
 
373
+# Taskflow flow and task names
357 374
 CERT_ROTATE_AMPHORA_FLOW = 'octavia-cert-rotate-amphora-flow'
358 375
 CREATE_AMPHORA_FLOW = 'octavia-create-amphora-flow'
359 376
 CREATE_AMPHORA_FOR_LB_FLOW = 'octavia-create-amp-for-lb-flow'

+ 341
- 317
octavia/tests/common/sample_data_models.py View File

@@ -70,96 +70,103 @@ class SampleDriverDataModels(object):
70 70
         self.updated_at = (datetime.datetime.now() +
71 71
                            datetime.timedelta(minutes=1))
72 72
 
73
-        self._common_test_dict = {'provisioning_status': constants.ACTIVE,
74
-                                  'operating_status': constants.ONLINE,
75
-                                  'project_id': self.project_id,
76
-                                  'created_at': self.created_at,
77
-                                  'updated_at': self.updated_at,
78
-                                  'enabled': True}
73
+        self._common_test_dict = {
74
+            lib_consts.PROVISIONING_STATUS: constants.ACTIVE,
75
+            lib_consts.OPERATING_STATUS: constants.ONLINE,
76
+            lib_consts.PROJECT_ID: self.project_id,
77
+            constants.CREATED_AT: self.created_at,
78
+            constants.UPDATED_AT: self.updated_at,
79
+            constants.ENABLED: True}
79 80
 
80 81
         # Setup Health Monitors
81
-        self.test_hm1_dict = {'id': self.hm1_id,
82
-                              'type': constants.HEALTH_MONITOR_PING,
83
-                              'delay': 1, 'timeout': 3, 'fall_threshold': 1,
84
-                              'rise_threshold': 2, 'http_method': 'GET',
85
-                              'url_path': '/', 'expected_codes': '200',
86
-                              'name': 'hm1', 'pool_id': self.pool1_id,
87
-                              'http_version': 1.0, 'domain_name': None,
88
-                              'project_id': self.project_id}
82
+        self.test_hm1_dict = {
83
+            lib_consts.ID: self.hm1_id,
84
+            lib_consts.TYPE: constants.HEALTH_MONITOR_PING,
85
+            lib_consts.DELAY: 1, lib_consts.TIMEOUT: 3,
86
+            lib_consts.FALL_THRESHOLD: 1, lib_consts.RISE_THRESHOLD: 2,
87
+            lib_consts.HTTP_METHOD: lib_consts.HEALTH_MONITOR_HTTP_METHOD_GET,
88
+            lib_consts.URL_PATH: '/', lib_consts.EXPECTED_CODES: '200',
89
+            lib_consts.NAME: 'hm1', lib_consts.POOL_ID: self.pool1_id,
90
+            lib_consts.HTTP_VERSION: 1.0, lib_consts.DOMAIN_NAME: None,
91
+            lib_consts.PROJECT_ID: self.project_id}
89 92
 
90 93
         self.test_hm1_dict.update(self._common_test_dict)
91 94
 
92 95
         self.test_hm2_dict = copy.deepcopy(self.test_hm1_dict)
93
-        self.test_hm2_dict['id'] = self.hm2_id
94
-        self.test_hm2_dict['name'] = 'hm2'
95
-        self.test_hm2_dict.update({'http_version': 1.1,
96
-                                   'domain_name': 'testdomainname.com'})
96
+        self.test_hm2_dict[lib_consts.ID] = self.hm2_id
97
+        self.test_hm2_dict[lib_consts.NAME] = 'hm2'
98
+        self.test_hm2_dict.update(
99
+            {lib_consts.HTTP_VERSION: 1.1,
100
+             lib_consts.DOMAIN_NAME: 'testdomainname.com'})
97 101
 
98 102
         self.db_hm1 = data_models.HealthMonitor(**self.test_hm1_dict)
99 103
         self.db_hm2 = data_models.HealthMonitor(**self.test_hm2_dict)
100 104
 
101
-        self.provider_hm1_dict = {'admin_state_up': True,
102
-                                  'delay': 1, 'expected_codes': '200',
103
-                                  'healthmonitor_id': self.hm1_id,
104
-                                  'http_method': 'GET',
105
-                                  'max_retries': 2,
106
-                                  'max_retries_down': 1,
107
-                                  'name': 'hm1',
108
-                                  'pool_id': self.pool1_id,
109
-                                  'project_id': self.project_id,
110
-                                  'timeout': 3,
111
-                                  'type': constants.HEALTH_MONITOR_PING,
112
-                                  'url_path': '/',
113
-                                  'http_version': 1.0,
114
-                                  'domain_name': None}
105
+        self.provider_hm1_dict = {
106
+            lib_consts.ADMIN_STATE_UP: True,
107
+            lib_consts.DELAY: 1, lib_consts.EXPECTED_CODES: '200',
108
+            lib_consts.HEALTHMONITOR_ID: self.hm1_id,
109
+            lib_consts.HTTP_METHOD: lib_consts.HEALTH_MONITOR_HTTP_METHOD_GET,
110
+            lib_consts.MAX_RETRIES: 2,
111
+            lib_consts.MAX_RETRIES_DOWN: 1,
112
+            lib_consts.NAME: 'hm1',
113
+            lib_consts.POOL_ID: self.pool1_id,
114
+            lib_consts.PROJECT_ID: self.project_id,
115
+            lib_consts.TIMEOUT: 3,
116
+            lib_consts.TYPE: constants.HEALTH_MONITOR_PING,
117
+            lib_consts.URL_PATH: '/',
118
+            lib_consts.HTTP_VERSION: 1.0,
119
+            lib_consts.DOMAIN_NAME: None}
115 120
 
116 121
         self.provider_hm2_dict = copy.deepcopy(self.provider_hm1_dict)
117
-        self.provider_hm2_dict['healthmonitor_id'] = self.hm2_id
118
-        self.provider_hm2_dict['name'] = 'hm2'
119
-        self.provider_hm2_dict.update({'http_version': 1.1,
120
-                                       'domain_name': 'testdomainname.com'})
122
+        self.provider_hm2_dict[lib_consts.HEALTHMONITOR_ID] = self.hm2_id
123
+        self.provider_hm2_dict[lib_consts.NAME] = 'hm2'
124
+        self.provider_hm2_dict.update(
125
+            {lib_consts.HTTP_VERSION: 1.1,
126
+             lib_consts.DOMAIN_NAME: 'testdomainname.com'})
121 127
 
122 128
         self.provider_hm1 = driver_dm.HealthMonitor(**self.provider_hm1_dict)
123 129
         self.provider_hm2 = driver_dm.HealthMonitor(**self.provider_hm2_dict)
124 130
 
125 131
         # Setup Members
126
-        self.test_member1_dict = {'id': self.member1_id,
127
-                                  'pool_id': self.pool1_id,
128
-                                  'ip_address': '192.0.2.16',
129
-                                  'protocol_port': 80, 'weight': 0,
130
-                                  'backup': False,
131
-                                  'subnet_id': self.subnet_id,
132
-                                  'project_id': self.project_id,
133
-                                  'name': 'member1',
134
-                                  'operating_status': lib_consts.ONLINE,
135
-                                  'provisioning_status': lib_consts.ACTIVE,
136
-                                  'enabled': True,
137
-                                  'created_at': self.created_at,
138
-                                  'updated_at': self.updated_at,
139
-                                  'monitor_address': '192.0.2.26',
140
-                                  'monitor_port': 81}
132
+        self.test_member1_dict = {
133
+            lib_consts.ID: self.member1_id,
134
+            lib_consts.POOL_ID: self.pool1_id,
135
+            constants.IP_ADDRESS: '192.0.2.16',
136
+            lib_consts.PROTOCOL_PORT: 80, lib_consts.WEIGHT: 0,
137
+            lib_consts.BACKUP: False,
138
+            lib_consts.SUBNET_ID: self.subnet_id,
139
+            lib_consts.PROJECT_ID: self.project_id,
140
+            lib_consts.NAME: 'member1',
141
+            lib_consts.OPERATING_STATUS: lib_consts.ONLINE,
142
+            lib_consts.PROVISIONING_STATUS: lib_consts.ACTIVE,
143
+            constants.ENABLED: True,
144
+            constants.CREATED_AT: self.created_at,
145
+            constants.UPDATED_AT: self.updated_at,
146
+            lib_consts.MONITOR_ADDRESS: '192.0.2.26',
147
+            lib_consts.MONITOR_PORT: 81}
141 148
 
142 149
         self.test_member1_dict.update(self._common_test_dict)
143 150
 
144 151
         self.test_member2_dict = copy.deepcopy(self.test_member1_dict)
145
-        self.test_member2_dict['id'] = self.member2_id
146
-        self.test_member2_dict['ip_address'] = '192.0.2.17'
147
-        self.test_member2_dict['monitor_address'] = '192.0.2.27'
148
-        self.test_member2_dict['name'] = 'member2'
152
+        self.test_member2_dict[lib_consts.ID] = self.member2_id
153
+        self.test_member2_dict[constants.IP_ADDRESS] = '192.0.2.17'
154
+        self.test_member2_dict[lib_consts.MONITOR_ADDRESS] = '192.0.2.27'
155
+        self.test_member2_dict[lib_consts.NAME] = 'member2'
149 156
 
150 157
         self.test_member3_dict = copy.deepcopy(self.test_member1_dict)
151
-        self.test_member3_dict['id'] = self.member3_id
152
-        self.test_member3_dict['ip_address'] = '192.0.2.18'
153
-        self.test_member3_dict['monitor_address'] = '192.0.2.28'
154
-        self.test_member3_dict['name'] = 'member3'
155
-        self.test_member3_dict['pool_id'] = self.pool2_id
158
+        self.test_member3_dict[lib_consts.ID] = self.member3_id
159
+        self.test_member3_dict[constants.IP_ADDRESS] = '192.0.2.18'
160
+        self.test_member3_dict[lib_consts.MONITOR_ADDRESS] = '192.0.2.28'
161
+        self.test_member3_dict[lib_consts.NAME] = 'member3'
162
+        self.test_member3_dict[lib_consts.POOL_ID] = self.pool2_id
156 163
 
157 164
         self.test_member4_dict = copy.deepcopy(self.test_member1_dict)
158
-        self.test_member4_dict['id'] = self.member4_id
159
-        self.test_member4_dict['ip_address'] = '192.0.2.19'
160
-        self.test_member4_dict['monitor_address'] = '192.0.2.29'
161
-        self.test_member4_dict['name'] = 'member4'
162
-        self.test_member4_dict['pool_id'] = self.pool2_id
165
+        self.test_member4_dict[lib_consts.ID] = self.member4_id
166
+        self.test_member4_dict[constants.IP_ADDRESS] = '192.0.2.19'
167
+        self.test_member4_dict[lib_consts.MONITOR_ADDRESS] = '192.0.2.29'
168
+        self.test_member4_dict[lib_consts.NAME] = 'member4'
169
+        self.test_member4_dict[lib_consts.POOL_ID] = self.pool2_id
163 170
 
164 171
         self.test_pool1_members_dict = [self.test_member1_dict,
165 172
                                         self.test_member2_dict]
@@ -174,38 +181,38 @@ class SampleDriverDataModels(object):
174 181
         self.db_pool1_members = [self.db_member1, self.db_member2]
175 182
         self.db_pool2_members = [self.db_member3, self.db_member4]
176 183
 
177
-        self.provider_member1_dict = {'address': '192.0.2.16',
178
-                                      'admin_state_up': True,
179
-                                      'member_id': self.member1_id,
180
-                                      'monitor_address': '192.0.2.26',
181
-                                      'monitor_port': 81,
182
-                                      'name': 'member1',
183
-                                      'pool_id': self.pool1_id,
184
-                                      'project_id': self.project_id,
185
-                                      'protocol_port': 80,
186
-                                      'subnet_id': self.subnet_id,
187
-                                      'weight': 0,
188
-                                      'backup': False}
184
+        self.provider_member1_dict = {lib_consts.ADDRESS: '192.0.2.16',
185
+                                      lib_consts.ADMIN_STATE_UP: True,
186
+                                      lib_consts.MEMBER_ID: self.member1_id,
187
+                                      lib_consts.MONITOR_ADDRESS: '192.0.2.26',
188
+                                      lib_consts.MONITOR_PORT: 81,
189
+                                      lib_consts.NAME: 'member1',
190
+                                      lib_consts.POOL_ID: self.pool1_id,
191
+                                      lib_consts.PROJECT_ID: self.project_id,
192
+                                      lib_consts.PROTOCOL_PORT: 80,
193
+                                      lib_consts.SUBNET_ID: self.subnet_id,
194
+                                      lib_consts.WEIGHT: 0,
195
+                                      lib_consts.BACKUP: False}
189 196
 
190 197
         self.provider_member2_dict = copy.deepcopy(self.provider_member1_dict)
191
-        self.provider_member2_dict['member_id'] = self.member2_id
192
-        self.provider_member2_dict['address'] = '192.0.2.17'
193
-        self.provider_member2_dict['monitor_address'] = '192.0.2.27'
194
-        self.provider_member2_dict['name'] = 'member2'
198
+        self.provider_member2_dict[lib_consts.MEMBER_ID] = self.member2_id
199
+        self.provider_member2_dict[lib_consts.ADDRESS] = '192.0.2.17'
200
+        self.provider_member2_dict[lib_consts.MONITOR_ADDRESS] = '192.0.2.27'
201
+        self.provider_member2_dict[lib_consts.NAME] = 'member2'
195 202
 
196 203
         self.provider_member3_dict = copy.deepcopy(self.provider_member1_dict)
197
-        self.provider_member3_dict['member_id'] = self.member3_id
198
-        self.provider_member3_dict['address'] = '192.0.2.18'
199
-        self.provider_member3_dict['monitor_address'] = '192.0.2.28'
200
-        self.provider_member3_dict['name'] = 'member3'
201
-        self.provider_member3_dict['pool_id'] = self.pool2_id
204
+        self.provider_member3_dict[lib_consts.MEMBER_ID] = self.member3_id
205
+        self.provider_member3_dict[lib_consts.ADDRESS] = '192.0.2.18'
206
+        self.provider_member3_dict[lib_consts.MONITOR_ADDRESS] = '192.0.2.28'
207
+        self.provider_member3_dict[lib_consts.NAME] = 'member3'
208
+        self.provider_member3_dict[lib_consts.POOL_ID] = self.pool2_id
202 209
 
203 210
         self.provider_member4_dict = copy.deepcopy(self.provider_member1_dict)
204
-        self.provider_member4_dict['member_id'] = self.member4_id
205
-        self.provider_member4_dict['address'] = '192.0.2.19'
206
-        self.provider_member4_dict['monitor_address'] = '192.0.2.29'
207
-        self.provider_member4_dict['name'] = 'member4'
208
-        self.provider_member4_dict['pool_id'] = self.pool2_id
211
+        self.provider_member4_dict[lib_consts.MEMBER_ID] = self.member4_id
212
+        self.provider_member4_dict[lib_consts.ADDRESS] = '192.0.2.19'
213
+        self.provider_member4_dict[lib_consts.MONITOR_ADDRESS] = '192.0.2.29'
214
+        self.provider_member4_dict[lib_consts.NAME] = 'member4'
215
+        self.provider_member4_dict[lib_consts.POOL_ID] = self.pool2_id
209 216
 
210 217
         self.provider_pool1_members_dict = [self.provider_member1_dict,
211 218
                                             self.provider_member2_dict]
@@ -224,35 +231,35 @@ class SampleDriverDataModels(object):
224 231
                                        self.provider_member4]
225 232
 
226 233
         # Setup test pools
227
-        self.test_pool1_dict = {'id': self.pool1_id,
228
-                                'name': 'pool1', 'description': 'Pool 1',
229
-                                'load_balancer_id': self.lb_id,
230
-                                'project_id': self.project_id,
231
-                                'protocol': 'TCP',
232
-                                'lb_algorithm': 'ROUND_ROBIN',
233
-                                'members': self.test_pool1_members_dict,
234
-                                'health_monitor': self.test_hm1_dict,
235
-                                'session_persistence': {'type': 'SOURCE_IP'},
236
-                                'listeners': [],
237
-                                'l7policies': [],
238
-                                'tls_certificate_id':
239
-                                    self.pool_sni_container_ref,
240
-                                'ca_tls_certificate_id':
241
-                                    self.pool_ca_container_ref,
242
-                                'crl_container_id':
243
-                                    self.pool_crl_container_ref,
244
-                                'tls_enabled': True}
234
+        self.test_pool1_dict = {
235
+            lib_consts.ID: self.pool1_id,
236
+            lib_consts.NAME: 'pool1', lib_consts.DESCRIPTION: 'Pool 1',
237
+            constants.LOAD_BALANCER_ID: self.lb_id,
238
+            lib_consts.PROJECT_ID: self.project_id,
239
+            lib_consts.PROTOCOL: lib_consts.PROTOCOL_TCP,
240
+            lib_consts.LB_ALGORITHM: lib_consts.LB_ALGORITHM_ROUND_ROBIN,
241
+            lib_consts.MEMBERS: self.test_pool1_members_dict,
242
+            constants.HEALTH_MONITOR: self.test_hm1_dict,
243
+            lib_consts.SESSION_PERSISTENCE: {
244
+                lib_consts.TYPE: lib_consts.LB_ALGORITHM_SOURCE_IP},
245
+            lib_consts.LISTENERS: [],
246
+            lib_consts.L7POLICIES: [],
247
+            constants.TLS_CERTIFICATE_ID: self.pool_sni_container_ref,
248
+            constants.CA_TLS_CERTIFICATE_ID: self.pool_ca_container_ref,
249
+            constants.CRL_CONTAINER_ID: self.pool_crl_container_ref,
250
+            lib_consts.TLS_ENABLED: True}
245 251
 
246 252
         self.test_pool1_dict.update(self._common_test_dict)
247 253
 
248 254
         self.test_pool2_dict = copy.deepcopy(self.test_pool1_dict)
249
-        self.test_pool2_dict['id'] = self.pool2_id
250
-        self.test_pool2_dict['name'] = 'pool2'
251
-        self.test_pool2_dict['description'] = 'Pool 2'
252
-        self.test_pool2_dict['members'] = self.test_pool2_members_dict
253
-        del self.test_pool2_dict['tls_certificate_id']
254
-        del self.test_pool2_dict['ca_tls_certificate_id']
255
-        del self.test_pool2_dict['crl_container_id']
255
+        self.test_pool2_dict[lib_consts.ID] = self.pool2_id
256
+        self.test_pool2_dict[lib_consts.NAME] = 'pool2'
257
+        self.test_pool2_dict[lib_consts.DESCRIPTION] = 'Pool 2'
258
+        self.test_pool2_dict[
259
+            lib_consts.MEMBERS] = self.test_pool2_members_dict
260
+        del self.test_pool2_dict[constants.TLS_CERTIFICATE_ID]
261
+        del self.test_pool2_dict[constants.CA_TLS_CERTIFICATE_ID]
262
+        del self.test_pool2_dict[constants.CRL_CONTAINER_ID]
256 263
 
257 264
         self.test_pools = [self.test_pool1_dict, self.test_pool2_dict]
258 265
 
@@ -269,38 +276,41 @@ class SampleDriverDataModels(object):
269 276
         pool_crl_file_content = 'X509 POOL CRL FILE'
270 277
 
271 278
         self.provider_pool1_dict = {
272
-            'admin_state_up': True,
273
-            'description': 'Pool 1',
274
-            'healthmonitor': self.provider_hm1_dict,
275
-            'lb_algorithm': 'ROUND_ROBIN',
276
-            'loadbalancer_id': self.lb_id,
277
-            'members': self.provider_pool1_members_dict,
278
-            'name': 'pool1',
279
-            'pool_id': self.pool1_id,
280
-            'project_id': self.project_id,
281
-            'protocol': 'TCP',
282
-            'session_persistence': {'type': 'SOURCE_IP'},
283
-            'tls_container_ref': self.pool_sni_container_ref,
284
-            'tls_container_data': pool_cert.to_dict(),
285
-            'ca_tls_container_ref': self.pool_ca_container_ref,
286
-            'ca_tls_container_data': pool_ca_file_content,
287
-            'crl_container_ref': self.pool_crl_container_ref,
288
-            'crl_container_data': pool_crl_file_content,
289
-            'tls_enabled': True
279
+            lib_consts.ADMIN_STATE_UP: True,
280
+            lib_consts.DESCRIPTION: 'Pool 1',
281
+            lib_consts.HEALTHMONITOR: self.provider_hm1_dict,
282
+            lib_consts.LB_ALGORITHM: lib_consts.LB_ALGORITHM_ROUND_ROBIN,
283
+            lib_consts.LOADBALANCER_ID: self.lb_id,
284
+            lib_consts.MEMBERS: self.provider_pool1_members_dict,
285
+            lib_consts.NAME: 'pool1',
286
+            lib_consts.POOL_ID: self.pool1_id,
287
+            lib_consts.PROJECT_ID: self.project_id,
288
+            lib_consts.PROTOCOL: lib_consts.PROTOCOL_TCP,
289
+            lib_consts.SESSION_PERSISTENCE: {
290
+                lib_consts.TYPE: lib_consts.LB_ALGORITHM_SOURCE_IP},
291
+            lib_consts.TLS_CONTAINER_REF: self.pool_sni_container_ref,
292
+            lib_consts.TLS_CONTAINER_DATA: pool_cert.to_dict(),
293
+            lib_consts.CA_TLS_CONTAINER_REF: self.pool_ca_container_ref,
294
+            lib_consts.CA_TLS_CONTAINER_DATA: pool_ca_file_content,
295
+            lib_consts.CRL_CONTAINER_REF: self.pool_crl_container_ref,
296
+            lib_consts.CRL_CONTAINER_DATA: pool_crl_file_content,
297
+            lib_consts.TLS_ENABLED: True
290 298
         }
291 299
 
292 300
         self.provider_pool2_dict = copy.deepcopy(self.provider_pool1_dict)
293
-        self.provider_pool2_dict['pool_id'] = self.pool2_id
294
-        self.provider_pool2_dict['name'] = 'pool2'
295
-        self.provider_pool2_dict['description'] = 'Pool 2'
296
-        self.provider_pool2_dict['members'] = self.provider_pool2_members_dict
297
-        self.provider_pool2_dict['healthmonitor'] = self.provider_hm2_dict
298
-        self.provider_pool2_dict['tls_container_ref'] = None
299
-        del self.provider_pool2_dict['tls_container_data']
300
-        self.provider_pool2_dict['ca_tls_container_ref'] = None
301
-        del self.provider_pool2_dict['ca_tls_container_data']
302
-        self.provider_pool2_dict['crl_container_ref'] = None
303
-        del self.provider_pool2_dict['crl_container_data']
301
+        self.provider_pool2_dict[lib_consts.POOL_ID] = self.pool2_id
302
+        self.provider_pool2_dict[lib_consts.NAME] = 'pool2'
303
+        self.provider_pool2_dict[lib_consts.DESCRIPTION] = 'Pool 2'
304
+        self.provider_pool2_dict[
305
+            lib_consts.MEMBERS] = self.provider_pool2_members_dict
306
+        self.provider_pool2_dict[
307
+            lib_consts.HEALTHMONITOR] = self.provider_hm2_dict
308
+        self.provider_pool2_dict[lib_consts.TLS_CONTAINER_REF] = None
309
+        del self.provider_pool2_dict[lib_consts.TLS_CONTAINER_DATA]
310
+        self.provider_pool2_dict[lib_consts.CA_TLS_CONTAINER_REF] = None
311
+        del self.provider_pool2_dict[lib_consts.CA_TLS_CONTAINER_DATA]
312
+        self.provider_pool2_dict[lib_consts.CRL_CONTAINER_REF] = None
313
+        del self.provider_pool2_dict[lib_consts.CRL_CONTAINER_DATA]
304 314
 
305 315
         self.provider_pool1 = driver_dm.Pool(**self.provider_pool1_dict)
306 316
         self.provider_pool1.members = self.provider_pool1_members
@@ -313,20 +323,20 @@ class SampleDriverDataModels(object):
313 323
 
314 324
         # Setup L7Rules
315 325
         self.test_l7rule1_dict = {
316
-            'id': self.l7rule1_id,
317
-            'l7policy_id': self.l7policy1_id,
318
-            'type': lib_consts.L7RULE_TYPE_PATH,
319
-            'compare_type': lib_consts.L7RULE_COMPARE_TYPE_EQUAL_TO,
320
-            'key': 'fake_key',
321
-            'value': 'fake_value',
322
-            'project_id': self.project_id,
323
-            'l7policy': None,
324
-            'invert': False}
326
+            lib_consts.ID: self.l7rule1_id,
327
+            lib_consts.L7POLICY_ID: self.l7policy1_id,
328
+            lib_consts.TYPE: lib_consts.L7RULE_TYPE_PATH,
329
+            lib_consts.COMPARE_TYPE: lib_consts.L7RULE_COMPARE_TYPE_EQUAL_TO,
330
+            lib_consts.KEY: 'fake_key',
331
+            lib_consts.VALUE: 'fake_value',
332
+            lib_consts.PROJECT_ID: self.project_id,
333
+            constants.L7POLICY: None,
334
+            lib_consts.INVERT: False}
325 335
 
326 336
         self.test_l7rule1_dict.update(self._common_test_dict)
327 337
 
328 338
         self.test_l7rule2_dict = copy.deepcopy(self.test_l7rule1_dict)
329
-        self.test_l7rule2_dict['id'] = self.l7rule2_id
339
+        self.test_l7rule2_dict[lib_consts.ID] = self.l7rule2_id
330 340
 
331 341
         self.test_l7rules = [self.test_l7rule1_dict, self.test_l7rule2_dict]
332 342
 
@@ -336,18 +346,18 @@ class SampleDriverDataModels(object):
336 346
         self.db_l7Rules = [self.db_l7Rule1, self.db_l7Rule2]
337 347
 
338 348
         self.provider_l7rule1_dict = {
339
-            'admin_state_up': True,
340
-            'compare_type': lib_consts.L7RULE_COMPARE_TYPE_EQUAL_TO,
341
-            'invert': False,
342
-            'key': 'fake_key',
343
-            'l7policy_id': self.l7policy1_id,
344
-            'l7rule_id': self.l7rule1_id,
345
-            'type': lib_consts.L7RULE_TYPE_PATH,
346
-            'project_id': self.project_id,
347
-            'value': 'fake_value'}
349
+            lib_consts.ADMIN_STATE_UP: True,
350
+            lib_consts.COMPARE_TYPE: lib_consts.L7RULE_COMPARE_TYPE_EQUAL_TO,
351
+            lib_consts.INVERT: False,
352
+            lib_consts.KEY: 'fake_key',
353
+            lib_consts.L7POLICY_ID: self.l7policy1_id,
354
+            lib_consts.L7RULE_ID: self.l7rule1_id,
355
+            lib_consts.TYPE: lib_consts.L7RULE_TYPE_PATH,
356
+            lib_consts.PROJECT_ID: self.project_id,
357
+            lib_consts.VALUE: 'fake_value'}
348 358
 
349 359
         self.provider_l7rule2_dict = copy.deepcopy(self.provider_l7rule1_dict)
350
-        self.provider_l7rule2_dict['l7rule_id'] = self.l7rule2_id
360
+        self.provider_l7rule2_dict[lib_consts.L7RULE_ID] = self.l7rule2_id
351 361
         self.provider_l7rules_dicts = [self.provider_l7rule1_dict,
352 362
                                        self.provider_l7rule2_dict]
353 363
 
@@ -358,27 +368,27 @@ class SampleDriverDataModels(object):
358 368
 
359 369
         # Setup L7Policies
360 370
         self.test_l7policy1_dict = {
361
-            'id': self.l7policy1_id,
362
-            'name': 'l7policy_1',
363
-            'description': 'L7policy 1',
364
-            'listener_id': self.listener1_id,
365
-            'action': lib_consts.L7POLICY_ACTION_REDIRECT_TO_URL,
366
-            'redirect_pool_id': None,
367
-            'redirect_url': 'http://example.com/index.html',
368
-            'redirect_prefix': None,
369
-            'project_id': self.project_id,
370
-            'position': 1,
371
-            'listener': None,
372
-            'redirect_pool': None,
373
-            'l7rules': self.test_l7rules,
374
-            'redirect_http_code': 302}
371
+            lib_consts.ID: self.l7policy1_id,
372
+            lib_consts.NAME: 'l7policy_1',
373
+            lib_consts.DESCRIPTION: 'L7policy 1',
374
+            lib_consts.LISTENER_ID: self.listener1_id,
375
+            lib_consts.ACTION: lib_consts.L7POLICY_ACTION_REDIRECT_TO_URL,
376
+            lib_consts.REDIRECT_POOL_ID: None,
377
+            lib_consts.REDIRECT_URL: 'http://example.com/index.html',
378
+            lib_consts.REDIRECT_PREFIX: None,
379
+            lib_consts.PROJECT_ID: self.project_id,
380
+            lib_consts.POSITION: 1,
381
+            constants.LISTENER: None,
382
+            constants.REDIRECT_POOL: None,
383
+            lib_consts.L7RULES: self.test_l7rules,
384
+            lib_consts.REDIRECT_HTTP_CODE: 302}
375 385
 
376 386
         self.test_l7policy1_dict.update(self._common_test_dict)
377 387
 
378 388
         self.test_l7policy2_dict = copy.deepcopy(self.test_l7policy1_dict)
379
-        self.test_l7policy2_dict['id'] = self.l7policy2_id
380
-        self.test_l7policy2_dict['name'] = 'l7policy_2'
381
-        self.test_l7policy2_dict['description'] = 'L7policy 2'
389
+        self.test_l7policy2_dict[lib_consts.ID] = self.l7policy2_id
390
+        self.test_l7policy2_dict[lib_consts.NAME] = 'l7policy_2'
391
+        self.test_l7policy2_dict[lib_consts.DESCRIPTION] = 'L7policy 2'
382 392
 
383 393
         self.test_l7policies = [self.test_l7policy1_dict,
384 394
                                 self.test_l7policy2_dict]
@@ -391,26 +401,27 @@ class SampleDriverDataModels(object):
391 401
         self.db_l7policies = [self.db_l7policy1, self.db_l7policy2]
392 402
 
393 403
         self.provider_l7policy1_dict = {
394
-            'action': lib_consts.L7POLICY_ACTION_REDIRECT_TO_URL,
395
-            'admin_state_up': True,
396
-            'description': 'L7policy 1',
397
-            'l7policy_id': self.l7policy1_id,
398
-            'listener_id': self.listener1_id,
399
-            'name': 'l7policy_1',
400
-            'position': 1,
401
-            'project_id': self.project_id,
402
-            'redirect_pool_id': None,
403
-            'redirect_url': 'http://example.com/index.html',
404
-            'redirect_prefix': None,
405
-            'rules': self.provider_l7rules_dicts,
406
-            'redirect_http_code': 302
404
+            lib_consts.ACTION: lib_consts.L7POLICY_ACTION_REDIRECT_TO_URL,
405
+            lib_consts.ADMIN_STATE_UP: True,
406
+            lib_consts.DESCRIPTION: 'L7policy 1',
407
+            lib_consts.L7POLICY_ID: self.l7policy1_id,
408
+            lib_consts.LISTENER_ID: self.listener1_id,
409
+            lib_consts.NAME: 'l7policy_1',
410
+            lib_consts.POSITION: 1,
411
+            lib_consts.PROJECT_ID: self.project_id,
412
+            lib_consts.REDIRECT_POOL_ID: None,
413
+            lib_consts.REDIRECT_URL: 'http://example.com/index.html',
414
+            lib_consts.REDIRECT_PREFIX: None,
415
+            lib_consts.RULES: self.provider_l7rules_dicts,
416
+            lib_consts.REDIRECT_HTTP_CODE: 302
407 417
         }
408 418
 
409 419
         self.provider_l7policy2_dict = copy.deepcopy(
410 420
             self.provider_l7policy1_dict)
411
-        self.provider_l7policy2_dict['l7policy_id'] = self.l7policy2_id
412
-        self.provider_l7policy2_dict['name'] = 'l7policy_2'
413
-        self.provider_l7policy2_dict['description'] = 'L7policy 2'
421
+        self.provider_l7policy2_dict[
422
+            lib_consts.L7POLICY_ID] = self.l7policy2_id
423
+        self.provider_l7policy2_dict[lib_consts.NAME] = 'l7policy_2'
424
+        self.provider_l7policy2_dict[lib_consts.DESCRIPTION] = 'L7policy 2'
414 425
 
415 426
         self.provider_l7policies_dict = [self.provider_l7policy1_dict,
416 427
                                          self.provider_l7policy2_dict]
@@ -427,43 +438,46 @@ class SampleDriverDataModels(object):
427 438
 
428 439
         # Setup Listeners
429 440
         self.test_listener1_dict = {
430
-            'id': self.listener1_id,
431
-            'name': 'listener_1',
432
-            'description': 'Listener 1',
433
-            'default_pool_id': self.pool1_id,
434
-            'load_balancer_id': self.lb_id,
435
-            'project_id': self.project_id,
436
-            'protocol': 'TCP',
437
-            'protocol_port': 90,
438
-            'connection_limit': 10000,
439
-            'tls_certificate_id': self.default_tls_container_ref,
440
-            'default_pool': self.test_pool1_dict,
441
-            'sni_containers': [{'tls_container_id': self.sni_container_ref_1},
442
-                               {'tls_container_id': self.sni_container_ref_2}],
443
-            'peer_port': 55,
444
-            'l7policies': self.test_l7policies,
445
-            'insert_headers': {},
446
-            'timeout_client_data': 1000,
447
-            'timeout_member_connect': 2000,
448
-            'timeout_member_data': 3000,
449
-            'timeout_tcp_inspect': 4000,
450
-            'client_ca_tls_certificate_id': self.client_ca_tls_certificate_ref,
451
-            'client_authentication': constants.CLIENT_AUTH_NONE,
452
-            'client_crl_container_id': self.client_crl_container_ref
441
+            lib_consts.ID: self.listener1_id,
442
+            lib_consts.NAME: 'listener_1',
443
+            lib_consts.DESCRIPTION: 'Listener 1',
444
+            lib_consts.DEFAULT_POOL_ID: self.pool1_id,
445
+            constants.LOAD_BALANCER_ID: self.lb_id,
446
+            lib_consts.PROJECT_ID: self.project_id,
447
+            lib_consts.PROTOCOL: lib_consts.PROTOCOL_TCP,
448
+            lib_consts.PROTOCOL_PORT: 90,
449
+            lib_consts.CONNECTION_LIMIT: 10000,
450
+            constants.TLS_CERTIFICATE_ID: self.default_tls_container_ref,
451
+            lib_consts.DEFAULT_POOL: self.test_pool1_dict,
452
+            constants.SNI_CONTAINERS: [
453
+                {constants.TLS_CONTAINER_ID: self.sni_container_ref_1},
454
+                {constants.TLS_CONTAINER_ID: self.sni_container_ref_2}],
455
+            constants.PEER_PORT: 55,
456
+            lib_consts.L7POLICIES: self.test_l7policies,
457
+            lib_consts.INSERT_HEADERS: {},
458
+            lib_consts.TIMEOUT_CLIENT_DATA: 1000,
459
+            lib_consts.TIMEOUT_MEMBER_CONNECT: 2000,
460
+            lib_consts.TIMEOUT_MEMBER_DATA: 3000,
461
+            lib_consts.TIMEOUT_TCP_INSPECT: 4000,
462
+            constants.CLIENT_CA_TLS_CERTIFICATE_ID:
463
+                self.client_ca_tls_certificate_ref,
464
+            lib_consts.CLIENT_AUTHENTICATION: constants.CLIENT_AUTH_NONE,
465
+            constants.CLIENT_CRL_CONTAINER_ID: self.client_crl_container_ref
453 466
         }
454 467
 
455 468
         self.test_listener1_dict.update(self._common_test_dict)
456 469
 
457 470
         self.test_listener2_dict = copy.deepcopy(self.test_listener1_dict)
458
-        self.test_listener2_dict['id'] = self.listener2_id
459
-        self.test_listener2_dict['name'] = 'listener_2'
460
-        self.test_listener2_dict['description'] = 'Listener 1'
461
-        self.test_listener2_dict['default_pool_id'] = self.pool2_id
462
-        self.test_listener2_dict['default_pool'] = self.test_pool2_dict
463
-        del self.test_listener2_dict['l7policies']
464
-        del self.test_listener2_dict['sni_containers']
465
-        del self.test_listener2_dict['client_ca_tls_certificate_id']
466
-        del self.test_listener2_dict['client_crl_container_id']
471
+        self.test_listener2_dict[lib_consts.ID] = self.listener2_id
472
+        self.test_listener2_dict[lib_consts.NAME] = 'listener_2'
473
+        self.test_listener2_dict[lib_consts.DESCRIPTION] = 'Listener 1'
474
+        self.test_listener2_dict[lib_consts.DEFAULT_POOL_ID] = self.pool2_id
475
+        self.test_listener2_dict[
476
+            lib_consts.DEFAULT_POOL] = self.test_pool2_dict
477
+        del self.test_listener2_dict[lib_consts.L7POLICIES]
478
+        del self.test_listener2_dict[constants.SNI_CONTAINERS]
479
+        del self.test_listener2_dict[constants.CLIENT_CA_TLS_CERTIFICATE_ID]
480
+        del self.test_listener2_dict[constants.CLIENT_CRL_CONTAINER_ID]
467 481
 
468 482
         self.test_listeners = [self.test_listener1_dict,
469 483
                                self.test_listener2_dict]
@@ -486,49 +500,58 @@ class SampleDriverDataModels(object):
486 500
         crl_file_content = 'X509 CRL FILE'
487 501
 
488 502
         self.provider_listener1_dict = {
489
-            'admin_state_up': True,
490
-            'connection_limit': 10000,
491
-            'default_pool': self.provider_pool1_dict,
492
-            'default_pool_id': self.pool1_id,
493
-            'default_tls_container_data': cert1.to_dict(),
494
-            'default_tls_container_ref': self.default_tls_container_ref,
495
-            'description': 'Listener 1',
496
-            'insert_headers': {},
497
-            'l7policies': self.provider_l7policies_dict,
498
-            'listener_id': self.listener1_id,
499
-            'loadbalancer_id': self.lb_id,
500
-            'name': 'listener_1',
501
-            'project_id': self.project_id,
502
-            'protocol': 'TCP',
503
-            'protocol_port': 90,
504
-            'sni_container_data': [cert2.to_dict(), cert3.to_dict()],
505
-            'sni_container_refs': [self.sni_container_ref_1,
506
-                                   self.sni_container_ref_2],
507
-            'timeout_client_data': 1000,
508
-            'timeout_member_connect': 2000,
509
-            'timeout_member_data': 3000,
510
-            'timeout_tcp_inspect': 4000,
511
-            'client_ca_tls_container_ref': self.client_ca_tls_certificate_ref,
512
-            'client_ca_tls_container_data': ca_cert,
513
-            'client_authentication': constants.CLIENT_AUTH_NONE,
514
-            'client_crl_container_ref': self.client_crl_container_ref,
515
-            'client_crl_container_data': crl_file_content
503
+            lib_consts.ADMIN_STATE_UP: True,
504
+            lib_consts.ALLOWED_CIDRS: None,
505
+            lib_consts.CONNECTION_LIMIT: 10000,
506
+            lib_consts.DEFAULT_POOL: self.provider_pool1_dict,
507
+            lib_consts.DEFAULT_POOL_ID: self.pool1_id,
508
+            lib_consts.DEFAULT_TLS_CONTAINER_DATA: cert1.to_dict(),
509
+            lib_consts.DEFAULT_TLS_CONTAINER_REF:
510
+                self.default_tls_container_ref,
511
+            lib_consts.DESCRIPTION: 'Listener 1',
512
+            lib_consts.INSERT_HEADERS: {},
513
+            lib_consts.L7POLICIES: self.provider_l7policies_dict,
514
+            lib_consts.LISTENER_ID: self.listener1_id,
515
+            lib_consts.LOADBALANCER_ID: self.lb_id,
516
+            lib_consts.NAME: 'listener_1',
517
+            lib_consts.PROJECT_ID: self.project_id,
518
+            lib_consts.PROTOCOL: lib_consts.PROTOCOL_TCP,
519
+            lib_consts.PROTOCOL_PORT: 90,
520
+            lib_consts.SNI_CONTAINER_DATA: [cert2.to_dict(), cert3.to_dict()],
521
+            lib_consts.SNI_CONTAINER_REFS: [self.sni_container_ref_1,
522
+                                            self.sni_container_ref_2],
523
+            lib_consts.TIMEOUT_CLIENT_DATA: 1000,
524
+            lib_consts.TIMEOUT_MEMBER_CONNECT: 2000,
525
+            lib_consts.TIMEOUT_MEMBER_DATA: 3000,
526
+            lib_consts.TIMEOUT_TCP_INSPECT: 4000,
527
+            lib_consts.CLIENT_CA_TLS_CONTAINER_REF:
528
+                self.client_ca_tls_certificate_ref,
529
+            lib_consts.CLIENT_CA_TLS_CONTAINER_DATA: ca_cert,
530
+            lib_consts.CLIENT_AUTHENTICATION: constants.CLIENT_AUTH_NONE,
531
+            lib_consts.CLIENT_CRL_CONTAINER_REF: self.client_crl_container_ref,
532
+            lib_consts.CLIENT_CRL_CONTAINER_DATA: crl_file_content
516 533
         }
517 534
 
518 535
         self.provider_listener2_dict = copy.deepcopy(
519 536
             self.provider_listener1_dict)
520
-        self.provider_listener2_dict['listener_id'] = self.listener2_id
521
-        self.provider_listener2_dict['name'] = 'listener_2'
522
-        self.provider_listener2_dict['description'] = 'Listener 1'
523
-        self.provider_listener2_dict['default_pool_id'] = self.pool2_id
524
-        self.provider_listener2_dict['default_pool'] = self.provider_pool2_dict
525
-        del self.provider_listener2_dict['l7policies']
526
-        self.provider_listener2_dict['client_ca_tls_container_ref'] = None
527
-        del self.provider_listener2_dict['client_ca_tls_container_data']
528
-        self.provider_listener2_dict['client_authentication'] = (
537
+        self.provider_listener2_dict[
538
+            lib_consts.LISTENER_ID] = self.listener2_id
539
+        self.provider_listener2_dict[lib_consts.NAME] = 'listener_2'
540
+        self.provider_listener2_dict[lib_consts.DESCRIPTION] = 'Listener 1'
541
+        self.provider_listener2_dict[
542
+            lib_consts.DEFAULT_POOL_ID] = self.pool2_id
543
+        self.provider_listener2_dict[
544
+            lib_consts.DEFAULT_POOL] = self.provider_pool2_dict
545
+        del self.provider_listener2_dict[lib_consts.L7POLICIES]
546
+        self.provider_listener2_dict[
547
+            lib_consts.CLIENT_CA_TLS_CONTAINER_REF] = None
548
+        del self.provider_listener2_dict[
549
+            lib_consts.CLIENT_CA_TLS_CONTAINER_DATA]
550
+        self.provider_listener2_dict[lib_consts.CLIENT_AUTHENTICATION] = (
529 551
             constants.CLIENT_AUTH_NONE)
530
-        self.provider_listener2_dict['client_crl_container_ref'] = None
531
-        del self.provider_listener2_dict['client_crl_container_data']
552
+        self.provider_listener2_dict[
553
+            lib_consts.CLIENT_CRL_CONTAINER_REF] = None
554
+        del self.provider_listener2_dict[lib_consts.CLIENT_CRL_CONTAINER_DATA]
532 555
 
533 556
         self.provider_listener1 = driver_dm.Listener(
534 557
             **self.provider_listener1_dict)
@@ -541,18 +564,18 @@ class SampleDriverDataModels(object):
541 564
         self.provider_listeners = [self.provider_listener1,
542 565
                                    self.provider_listener2]
543 566
 
544
-        self.test_vip_dict = {'ip_address': self.ip_address,
545
-                              'network_id': self.network_id,
546
-                              'port_id': self.port_id,
547
-                              'subnet_id': self.subnet_id,
548
-                              'qos_policy_id': self.qos_policy_id}
567
+        self.test_vip_dict = {constants.IP_ADDRESS: self.ip_address,
568
+                              constants.NETWORK_ID: self.network_id,
569
+                              constants.PORT_ID: self.port_id,
570
+                              lib_consts.SUBNET_ID: self.subnet_id,
571
+                              constants.QOS_POLICY_ID: self.qos_policy_id}
549 572
 
550 573
         self.provider_vip_dict = {
551
-            'vip_address': self.ip_address,
552
-            'vip_network_id': self.network_id,
553
-            'vip_port_id': self.port_id,
554
-            'vip_subnet_id': self.subnet_id,
555
-            'vip_qos_policy_id': self.qos_policy_id}
574
+            lib_consts.VIP_ADDRESS: self.ip_address,
575
+            lib_consts.VIP_NETWORK_ID: self.network_id,
576
+            lib_consts.VIP_PORT_ID: self.port_id,
577
+            lib_consts.VIP_SUBNET_ID: self.subnet_id,
578
+            lib_consts.VIP_QOS_POLICY_ID: self.qos_policy_id}
556 579
 
557 580
         self.db_vip = data_models.Vip(
558 581
             ip_address=self.ip_address,
@@ -562,46 +585,47 @@ class SampleDriverDataModels(object):
562 585
             qos_policy_id=self.qos_policy_id)
563 586
 
564 587
         self.test_loadbalancer1_dict = {
565
-            'name': self.lb_name, 'description': self.lb_description,
566
-            'enabled': True,
567
-            'provisioning_status': lib_consts.PENDING_UPDATE,
568
-            'operating_status': lib_consts.OFFLINE,
569
-            'topology': constants.TOPOLOGY_ACTIVE_STANDBY,
570
-            'vrrp_group': None,
571
-            'provider': 'amphora',
572
-            'server_group_id': uuidutils.generate_uuid(),
573
-            'project_id': self.project_id,
574
-            'id': self.lb_id, 'flavor_id': self.flavor_id,
575
-            'tags': ['test_tag']}
588
+            lib_consts.NAME: self.lb_name,
589
+            lib_consts.DESCRIPTION: self.lb_description,
590
+            constants.ENABLED: True,
591
+            lib_consts.PROVISIONING_STATUS: lib_consts.PENDING_UPDATE,
592
+            lib_consts.OPERATING_STATUS: lib_consts.OFFLINE,
593
+            constants.TOPOLOGY: constants.TOPOLOGY_ACTIVE_STANDBY,
594
+            constants.VRRP_GROUP: None,
595
+            constants.PROVIDER: constants.AMPHORA,
596
+            constants.SERVER_GROUP_ID: uuidutils.generate_uuid(),
597
+            lib_consts.PROJECT_ID: self.project_id,
598
+            lib_consts.ID: self.lb_id, constants.FLAVOR_ID: self.flavor_id,
599
+            constants.TAGS: ['test_tag']}
576 600
 
577 601
         self.provider_loadbalancer_dict = {
578
-            'additional_vips': None,
579
-            'admin_state_up': True,
580
-            'description': self.lb_description,
581
-            'flavor': {"something": "else"},
582
-            'listeners': None,
583
-            'loadbalancer_id': self.lb_id,
584
-            'name': self.lb_name,
585
-            'pools': None,
586
-            'project_id': self.project_id,
587
-            'vip_address': self.ip_address,
588
-            'vip_network_id': self.network_id,
589
-            'vip_port_id': self.port_id,
590
-            'vip_qos_policy_id': self.qos_policy_id,
591
-            'vip_subnet_id': self.subnet_id}
602
+            lib_consts.ADDITIONAL_VIPS: None,
603
+            lib_consts.ADMIN_STATE_UP: True,
604
+            lib_consts.DESCRIPTION: self.lb_description,
605
+            lib_consts.FLAVOR: {"something": "else"},
606
+            lib_consts.LISTENERS: None,
607
+            lib_consts.LOADBALANCER_ID: self.lb_id,
608
+            lib_consts.NAME: self.lb_name,
609
+            lib_consts.POOLS: None,
610
+            lib_consts.PROJECT_ID: self.project_id,
611
+            lib_consts.VIP_ADDRESS: self.ip_address,
612
+            lib_consts.VIP_NETWORK_ID: self.network_id,
613
+            lib_consts.VIP_PORT_ID: self.port_id,
614
+            lib_consts.VIP_QOS_POLICY_ID: self.qos_policy_id,
615
+            lib_consts.VIP_SUBNET_ID: self.subnet_id}
592 616
 
593 617
         self.provider_loadbalancer_tree_dict = {
594
-            'additional_vips': None,
595
-            'admin_state_up': True,
596
-            'description': self.lb_description,
597
-            'flavor': {"something": "else"},
598
-            'listeners': None,
599
-            'loadbalancer_id': self.lb_id,
600
-            'name': self.lb_name,
601
-            'pools': None,
602
-            'project_id': self.project_id,
603
-            'vip_address': self.ip_address,
604
-            'vip_network_id': self.network_id,
605
-            'vip_port_id': self.port_id,
606
-            'vip_qos_policy_id': self.qos_policy_id,
607
-            'vip_subnet_id': self.subnet_id}
618
+            lib_consts.ADDITIONAL_VIPS: None,
619
+            lib_consts.ADMIN_STATE_UP: True,
620
+            lib_consts.DESCRIPTION: self.lb_description,
621
+            lib_consts.FLAVOR: {"something": "else"},
622
+            lib_consts.LISTENERS: None,
623
+            lib_consts.LOADBALANCER_ID: self.lb_id,
624
+            lib_consts.NAME: self.lb_name,
625
+            lib_consts.POOLS: None,
626
+            lib_consts.PROJECT_ID: self.project_id,
627
+            lib_consts.VIP_ADDRESS: self.ip_address,
628
+            lib_consts.VIP_NETWORK_ID: self.network_id,
629
+            lib_consts.VIP_PORT_ID: self.port_id,
630
+            lib_consts.VIP_QOS_POLICY_ID: self.qos_policy_id,
631
+            lib_consts.VIP_SUBNET_ID: self.subnet_id}

+ 53
- 42
octavia/tests/functional/api/drivers/driver_agent/test_driver_agent.py View File

@@ -123,18 +123,19 @@ class DriverAgentTest(base.OctaviaDBTestBase):
123 123
 
124 124
         # Create the full load balancer in the database
125 125
         self.tls_container_dict = {
126
-            'certificate': sample_certs.X509_CERT.decode('utf-8'),
127
-            'id': sample_certs.X509_CERT_SHA1,
128
-            'intermediates': [
126
+            lib_consts.CERTIFICATE: sample_certs.X509_CERT.decode('utf-8'),
127
+            lib_consts.ID: sample_certs.X509_CERT_SHA1,
128
+            lib_consts.INTERMEDIATES: [
129 129
                 i.decode('utf-8') for i in sample_certs.X509_IMDS_LIST],
130
-            'passphrase': None,
131
-            'primary_cn': sample_certs.X509_CERT_CN,
132
-            'private_key': sample_certs.X509_CERT_KEY.decode('utf-8')}
130
+            lib_consts.PASSPHRASE: None,
131
+            lib_consts.PRIMARY_CN: sample_certs.X509_CERT_CN,
132
+            lib_consts.PRIVATE_KEY: sample_certs.X509_CERT_KEY.decode('utf-8')}
133 133
 
134 134
         # ### Create load balancer
135 135
         self.repos.flavor_profile.create(
136 136
             self.session, id=self.sample_data.flavor_profile_id,
137
-            provider_name='amphora', flavor_data='{"something": "else"}')
137
+            provider_name=constants.AMPHORA,
138
+            flavor_data='{"something": "else"}')
138 139
         self.repos.flavor.create(
139 140
             self.session, id=self.sample_data.flavor_id,
140 141
             enabled=True, flavor_profile_id=self.sample_data.flavor_profile_id)
@@ -145,17 +146,17 @@ class DriverAgentTest(base.OctaviaDBTestBase):
145 146
         # ### Create Pool
146 147
         pool_dict = copy.deepcopy(self.sample_data.test_pool1_dict)
147 148
 
148
-        pool_dict['load_balancer_id'] = self.sample_data.lb_id
149
+        pool_dict[constants.LOAD_BALANCER_ID] = self.sample_data.lb_id
149 150
 
150 151
         # Use a live certificate
151
-        pool_dict['tls_certificate_id'] = self.cert_ref
152
-        pool_dict['ca_tls_certificate_id'] = self.cert_ref
153
-        pool_dict['crl_container_id'] = self.cert_ref
152
+        pool_dict[constants.TLS_CERTIFICATE_ID] = self.cert_ref
153
+        pool_dict[constants.CA_TLS_CERTIFICATE_ID] = self.cert_ref
154
+        pool_dict[constants.CRL_CONTAINER_ID] = self.cert_ref
154 155
 
155 156
         # Remove items that are linked in the DB
156 157
         del pool_dict[lib_consts.MEMBERS]
157 158
         del pool_dict[constants.HEALTH_MONITOR]
158
-        del pool_dict['session_persistence']
159
+        del pool_dict[lib_consts.SESSION_PERSISTENCE]
159 160
         del pool_dict[lib_consts.LISTENERS]
160 161
         del pool_dict[lib_consts.L7POLICIES]
161 162
 
@@ -171,21 +172,26 @@ class DriverAgentTest(base.OctaviaDBTestBase):
171 172
             constants.LISTENER_ID] = self.sample_data.listener1_id
172 173
 
173 174
         # Fix for render_unsets = True
174
-        self.provider_pool_dict['session_persistence']['cookie_name'] = None
175
-        self.provider_pool_dict['session_persistence'][
176
-            'persistence_granularity'] = None
177
-        self.provider_pool_dict['session_persistence'][
178
-            'persistence_timeout'] = None
175
+        self.provider_pool_dict[
176
+            lib_consts.SESSION_PERSISTENCE][lib_consts.COOKIE_NAME] = None
177
+        self.provider_pool_dict[lib_consts.SESSION_PERSISTENCE][
178
+            lib_consts.PERSISTENCE_GRANULARITY] = None
179
+        self.provider_pool_dict[lib_consts.SESSION_PERSISTENCE][
180
+            lib_consts.PERSISTENCE_TIMEOUT] = None
179 181
 
180 182
         # Use a live certificate
181
-        self.provider_pool_dict['tls_container_data'] = self.tls_container_dict
182
-        self.provider_pool_dict['tls_container_ref'] = self.cert_ref
183 183
         self.provider_pool_dict[
184
-            'ca_tls_container_data'] = sample_certs.X509_CERT.decode('utf-8')
185
-        self.provider_pool_dict['ca_tls_container_ref'] = self.cert_ref
184
+            lib_consts.TLS_CONTAINER_DATA] = self.tls_container_dict
185
+        self.provider_pool_dict[lib_consts.TLS_CONTAINER_REF] = self.cert_ref
186
+        self.provider_pool_dict[
187
+            lib_consts.CA_TLS_CONTAINER_DATA] = (
188
+                sample_certs.X509_CERT.decode('utf-8'))
186 189
         self.provider_pool_dict[
187
-            'crl_container_data'] = sample_certs.X509_CERT.decode('utf-8')
188
-        self.provider_pool_dict['crl_container_ref'] = self.cert_ref
190
+            lib_consts.CA_TLS_CONTAINER_REF] = self.cert_ref
191
+        self.provider_pool_dict[
192
+            lib_consts.CRL_CONTAINER_DATA] = (
193
+                sample_certs.X509_CERT.decode('utf-8'))
194
+        self.provider_pool_dict[lib_consts.CRL_CONTAINER_REF] = self.cert_ref
189 195
 
190 196
         # ### Create Member
191 197
         member_dict = copy.deepcopy(self.sample_data.test_member1_dict)
@@ -197,21 +203,21 @@ class DriverAgentTest(base.OctaviaDBTestBase):
197 203
         hm_dict = copy.deepcopy(self.sample_data.test_hm1_dict)
198 204
         self.repos.health_monitor.create(self.session, **hm_dict)
199 205
         self.provider_pool_dict[
200
-            'healthmonitor'] = self.sample_data.provider_hm1_dict
206
+            lib_consts.HEALTHMONITOR] = self.sample_data.provider_hm1_dict
201 207
 
202 208
         # ### Create Listener
203 209
         listener_dict = copy.deepcopy(self.sample_data.test_listener1_dict)
204
-        listener_dict['default_pool_id'] = self.sample_data.pool1_id
210
+        listener_dict[lib_consts.DEFAULT_POOL_ID] = self.sample_data.pool1_id
205 211
 
206 212
         # Remove items that are linked in the DB
207 213
         del listener_dict[lib_consts.L7POLICIES]
208
-        del listener_dict['default_pool']
214
+        del listener_dict[lib_consts.DEFAULT_POOL]
209 215
         del listener_dict[constants.SNI_CONTAINERS]
210 216
 
211 217
         # Use a live certificate
212
-        listener_dict['tls_certificate_id'] = self.cert_ref
213
-        listener_dict['client_ca_tls_certificate_id'] = self.cert_ref
214
-        listener_dict['client_crl_container_id'] = self.cert_ref
218
+        listener_dict[constants.TLS_CERTIFICATE_ID] = self.cert_ref
219
+        listener_dict[constants.CLIENT_CA_TLS_CERTIFICATE_ID] = self.cert_ref
220
+        listener_dict[constants.CLIENT_CRL_CONTAINER_ID] = self.cert_ref
215 221
 
216 222
         self.repos.listener.create(self.session,
217 223
                                    **listener_dict)
@@ -224,30 +230,35 @@ class DriverAgentTest(base.OctaviaDBTestBase):
224 230
             self.sample_data.provider_listener1_dict)
225 231
         self.provider_listener_dict['allowed_cidrs'] = None
226 232
         self.provider_listener_dict[
227
-            'default_tls_container_ref'] = self.cert_ref
233
+            lib_consts.DEFAULT_TLS_CONTAINER_REF] = self.cert_ref
234
+        self.provider_listener_dict[
235
+            lib_consts.DEFAULT_TLS_CONTAINER_DATA] = self.tls_container_dict
228 236
         self.provider_listener_dict[
229
-            'default_tls_container_data'] = self.tls_container_dict
237
+            lib_consts.CLIENT_CA_TLS_CONTAINER_REF] = self.cert_ref
230 238
         self.provider_listener_dict[
231
-            'client_ca_tls_container_ref'] = self.cert_ref
232
-        self.provider_listener_dict['client_ca_tls_container_data'] = (
233
-            sample_certs.X509_CERT.decode('utf-8'))
234
-        self.provider_listener_dict['client_crl_container_ref'] = self.cert_ref
235
-        self.provider_listener_dict['client_crl_container_data'] = (
236
-            sample_certs.X509_CERT.decode('utf-8'))
239
+            lib_consts.CLIENT_CA_TLS_CONTAINER_DATA] = (
240
+                sample_certs.X509_CERT.decode('utf-8'))
237 241
         self.provider_listener_dict[
238
-            'sni_container_data'] = [self.tls_container_dict]
239
-        self.provider_listener_dict['sni_container_refs'] = [self.cert_ref]
242
+            lib_consts.CLIENT_CRL_CONTAINER_REF] = self.cert_ref
243
+        self.provider_listener_dict[
244
+            lib_consts.CLIENT_CRL_CONTAINER_DATA] = (
245
+                sample_certs.X509_CERT.decode('utf-8'))
246
+        self.provider_listener_dict[
247
+            lib_consts.SNI_CONTAINER_DATA] = [self.tls_container_dict]
248
+        self.provider_listener_dict[
249
+            lib_consts.SNI_CONTAINER_REFS] = [self.cert_ref]
240 250
 
241
-        self.provider_listener_dict['default_pool'] = self.provider_pool_dict
242 251
         self.provider_listener_dict[
243
-            'default_pool_id'] = self.sample_data.pool1_id
252
+            lib_consts.DEFAULT_POOL] = self.provider_pool_dict
253
+        self.provider_listener_dict[
254
+            lib_consts.DEFAULT_POOL_ID] = self.sample_data.pool1_id
244 255
 
245 256
         self.provider_listener_dict[lib_consts.L7POLICIES] = [
246 257
             self.sample_data.provider_l7policy1_dict]
247 258
 
248 259
         # ### Create L7 Policy
249 260
         l7policy_dict = copy.deepcopy(self.sample_data.test_l7policy1_dict)
250
-        del l7policy_dict['l7rules']
261
+        del l7policy_dict[lib_consts.L7RULES]
251 262
         self.repos.l7policy.create(self.session, **l7policy_dict)
252 263
 
253 264
         # ### Create L7 Rules

+ 3
- 0
octavia/tests/unit/api/drivers/test_utils.py View File

@@ -253,6 +253,9 @@ class TestUtils(base.TestCase):
253 253
         expect_prov['default_pool'] = expect_pool_prov
254 254
         provider_listener = utils.listener_dict_to_provider_dict(
255 255
             self.sample_data.test_listener1_dict)
256
+        # TODO(johnsom) Remove this once the listener ACLs patch merges
257
+        # https://review.opendev.org/#/c/659626/
258
+        del expect_prov['allowed_cidrs']
256 259
         self.assertEqual(expect_prov, provider_listener)
257 260
 
258 261
     @mock.patch('octavia.api.drivers.utils._get_secret_data')

Loading…
Cancel
Save