File: provider_base.py

package info (click to toggle)
python-octavia-lib 3.8.0-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 536 kB
  • sloc: python: 2,148; sh: 57; makefile: 23
file content (532 lines) | stat: -rw-r--r-- 24,798 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
# Copyright 2018 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 octavia_lib.api.drivers import exceptions

# This class describes the abstraction of a provider driver interface.
# Load balancing provider drivers will implement this interface.


class ProviderDriver():
    # name is for internal Octavia use and should not be used by drivers
    name = None

    # Load Balancer
    def create_vip_port(self, loadbalancer_id, project_id, vip_dictionary,
                        additional_vip_dicts):
        """Creates a port for a load balancer VIP.

        If the driver supports creating VIP ports, the driver will create a
        VIP port with the primary VIP and all additional VIPs added to the
        port, and return the vip_dictionary populated with the vip_port_id and
        a list of vip_dictionaries populated with data from the additional
        VIPs (which are guaranteed to be in the same Network).
        This might look like:
        {'port_id': port_id, 'subnet_id': subnet_id_1, 'ip_address': ip1},
        [{'subnet_id': subnet_id_2, 'ip_address': ip2}, {...}, {...}]
        If the driver does not support port creation, the driver will raise
        a NotImplementedError.

        :param loadbalancer_id: ID of loadbalancer.
        :type loadbalancer_id: string
        :param project_id: The project ID to create the VIP under.
        :type project_id: string
        :param: vip_dictionary: The VIP dictionary.
        :type vip_dictionary: dict
        :param: additional_vip_dicts: A list of additional VIP dictionaries,
                                      with subnets guaranteed to be in the same
                                      network as the primary vip_dictionary.
        :type additional_vip_dicts: list(dict)
        :returns: VIP dictionary with vip_port_id + a list of additional VIP
                  dictionaries (vip_dict, additional_vip_dicts).
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: The driver does not support creating VIP
                                     ports.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support creating VIP '
                              'ports.',
            operator_fault_string='This provider does not support creating '
                                  'VIP ports. Octavia will create it.')

    def loadbalancer_create(self, loadbalancer):
        """Creates a new load balancer.

        :param loadbalancer: The load balancer object.
        :type loadbalancer: object
        :return: Nothing if the create request was accepted.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: The driver does not support create.
        :raises UnsupportedOptionError: The driver does not
          support one of the configuration options.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support creating '
                              'load balancers.',
            operator_fault_string='This provider does not support creating '
                                  'load balancers. What?')

    def loadbalancer_delete(self, loadbalancer, cascade=False):
        """Deletes a load balancer.

        :param loadbalancer: The load balancer to delete.
        :type loadbalancer: object
        :param cascade: If True, deletes all child objects (listeners,
          pools, etc.) in addition to the load balancer.
        :type cascade: bool
        :return: Nothing if the delete request was accepted.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: if driver does not support request.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support deleting '
                              'load balancers.',
            operator_fault_string='This provider does not support deleting '
                                  'load balancers.')

    def loadbalancer_failover(self, loadbalancer_id):
        """Performs a fail over of a load balancer.

        :param loadbalancer_id: ID of the load balancer to failover.
        :type loadbalancer_id: string
        :return: Nothing if the failover request was accepted.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises: NotImplementedError if driver does not support request.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support failing over '
                              'load balancers.',
            operator_fault_string='This provider does not support failing '
                                  'over load balancers.')

    def loadbalancer_update(self, old_loadbalancer, new_loadbalancer):
        """Updates a load balancer.

        :param old_loadbalancer: The baseline load balancer object.
        :type old_loadbalancer: object
        :param new_loadbalancer: The updated load balancer object.
        :type new_loadbalancer: object
        :return: Nothing if the update request was accepted.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: The driver does not support request.
        :raises UnsupportedOptionError: The driver does not
          support one of the configuration options.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support updating '
                              'load balancers.',
            operator_fault_string='This provider does not support updating '
                                  'load balancers.')

    # Listener
    def listener_create(self, listener):
        """Creates a new listener.

        :param listener: The listener object.
        :type listener: object
        :return: Nothing if the create request was accepted.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: if driver does not support request.
        :raises UnsupportedOptionError: if driver does not
          support one of the configuration options.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support creating '
                              'listeners.',
            operator_fault_string='This provider does not support creating '
                                  'listeners.')

    def listener_delete(self, listener):
        """Deletes a listener.

        :param listener: The listener to delete.
        :type listener: object
        :return: Nothing if the delete request was accepted.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: if driver does not support request.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support deleting '
                              'listeners.',
            operator_fault_string='This provider does not support deleting '
                                  'listeners.')

    def listener_update(self, old_listener, new_listener):
        """Updates a listener.

        :param old_listener: The baseline listener object.
        :type old_listener: object
        :param new_listener: The updated listener object.
        :type new_listener: object
        :return: Nothing if the update request was accepted.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: if driver does not support request.
        :raises UnsupportedOptionError: if driver does not
          support one of the configuration options.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support updating '
                              'listeners.',
            operator_fault_string='This provider does not support updating '
                                  'listeners.')

    # Pool
    def pool_create(self, pool):
        """Creates a new pool.

        :param pool: The pool object.
        :type pool: object
        :return: Nothing if the create request was accepted.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: if driver does not support request.
        :raises UnsupportedOptionError: if driver does not
          support one of the configuration options.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support creating '
                              'pools.',
            operator_fault_string='This provider does not support creating '
                                  'pools.')

    def pool_delete(self, pool):
        """Deletes a pool and its members.

        :param pool: The pool to delete.
        :type pool: object
        :return: Nothing if the create request was accepted.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: if driver does not support request.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support deleting '
                              'pools.',
            operator_fault_string='This provider does not support deleting '
                                  'pools.')

    def pool_update(self, old_pool, new_pool):
        """Updates a pool.

        :param pool: The baseline pool object.
        :type pool: object
        :param pool: The updated pool object.
        :type pool: object
        :return: Nothing if the create request was accepted.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: if driver does not support request.
        :raises UnsupportedOptionError: if driver does not
          support one of the configuration options.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support updating '
                              'pools.',
            operator_fault_string='This provider does not support updating '
                                  'pools.')

    # Member
    def member_create(self, member):
        """Creates a new member for a pool.

        :param member: The member object.
        :type member: object
        :return: Nothing if the create request was accepted.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: if driver does not support request.
        :raises UnsupportedOptionError: if driver does not
          support one of the configuration options.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support creating '
                              'members.',
            operator_fault_string='This provider does not support creating '
                                  'members.')

    def member_delete(self, member):
        """Deletes a pool member.

        :param member: The member to delete.
        :type member: object
        :return: Nothing if the create request was accepted.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: if driver does not support request.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support deleting '
                              'members.',
            operator_fault_string='This provider does not support deleting '
                                  'members.')

    def member_update(self, old_member, new_member):
        """Updates a pool member.

        :param old_member: The baseline member object.
        :type old_member: object
        :param new_member: The updated member object.
        :type new_member: object
        :return: Nothing if the create request was accepted.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: if driver does not support request.
        :raises UnsupportedOptionError: if driver does not
          support one of the configuration options.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support updating '
                              'members.',
            operator_fault_string='This provider does not support updating '
                                  'members.')

    def member_batch_update(self, pool_id, members):
        """Creates, updates, or deletes a set of pool members.

        :param pool_id: The id of the pool to update.
        :type pool_id: string
        :param members: List of member objects.
        :type members: list
        :return: Nothing if the create request was accepted.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: if driver does not support request.
        :raises UnsupportedOptionError: if driver does not
          support one of the configuration options.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support batch '
                              'updating members.',
            operator_fault_string='This provider does not support batch '
                                  'updating members.')

    # Health Monitor
    def health_monitor_create(self, healthmonitor):
        """Creates a new health monitor.

        :param healthmonitor: The health monitor object.
        :type healthmonitor: object
        :return: Nothing if the create request was accepted.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: if driver does not support request.
        :raises UnsupportedOptionError: if driver does not
          support one of the configuration options.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support creating '
                              'health monitors.',
            operator_fault_string='This provider does not support creating '
                                  'health monitors.')

    def health_monitor_delete(self, healthmonitor):
        """Deletes a healthmonitor_id.

        :param healthmonitor: The monitor to delete.
        :type healthmonitor: object
        :return: Nothing if the create request was accepted.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: if driver does not support request.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support deleting '
                              'health monitors.',
            operator_fault_string='This provider does not support deleting '
                                  'health monitors.')

    def health_monitor_update(self, old_healthmonitor, new_healthmonitor):
        """Updates a health monitor.

        :param old_healthmonitor: The baseline health monitor object.
        :type old_healthmonitor: object
        :param new_healthmonitor: The updated health monitor object.
        :type new_healthmonitor: object
        :return: Nothing if the create request was accepted.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: if driver does not support request.
        :raises UnsupportedOptionError: if driver does not
          support one of the configuration options.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support updating '
                              'health monitors.',
            operator_fault_string='This provider does not support updating '
                                  'health monitors.')

    # L7 Policy
    def l7policy_create(self, l7policy):
        """Creates a new L7 policy.

        :param l7policy: The L7 policy object.
        :type l7policy: object
        :return: Nothing if the create request was accepted.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: if driver does not support request.
        :raises UnsupportedOptionError: if driver does not
          support one of the configuration options.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support creating '
                              'l7policies.',
            operator_fault_string='This provider does not support creating '
                                  'l7policies.')

    def l7policy_delete(self, l7policy):
        """Deletes an L7 policy.

        :param l7policy: The L7 policy to delete.
        :type l7policy: object
        :return: Nothing if the delete request was accepted.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: if driver does not support request.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support deleting '
                              'l7policies.',
            operator_fault_string='This provider does not support deleting '
                                  'l7policies.')

    def l7policy_update(self, old_l7policy, new_l7policy):
        """Updates an L7 policy.

        :param old_l7policy: The baseline L7 policy object.
        :type old_l7policy: object
        :param new_l7policy: The updated L7 policy object.
        :type new_l7policy: object
        :return: Nothing if the update request was accepted.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: if driver does not support request.
        :raises UnsupportedOptionError: if driver does not
          support one of the configuration options.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support updating '
                              'l7policies.',
            operator_fault_string='This provider does not support updating '
                                  'l7policies.')

    # L7 Rule
    def l7rule_create(self, l7rule):
        """Creates a new L7 rule.

        :param l7rule: The L7 rule object.
        :type l7rule: object
        :return: Nothing if the create request was accepted.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: if driver does not support request.
        :raises UnsupportedOptionError: if driver does not
          support one of the configuration options.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support creating '
                              'l7rules.',
            operator_fault_string='This provider does not support creating '
                                  'l7rules.')

    def l7rule_delete(self, l7rule):
        """Deletes an L7 rule.

        :param l7rule: The L7 rule to delete.
        :type l7rule: object
        :return: Nothing if the delete request was accepted.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: if driver does not support request.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support deleting '
                              'l7rules.',
            operator_fault_string='This provider does not support deleting '
                                  'l7rules.')

    def l7rule_update(self, old_l7rule, new_l7rule):
        """Updates an L7 rule.

        :param old_l7rule: The baseline L7 rule object.
        :type old_l7rule: object
        :param new_l7rule: The updated L7 rule object.
        :type new_l7rule: object
        :return: Nothing if the update request was accepted.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: if driver does not support request.
        :raises UnsupportedOptionError: if driver does not
          support one of the configuration options.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support updating '
                              'l7rules.',
            operator_fault_string='This provider does not support updating '
                                  'l7rules.')

    # Flavor
    def get_supported_flavor_metadata(self):
        """Returns a dict of flavor metadata keys supported by this driver.

        The returned dictionary will include key/value pairs, 'name' and
        'description.'

        :returns: The flavor metadata dictionary
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: The driver does not support flavors.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support getting the '
                              'supported flavor metadata.',
            operator_fault_string='This provider does not support getting '
                                  'the supported flavor metadata.')

    def validate_flavor(self, flavor_metadata):
        """Validates if driver can support the flavor.

        :param flavor_metadata: Dictionary with flavor metadata.
        :type flavor_metadata: dict
        :return: Nothing if the flavor is valid and supported.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: The driver does not support flavors.
        :raises UnsupportedOptionError: if driver does not
          support one of the configuration options.
        :raises octavia_lib.api.drivers.exceptions.NotFound: if the driver
          cannot find a resource.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support validating '
                              'flavors.',
            operator_fault_string='This provider does not support validating '
                                  'the supported flavor metadata.')

    # Availability Zone
    def get_supported_availability_zone_metadata(self):
        """Returns a dict of supported availability zone metadata keys.

        The returned dictionary will include key/value pairs, 'name' and
        'description.'

        :returns: The availability zone metadata dictionary
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: The driver does not support AZs.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support getting the '
                              'supported availability zone metadata.',
            operator_fault_string='This provider does not support getting '
                                  'the supported availability zone metadata.')

    def validate_availability_zone(self, availability_zone_metadata):
        """Validates if driver can support the availability zone.

        :param availability_zone_metadata: Dictionary with az metadata.
        :type availability_zone_metadata: dict
        :return: Nothing if the availability zone is valid and supported.
        :raises DriverError: An unexpected error occurred in the driver.
        :raises NotImplementedError: The driver does not support availability
          zones.
        :raises UnsupportedOptionError: if driver does not
          support one of the configuration options.
        """
        raise exceptions.NotImplementedError(
            user_fault_string='This provider does not support validating '
                              'availability zones.',
            operator_fault_string='This provider does not support validating '
                                  'the supported availability zone metadata.')