Repository navigation
Expand file tree
/
Copy path_proxy.py
More file actions
3016 lines (2469 loc) · 133 KB
/
Copy path_proxy.py
File metadata and controls
3016 lines (2469 loc) · 133 KB
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.network.v2 import address_scope as _address_scope
from openstack.network.v2 import agent as _agent
from openstack.network.v2 import auto_allocated_topology as \
_auto_allocated_topology
from openstack.network.v2 import availability_zone
from openstack.network.v2 import extension
from openstack.network.v2 import flavor as _flavor
from openstack.network.v2 import floating_ip as _floating_ip
from openstack.network.v2 import health_monitor as _health_monitor
from openstack.network.v2 import listener as _listener
from openstack.network.v2 import load_balancer as _load_balancer
from openstack.network.v2 import metering_label as _metering_label
from openstack.network.v2 import metering_label_rule as _metering_label_rule
from openstack.network.v2 import network as _network
from openstack.network.v2 import network_ip_availability
from openstack.network.v2 import pool as _pool
from openstack.network.v2 import pool_v1 as _pool_v1
from openstack.network.v2 import pool_member as _pool_member
from openstack.network.v2 import pool_member_v1 as _pool_member_v1
from openstack.network.v2 import port as _port
from openstack.network.v2 import qos_bandwidth_limit_rule as \
_qos_bandwidth_limit_rule
from openstack.network.v2 import qos_dscp_marking_rule as \
_qos_dscp_marking_rule
from openstack.network.v2 import qos_minimum_bandwidth_rule as \
_qos_minimum_bandwidth_rule
from openstack.network.v2 import qos_policy as _qos_policy
from openstack.network.v2 import qos_rule_type as _qos_rule_type
from openstack.network.v2 import quota as _quota
from openstack.network.v2 import rbac_policy as _rbac_policy
from openstack.network.v2 import router as _router
from openstack.network.v2 import security_group as _security_group
from openstack.network.v2 import security_group_rule as _security_group_rule
from openstack.network.v2 import segment as _segment
from openstack.network.v2 import service_profile as _service_profile
from openstack.network.v2 import service_provider as _service_provider
from openstack.network.v2 import subnet as _subnet
from openstack.network.v2 import subnet_pool as _subnet_pool
from openstack.network.v2 import vpn_service as _vpn_service
from openstack import proxy2
class Proxy(proxy2.BaseProxy):
def create_address_scope(self, **attrs):
"""Create a new address scope from attributes
:param dict attrs: Keyword arguments which will be used to create
a :class:`~openstack.network.v2.address_scope.AddressScope`,
comprised of the properties on the AddressScope class.
:returns: The results of address scope creation
:rtype: :class:`~openstack.network.v2.address_scope.AddressScope`
"""
return self._create(_address_scope.AddressScope, **attrs)
def delete_address_scope(self, address_scope, ignore_missing=True):
"""Delete an address scope
:param address_scope: The value can be either the ID of an
address scope or
a :class:`~openstack.network.v2.address_scope.AddressScope`
instance.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the address scope does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent address scope.
:returns: ``None``
"""
self._delete(_address_scope.AddressScope, address_scope,
ignore_missing=ignore_missing)
def find_address_scope(self, name_or_id, ignore_missing=True):
"""Find a single address scope
:param name_or_id: The name or ID of an address scope.
: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.network.v2.address_scope.AddressScope`
or None
"""
return self._find(_address_scope.AddressScope, name_or_id,
ignore_missing=ignore_missing)
def get_address_scope(self, address_scope):
"""Get a single address scope
:param address_scope: The value can be the ID of an address scope or a
:class:`~openstack.network.v2.address_scope.AddressScope` instance.
:returns: One :class:`~openstack.network.v2.address_scope.AddressScope`
:raises: :class:`~openstack.exceptions.ResourceNotFound`
when no resource can be found.
"""
return self._get(_address_scope.AddressScope, address_scope)
def address_scopes(self, **query):
"""Return a generator of address scopes
:param dict query: Optional query parameters to be sent to limit
the resources being returned.
* ``name``: Address scope name
* ``ip_version``: Address scope IP address version
* ``tenant_id``: Owner tenant ID
* ``shared``: Address scope is shared (boolean)
:returns: A generator of address scope objects
:rtype: :class:`~openstack.network.v2.address_scope.AddressScope`
"""
return self._list(_address_scope.AddressScope, paginated=False,
**query)
def update_address_scope(self, address_scope, **attrs):
"""Update an address scope
:param address_scope: Either the ID of an address scope or a
:class:`~openstack.network.v2.address_scope.AddressScope` instance.
:param dict attrs: The attributes to update on the address scope
represented by ``value``.
:returns: The updated address scope
:rtype: :class:`~openstack.network.v2.address_scope.AddressScope`
"""
return self._update(_address_scope.AddressScope, address_scope,
**attrs)
def agents(self, **query):
"""Return a generator of network agents
:param dict query: Optional query parameters to be sent to limit the
resources being returned.
* ``agent_type``: Agent type.
* ``availability_zone``: The availability zone for an agent.
* ``binary``: The name of the agent's application binary.
* ``description``: The description of the agent.
* ``host``: The host (host name or host address) the agent is
running on.
* ``topic``: The message queue topic used.
* ``is_admin_state_up``: The administrative state of the agent.
: ``is_alive``: Whether the agent is alive.
:returns: A generator of agents
:rtype: :class:`~openstack.network.v2.agent.Agent`
"""
return self._list(_agent.Agent, paginated=False, **query)
def delete_agent(self, agent, ignore_missing=True):
"""Delete a network agent
:param agent: The value can be the ID of a agent or a
:class:`~openstack.network.v2.agent.Agent` instance.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the agent does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent agent.
:returns: ``None``
"""
self._delete(_agent.Agent, agent, ignore_missing=ignore_missing)
def get_agent(self, agent):
"""Get a single network agent
:param agent: The value can be the ID of a agent or a
:class:`~openstack.network.v2.agent.Agent` instance.
:returns: One :class:`~openstack.network.v2.agent.Agent`
:rtype: :class:`~openstack.network.v2.agent.Agent`
:raises: :class:`~openstack.exceptions.ResourceNotFound`
when no resource can be found.
"""
return self._get(_agent.Agent, agent)
def update_agent(self, agent, **attrs):
"""Update a network agent
:param agent: The value can be the ID of a agent or a
:class:`~openstack.network.v2.agent.Agent` instance.
:param dict attrs: The attributes to update on the agent represented
by ``value``.
:returns: One :class:`~openstack.network.v2.agent.Agent`
:rtype: :class:`~openstack.network.v2.agent.Agent`
"""
return self._update(_agent.Agent, agent, **attrs)
def dhcp_agent_hosting_networks(self, agent, **query):
"""A generator of networks hosted by a DHCP agent.
:param agent: Either the agent id of an instance of
:class:`~openstack.network.v2.network_agent.Agent`
:param query: kwargs \*\*query: Optional query parameters to be sent
to limit the resources being returned.
:return: A generator of networks
"""
agent_obj = self._get_resource(_agent.Agent, agent)
return self._list(_network.DHCPAgentHostingNetwork, paginated=False,
agent_id=agent_obj.id, **query)
def add_dhcp_agent_to_network(self, agent, network):
"""Add a DHCP Agent to a network
:param agent: Either the agent id of an instance of
:class:`~openstack.network.v2.network_agent.Agent`
:param network: Network instance
:return:
"""
network = self._get_resource(_network.Network, network)
agent = self._get_resource(_agent.Agent, agent)
return agent.add_agent_to_network(self.session, network.id)
def remove_dhcp_agent_from_network(self, agent, network):
"""Remove a DHCP Agent from a network
:param agent: Either the agent id of an instance of
:class:`~openstack.network.v2.network_agent.Agent`
:param network: Network instance
:return:
"""
network = self._get_resource(_network.Network, network)
agent = self._get_resource(_agent.Agent, agent)
return agent.remove_agent_from_network(self.session, network.id)
def network_hosting_dhcp_agents(self, network, **query):
"""A generator of DHCP agents hosted on a network.
:param network: The instance of
:class:`~openstack.network.v2.network.Network`
:param dict query: Optional query parameters to be sent to limit the
resources returned.
:return: A generator of hosted DHCP agents
"""
net = self._get_resource(_network.Network, network)
return self._list(_agent.NetworkHostingDHCPAgent, paginated=False,
network_id=net.id, **query)
def get_auto_allocated_topology(self, project=None):
"""Get the auto-allocated topology of a given tenant
:param project:
The value is the ID or name of a project
:returns: The auto-allocated topology
:rtype: :class:`~openstack.network.v2.\
auto_allocated_topology.AutoAllocatedTopology`
"""
# If project option is not given, grab project id from session
if project is None:
project = self.session.get_project_id()
return self._get(_auto_allocated_topology.AutoAllocatedTopology,
project)
def delete_auto_allocated_topology(self, project=None,
ignore_missing=False):
"""Delete auto-allocated topology
:param project:
The value is the ID or name of a project
:param ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the topology does not exist.
When set to ``True``, no exception will be raised when
attempting to delete nonexistant topology
:returns: ``None``
"""
# If project option is not given, grab project id from session
if project is None:
project = self.session.get_project_id()
self._delete(_auto_allocated_topology.AutoAllocatedTopology,
project, ignore_missing=ignore_missing)
def validate_auto_allocated_topology(self, project=None):
"""Validate the resources for auto allocation
:param project:
The value is the ID or name of a project
:returns: Whether all resources are correctly configured or not
:rtype: :class:`~openstack.network.v2.\
auto_allocated_topology.ValidateTopology`
"""
# If project option is not given, grab project id from session
if project is None:
project = self.session.get_project_id()
return self._get(_auto_allocated_topology.ValidateTopology,
project=project)
def availability_zones(self, **query):
"""Return a generator of availability zones
:param dict query: optional query parameters to be set to limit the
returned resources. Valid parameters include:
* ``name``: The name of an availability zone.
* ``resource``: The type of resource for the availability zone.
:returns: A generator of availability zone objects
:rtype:
:class:`~openstack.network.v2.availability_zone.AvailabilityZone`
"""
return self._list(availability_zone.AvailabilityZone, paginated=False)
def find_extension(self, name_or_id, ignore_missing=True):
"""Find a single extension
:param name_or_id: The name or ID of a extension.
: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.network.v2.extension.Extension`
or None
"""
return self._find(extension.Extension, name_or_id,
ignore_missing=ignore_missing)
def extensions(self, **query):
"""Return a generator of extensions
:param dict query: Optional query parameters to be sent to limit
the resources being returned. Currently no
parameter is supported.
:returns: A generator of extension objects
:rtype: :class:`~openstack.network.v2.extension.Extension`
"""
return self._list(extension.Extension, paginated=False, **query)
def create_flavor(self, **attrs):
"""Create a new network service flavor from attributes
:param dict attrs: Keyword arguments which will be used to create
a :class:`~openstack.network.v2.flavor.Flavor`,
comprised of the properties on the Flavor class.
:returns: The results of flavor creation
:rtype: :class:`~openstack.network.v2.flavor.Flavor`
"""
return self._create(_flavor.Flavor, **attrs)
def delete_flavor(self, flavor, ignore_missing=True):
"""Delete a network service flavor
:param flavor:
The value can be either the ID of a flavor or a
:class:`~openstack.network.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 network service 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 resource does not exist.
When set to ``True``, None will be returned when
attempting to find a nonexistent resource.
:returns: One :class:`~openstack.network.v2.flavor.Flavor` or None
"""
return self._find(_flavor.Flavor, name_or_id,
ignore_missing=ignore_missing)
def get_flavor(self, flavor):
"""Get a single network service flavor
:param flavor:
The value can be the ID of a flavor or a
:class:`~openstack.network.v2.flavor.Flavor` instance.
:returns: One :class:`~openstack.network.v2.flavor.Flavor`
:raises: :class:`~openstack.exceptions.ResourceNotFound`
when no resource can be found.
"""
return self._get(_flavor.Flavor, flavor)
def update_flavor(self, flavor, **attrs):
"""Update a network service flavor
:param flavor:
Either the id of a flavor or a
:class:`~openstack.network.v2.flavor.Flavor` instance.
:attrs kwargs: The attributes to update on the flavor represented
by ``value``.
:returns: The updated flavor
:rtype: :class:`~openstack.network.v2.flavor.Flavor`
"""
return self._update(_flavor.Flavor, flavor, **attrs)
def flavors(self, **query):
"""Return a generator of network service flavors
:param dict query: Optional query parameters to be sent to limit
the resources being returned. Valid parameters
include:
* ``description``: The description of a flavor.
* ``is_enabled``: Whether a flavor is enabled.
* ``name``: The name of a flavor.
* ``service_type``: The service type to which a falvor applies.
:returns: A generator of flavor objects
:rtype: :class:`~openstack.network.v2.flavor.Flavor`
"""
return self._list(_flavor.Flavor, paginated=True, **query)
def create_ip(self, **attrs):
"""Create a new floating ip from attributes
:param dict attrs: Keyword arguments which will be used to create
a :class:`~openstack.network.v2.floating_ip.FloatingIP`,
comprised of the properties on the FloatingIP class.
:returns: The results of floating ip creation
:rtype: :class:`~openstack.network.v2.floating_ip.FloatingIP`
"""
return self._create(_floating_ip.FloatingIP, **attrs)
def delete_ip(self, floating_ip, ignore_missing=True):
"""Delete a floating ip
:param floating_ip: The value can be either the ID of a floating ip
or a :class:`~openstack.network.v2.floating_ip.FloatingIP`
instance.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the floating ip does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent ip.
:returns: ``None``
"""
self._delete(_floating_ip.FloatingIP, floating_ip,
ignore_missing=ignore_missing)
def find_available_ip(self):
"""Find an available IP
:returns: One :class:`~openstack.network.v2.floating_ip.FloatingIP`
or None
"""
return _floating_ip.FloatingIP.find_available(self.session)
def find_ip(self, name_or_id, ignore_missing=True):
"""Find a single IP
:param name_or_id: The name or ID of an IP.
: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.network.v2.floating_ip.FloatingIP`
or None
"""
return self._find(_floating_ip.FloatingIP, name_or_id,
ignore_missing=ignore_missing)
def get_ip(self, floating_ip):
"""Get a single floating ip
:param floating_ip: The value can be the ID of a floating ip or a
:class:`~openstack.network.v2.floating_ip.FloatingIP`
instance.
:returns: One :class:`~openstack.network.v2.floating_ip.FloatingIP`
:raises: :class:`~openstack.exceptions.ResourceNotFound`
when no resource can be found.
"""
return self._get(_floating_ip.FloatingIP, floating_ip)
def ips(self, **query):
"""Return a generator of ips
:param dict query: Optional query parameters to be sent to limit
the resources being returned. Valid parameters are:
* ``description``: The description of a floating IP.
* ``fixed_ip_address``: The fixed IP address associated with a
floating IP address.
* ``floating_ip_address``: The IP address of a floating IP.
* ``floating_network_id``: The ID of the network associated with
a floating IP.
* ``port_id``: The ID of the port to which a floating IP is
associated.
* ``project_id``: The ID of the project a floating IP is
associated with.
* ``router_id``: The ID of an associated router.
* ``status``: The status of a floating IP, which can be ``ACTIVE``
or ``DOWN``.
:returns: A generator of floating IP objects
:rtype: :class:`~openstack.network.v2.floating_ip.FloatingIP`
"""
return self._list(_floating_ip.FloatingIP, paginated=False, **query)
def update_ip(self, floating_ip, **attrs):
"""Update a ip
:param floating_ip: Either the id of a ip or a
:class:`~openstack.network.v2.floating_ip.FloatingIP`
instance.
:param dict attrs: The attributes to update on the ip represented
by ``value``.
:returns: The updated ip
:rtype: :class:`~openstack.network.v2.floating_ip.FloatingIP`
"""
return self._update(_floating_ip.FloatingIP, floating_ip, **attrs)
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.network.v2.health_monitor.HealthMonitor`,
comprised of the properties on the HealthMonitor class.
:returns: The results of health monitor creation
:rtype: :class:`~openstack.network.v2.health_monitor.HealthMonitor`
"""
return self._create(_health_monitor.HealthMonitor, **attrs)
def delete_health_monitor(self, health_monitor, ignore_missing=True):
"""Delete a health monitor
:param health_monitor: The value can be either the ID of a
health monitor or a
:class:`~openstack.network.v2.health_monitor.HealthMonitor`
instance.
: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 delete a nonexistent health monitor.
:returns: ``None``
"""
self._delete(_health_monitor.HealthMonitor, health_monitor,
ignore_missing=ignore_missing)
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 resource does not exist.
When set to ``True``, None will be returned when
attempting to find a nonexistent resource.
:returns: One :class:`~openstack.network.v2.health_monitor.
HealthMonitor` or None
"""
return self._find(_health_monitor.HealthMonitor,
name_or_id, ignore_missing=ignore_missing)
def get_health_monitor(self, health_monitor):
"""Get a single health monitor
:param health_monitor: The value can be the ID of a health monitor or a
:class:`~openstack.network.v2.health_monitor.HealthMonitor`
instance.
:returns: One
:class:`~openstack.network.v2.health_monitor.HealthMonitor`
:raises: :class:`~openstack.exceptions.ResourceNotFound`
when no resource can be found.
"""
return self._get(_health_monitor.HealthMonitor, health_monitor)
def health_monitors(self, **query):
"""Return a generator of health monitors
:param dict query: Optional query parameters to be sent to limit
the resources being returned. Valid parameters are:
* ``delay``: the time in milliseconds between sending probes.
* ``expected_codes``: The expected HTTP codes for a pssing HTTP(S)
monitor.
* ``http_method``: The HTTP method a monitor uses for requests.
* ``is_admin_state_up``: The administrative state of a health
monitor.
* ``max_retries``: The maximum consecutive health probe attempts.
* ``project_id``: The ID of the project this health monitor is
associated with.
* ``timeout``: The maximum number of milliseconds for a monitor to
wait for a connection to be established before it
times out.
* ``type``: The type of probe sent by the load balancer for health
check, which can be ``PING``, ``TCP``, ``HTTP`` or
``HTTPS``.
* ``url_path``: The path portion of a URI that will be probed.
:returns: A generator of health monitor objects
:rtype: :class:`~openstack.network.v2.health_monitor.HealthMonitor`
"""
return self._list(_health_monitor.HealthMonitor, paginated=False,
**query)
def update_health_monitor(self, health_monitor, **attrs):
"""Update a health monitor
:param health_monitor: Either the id of a health monitor or a
:class:`~openstack.network.v2.health_monitor.
HealthMonitor` instance.
:param dict attrs: The attributes to update on the health monitor
represented by ``value``.
:returns: The updated health monitor
:rtype: :class:`~openstack.network.v2.health_monitor.HealthMonitor`
"""
return self._update(_health_monitor.HealthMonitor, health_monitor,
**attrs)
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.network.v2.listener.Listener`,
comprised of the properties on the Listener class.
:returns: The results of listener creation
:rtype: :class:`~openstack.network.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.network.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.network.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.network.v2.listener.Listener`
instance.
:returns: One :class:`~openstack.network.v2.listener.Listener`
:raises: :class:`~openstack.exceptions.ResourceNotFound`
when no resource can be found.
"""
return self._get(_listener.Listener, listener)
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:
* ``connection_limit``: The maximum number of connections
permitted for the load-balancer.
* ``default_pool_id``: The ID of the default pool.
* ``default_tls_container_ref``: A reference to a container of TLS
secret.
* ``description``: The description of a listener.
* ``is_admin_state_up``: The administrative state of the listener.
* ``name``: The name of a listener.
* ``project_id``: The ID of the project associated with a listener.
* ``protocol``: The protocol of the listener.
* ``protocol_port``: Port the listener will listen to.
:returns: A generator of listener objects
:rtype: :class:`~openstack.network.v2.listener.Listener`
"""
return self._list(_listener.Listener, paginated=False, **query)
def update_listener(self, listener, **attrs):
"""Update a listener
:param listener: Either the id of a listener or a
:class:`~openstack.network.v2.listener.Listener`
instance.
:param dict attrs: The attributes to update on the listener
represented by ``listener``.
:returns: The updated listener
:rtype: :class:`~openstack.network.v2.listener.Listener`
"""
return self._update(_listener.Listener, listener, **attrs)
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.network.v2.load_balancer.LoadBalancer`,
comprised of the properties on the LoadBalancer class.
:returns: The results of load balancer creation
:rtype: :class:`~openstack.network.v2.load_balancer.LoadBalancer`
"""
return self._create(_load_balancer.LoadBalancer, **attrs)
def delete_load_balancer(self, load_balancer, ignore_missing=True):
"""Delete a load balancer
:param load_balancer: The value can be the ID of a load balancer or a
:class:`~openstack.network.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.
:returns: ``None``
"""
self._delete(_load_balancer.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 resource does not exist.
When set to ``True``, None will be returned when
attempting to find a nonexistent resource.
:returns: One :class:`~openstack.network.v2.load_balancer.LoadBalancer`
or None
"""
return self._find(_load_balancer.LoadBalancer, name_or_id,
ignore_missing=ignore_missing)
def get_load_balancer(self, load_balancer):
"""Get a single load balancer
:param load_balancer: The value can be the ID of a load balancer or a
:class:`~openstack.network.v2.load_balancer.LoadBalancer`
instance.
:returns: One :class:`~openstack.network.v2.load_balancer.LoadBalancer`
:raises: :class:`~openstack.exceptions.ResourceNotFound`
when no resource can be found.
"""
return self._get(_load_balancer.LoadBalancer, load_balancer)
def load_balancers(self, **query):
"""Return a generator of load balancers
:param dict query: Optional query parameters to be sent to limit
the resources being returned.
:returns: A generator of load balancer objects
:rtype: :class:`~openstack.network.v2.load_balancer.LoadBalancer`
"""
return self._list(_load_balancer.LoadBalancer, paginated=False,
**query)
def update_load_balancer(self, load_balancer, **attrs):
"""Update a load balancer
:param load_balancer: Either the id of a load balancer or a
:class:`~openstack.network.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.network.v2.load_balancer.LoadBalancer`
"""
return self._update(_load_balancer.LoadBalancer, load_balancer,
**attrs)
def create_metering_label(self, **attrs):
"""Create a new metering label from attributes
:param dict attrs: Keyword arguments which will be used to create
a :class:`~openstack.network.v2.metering_label.MeteringLabel`,
comprised of the properties on the MeteringLabel class.
:returns: The results of metering label creation
:rtype: :class:`~openstack.network.v2.metering_label.MeteringLabel`
"""
return self._create(_metering_label.MeteringLabel, **attrs)
def delete_metering_label(self, metering_label, ignore_missing=True):
"""Delete a metering label
:param metering_label:
The value can be either the ID of a metering label or a
:class:`~openstack.network.v2.metering_label.MeteringLabel`
instance.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the metering label does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent metering label.
:returns: ``None``
"""
self._delete(_metering_label.MeteringLabel, metering_label,
ignore_missing=ignore_missing)
def find_metering_label(self, name_or_id, ignore_missing=True):
"""Find a single metering label
:param name_or_id: The name or ID of a metering label.
: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.network.v2.metering_label.
MeteringLabel` or None
"""
return self._find(_metering_label.MeteringLabel, name_or_id,
ignore_missing=ignore_missing)
def get_metering_label(self, metering_label):
"""Get a single metering label
:param metering_label: The value can be the ID of a metering label or a
:class:`~openstack.network.v2.metering_label.MeteringLabel`
instance.
:returns: One
:class:`~openstack.network.v2.metering_label.MeteringLabel`
:raises: :class:`~openstack.exceptions.ResourceNotFound`
when no resource can be found.
"""
return self._get(_metering_label.MeteringLabel, metering_label)
def metering_labels(self, **query):
"""Return a generator of metering labels
:param dict query: Optional query parameters to be sent to limit
the resources being returned. Valid parameters are:
* ``description``: Description of a metering label.
* ``name``: Name of a metering label.
* ``is_shared``: Boolean indicating whether a metering label is
shared.
* ``project_id``: The ID of the project a metering label is
associated with.
:returns: A generator of metering label objects
:rtype: :class:`~openstack.network.v2.metering_label.MeteringLabel`
"""
return self._list(_metering_label.MeteringLabel, paginated=False,
**query)
def update_metering_label(self, metering_label, **attrs):
"""Update a metering label
:param metering_label: Either the id of a metering label or a
:class:`~openstack.network.v2.metering_label.
MeteringLabel` instance.
:param dict attrs: The attributes to update on the metering label
represented by ``metering_label``.
:returns: The updated metering label
:rtype: :class:`~openstack.network.v2.metering_label.MeteringLabel`
"""
return self._update(_metering_label.MeteringLabel, metering_label,
**attrs)
def create_metering_label_rule(self, **attrs):
"""Create a new metering label rule from attributes
:param dict attrs: Keyword arguments which will be used to create a
:class:`~openstack.network.v2.metering_label_rule.\
MeteringLabelRule`, comprised of the properties on
the MeteringLabelRule class.
:returns: The results of metering label rule creation
:rtype: :class:`~openstack.network.v2.metering_label_rule.\
MeteringLabelRule`
"""
return self._create(_metering_label_rule.MeteringLabelRule, **attrs)
def delete_metering_label_rule(self, metering_label_rule,
ignore_missing=True):
"""Delete a metering label rule
:param metering_label_rule:
The value can be either the ID of a metering label rule
or a :class:`~openstack.network.v2.metering_label_rule.\
MeteringLabelRule` instance.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be raised
when the metering label rule does not exist. When set to ``True``,
no exception will be set when attempting to delete a nonexistent
metering label rule.
:returns: ``None``
"""
self._delete(_metering_label_rule.MeteringLabelRule,
metering_label_rule, ignore_missing=ignore_missing)
def find_metering_label_rule(self, name_or_id, ignore_missing=True):
"""Find a single metering label rule
:param name_or_id: The name or ID of a metering label rule.
: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.network.v2.metering_label_rule.
MeteringLabelRule` or None
"""
return self._find(_metering_label_rule.MeteringLabelRule, name_or_id,
ignore_missing=ignore_missing)
def get_metering_label_rule(self, metering_label_rule):
"""Get a single metering label rule
:param metering_label_rule:
The value can be the ID of a metering label rule or a
:class:`~openstack.network.v2.metering_label_rule.\
MeteringLabelRule` instance.
:returns: One
:class:`~openstack.network.v2.metering_label_rule.\
MeteringLabelRule`
:raises: :class:`~openstack.exceptions.ResourceNotFound`
when no resource can be found.
"""
return self._get(_metering_label_rule.MeteringLabelRule,
metering_label_rule)
def metering_label_rules(self, **query):
"""Return a generator of metering label rules
:param dict query: Optional query parameters to be sent to limit
the resources being returned. Valid parameters are:
* ``direction``: The direction in which metering label rule is
applied.
* ``metering_label_id``: The ID of a metering label this rule is
associated with.
* ``project_id``: The ID of the project the metering label rule is
associated with.
* ``remote_ip_prefix``: The remote IP prefix to be associated with
this metering label rule.
:returns: A generator of metering label rule objects
:rtype: :class:`~openstack.network.v2.metering_label_rule.
MeteringLabelRule`
"""
return self._list(_metering_label_rule.MeteringLabelRule,