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 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350
|
# 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.
import typing as ty
from openstack.load_balancer.v2 import amphora as _amphora
from openstack.load_balancer.v2 import availability_zone as _availability_zone
from openstack.load_balancer.v2 import (
availability_zone_profile as _availability_zone_profile,
)
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):
_resource_registry = {
"amphora": _amphora.Amphora,
"availability_zone": _availability_zone.AvailabilityZone,
"availability_zone_profile": _availability_zone_profile.AvailabilityZoneProfile, # noqa: E501
"flavor": _flavor.Flavor,
"flavor_profile": _flavor_profile.FlavorProfile,
"health_monitor": _hm.HealthMonitor,
"l7_policy": _l7policy.L7Policy,
"l7_rule": _l7rule.L7Rule,
"load_balancer": _lb.LoadBalancer,
"member": _member.Member,
"pool": _pool.Pool,
"provider": _provider.Provider,
"quota": _quota.Quota,
}
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 ID 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, load_balancer):
"""Get the load balancer statistics
:param load_balancer: The value can be the ID of a load balancer
or :class:`~openstack.load_balancer.v2.load_balancer.LoadBalancer`
instance.
:returns: One
:class:`~openstack.load_balancer.v2.load_balancer.LoadBalancerStats`
"""
return self._get(
_lb.LoadBalancerStats, lb_id=load_balancer, 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 ID or a
:class:`~openstack.load_balancer.v2.load_balancer.LoadBalancer`
instance
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.NotFoundException` 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.NotFoundException` will be raised
when the load balancer does not exist.
When set to ``True``, no exception will be set when attempting
to find 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 ID 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,
):
"""Wait for load balancer status
:param name_or_id: The name or ID of the load balancer.
:param status: Desired status.
:param failures: Statuses that would be interpreted as failures.
Default to ['ERROR'].
:type failures: :py:class:`list`
:param interval: Number of seconds to wait between consecutive
checks. Defaults to 2.
:param wait: Maximum number of seconds to wait before the status
to be reached. Defaults to 300.
:returns: The load balancer is returned on success.
:raises: :class:`~openstack.exceptions.ResourceTimeout` if transition
to the desired status failed to occur within the specified wait
time.
:raises: :class:`~openstack.exceptions.ResourceFailure` if the resource
has transited to one of the failure statuses.
:raises: :class:`~AttributeError` if the resource does not have a
``status`` attribute.
"""
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, load_balancer):
"""Failover a load balancer
:param load_balancer: The value can be the ID of a load balancer
or :class:`~openstack.load_balancer.v2.load_balancer.LoadBalancer`
instance.
:returns: ``None``
"""
lb = self._get_resource(_lb.LoadBalancer, load_balancer)
lb.failover(self)
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 listener or a
:class:`~openstack.load_balancer.v2.listener.Listener` instance.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.NotFoundException` 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.NotFoundException` 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.NotFoundException`
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.NotFoundException` 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 either a pool ID or a
: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 either a pool ID or a
:class:`~openstack.load_balancer.v2.pool.Pool`
instance
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.NotFoundException` 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.NotFoundException` will be raised
when the pool does not exist.
When set to ``True``, no exception will be set when attempting
to find 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.NotFoundException` 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.NotFoundException` 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.NotFoundException`
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.NotFoundException` 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.NotFoundException` 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.NotFoundException` 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.NotFoundException` 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.NotFoundException` 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.NotFoundException`
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.NotFoundException` 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.NotFoundException` 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.NotFoundException`
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.NotFoundException`
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.NotFoundException` 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 ID or a
:class:`~openstack.load_balancer.v2.flavor_profile.FlavorProfile`
instance
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.NotFoundException` 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.NotFoundException` will be raised
when the flavor profile does not exist.
When set to ``True``, no exception will be set when attempting
to find 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 ID 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 ID 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 ID or a
:class:`~openstack.load_balancer.v2.flavor.Flavor` instance
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.NotFoundException` 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.NotFoundException` will be raised
when the flavor does not exist.
When set to ``True``, no exception will be set when attempting
to find 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 ID 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.NotFoundException` 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):
"""Update the configuration of an amphora agent
:param amphora_id: The ID of an amphora
:returns: ``None``
"""
lb = self._get_resource(_amphora.Amphora, amphora_id)
lb.configure(self)
def failover_amphora(self, amphora_id):
"""Failover an amphora
:param amphora_id: The ID of an amphora
:returns: ``None``
"""
lb = self._get_resource(_amphora.Amphora, amphora_id)
lb.failover(self)
def create_availability_zone_profile(self, **attrs):
"""Create a new availability zone profile from attributes
:param dict attrs: Keyword arguments which will be used to create a
:class:`~openstack.load_balancer.v2.availability_zone_profile.AvailabilityZoneProfile`
comprised of the properties on the AvailabilityZoneProfile
class.
:returns: The results of profile creation
:rtype:
:class:`~openstack.load_balancer.v2.availability_zone_profile.AvailabilityZoneProfile`
"""
return self._create(
_availability_zone_profile.AvailabilityZoneProfile, **attrs
)
def get_availability_zone_profile(self, *attrs):
"""Get an availability zone profile
:param availability_zone_profile: The value can be the ID of an
availability_zone profile or
:class:`~openstack.load_balancer.v2.availability_zone_profile.AvailabilityZoneProfile`
instance.
:returns: One
:class:`~openstack.load_balancer.v2.availability_zone_profile.AvailabilityZoneProfile`
"""
return self._get(
_availability_zone_profile.AvailabilityZoneProfile, *attrs
)
def availability_zone_profiles(self, **query):
"""Retrieve a generator of availability zone profiles
:returns: A generator of availability zone profiles instances
"""
return self._list(
_availability_zone_profile.AvailabilityZoneProfile, **query
)
def delete_availability_zone_profile(
self, availability_zone_profile, ignore_missing=True
):
"""Delete an availability zone profile
:param availability_zone_profile: The availability_zone_profile can be
either the ID or a
:class:`~openstack.load_balancer.v2.availability_zone_profile.AvailabilityZoneProfile`
instance
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.NotFoundException` will be raised when
the availability zone profile does not exist.
When set to ``True``, no exception will be set when attempting to
delete a nonexistent availability zone profile.
:returns: ``None``
"""
self._delete(
_availability_zone_profile.AvailabilityZoneProfile,
availability_zone_profile,
ignore_missing=ignore_missing,
)
def find_availability_zone_profile(self, name_or_id, ignore_missing=True):
"""Find a single availability zone profile
:param name_or_id: The name or ID of a availability zone profile
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.NotFoundException` will be raised
when the availability zone profile does not exist.
When set to ``True``, no exception will be set when attempting
to find a nonexistent availability zone profile.
:returns: ``None``
"""
return self._find(
_availability_zone_profile.AvailabilityZoneProfile,
name_or_id,
ignore_missing=ignore_missing,
)
def update_availability_zone_profile(
self, availability_zone_profile, **attrs
):
"""Update an availability zone profile
:param availability_zone_profile: The availability_zone_profile can be
either the ID or a
:class:`~openstack.load_balancer.v2.availability_zone_profile.AvailabilityZoneProfile`
instance
:param dict attrs: The attributes to update on the availability_zone
profile represented by ``availability_zone_profile``.
:returns: The updated availability zone profile
:rtype:
:class:`~openstack.load_balancer.v2.availability_zone_profile.AvailabilityZoneProfile`
"""
return self._update(
_availability_zone_profile.AvailabilityZoneProfile,
availability_zone_profile,
**attrs,
)
def create_availability_zone(self, **attrs):
"""Create a new availability zone from attributes
:param dict attrs: Keyword arguments which will be used to create a
:class:`~openstack.load_balancer.v2.availability_zone.AvailabilityZone`
comprised of the properties on the AvailabilityZoneclass.
:returns: The results of availability_zone creation creation
:rtype:
:class:`~openstack.load_balancer.v2.availability_zone.AvailabilityZone`
"""
return self._create(_availability_zone.AvailabilityZone, **attrs)
def get_availability_zone(self, *attrs):
"""Get an availability zone
:param availability_zone: The value can be the ID of a
availability_zone or
:class:`~openstack.load_balancer.v2.availability_zone.AvailabilityZone`
instance.
:returns: One
:class:`~openstack.load_balancer.v2.availability_zone.AvailabilityZone`
"""
return self._get(_availability_zone.AvailabilityZone, *attrs)
def availability_zones(self, **query):
"""Retrieve a generator of availability zones
:returns: A generator of availability zone instances
"""
return self._list(_availability_zone.AvailabilityZone, **query)
def delete_availability_zone(self, availability_zone, ignore_missing=True):
"""Delete an availability_zone
:param availability_zone: The availability_zone can be either the ID
or a
:class:`~openstack.load_balancer.v2.availability_zone.AvailabilityZone`
instance
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.NotFoundException` will be raised when
the availability zone does not exist.
When set to ``True``, no exception will be set when attempting to
delete a nonexistent availability zone.
:returns: ``None``
"""
self._delete(
_availability_zone.AvailabilityZone,
availability_zone,
ignore_missing=ignore_missing,
)
def find_availability_zone(self, name_or_id, ignore_missing=True):
"""Find a single availability zone
:param name_or_id: The name or ID of a availability zone
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.NotFoundException` will be raised
when the availability zone does not exist.
When set to ``True``, no exception will be set when attempting
to find a nonexistent availability zone.
:returns: ``None``
"""
return self._find(
_availability_zone.AvailabilityZone,
name_or_id,
ignore_missing=ignore_missing,
)
def update_availability_zone(self, availability_zone, **attrs):
"""Update an availability zone
:param availability_zone: The availability_zone can be either the ID
or a
:class:`~openstack.load_balancer.v2.availability_zone.AvailabilityZone`
instance
:param dict attrs: The attributes to update on the availability_zone
represented by ``availability_zone``.
:returns: The updated availability_zone
:rtype:
:class:`~openstack.load_balancer.v2.availability_zone.AvailabilityZone`
"""
return self._update(
_availability_zone.AvailabilityZone, availability_zone, **attrs
)
# ========== Utilities ==========
def wait_for_status(
self,
res: resource.ResourceT,
status: str,
failures: ty.Optional[list[str]] = None,
interval: ty.Union[int, float, None] = 2,
wait: ty.Optional[int] = None,
attribute: str = 'status',
callback: ty.Optional[ty.Callable[[int], None]] = None,
) -> resource.ResourceT:
"""Wait for the resource to be in a particular status.
:param session: The session to use for making this request.
:param resource: The resource to wait on to reach the status. The
resource must have a status attribute specified via ``attribute``.
:param status: Desired status of the resource.
:param failures: Statuses that would indicate the transition
failed such as 'ERROR'. Defaults to ['ERROR'].
:param interval: Number of seconds to wait between checks.
:param wait: Maximum number of seconds to wait for transition.
Set to ``None`` to wait forever.
:param attribute: Name of the resource attribute that contains the
status.
:param callback: A callback function. This will be called with a single
value, progress. This is API specific but is generally a percentage
value from 0-100.
:return: The updated resource.
:raises: :class:`~openstack.exceptions.ResourceTimeout` if the
transition to status failed to occur in ``wait`` seconds.
:raises: :class:`~openstack.exceptions.ResourceFailure` if the resource
transitioned to one of the states in ``failures``.
:raises: :class:`~AttributeError` if the resource does not have a
``status`` attribute
"""
return resource.wait_for_status(
self, res, status, failures, interval, wait, attribute, callback
)
def wait_for_delete(
self,
res: resource.ResourceT,
interval: int = 2,
wait: int = 120,
callback: ty.Optional[ty.Callable[[int], None]] = None,
) -> resource.ResourceT:
"""Wait for a resource to be deleted.
:param res: The resource to wait on to be deleted.
:param interval: Number of seconds to wait before to consecutive
checks.
:param wait: Maximum number of seconds to wait before the change.
:param callback: A callback function. This will be called with a single
value, progress, which is a percentage value from 0-100.
:returns: The resource is returned on success.
:raises: :class:`~openstack.exceptions.ResourceTimeout` if transition
to delete failed to occur in the specified seconds.
"""
return resource.wait_for_delete(self, res, interval, wait, callback)
|