/
_proxy.py
1007 lines (802 loc) · 40.9 KB
/
_proxy.py
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
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from openstack.load_balancer.v2 import amphora as _amphora
from openstack.load_balancer.v2 import flavor as _flavor
from openstack.load_balancer.v2 import flavor_profile as _flavor_profile
from openstack.load_balancer.v2 import health_monitor as _hm
from openstack.load_balancer.v2 import l7_policy as _l7policy
from openstack.load_balancer.v2 import l7_rule as _l7rule
from openstack.load_balancer.v2 import listener as _listener
from openstack.load_balancer.v2 import load_balancer as _lb
from openstack.load_balancer.v2 import member as _member
from openstack.load_balancer.v2 import pool as _pool
from openstack.load_balancer.v2 import provider as _provider
from openstack.load_balancer.v2 import quota as _quota
from openstack import proxy
from openstack import resource
class Proxy(proxy.Proxy):
def create_load_balancer(self, **attrs):
"""Create a new load balancer from attributes
:param dict attrs: Keyword arguments which will be used to create
a :class:`~openstack.load_balancer.v2.
load_balancer.LoadBalancer`,
comprised of the properties on the
LoadBalancer class.
:returns: The results of load balancer creation
:rtype: :class:`~openstack.load_balancer.v2.load_balancer.LoadBalancer`
"""
return self._create(_lb.LoadBalancer, **attrs)
def get_load_balancer(self, *attrs):
"""Get a load balancer
:param load_balancer: The value can be the name of a load balancer
or :class:`~openstack.load_balancer.v2.load_balancer.LoadBalancer`
instance.
:returns: One
:class:`~openstack.load_balancer.v2.load_balancer.LoadBalancer`
"""
return self._get(_lb.LoadBalancer, *attrs)
def get_load_balancer_statistics(self, name_or_id):
"""Get the load balancer statistics
:param name_or_id: The name or ID of a load balancer
:returns: One :class:`~openstack.load_balancer.v2.load_balancer.
LoadBalancerStats`
"""
return self._get(_lb.LoadBalancerStats, lb_id=name_or_id,
requires_id=False)
def load_balancers(self, **query):
"""Retrieve a generator of load balancers
:returns: A generator of load balancer instances
"""
return self._list(_lb.LoadBalancer, **query)
def delete_load_balancer(self, load_balancer, ignore_missing=True,
cascade=False):
"""Delete a load balancer
:param load_balancer: The load_balancer can be either the name or a
:class:`~openstack.load_balancer.v2.load_balancer.LoadBalancer`
instance
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be raised when
the load balancer does not exist.
When set to ``True``, no exception will be set when attempting to
delete a nonexistent load balancer.
:param bool cascade: If true will delete all child objects of
the load balancer.
:returns: ``None``
"""
load_balancer = self._get_resource(_lb.LoadBalancer, load_balancer)
load_balancer.cascade = cascade
return self._delete(_lb.LoadBalancer, load_balancer,
ignore_missing=ignore_missing)
def find_load_balancer(self, name_or_id, ignore_missing=True):
"""Find a single load balancer
:param name_or_id: The name or ID of a load balancer
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be raised
when the load balancer does not exist.
When set to ``True``, no exception will be set when attempting
to delete a nonexistent load balancer.
:returns: ``None``
"""
return self._find(_lb.LoadBalancer, name_or_id,
ignore_missing=ignore_missing)
def update_load_balancer(self, load_balancer, **attrs):
"""Update a load balancer
:param load_balancer: The load_balancer can be either the name or a
:class:`~openstack.load_balancer.v2.load_balancer.LoadBalancer`
instance
:param dict attrs: The attributes to update on the load balancer
represented by ``load_balancer``.
:returns: The updated load_balancer
:rtype: :class:`~openstack.load_balancer.v2.load_balancer.LoadBalancer`
"""
return self._update(_lb.LoadBalancer, load_balancer, **attrs)
def wait_for_load_balancer(self, name_or_id, status='ACTIVE',
failures=['ERROR'], interval=2, wait=300):
lb = self._find(_lb.LoadBalancer, name_or_id, ignore_missing=False)
return resource.wait_for_status(self, lb, status, failures, interval,
wait, attribute='provisioning_status')
def failover_load_balancer(self, name_or_id, **attrs):
"""Failover a load balancer
:param name_or_id: The name or ID of a load balancer
:returns: ``None``
"""
return self._update(_lb.LoadBalancerFailover, lb_id=name_or_id)
def create_listener(self, **attrs):
"""Create a new listener from attributes
:param dict attrs: Keyword arguments which will be used to create a
:class:`~openstack.load_balancer.v2.listener.Listener`,
comprised of the properties on the Listener class.
:returns: The results of listener creation
:rtype: :class:`~openstack.load_balancer.v2.listener.Listener`
"""
return self._create(_listener.Listener, **attrs)
def delete_listener(self, listener, ignore_missing=True):
"""Delete a listener
:param listener: The value can be either the ID of a listner or a
:class:`~openstack.load_balancer.v2.listener.Listener` instance.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the listner does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent listener.
:returns: ``None``
"""
self._delete(_listener.Listener, listener,
ignore_missing=ignore_missing)
def find_listener(self, name_or_id, ignore_missing=True):
"""Find a single listener
:param name_or_id: The name or ID of a listener.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the resource does not exist.
When set to ``True``, None will be returned when
attempting to find a nonexistent resource.
:returns: One :class:`~openstack.load_balancer.v2.listener.Listener`
or None
"""
return self._find(_listener.Listener, name_or_id,
ignore_missing=ignore_missing)
def get_listener(self, listener):
"""Get a single listener
:param listener: The value can be the ID of a listener or a
:class:`~openstack.load_balancer.v2.listener.Listener`
instance.
:returns: One :class:`~openstack.load_balancer.v2.listener.Listener`
:raises: :class:`~openstack.exceptions.ResourceNotFound`
when no resource can be found.
"""
return self._get(_listener.Listener, listener)
def get_listener_statistics(self, listener):
"""Get the listener statistics
:param listener: The value can be the ID of a listener or a
:class:`~openstack.load_balancer.v2.listener.Listener`
instance.
:returns: One :class:`~openstack.load_balancer.v2.listener.
ListenerStats`
:raises: :class:`~openstack.exceptions.ResourceNotFound`
when no resource can be found.
"""
return self._get(_listener.ListenerStats, listener_id=listener,
requires_id=False)
def listeners(self, **query):
"""Return a generator of listeners
:param dict query: Optional query parameters to be sent to limit
the resources being returned. Valid parameters are:
:returns: A generator of listener objects
:rtype: :class:`~openstack.load_balancer.v2.listener.Listener`
"""
return self._list(_listener.Listener, **query)
def update_listener(self, listener, **attrs):
"""Update a listener
:param listener: Either the id of a listener or a
:class:`~openstack.load_balancer.v2.listener.Listener`
instance.
:param dict attrs: The attributes to update on the listener
represented by ``listener``.
:returns: The updated listener
:rtype: :class:`~openstack.load_balancer.v2.listener.Listener`
"""
return self._update(_listener.Listener, listener, **attrs)
def create_pool(self, **attrs):
"""Create a new pool from attributes
:param dict attrs: Keyword arguments which will be used to create
a :class:`~openstack.load_balancer.v2.
pool.Pool`,
comprised of the properties on the
Pool class.
:returns: The results of Pool creation
:rtype: :class:`~openstack.load_balancer.v2.pool.Pool`
"""
return self._create(_pool.Pool, **attrs)
def get_pool(self, *attrs):
"""Get a pool
:param pool: Value is
:class:`~openstack.load_balancer.v2.pool.Pool`
instance.
:returns: One
:class:`~openstack.load_balancer.v2.pool.Pool`
"""
return self._get(_pool.Pool, *attrs)
def pools(self, **query):
"""Retrieve a generator of pools
:returns: A generator of Pool instances
"""
return self._list(_pool.Pool, **query)
def delete_pool(self, pool, ignore_missing=True):
"""Delete a pool
:param pool: The pool is a
:class:`~openstack.load_balancer.v2.pool.Pool`
instance
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be raised when
the pool does not exist.
When set to ``True``, no exception will be set when attempting to
delete a nonexistent pool.
:returns: ``None``
"""
return self._delete(_pool.Pool, pool,
ignore_missing=ignore_missing)
def find_pool(self, name_or_id, ignore_missing=True):
"""Find a single pool
:param name_or_id: The name or ID of a pool
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be raised
when the pool does not exist.
When set to ``True``, no exception will be set when attempting
to delete a nonexistent pool.
:returns: ``None``
"""
return self._find(_pool.Pool, name_or_id,
ignore_missing=ignore_missing)
def update_pool(self, pool, **attrs):
"""Update a pool
:param pool: Either the id of a pool or a
:class:`~openstack.load_balancer.v2.pool.Pool`
instance.
:param dict attrs: The attributes to update on the pool
represented by ``pool``.
:returns: The updated pool
:rtype: :class:`~openstack.load_balancer.v2.pool.Pool`
"""
return self._update(_pool.Pool, pool, **attrs)
def create_member(self, pool, **attrs):
"""Create a new member from attributes
:param pool: The pool can be either the ID of a pool or a
:class:`~openstack.load_balancer.v2.pool.Pool` instance
that the member will be created in.
:param dict attrs: Keyword arguments which will be used to create
a :class:`~openstack.load_balancer.v2.member.Member`,
comprised of the properties on the Member class.
:returns: The results of member creation
:rtype: :class:`~openstack.load_balancer.v2.member.Member`
"""
poolobj = self._get_resource(_pool.Pool, pool)
return self._create(_member.Member, pool_id=poolobj.id,
**attrs)
def delete_member(self, member, pool, ignore_missing=True):
"""Delete a member
:param member:
The member can be either the ID of a member or a
:class:`~openstack.load_balancer.v2.member.Member` instance.
:param pool: The pool can be either the ID of a pool or a
:class:`~openstack.load_balancer.v2.pool.Pool` instance
that the member belongs to.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the member does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent member.
:returns: ``None``
"""
poolobj = self._get_resource(_pool.Pool, pool)
self._delete(_member.Member, member,
ignore_missing=ignore_missing, pool_id=poolobj.id)
def find_member(self, name_or_id, pool, ignore_missing=True):
"""Find a single member
:param str name_or_id: The name or ID of a member.
:param pool: The pool can be either the ID of a pool or a
:class:`~openstack.load_balancer.v2.pool.Pool` instance
that the member belongs to.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the resource does not exist.
When set to ``True``, None will be returned when
attempting to find a nonexistent resource.
:returns: One :class:`~openstack.load_balancer.v2.member.Member`
or None
"""
poolobj = self._get_resource(_pool.Pool, pool)
return self._find(_member.Member, name_or_id,
ignore_missing=ignore_missing, pool_id=poolobj.id)
def get_member(self, member, pool):
"""Get a single member
:param member: The member can be the ID of a member or a
:class:`~openstack.load_balancer.v2.member.Member`
instance.
:param pool: The pool can be either the ID of a pool or a
:class:`~openstack.load_balancer.v2.pool.Pool` instance
that the member belongs to.
:returns: One :class:`~openstack.load_balancer.v2.member.Member`
:raises: :class:`~openstack.exceptions.ResourceNotFound`
when no resource can be found.
"""
poolobj = self._get_resource(_pool.Pool, pool)
return self._get(_member.Member, member,
pool_id=poolobj.id)
def members(self, pool, **query):
"""Return a generator of members
:param pool: The pool can be either the ID of a pool or a
:class:`~openstack.load_balancer.v2.pool.Pool` instance
that the member belongs to.
:param dict query: Optional query parameters to be sent to limit
the resources being returned. Valid parameters are:
:returns: A generator of member objects
:rtype: :class:`~openstack.load_balancer.v2.member.Member`
"""
poolobj = self._get_resource(_pool.Pool, pool)
return self._list(_member.Member, pool_id=poolobj.id, **query)
def update_member(self, member, pool, **attrs):
"""Update a member
:param member: Either the ID of a member or a
:class:`~openstack.load_balancer.v2.member.Member`
instance.
:param pool: The pool can be either the ID of a pool or a
:class:`~openstack.load_balancer.v2.pool.Pool` instance
that the member belongs to.
:param dict attrs: The attributes to update on the member
represented by ``member``.
:returns: The updated member
:rtype: :class:`~openstack.load_balancer.v2.member.Member`
"""
poolobj = self._get_resource(_pool.Pool, pool)
return self._update(_member.Member, member,
pool_id=poolobj.id, **attrs)
def find_health_monitor(self, name_or_id, ignore_missing=True):
"""Find a single health monitor
:param name_or_id: The name or ID of a health monitor
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be raised
when the health monitor does not exist.
When set to ``True``, no exception will be set when attempting
to find a nonexistent health monitor.
:returns: The
:class:`openstack.load_balancer.v2.healthmonitor.HealthMonitor`
object matching the given name or id or None if nothing matches.
:raises: :class:`openstack.exceptions.DuplicateResource` if more
than one resource is found for this request.
:raises: :class:`openstack.exceptions.ResourceNotFound` if nothing
is found and ignore_missing is ``False``.
"""
return self._find(_hm.HealthMonitor, name_or_id,
ignore_missing=ignore_missing)
def create_health_monitor(self, **attrs):
"""Create a new health monitor from attributes
:param dict attrs: Keyword arguments which will be used to create
a :class:`~openstack.load_balancer.v2.
healthmonitor.HealthMonitor`,
comprised of the properties on the
HealthMonitor class.
:returns: The results of HealthMonitor creation
:rtype: :class:`~openstack.load_balancer.v2.
healthmonitor.HealthMonitor`
"""
return self._create(_hm.HealthMonitor, **attrs)
def get_health_monitor(self, healthmonitor):
"""Get a health monitor
:param healthmonitor: The value can be the ID of a health monitor or
:class:`~openstack.load_balancer.v2.healthmonitor.HealthMonitor`
instance.
:returns: One health monitor
:rtype: :class:`~openstack.load_balancer.v2.
healthmonitor.HealthMonitor`
"""
return self._get(_hm.HealthMonitor, healthmonitor)
def health_monitors(self, **query):
"""Retrieve a generator of health monitors
:param dict query: Optional query parameters to be sent to limit
the resources being returned. Valid parameters are:
'name', 'created_at', 'updated_at', 'delay',
'expected_codes', 'http_method', 'max_retries',
'max_retries_down', 'pool_id',
'provisioning_status', 'operating_status',
'timeout', 'project_id', 'type', 'url_path',
'is_admin_state_up'.
:returns: A generator of health monitor instances
"""
return self._list(_hm.HealthMonitor, **query)
def delete_health_monitor(self, healthmonitor, ignore_missing=True):
"""Delete a health monitor
:param healthmonitor: The healthmonitor can be either the ID of the
health monitor or a
:class:`~openstack.load_balancer.v2.healthmonitor.HealthMonitor`
instance
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be raised when
the healthmonitor does not exist.
When set to ``True``, no exception will be set when attempting to
delete a nonexistent healthmonitor.
:returns: ``None``
"""
return self._delete(_hm.HealthMonitor, healthmonitor,
ignore_missing=ignore_missing)
def update_health_monitor(self, healthmonitor, **attrs):
"""Update a health monitor
:param healthmonitor: The healthmonitor can be either the ID of the
health monitor or a
:class:`~openstack.load_balancer.v2.healthmonitor.HealthMonitor`
instance
:param dict attrs: The attributes to update on the health monitor
represented by ``healthmonitor``.
:returns: The updated health monitor
:rtype: :class:`~openstack.load_balancer.v2.
healthmonitor.HealthMonitor`
"""
return self._update(_hm.HealthMonitor, healthmonitor,
**attrs)
def create_l7_policy(self, **attrs):
"""Create a new l7policy from attributes
:param dict attrs: Keyword arguments which will be used to create a
:class:`~openstack.load_balancer.v2.l7_policy.L7Policy`,
comprised of the properties on the L7Policy class.
:returns: The results of l7policy creation
:rtype: :class:`~openstack.load_balancer.v2.l7_policy.L7Policy`
"""
return self._create(_l7policy.L7Policy, **attrs)
def delete_l7_policy(self, l7_policy, ignore_missing=True):
"""Delete a l7policy
:param l7_policy: The value can be either the ID of a l7policy or a
:class:`~openstack.load_balancer.v2.l7_policy.L7Policy` instance.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the l7policy does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent l7policy.
:returns: ``None``
"""
self._delete(_l7policy.L7Policy, l7_policy,
ignore_missing=ignore_missing)
def find_l7_policy(self, name_or_id, ignore_missing=True):
"""Find a single l7policy
:param name_or_id: The name or ID of a l7policy.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the resource does not exist.
When set to ``True``, None will be returned when
attempting to find a nonexistent resource.
:returns: One :class:`~openstack.load_balancer.v2.l7_policy.L7Policy`
or None
"""
return self._find(_l7policy.L7Policy, name_or_id,
ignore_missing=ignore_missing)
def get_l7_policy(self, l7_policy):
"""Get a single l7policy
:param l7_policy: The value can be the ID of a l7policy or a
:class:`~openstack.load_balancer.v2.l7_policy.L7Policy`
instance.
:returns: One :class:`~openstack.load_balancer.v2.l7_policy.L7Policy`
:raises: :class:`~openstack.exceptions.ResourceNotFound`
when no resource can be found.
"""
return self._get(_l7policy.L7Policy, l7_policy)
def l7_policies(self, **query):
"""Return a generator of l7policies
:param dict query: Optional query parameters to be sent to limit
the resources being returned. Valid parameters are:
:returns: A generator of l7policy objects
:rtype: :class:`~openstack.load_balancer.v2.l7_policy.L7Policy`
"""
return self._list(_l7policy.L7Policy, **query)
def update_l7_policy(self, l7_policy, **attrs):
"""Update a l7policy
:param l7_policy: Either the id of a l7policy or a
:class:`~openstack.load_balancer.v2.l7_policy.L7Policy`
instance.
:param dict attrs: The attributes to update on the l7policy
represented by ``l7policy``.
:returns: The updated l7policy
:rtype: :class:`~openstack.load_balancer.v2.l7_policy.L7Policy`
"""
return self._update(_l7policy.L7Policy, l7_policy, **attrs)
def create_l7_rule(self, l7_policy, **attrs):
"""Create a new l7rule from attributes
:param l7_policy: The l7_policy can be either the ID of a l7policy or
:class:`~openstack.load_balancer.v2.l7_policy.L7Policy`
instance that the l7rule will be created in.
:param dict attrs: Keyword arguments which will be used to create
a :class:`~openstack.load_balancer.v2.l7_rule.L7Rule`,
comprised of the properties on the L7Rule class.
:returns: The results of l7rule creation
:rtype: :class:`~openstack.load_balancer.v2.l7_rule.L7Rule`
"""
l7policyobj = self._get_resource(_l7policy.L7Policy, l7_policy)
return self._create(_l7rule.L7Rule, l7policy_id=l7policyobj.id,
**attrs)
def delete_l7_rule(self, l7rule, l7_policy, ignore_missing=True):
"""Delete a l7rule
:param l7rule:
The l7rule can be either the ID of a l7rule or a
:class:`~openstack.load_balancer.v2.l7_rule.L7Rule` instance.
:param l7_policy: The l7_policy can be either the ID of a l7policy or
:class:`~openstack.load_balancer.v2.l7_policy.L7Policy`
instance that the l7rule belongs to.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the l7rule does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent l7rule.
:returns: ``None``
"""
l7policyobj = self._get_resource(_l7policy.L7Policy, l7_policy)
self._delete(_l7rule.L7Rule, l7rule, ignore_missing=ignore_missing,
l7policy_id=l7policyobj.id)
def find_l7_rule(self, name_or_id, l7_policy, ignore_missing=True):
"""Find a single l7rule
:param str name_or_id: The name or ID of a l7rule.
:param l7_policy: The l7_policy can be either the ID of a l7policy or
:class:`~openstack.load_balancer.v2.l7_policy.L7Policy`
instance that the l7rule belongs to.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the resource does not exist.
When set to ``True``, None will be returned when
attempting to find a nonexistent resource.
:returns: One :class:`~openstack.load_balancer.v2.l7_rule.L7Rule`
or None
"""
l7policyobj = self._get_resource(_l7policy.L7Policy, l7_policy)
return self._find(_l7rule.L7Rule, name_or_id,
ignore_missing=ignore_missing,
l7policy_id=l7policyobj.id)
def get_l7_rule(self, l7rule, l7_policy):
"""Get a single l7rule
:param l7rule: The l7rule can be the ID of a l7rule or a
:class:`~openstack.load_balancer.v2.l7_rule.L7Rule`
instance.
:param l7_policy: The l7_policy can be either the ID of a l7policy or
:class:`~openstack.load_balancer.v2.l7_policy.L7Policy`
instance that the l7rule belongs to.
:returns: One :class:`~openstack.load_balancer.v2.l7_rule.L7Rule`
:raises: :class:`~openstack.exceptions.ResourceNotFound`
when no resource can be found.
"""
l7policyobj = self._get_resource(_l7policy.L7Policy, l7_policy)
return self._get(_l7rule.L7Rule, l7rule,
l7policy_id=l7policyobj.id)
def l7_rules(self, l7_policy, **query):
"""Return a generator of l7rules
:param l7_policy: The l7_policy can be either the ID of a l7_policy or
:class:`~openstack.load_balancer.v2.l7_policy.L7Policy`
instance that the l7rule belongs to.
:param dict query: Optional query parameters to be sent to limit
the resources being returned. Valid parameters are:
:returns: A generator of l7rule objects
:rtype: :class:`~openstack.load_balancer.v2.l7_rule.L7Rule`
"""
l7policyobj = self._get_resource(_l7policy.L7Policy, l7_policy)
return self._list(_l7rule.L7Rule, l7policy_id=l7policyobj.id, **query)
def update_l7_rule(self, l7rule, l7_policy, **attrs):
"""Update a l7rule
:param l7rule: Either the ID of a l7rule or a
:class:`~openstack.load_balancer.v2.l7_rule.L7Rule`
instance.
:param l7_policy: The l7_policy can be either the ID of a l7policy or
:class:`~openstack.load_balancer.v2.l7_policy.L7Policy`
instance that the l7rule belongs to.
:param dict attrs: The attributes to update on the l7rule
represented by ``l7rule``.
:returns: The updated l7rule
:rtype: :class:`~openstack.load_balancer.v2.l7_rule.L7Rule`
"""
l7policyobj = self._get_resource(_l7policy.L7Policy, l7_policy)
return self._update(_l7rule.L7Rule, l7rule,
l7policy_id=l7policyobj.id, **attrs)
def quotas(self, **query):
"""Return a generator of quotas
:param dict query: Optional query parameters to be sent to limit
the resources being returned. Currently no query
parameter is supported.
:returns: A generator of quota objects
:rtype: :class:`~openstack.load_balancer.v2.quota.Quota`
"""
return self._list(_quota.Quota, **query)
def get_quota(self, quota):
"""Get a quota
:param quota: The value can be the ID of a quota or a
:class:`~openstack.load_balancer.v2.quota.Quota`
instance. The ID of a quota is the same as the project
ID for the quota.
:returns: One :class:`~openstack.load_balancer.v2.quota.Quota`
:raises: :class:`~openstack.exceptions.ResourceNotFound`
when no resource can be found.
"""
return self._get(_quota.Quota, quota)
def update_quota(self, quota, **attrs):
"""Update a quota
:param quota: Either the ID of a quota or a
:class:`~openstack.load_balancer.v2.quota.Quota`
instance. The ID of a quota is the same as the
project ID for the quota.
:param dict attrs: The attributes to update on the quota represented
by ``quota``.
:returns: The updated quota
:rtype: :class:`~openstack.load_balancer.v2.quota.Quota`
"""
return self._update(_quota.Quota, quota, **attrs)
def get_quota_default(self):
"""Get a default quota
:returns: One :class:`~openstack.load_balancer.v2.quota.QuotaDefault`
"""
return self._get(_quota.QuotaDefault, requires_id=False)
def delete_quota(self, quota, ignore_missing=True):
"""Delete a quota (i.e. reset to the default quota)
:param quota: The value can be either the ID of a quota or a
:class:`~openstack.load_balancer.v2.quota.Quota`
instance. The ID of a quota is the same as the
project ID for the quota.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when quota does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent quota.
:returns: ``None``
"""
self._delete(_quota.Quota, quota, ignore_missing=ignore_missing)
def providers(self, **query):
"""Retrieve a generator of providers
:returns: A generator of providers instances
"""
return self._list(_provider.Provider, **query)
def provider_flavor_capabilities(self, provider, **query):
"""Retrieve a generator of provider flavor capabilities
:returns: A generator of provider flavor capabilities instances
"""
return self._list(_provider.ProviderFlavorCapabilities,
provider=provider, **query)
def create_flavor_profile(self, **attrs):
"""Create a new flavor profile from attributes
:param dict attrs: Keyword arguments which will be used to create
a :class:`~openstack.load_balancer.v2.
flavor_profile.FlavorProfile`,
comprised of the properties on the
FlavorProfile class.
:returns: The results of profile creation creation
:rtype: :class:`~openstack.load_balancer.v2.flavor_profile.
FlavorProfile`
"""
return self._create(_flavor_profile.FlavorProfile, **attrs)
def get_flavor_profile(self, *attrs):
"""Get a flavor profile
:param flavor_profile: The value can be the name of a flavor profile
or :class:`~openstack.load_balancer.v2.flavor_profile.
FlavorProfile` instance.
:returns: One
:class:`~openstack.load_balancer.v2.flavor_profile.FlavorProfile`
"""
return self._get(_flavor_profile.FlavorProfile, *attrs)
def flavor_profiles(self, **query):
"""Retrieve a generator of flavor profiles
:returns: A generator of flavor profiles instances
"""
return self._list(_flavor_profile.FlavorProfile, **query)
def delete_flavor_profile(self, flavor_profile, ignore_missing=True):
"""Delete a flavor profile
:param flavor_profile: The flavor_profile can be either the name or a
:class:`~openstack.load_balancer.v2.flavor_profile.FlavorProfile`
instance
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be raised when
the flavor profile does not exist.
When set to ``True``, no exception will be set when attempting to
delete a nonexistent flavor profile.
:returns: ``None``
"""
self._delete(_flavor_profile.FlavorProfile, flavor_profile,
ignore_missing=ignore_missing)
def find_flavor_profile(self, name_or_id, ignore_missing=True):
"""Find a single flavor profile
:param name_or_id: The name or ID of a flavor profile
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be raised
when the flavor profile does not exist.
When set to ``True``, no exception will be set when attempting
to delete a nonexistent flavor profile.
:returns: ``None``
"""
return self._find(_flavor_profile.FlavorProfile, name_or_id,
ignore_missing=ignore_missing)
def update_flavor_profile(self, flavor_profile, **attrs):
"""Update a flavor profile
:param flavor_profile: The flavor_profile can be either the name or a
:class:`~openstack.load_balancer.v2.flavor_profile.FlavorProfile`
instance
:param dict attrs: The attributes to update on the flavor profile
represented by ``flavor_profile``.
:returns: The updated flavor profile
:rtype: :class:`~openstack.load_balancer.v2.flavor_profile.
FlavorProfile`
"""
return self._update(_flavor_profile.FlavorProfile, flavor_profile,
**attrs)
def create_flavor(self, **attrs):
"""Create a new flavor from attributes
:param dict attrs: Keyword arguments which will be used to create
a :class:`~openstack.load_balancer.v2.
flavor.Flavor`, comprised of the properties on the
Flavorclass.
:returns: The results of flavor creation creation
:rtype: :class:`~openstack.load_balancer.v2.flavor.Flavor`
"""
return self._create(_flavor.Flavor, **attrs)
def get_flavor(self, *attrs):
"""Get a flavor
:param flavor: The value can be the name of a flavor
or :class:`~openstack.load_balancer.v2.flavor.Flavor` instance.
:returns: One
:class:`~openstack.load_balancer.v2.flavor.Flavor`
"""
return self._get(_flavor.Flavor, *attrs)
def flavors(self, **query):
"""Retrieve a generator of flavors
:returns: A generator of flavor instances
"""
return self._list(_flavor.Flavor, **query)
def delete_flavor(self, flavor, ignore_missing=True):
"""Delete a flavor
:param flavor: The flavorcan be either the name or a
:class:`~openstack.load_balancer.v2.flavor.Flavor` instance
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be raised when
the flavor does not exist.
When set to ``True``, no exception will be set when attempting to
delete a nonexistent flavor.
:returns: ``None``
"""
self._delete(_flavor.Flavor, flavor, ignore_missing=ignore_missing)
def find_flavor(self, name_or_id, ignore_missing=True):
"""Find a single flavor
:param name_or_id: The name or ID of a flavor
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be raised
when the flavor does not exist.
When set to ``True``, no exception will be set when attempting
to delete a nonexistent flavor.
:returns: ``None``
"""
return self._find(_flavor.Flavor, name_or_id,
ignore_missing=ignore_missing)
def update_flavor(self, flavor, **attrs):
"""Update a flavor
:param flavor: The flavor can be either the name or a
:class:`~openstack.load_balancer.v2.flavor.Flavor` instance
:param dict attrs: The attributes to update on the flavor
represented by ``flavor``.
:returns: The updated flavor
:rtype: :class:`~openstack.load_balancer.v2.flavor.Flavor`
"""
return self._update(_flavor.Flavor, flavor, **attrs)
def amphorae(self, **query):
"""Retrieve a generator of amphorae
:returns: A generator of amphora instances
"""
return self._list(_amphora.Amphora, **query)
def get_amphora(self, *attrs):
"""Get a amphora
:param amphora: The value can be the ID of an amphora
or :class:`~openstack.load_balancer.v2.amphora.Amphora` instance.
:returns: One
:class:`~openstack.load_balancer.v2.amphora.Amphora`
"""
return self._get(_amphora.Amphora, *attrs)
def find_amphora(self, amphora_id, ignore_missing=True):
"""Find a single amphora
:param amphora_id: The ID of a amphora
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be raised
when the amphora does not exist.
When set to ``True``, no exception will be set when attempting
to find a nonexistent amphora.
:returns: ``None``
"""
return self._find(_amphora.Amphora, amphora_id,
ignore_missing=ignore_missing)
def configure_amphora(self, amphora_id, **attrs):
"""Update the configuration of an amphora agent
:param amphora_id: The ID of an amphora
:returns: ``None``
"""
return self._update(_amphora.AmphoraConfig, amphora_id=amphora_id)
def failover_amphora(self, amphora_id, **attrs):