1# Licensed under the Apache License, Version 2.0 (the "License"); you may 2# not use this file except in compliance with the License. You may obtain 3# a copy of the License at 4# 5# http://www.apache.org/licenses/LICENSE-2.0 6# 7# Unless required by applicable law or agreed to in writing, software 8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10# License for the specific language governing permissions and limitations 11# under the License. 12 13from openstack import exceptions 14from openstack.network.v2 import address_group as _address_group 15from openstack.network.v2 import address_scope as _address_scope 16from openstack.network.v2 import agent as _agent 17from openstack.network.v2 import auto_allocated_topology as \ 18 _auto_allocated_topology 19from openstack.network.v2 import availability_zone 20from openstack.network.v2 import extension 21from openstack.network.v2 import firewall_group as _firewall_group 22from openstack.network.v2 import firewall_policy as _firewall_policy 23from openstack.network.v2 import firewall_rule as _firewall_rule 24from openstack.network.v2 import flavor as _flavor 25from openstack.network.v2 import floating_ip as _floating_ip 26from openstack.network.v2 import health_monitor as _health_monitor 27from openstack.network.v2 import ipsec_site_connection as \ 28 _ipsec_site_connection 29from openstack.network.v2 import l3_conntrack_helper as _l3_conntrack_helper 30from openstack.network.v2 import listener as _listener 31from openstack.network.v2 import load_balancer as _load_balancer 32from openstack.network.v2 import metering_label as _metering_label 33from openstack.network.v2 import metering_label_rule as _metering_label_rule 34from openstack.network.v2 import network as _network 35from openstack.network.v2 import network_ip_availability 36from openstack.network.v2 import network_segment_range as \ 37 _network_segment_range 38from openstack.network.v2 import pool as _pool 39from openstack.network.v2 import pool_member as _pool_member 40from openstack.network.v2 import port as _port 41from openstack.network.v2 import port_forwarding as _port_forwarding 42from openstack.network.v2 import qos_bandwidth_limit_rule as \ 43 _qos_bandwidth_limit_rule 44from openstack.network.v2 import qos_dscp_marking_rule as \ 45 _qos_dscp_marking_rule 46from openstack.network.v2 import qos_minimum_bandwidth_rule as \ 47 _qos_minimum_bandwidth_rule 48from openstack.network.v2 import qos_policy as _qos_policy 49from openstack.network.v2 import qos_rule_type as _qos_rule_type 50from openstack.network.v2 import quota as _quota 51from openstack.network.v2 import rbac_policy as _rbac_policy 52from openstack.network.v2 import router as _router 53from openstack.network.v2 import security_group as _security_group 54from openstack.network.v2 import security_group_rule as _security_group_rule 55from openstack.network.v2 import segment as _segment 56from openstack.network.v2 import service_profile as _service_profile 57from openstack.network.v2 import service_provider as _service_provider 58from openstack.network.v2 import subnet as _subnet 59from openstack.network.v2 import subnet_pool as _subnet_pool 60from openstack.network.v2 import trunk as _trunk 61from openstack.network.v2 import vpn_service as _vpn_service 62from openstack import proxy 63 64 65class Proxy(proxy.Proxy): 66 67 @proxy._check_resource(strict=False) 68 def _update(self, resource_type, value, base_path=None, 69 if_revision=None, **attrs): 70 res = self._get_resource(resource_type, value, **attrs) 71 return res.commit(self, base_path=base_path, if_revision=if_revision) 72 73 @proxy._check_resource(strict=False) 74 def _delete(self, resource_type, value, ignore_missing=True, 75 if_revision=None, **attrs): 76 res = self._get_resource(resource_type, value, **attrs) 77 78 try: 79 rv = res.delete(self, if_revision=if_revision) 80 except exceptions.ResourceNotFound: 81 if ignore_missing: 82 return None 83 raise 84 85 return rv 86 87 def create_address_group(self, **attrs): 88 """Create a new address group from attributes 89 90 :param dict attrs: Keyword arguments which will be used to create 91 a :class:`~openstack.network.v2.address_group.AddressGroup`, 92 comprised of the properties on the AddressGroup class. 93 94 :returns: The results of address group creation 95 :rtype: :class:`~openstack.network.v2.address_group.AddressGroup` 96 """ 97 return self._create(_address_group.AddressGroup, **attrs) 98 99 def delete_address_group(self, address_group, ignore_missing=True): 100 """Delete an address group 101 102 :param address_group: The value can be either the ID of an 103 address group or 104 a :class:`~openstack.network.v2.address_group.AddressGroup` 105 instance. 106 :param bool ignore_missing: When set to ``False`` 107 :class:`~openstack.exceptions.ResourceNotFound` will 108 be raised when the address group does not exist. 109 When set to ``True``, no exception will be set when 110 attempting to delete a nonexistent address group. 111 112 :returns: ``None`` 113 """ 114 self._delete(_address_group.AddressGroup, address_group, 115 ignore_missing=ignore_missing) 116 117 def find_address_group(self, name_or_id, ignore_missing=True, **args): 118 """Find a single address group 119 120 :param name_or_id: The name or ID of an address group. 121 :param bool ignore_missing: When set to ``False`` 122 :class:`~openstack.exceptions.ResourceNotFound` will be 123 raised when the resource does not exist. 124 When set to ``True``, None will be returned when 125 attempting to find a nonexistent resource. 126 :param dict args: Any additional parameters to be passed into 127 underlying methods. such as query filters. 128 :returns: One :class:`~openstack.network.v2.address_group.AddressGroup` 129 or None 130 """ 131 return self._find(_address_group.AddressGroup, name_or_id, 132 ignore_missing=ignore_missing, **args) 133 134 def get_address_group(self, address_group): 135 """Get a single address group 136 137 :param address_group: The value can be the ID of an address group or a 138 :class:`~openstack.network.v2.address_group.AddressGroup` instance. 139 140 :returns: One :class:`~openstack.network.v2.address_group.AddressGroup` 141 :raises: :class:`~openstack.exceptions.ResourceNotFound` 142 when no resource can be found. 143 """ 144 return self._get(_address_group.AddressGroup, address_group) 145 146 def address_groups(self, **query): 147 """Return a generator of address groups 148 149 :param dict query: Optional query parameters to be sent to limit 150 the resources being returned. 151 152 * ``name``: Address group name 153 * ``description``: Address group description 154 * ``project_id``: Owner project ID 155 156 :returns: A generator of address group objects 157 :rtype: :class:`~openstack.network.v2.address_group.AddressGroup` 158 """ 159 return self._list(_address_group.AddressGroup, **query) 160 161 def update_address_group(self, address_group, **attrs): 162 """Update an address group 163 164 :param address_group: Either the ID of an address group or a 165 :class:`~openstack.network.v2.address_group.AddressGroup` instance. 166 :param dict attrs: The attributes to update on the address group 167 represented by ``value``. 168 169 :returns: The updated address group 170 :rtype: :class:`~openstack.network.v2.address_group.AddressGroup` 171 """ 172 return self._update(_address_group.AddressGroup, address_group, 173 **attrs) 174 175 def add_addresses_to_address_group(self, address_group, addresses): 176 """Add addresses to a address group 177 178 :param address_group: Either the ID of an address group or a 179 :class:`~openstack.network.v2.address_group.AddressGroup` instance. 180 :param list addresses: List of address strings. 181 :returns: AddressGroup with updated addresses 182 :rtype: :class: `~openstack.network.v2.address_group.AddressGroup` 183 """ 184 ag = self._get_resource(_address_group.AddressGroup, address_group) 185 return ag.add_addresses(self, addresses) 186 187 def remove_addresses_from_address_group(self, address_group, addresses): 188 """Remove addresses from a address group 189 190 :param address_group: Either the ID of an address group or a 191 :class:`~openstack.network.v2.address_group.AddressGroup` instance. 192 :param list addresses: List of address strings. 193 :returns: AddressGroup with updated addresses 194 :rtype: :class: `~openstack.network.v2.address_group.AddressGroup` 195 """ 196 ag = self._get_resource(_address_group.AddressGroup, address_group) 197 return ag.remove_addresses(self, addresses) 198 199 def create_address_scope(self, **attrs): 200 """Create a new address scope from attributes 201 202 :param dict attrs: Keyword arguments which will be used to create 203 a :class:`~openstack.network.v2.address_scope.AddressScope`, 204 comprised of the properties on the AddressScope class. 205 206 :returns: The results of address scope creation 207 :rtype: :class:`~openstack.network.v2.address_scope.AddressScope` 208 """ 209 return self._create(_address_scope.AddressScope, **attrs) 210 211 def delete_address_scope(self, address_scope, ignore_missing=True): 212 """Delete an address scope 213 214 :param address_scope: The value can be either the ID of an 215 address scope or 216 a :class:`~openstack.network.v2.address_scope.AddressScope` 217 instance. 218 :param bool ignore_missing: When set to ``False`` 219 :class:`~openstack.exceptions.ResourceNotFound` will be 220 raised when the address scope does not exist. 221 When set to ``True``, no exception will be set when 222 attempting to delete a nonexistent address scope. 223 224 :returns: ``None`` 225 """ 226 self._delete(_address_scope.AddressScope, address_scope, 227 ignore_missing=ignore_missing) 228 229 def find_address_scope(self, name_or_id, ignore_missing=True, **args): 230 """Find a single address scope 231 232 :param name_or_id: The name or ID of an address scope. 233 :param bool ignore_missing: When set to ``False`` 234 :class:`~openstack.exceptions.ResourceNotFound` will be 235 raised when the resource does not exist. 236 When set to ``True``, None will be returned when 237 attempting to find a nonexistent resource. 238 :param dict args: Any additional parameters to be passed into 239 underlying methods. such as query filters. 240 :returns: One :class:`~openstack.network.v2.address_scope.AddressScope` 241 or None 242 """ 243 return self._find(_address_scope.AddressScope, name_or_id, 244 ignore_missing=ignore_missing, **args) 245 246 def get_address_scope(self, address_scope): 247 """Get a single address scope 248 249 :param address_scope: The value can be the ID of an address scope or a 250 :class:`~openstack.network.v2.address_scope.AddressScope` instance. 251 252 :returns: One :class:`~openstack.network.v2.address_scope.AddressScope` 253 :raises: :class:`~openstack.exceptions.ResourceNotFound` 254 when no resource can be found. 255 """ 256 return self._get(_address_scope.AddressScope, address_scope) 257 258 def address_scopes(self, **query): 259 """Return a generator of address scopes 260 261 :param dict query: Optional query parameters to be sent to limit 262 the resources being returned. 263 264 * ``name``: Address scope name 265 * ``ip_version``: Address scope IP address version 266 * ``tenant_id``: Owner tenant ID 267 * ``shared``: Address scope is shared (boolean) 268 269 :returns: A generator of address scope objects 270 :rtype: :class:`~openstack.network.v2.address_scope.AddressScope` 271 """ 272 return self._list(_address_scope.AddressScope, **query) 273 274 def update_address_scope(self, address_scope, **attrs): 275 """Update an address scope 276 277 :param address_scope: Either the ID of an address scope or a 278 :class:`~openstack.network.v2.address_scope.AddressScope` instance. 279 :param dict attrs: The attributes to update on the address scope 280 represented by ``value``. 281 282 :returns: The updated address scope 283 :rtype: :class:`~openstack.network.v2.address_scope.AddressScope` 284 """ 285 return self._update(_address_scope.AddressScope, address_scope, 286 **attrs) 287 288 def agents(self, **query): 289 """Return a generator of network agents 290 291 :param dict query: Optional query parameters to be sent to limit the 292 resources being returned. 293 294 * ``agent_type``: Agent type. 295 * ``availability_zone``: The availability zone for an agent. 296 * ``binary``: The name of the agent's application binary. 297 * ``description``: The description of the agent. 298 * ``host``: The host (host name or host address) the agent is 299 running on. 300 * ``topic``: The message queue topic used. 301 * ``is_admin_state_up``: The administrative state of the agent. 302 * ``is_alive``: Whether the agent is alive. 303 304 :returns: A generator of agents 305 :rtype: :class:`~openstack.network.v2.agent.Agent` 306 """ 307 return self._list(_agent.Agent, **query) 308 309 def delete_agent(self, agent, ignore_missing=True): 310 """Delete a network agent 311 312 :param agent: The value can be the ID of a agent or a 313 :class:`~openstack.network.v2.agent.Agent` instance. 314 :param bool ignore_missing: When set to ``False`` 315 :class:`~openstack.exceptions.ResourceNotFound` will be 316 raised when the agent does not exist. 317 When set to ``True``, no exception will be set when 318 attempting to delete a nonexistent agent. 319 320 :returns: ``None`` 321 """ 322 self._delete(_agent.Agent, agent, ignore_missing=ignore_missing) 323 324 def get_agent(self, agent): 325 """Get a single network agent 326 327 :param agent: The value can be the ID of a agent or a 328 :class:`~openstack.network.v2.agent.Agent` instance. 329 330 :returns: One :class:`~openstack.network.v2.agent.Agent` 331 :rtype: :class:`~openstack.network.v2.agent.Agent` 332 :raises: :class:`~openstack.exceptions.ResourceNotFound` 333 when no resource can be found. 334 """ 335 return self._get(_agent.Agent, agent) 336 337 def update_agent(self, agent, **attrs): 338 """Update a network agent 339 340 :param agent: The value can be the ID of a agent or a 341 :class:`~openstack.network.v2.agent.Agent` instance. 342 :param dict attrs: The attributes to update on the agent represented 343 by ``value``. 344 345 :returns: One :class:`~openstack.network.v2.agent.Agent` 346 :rtype: :class:`~openstack.network.v2.agent.Agent` 347 """ 348 return self._update(_agent.Agent, agent, **attrs) 349 350 def dhcp_agent_hosting_networks(self, agent, **query): 351 """A generator of networks hosted by a DHCP agent. 352 353 :param agent: Either the agent id of an instance of 354 :class:`~openstack.network.v2.network_agent.Agent` 355 :param query: kwargs query: Optional query parameters to be sent 356 to limit the resources being returned. 357 :return: A generator of networks 358 """ 359 agent_obj = self._get_resource(_agent.Agent, agent) 360 return self._list(_network.DHCPAgentHostingNetwork, 361 agent_id=agent_obj.id, **query) 362 363 def add_dhcp_agent_to_network(self, agent, network): 364 """Add a DHCP Agent to a network 365 366 :param agent: Either the agent id of an instance of 367 :class:`~openstack.network.v2.network_agent.Agent` 368 :param network: Network instance 369 :return: 370 """ 371 network = self._get_resource(_network.Network, network) 372 agent = self._get_resource(_agent.Agent, agent) 373 return agent.add_agent_to_network(self, network.id) 374 375 def remove_dhcp_agent_from_network(self, agent, network): 376 """Remove a DHCP Agent from a network 377 378 :param agent: Either the agent id of an instance of 379 :class:`~openstack.network.v2.network_agent.Agent` 380 :param network: Network instance 381 :return: 382 """ 383 network = self._get_resource(_network.Network, network) 384 agent = self._get_resource(_agent.Agent, agent) 385 return agent.remove_agent_from_network(self, network.id) 386 387 def network_hosting_dhcp_agents(self, network, **query): 388 """A generator of DHCP agents hosted on a network. 389 390 :param network: The instance of 391 :class:`~openstack.network.v2.network.Network` 392 :param dict query: Optional query parameters to be sent to limit the 393 resources returned. 394 :return: A generator of hosted DHCP agents 395 """ 396 net = self._get_resource(_network.Network, network) 397 return self._list(_agent.NetworkHostingDHCPAgent, network_id=net.id, 398 **query) 399 400 def get_auto_allocated_topology(self, project=None): 401 """Get the auto-allocated topology of a given tenant 402 403 :param project: 404 The value is the ID or name of a project 405 406 :returns: The auto-allocated topology 407 :rtype: :class:`~openstack.network.v2.\ 408 auto_allocated_topology.AutoAllocatedTopology` 409 """ 410 411 # If project option is not given, grab project id from session 412 if project is None: 413 project = self.get_project_id() 414 return self._get(_auto_allocated_topology.AutoAllocatedTopology, 415 project) 416 417 def delete_auto_allocated_topology(self, project=None, 418 ignore_missing=False): 419 """Delete auto-allocated topology 420 421 :param project: 422 The value is the ID or name of a project 423 :param ignore_missing: When set to ``False`` 424 :class:`~openstack.exceptions.ResourceNotFound` will be 425 raised when the topology does not exist. 426 When set to ``True``, no exception will be raised when 427 attempting to delete nonexistant topology 428 429 :returns: ``None`` 430 """ 431 432 # If project option is not given, grab project id from session 433 if project is None: 434 project = self.get_project_id() 435 self._delete(_auto_allocated_topology.AutoAllocatedTopology, 436 project, ignore_missing=ignore_missing) 437 438 def validate_auto_allocated_topology(self, project=None): 439 """Validate the resources for auto allocation 440 441 :param project: 442 The value is the ID or name of a project 443 444 :returns: Whether all resources are correctly configured or not 445 :rtype: :class:`~openstack.network.v2.\ 446 auto_allocated_topology.ValidateTopology` 447 """ 448 449 # If project option is not given, grab project id from session 450 if project is None: 451 project = self.get_project_id() 452 return self._get(_auto_allocated_topology.ValidateTopology, 453 project=project, requires_id=False) 454 455 def availability_zones(self, **query): 456 """Return a generator of availability zones 457 458 :param dict query: optional query parameters to be set to limit the 459 returned resources. Valid parameters include: 460 461 * ``name``: The name of an availability zone. 462 * ``resource``: The type of resource for the availability zone. 463 464 :returns: A generator of availability zone objects 465 :rtype: 466 :class:`~openstack.network.v2.availability_zone.AvailabilityZone` 467 """ 468 return self._list(availability_zone.AvailabilityZone) 469 470 def find_extension(self, name_or_id, ignore_missing=True, **args): 471 """Find a single extension 472 473 :param name_or_id: The name or ID of a extension. 474 :param bool ignore_missing: When set to ``False`` 475 :class:`~openstack.exceptions.ResourceNotFound` will be 476 raised when the resource does not exist. 477 When set to ``True``, None will be returned when 478 attempting to find a nonexistent resource. 479 :param dict args: Any additional parameters to be passed into 480 underlying methods. such as query filters. 481 :returns: One :class:`~openstack.network.v2.extension.Extension` 482 or None 483 """ 484 return self._find(extension.Extension, name_or_id, 485 ignore_missing=ignore_missing, **args) 486 487 def extensions(self, **query): 488 """Return a generator of extensions 489 490 :param dict query: Optional query parameters to be sent to limit 491 the resources being returned. Currently no 492 parameter is supported. 493 494 :returns: A generator of extension objects 495 :rtype: :class:`~openstack.network.v2.extension.Extension` 496 """ 497 return self._list(extension.Extension, **query) 498 499 def create_flavor(self, **attrs): 500 """Create a new network service flavor from attributes 501 502 :param dict attrs: Keyword arguments which will be used to create 503 a :class:`~openstack.network.v2.flavor.Flavor`, 504 comprised of the properties on the Flavor class. 505 506 :returns: The results of flavor creation 507 :rtype: :class:`~openstack.network.v2.flavor.Flavor` 508 """ 509 return self._create(_flavor.Flavor, **attrs) 510 511 def delete_flavor(self, flavor, ignore_missing=True): 512 """Delete a network service flavor 513 514 :param flavor: 515 The value can be either the ID of a flavor or a 516 :class:`~openstack.network.v2.flavor.Flavor` instance. 517 :param bool ignore_missing: When set to ``False`` 518 :class:`~openstack.exceptions.ResourceNotFound` will be 519 raised when the flavor does not exist. 520 When set to ``True``, no exception will be set when 521 attempting to delete a nonexistent flavor. 522 523 :returns: ``None`` 524 """ 525 self._delete(_flavor.Flavor, flavor, ignore_missing=ignore_missing) 526 527 def find_flavor(self, name_or_id, ignore_missing=True, **args): 528 """Find a single network service flavor 529 530 :param name_or_id: The name or ID of a flavor. 531 :param bool ignore_missing: When set to ``False`` 532 :class:`~openstack.exceptions.ResourceNotFound` will be 533 raised when the resource does not exist. 534 When set to ``True``, None will be returned when 535 attempting to find a nonexistent resource. 536 :param dict args: Any additional parameters to be passed into 537 underlying methods. such as query filters. 538 :returns: One :class:`~openstack.network.v2.flavor.Flavor` or None 539 """ 540 return self._find(_flavor.Flavor, name_or_id, 541 ignore_missing=ignore_missing, **args) 542 543 def get_flavor(self, flavor): 544 """Get a single network service flavor 545 546 :param flavor: 547 The value can be the ID of a flavor or a 548 :class:`~openstack.network.v2.flavor.Flavor` instance. 549 550 :returns: One :class:`~openstack.network.v2.flavor.Flavor` 551 :raises: :class:`~openstack.exceptions.ResourceNotFound` 552 when no resource can be found. 553 """ 554 return self._get(_flavor.Flavor, flavor) 555 556 def update_flavor(self, flavor, **attrs): 557 """Update a network service flavor 558 559 :param flavor: 560 Either the id of a flavor or a 561 :class:`~openstack.network.v2.flavor.Flavor` instance. 562 :attrs kwargs: The attributes to update on the flavor represented 563 by ``value``. 564 565 :returns: The updated flavor 566 :rtype: :class:`~openstack.network.v2.flavor.Flavor` 567 """ 568 return self._update(_flavor.Flavor, flavor, **attrs) 569 570 def flavors(self, **query): 571 """Return a generator of network service flavors 572 573 :param dict query: Optional query parameters to be sent to limit 574 the resources being returned. Valid parameters 575 include: 576 577 * ``description``: The description of a flavor. 578 * ``is_enabled``: Whether a flavor is enabled. 579 * ``name``: The name of a flavor. 580 * ``service_type``: The service type to which a falvor applies. 581 582 :returns: A generator of flavor objects 583 :rtype: :class:`~openstack.network.v2.flavor.Flavor` 584 """ 585 return self._list(_flavor.Flavor, **query) 586 587 def associate_flavor_with_service_profile(self, flavor, service_profile): 588 """Associate network flavor with service profile. 589 590 :param flavor: 591 Either the id of a flavor or a 592 :class:`~openstack.network.v2.flavor.Flavor` instance. 593 :param service_profile: 594 The value can be either the ID of a service profile or a 595 :class:`~openstack.network.v2.service_profile.ServiceProfile` 596 instance. 597 :return: 598 """ 599 flavor = self._get_resource(_flavor.Flavor, flavor) 600 service_profile = self._get_resource( 601 _service_profile.ServiceProfile, service_profile) 602 return flavor.associate_flavor_with_service_profile( 603 self, service_profile.id) 604 605 def disassociate_flavor_from_service_profile( 606 self, flavor, service_profile): 607 """Disassociate network flavor from service profile. 608 609 :param flavor: 610 Either the id of a flavor or a 611 :class:`~openstack.network.v2.flavor.Flavor` instance. 612 :param service_profile: 613 The value can be either the ID of a service profile or a 614 :class:`~openstack.network.v2.service_profile.ServiceProfile` 615 instance. 616 :return: 617 """ 618 flavor = self._get_resource(_flavor.Flavor, flavor) 619 service_profile = self._get_resource( 620 _service_profile.ServiceProfile, service_profile) 621 return flavor.disassociate_flavor_from_service_profile( 622 self, service_profile.id) 623 624 def create_ip(self, **attrs): 625 """Create a new floating ip from attributes 626 627 :param dict attrs: Keyword arguments which will be used to create 628 a :class:`~openstack.network.v2.floating_ip.FloatingIP`, 629 comprised of the properties on the FloatingIP class. 630 631 :returns: The results of floating ip creation 632 :rtype: :class:`~openstack.network.v2.floating_ip.FloatingIP` 633 """ 634 return self._create(_floating_ip.FloatingIP, **attrs) 635 636 def delete_ip(self, floating_ip, ignore_missing=True, if_revision=None): 637 """Delete a floating ip 638 639 :param floating_ip: The value can be either the ID of a floating ip 640 or a :class:`~openstack.network.v2.floating_ip.FloatingIP` 641 instance. 642 :param bool ignore_missing: When set to ``False`` 643 :class:`~openstack.exceptions.ResourceNotFound` will be 644 raised when the floating ip does not exist. 645 When set to ``True``, no exception will be set when 646 attempting to delete a nonexistent ip. 647 :param int if_revision: Revision to put in If-Match header of update 648 request to perform compare-and-swap update. 649 650 :returns: ``None`` 651 """ 652 self._delete(_floating_ip.FloatingIP, floating_ip, 653 ignore_missing=ignore_missing, if_revision=if_revision) 654 655 def find_available_ip(self): 656 """Find an available IP 657 658 :returns: One :class:`~openstack.network.v2.floating_ip.FloatingIP` 659 or None 660 """ 661 return _floating_ip.FloatingIP.find_available(self) 662 663 def find_ip(self, name_or_id, ignore_missing=True, **args): 664 """Find a single IP 665 666 :param name_or_id: The name or ID of an IP. 667 :param bool ignore_missing: When set to ``False`` 668 :class:`~openstack.exceptions.ResourceNotFound` will be 669 raised when the resource does not exist. 670 When set to ``True``, None will be returned when 671 attempting to find a nonexistent resource. 672 :param dict args: Any additional parameters to be passed into 673 underlying methods. such as query filters. 674 :returns: One :class:`~openstack.network.v2.floating_ip.FloatingIP` 675 or None 676 """ 677 return self._find(_floating_ip.FloatingIP, name_or_id, 678 ignore_missing=ignore_missing, **args) 679 680 def get_ip(self, floating_ip): 681 """Get a single floating ip 682 683 :param floating_ip: The value can be the ID of a floating ip or a 684 :class:`~openstack.network.v2.floating_ip.FloatingIP` 685 instance. 686 687 :returns: One :class:`~openstack.network.v2.floating_ip.FloatingIP` 688 :raises: :class:`~openstack.exceptions.ResourceNotFound` 689 when no resource can be found. 690 """ 691 return self._get(_floating_ip.FloatingIP, floating_ip) 692 693 def ips(self, **query): 694 """Return a generator of ips 695 696 :param dict query: Optional query parameters to be sent to limit 697 the resources being returned. Valid parameters are: 698 699 * ``description``: The description of a floating IP. 700 * ``fixed_ip_address``: The fixed IP address associated with a 701 floating IP address. 702 * ``floating_ip_address``: The IP address of a floating IP. 703 * ``floating_network_id``: The ID of the network associated with 704 a floating IP. 705 * ``port_id``: The ID of the port to which a floating IP is 706 associated. 707 * ``project_id``: The ID of the project a floating IP is 708 associated with. 709 * ``router_id``: The ID of an associated router. 710 * ``status``: The status of a floating IP, which can be ``ACTIVE`` 711 or ``DOWN``. 712 713 :returns: A generator of floating IP objects 714 :rtype: :class:`~openstack.network.v2.floating_ip.FloatingIP` 715 """ 716 return self._list(_floating_ip.FloatingIP, **query) 717 718 def update_ip(self, floating_ip, if_revision=None, **attrs): 719 """Update a ip 720 721 :param floating_ip: Either the id of a ip or a 722 :class:`~openstack.network.v2.floating_ip.FloatingIP` 723 instance. 724 :param int if_revision: Revision to put in If-Match header of update 725 request to perform compare-and-swap update. 726 :param dict attrs: The attributes to update on the ip represented 727 by ``value``. 728 729 :returns: The updated ip 730 :rtype: :class:`~openstack.network.v2.floating_ip.FloatingIP` 731 """ 732 return self._update(_floating_ip.FloatingIP, floating_ip, 733 if_revision=if_revision, **attrs) 734 735 def create_port_forwarding(self, **attrs): 736 """Create a new floating ip port forwarding from attributes 737 738 :param dict attrs: Keyword arguments which will be used to create 739 a :class:`~openstack.network.v2.port_forwarding.PortForwarding`, 740 comprised of the properties on the PortForwarding class. 741 742 :returns: The results of port forwarding creation 743 :rtype: :class:`~openstack.network.v2.port_forwarding.PortForwarding` 744 """ 745 return self._create(_port_forwarding.PortForwarding, **attrs) 746 747 def get_port_forwarding(self, port_forwarding, floating_ip): 748 """Get a single port forwarding 749 750 :param port_forwarding: The value can be the ID of a port forwarding 751 or a :class:`~openstack.network.v2.port_forwarding.PortForwarding` 752 instance. 753 :param floating_ip: The value can be the ID of a Floating IP or a 754 :class:`~openstack.network.v2.floating_ip.FloatingIP` 755 instance. 756 757 :returns: One 758 :class:`~openstack.network.v2.port_forwarding.PortForwarding` 759 :raises: :class:`~openstack.exceptions.ResourceNotFound` 760 when no resource can be found. 761 """ 762 floating_ip = self._get_resource(_floating_ip.FloatingIP, floating_ip) 763 return self._get(_port_forwarding.PortForwarding, port_forwarding, 764 floatingip_id=floating_ip.id) 765 766 def find_port_forwarding(self, pf_id, floating_ip, ignore_missing=True, 767 **args): 768 """Find a single port forwarding 769 770 :param pf_id: The ID of a port forwarding. 771 :param floating_ip: The value can be the ID of a Floating IP or a 772 :class:`~openstack.network.v2.floating_ip.FloatingIP` 773 instance. 774 :param bool ignore_missing: When set to ``False`` 775 :class:`~openstack.exceptions.ResourceNotFound` will be 776 raised when the resource does not exist. 777 When set to ``True``, None will be returned when 778 attempting to find a nonexistent resource. 779 :param dict args: Any additional parameters to be passed into 780 underlying methods. such as query filters. 781 :returns: 782 One :class:`~openstack.network.v2.port_forwarding.PortForwarding` 783 or None 784 """ 785 floating_ip = self._get_resource(_floating_ip.FloatingIP, floating_ip) 786 return self._find(_port_forwarding.PortForwarding, pf_id, 787 floatingip_id=floating_ip.id, 788 ignore_missing=ignore_missing, **args) 789 790 def delete_port_forwarding(self, port_forwarding, floating_ip, 791 ignore_missing=True): 792 """Delete a port forwarding 793 794 :param port_forwarding: The value can be the ID of a port forwarding 795 or a :class:`~openstack.network.v2.port_forwarding.PortForwarding` 796 instance. 797 :param floating_ip: The value can be the ID of a Floating IP or a 798 :class:`~openstack.network.v2.floating_ip.FloatingIP` 799 instance. 800 :param bool ignore_missing: When set to ``False`` 801 :class:`~openstack.exceptions.ResourceNotFound` will be 802 raised when the floating ip does not exist. 803 When set to ``True``, no exception will be set when 804 attempting to delete a nonexistent ip. 805 806 :returns: ``None`` 807 """ 808 fip = self._get_resource(_floating_ip.FloatingIP, floating_ip) 809 self._delete(_port_forwarding.PortForwarding, port_forwarding, 810 floatingip_id=fip.id, 811 ignore_missing=ignore_missing) 812 813 def port_forwardings(self, floating_ip, **query): 814 """Return a generator of port forwardings 815 816 :param floating_ip: The value can be the ID of a Floating IP or a 817 :class:`~openstack.network.v2.floating_ip.FloatingIP` 818 instance. 819 :param dict query: Optional query parameters to be sent to limit 820 the resources being returned. Valid parameters are: 821 822 * ``internal_port_id``: The ID of internal port. 823 * ``external_port``: The external TCP/UDP/other port number 824 * ``protocol``: TCP/UDP/other protocol 825 826 :returns: A generator of port forwarding objects 827 :rtype: :class:`~openstack.network.v2.port_forwarding.PortForwarding` 828 """ 829 fip = self._get_resource(_floating_ip.FloatingIP, floating_ip) 830 return self._list(_port_forwarding.PortForwarding, 831 floatingip_id=fip.id, **query) 832 833 def update_port_forwarding(self, port_forwarding, floating_ip, **attrs): 834 """Update a port forwarding 835 836 :param port_forwarding: The value can be the ID of a port forwarding 837 or a :class:`~openstack.network.v2.port_forwarding.PortForwarding` 838 instance. 839 :param floating_ip: The value can be the ID of a Floating IP or a 840 :class:`~openstack.network.v2.floating_ip.FloatingIP` 841 instance. 842 :param dict attrs: The attributes to update on the ip represented 843 by ``value``. 844 845 :returns: The updated port_forwarding 846 :rtype: :class:`~openstack.network.v2.port_forwarding.PortForwarding` 847 """ 848 fip = self._get_resource(_floating_ip.FloatingIP, floating_ip) 849 return self._update(_port_forwarding.PortForwarding, 850 port_forwarding, floatingip_id=fip.id, **attrs) 851 852 def create_health_monitor(self, **attrs): 853 """Create a new health monitor from attributes 854 855 :param dict attrs: Keyword arguments which will be used to create 856 a :class:`~openstack.network.v2.health_monitor.HealthMonitor`, 857 comprised of the properties on the HealthMonitor class. 858 859 :returns: The results of health monitor creation 860 :rtype: :class:`~openstack.network.v2.health_monitor.HealthMonitor` 861 """ 862 return self._create(_health_monitor.HealthMonitor, **attrs) 863 864 def delete_health_monitor(self, health_monitor, ignore_missing=True): 865 """Delete a health monitor 866 867 :param health_monitor: The value can be either the ID of a 868 health monitor or a 869 :class:`~openstack.network.v2.health_monitor.HealthMonitor` 870 instance. 871 :param bool ignore_missing: When set to ``False`` 872 :class:`~openstack.exceptions.ResourceNotFound` will be 873 raised when the health monitor does not exist. 874 When set to ``True``, no exception will be set when 875 attempting to delete a nonexistent health monitor. 876 877 :returns: ``None`` 878 """ 879 self._delete(_health_monitor.HealthMonitor, health_monitor, 880 ignore_missing=ignore_missing) 881 882 def find_health_monitor(self, name_or_id, ignore_missing=True, **args): 883 """Find a single health monitor 884 885 :param name_or_id: The name or ID of a health monitor. 886 :param bool ignore_missing: When set to ``False`` 887 :class:`~openstack.exceptions.ResourceNotFound` will be 888 raised when the resource does not exist. 889 When set to ``True``, None will be returned when 890 attempting to find a nonexistent resource. 891 :param dict args: Any additional parameters to be passed into 892 underlying methods. such as query filters. 893 :returns: One :class:`~openstack.network.v2.health_monitor. 894 HealthMonitor` or None 895 """ 896 return self._find(_health_monitor.HealthMonitor, 897 name_or_id, ignore_missing=ignore_missing, **args) 898 899 def get_health_monitor(self, health_monitor): 900 """Get a single health monitor 901 902 :param health_monitor: The value can be the ID of a health monitor or a 903 :class:`~openstack.network.v2.health_monitor.HealthMonitor` 904 instance. 905 906 :returns: One 907 :class:`~openstack.network.v2.health_monitor.HealthMonitor` 908 :raises: :class:`~openstack.exceptions.ResourceNotFound` 909 when no resource can be found. 910 """ 911 return self._get(_health_monitor.HealthMonitor, health_monitor) 912 913 def health_monitors(self, **query): 914 """Return a generator of health monitors 915 916 :param dict query: Optional query parameters to be sent to limit 917 the resources being returned. Valid parameters are: 918 919 * ``delay``: the time in milliseconds between sending probes. 920 * ``expected_codes``: The expected HTTP codes for a pssing HTTP(S) 921 monitor. 922 * ``http_method``: The HTTP method a monitor uses for requests. 923 * ``is_admin_state_up``: The administrative state of a health 924 monitor. 925 * ``max_retries``: The maximum consecutive health probe attempts. 926 * ``project_id``: The ID of the project this health monitor is 927 associated with. 928 * ``timeout``: The maximum number of milliseconds for a monitor to 929 wait for a connection to be established before it 930 times out. 931 * ``type``: The type of probe sent by the load balancer for health 932 check, which can be ``PING``, ``TCP``, ``HTTP`` or 933 ``HTTPS``. 934 * ``url_path``: The path portion of a URI that will be probed. 935 936 :returns: A generator of health monitor objects 937 :rtype: :class:`~openstack.network.v2.health_monitor.HealthMonitor` 938 """ 939 return self._list(_health_monitor.HealthMonitor, **query) 940 941 def update_health_monitor(self, health_monitor, **attrs): 942 """Update a health monitor 943 944 :param health_monitor: Either the id of a health monitor or a 945 :class:`~openstack.network.v2.health_monitor. 946 HealthMonitor` instance. 947 :param dict attrs: The attributes to update on the health monitor 948 represented by ``value``. 949 950 :returns: The updated health monitor 951 :rtype: :class:`~openstack.network.v2.health_monitor.HealthMonitor` 952 """ 953 return self._update(_health_monitor.HealthMonitor, health_monitor, 954 **attrs) 955 956 def create_vpn_ipsec_site_connection(self, **attrs): 957 """Create a new ipsec site connection from attributes 958 959 :param dict attrs: Keyword arguments which will be used to create a 960 :class:`~openstack.network.v2.ipsec_site_connection. 961 IPSecSiteConnection`, comprised of the properties on the 962 IPSecSiteConnection class. 963 964 :returns: The results of ipsec site connection creation :rtype: 965 :class:`~openstack.network.v2.ipsec_site_connection. 966 IPSecSiteConnection` 967 """ 968 return self._create(_ipsec_site_connection.IPSecSiteConnection, 969 **attrs) 970 971 def find_vpn_ipsec_site_connection(self, name_or_id, 972 ignore_missing=True, **args): 973 """Find a single ipsec site connection 974 975 :param name_or_id: The name or ID of an ipsec site connection. 976 :param bool ignore_missing: When set to ``False`` :class:`~openstack. 977 exceptions.ResourceNotFound` will be raised when the resource does 978 not exist.When set to ``True``, None will be returned when 979 attempting to find a nonexistent resource. 980 :param dict args: Any additional parameters to be passed into 981 underlying methods such as query filters. 982 :returns: One :class:`~openstack.network.v2.ipsec_site_connection. 983 IPSecSiteConnection` or None 984 """ 985 return self._find(_ipsec_site_connection.IPSecSiteConnection, 986 name_or_id, ignore_missing=ignore_missing, **args) 987 988 def get_vpn_ipsec_site_connection(self, ipsec_site_connection): 989 """Get a single ipsec site connection 990 991 :param ipsec_site_connection: The value can be the ID of an ipsec site 992 connection or a :class:`~openstack.network.v2. 993 ipsec_site_connection.IPSecSiteConnection` instance. 994 995 :returns: One :class:`~openstack.network.v2.ipsec_site_connection. 996 IPSecSiteConnection` 997 :raises: :class:`~openstack.exceptions.ResourceNotFound` 998 when no resource can be found. 999 """ 1000 return self._get(_ipsec_site_connection.IPSecSiteConnection, 1001 ipsec_site_connection) 1002 1003 def vpn_ipsec_site_connections(self, **query): 1004 """Return a generator of ipsec site connections 1005 1006 :param dict query: Optional query parameters to be sent to limit the 1007 resources being returned. 1008 1009 :returns: A generator of ipsec site connection objects 1010 :rtype: :class:`~openstack.network.v2.ipsec_site_connection. 1011 IPSecSiteConnection` 1012 """ 1013 return self._list(_ipsec_site_connection.IPSecSiteConnection, **query) 1014 1015 def update_vpn_ipsec_site_connection(self, ipsec_site_connection, **attrs): 1016 """Update a ipsec site connection 1017 1018 :ipsec_site_connection: Either the id of an ipsec site connection or 1019 a :class:`~openstack.network.v2.ipsec_site_connection. 1020 IPSecSiteConnection` instance. 1021 :param dict attrs: The attributes to update on the ipsec site 1022 connection represented by ``ipsec_site_connection``. 1023 1024 :returns: The updated ipsec site connection 1025 :rtype: :class:`~openstack.network.v2.ipsec_site_connection. 1026 IPSecSiteConnection` 1027 """ 1028 return self._update(_ipsec_site_connection.IPSecSiteConnection, 1029 ipsec_site_connection, **attrs) 1030 1031 def delete_vpn_ipsec_site_connection(self, ipsec_site_connection, 1032 ignore_missing=True): 1033 """Delete a ipsec site connection 1034 1035 :param ipsec_site_connection: The value can be either the ID of an 1036 ipsec site connection, or a :class:`~openstack.network.v2. 1037 ipsec_site_connection.IPSecSiteConnection` instance. 1038 :param bool ignore_missing: 1039 When set to ``False`` :class:`~openstack.exceptions. 1040 ResourceNotFound` will be raised when the ipsec site connection 1041 does not exist. 1042 When set to ``True``, no exception will be set when attempting to 1043 delete a nonexistent ipsec site connection. 1044 1045 :returns: ``None`` 1046 """ 1047 self._delete(_ipsec_site_connection.IPSecSiteConnection, 1048 ipsec_site_connection, ignore_missing=ignore_missing) 1049 1050 def create_listener(self, **attrs): 1051 """Create a new listener from attributes 1052 1053 :param dict attrs: Keyword arguments which will be used to create 1054 a :class:`~openstack.network.v2.listener.Listener`, 1055 comprised of the properties on the Listener class. 1056 1057 :returns: The results of listener creation 1058 :rtype: :class:`~openstack.network.v2.listener.Listener` 1059 """ 1060 return self._create(_listener.Listener, **attrs) 1061 1062 def delete_listener(self, listener, ignore_missing=True): 1063 """Delete a listener 1064 1065 :param listener: The value can be either the ID of a listner or a 1066 :class:`~openstack.network.v2.listener.Listener` instance. 1067 :param bool ignore_missing: When set to ``False`` 1068 :class:`~openstack.exceptions.ResourceNotFound` will be 1069 raised when the listner does not exist. 1070 When set to ``True``, no exception will be set when 1071 attempting to delete a nonexistent listener. 1072 1073 :returns: ``None`` 1074 """ 1075 self._delete(_listener.Listener, listener, 1076 ignore_missing=ignore_missing) 1077 1078 def find_listener(self, name_or_id, ignore_missing=True, **args): 1079 """Find a single listener 1080 1081 :param name_or_id: The name or ID of a listener. 1082 :param bool ignore_missing: When set to ``False`` 1083 :class:`~openstack.exceptions.ResourceNotFound` will be 1084 raised when the resource does not exist. 1085 When set to ``True``, None will be returned when 1086 attempting to find a nonexistent resource. 1087 :param dict args: Any additional parameters to be passed into 1088 underlying methods. such as query filters. 1089 :returns: One :class:`~openstack.network.v2.listener.Listener` or None 1090 """ 1091 return self._find(_listener.Listener, name_or_id, 1092 ignore_missing=ignore_missing, **args) 1093 1094 def get_listener(self, listener): 1095 """Get a single listener 1096 1097 :param listener: The value can be the ID of a listener or a 1098 :class:`~openstack.network.v2.listener.Listener` 1099 instance. 1100 1101 :returns: One :class:`~openstack.network.v2.listener.Listener` 1102 :raises: :class:`~openstack.exceptions.ResourceNotFound` 1103 when no resource can be found. 1104 """ 1105 return self._get(_listener.Listener, listener) 1106 1107 def listeners(self, **query): 1108 """Return a generator of listeners 1109 1110 :param dict query: Optional query parameters to be sent to limit 1111 the resources being returned. Valid parameters are: 1112 1113 * ``connection_limit``: The maximum number of connections 1114 permitted for the load-balancer. 1115 * ``default_pool_id``: The ID of the default pool. 1116 * ``default_tls_container_ref``: A reference to a container of TLS 1117 secret. 1118 * ``description``: The description of a listener. 1119 * ``is_admin_state_up``: The administrative state of the listener. 1120 * ``name``: The name of a listener. 1121 * ``project_id``: The ID of the project associated with a listener. 1122 * ``protocol``: The protocol of the listener. 1123 * ``protocol_port``: Port the listener will listen to. 1124 1125 :returns: A generator of listener objects 1126 :rtype: :class:`~openstack.network.v2.listener.Listener` 1127 """ 1128 return self._list(_listener.Listener, **query) 1129 1130 def update_listener(self, listener, **attrs): 1131 """Update a listener 1132 1133 :param listener: Either the id of a listener or a 1134 :class:`~openstack.network.v2.listener.Listener` 1135 instance. 1136 :param dict attrs: The attributes to update on the listener 1137 represented by ``listener``. 1138 1139 :returns: The updated listener 1140 :rtype: :class:`~openstack.network.v2.listener.Listener` 1141 """ 1142 return self._update(_listener.Listener, listener, **attrs) 1143 1144 def create_load_balancer(self, **attrs): 1145 """Create a new load balancer from attributes 1146 1147 :param dict attrs: Keyword arguments which will be used to create 1148 a :class:`~openstack.network.v2.load_balancer.LoadBalancer`, 1149 comprised of the properties on the LoadBalancer class. 1150 1151 :returns: The results of load balancer creation 1152 :rtype: :class:`~openstack.network.v2.load_balancer.LoadBalancer` 1153 """ 1154 return self._create(_load_balancer.LoadBalancer, **attrs) 1155 1156 def delete_load_balancer(self, load_balancer, ignore_missing=True): 1157 """Delete a load balancer 1158 1159 :param load_balancer: The value can be the ID of a load balancer or a 1160 :class:`~openstack.network.v2.load_balancer.LoadBalancer` 1161 instance. 1162 :param bool ignore_missing: When set to ``False`` 1163 :class:`~openstack.exceptions.ResourceNotFound` will be 1164 raised when the load balancer does not exist. 1165 When set to ``True``, no exception will be set when 1166 attempting to delete a nonexistent load balancer. 1167 1168 :returns: ``None`` 1169 """ 1170 self._delete(_load_balancer.LoadBalancer, load_balancer, 1171 ignore_missing=ignore_missing) 1172 1173 def find_load_balancer(self, name_or_id, ignore_missing=True, **args): 1174 """Find a single load balancer 1175 1176 :param name_or_id: The name or ID of a load balancer. 1177 :param bool ignore_missing: When set to ``False`` 1178 :class:`~openstack.exceptions.ResourceNotFound` will be 1179 raised when the resource does not exist. 1180 When set to ``True``, None will be returned when 1181 attempting to find a nonexistent resource. 1182 :param dict args: Any additional parameters to be passed into 1183 underlying methods. such as query filters. 1184 :returns: One :class:`~openstack.network.v2.load_balancer.LoadBalancer` 1185 or None 1186 """ 1187 return self._find(_load_balancer.LoadBalancer, name_or_id, 1188 ignore_missing=ignore_missing, **args) 1189 1190 def get_load_balancer(self, load_balancer): 1191 """Get a single load balancer 1192 1193 :param load_balancer: The value can be the ID of a load balancer or a 1194 :class:`~openstack.network.v2.load_balancer.LoadBalancer` 1195 instance. 1196 1197 :returns: One :class:`~openstack.network.v2.load_balancer.LoadBalancer` 1198 :raises: :class:`~openstack.exceptions.ResourceNotFound` 1199 when no resource can be found. 1200 """ 1201 return self._get(_load_balancer.LoadBalancer, load_balancer) 1202 1203 def load_balancers(self, **query): 1204 """Return a generator of load balancers 1205 1206 :param dict query: Optional query parameters to be sent to limit 1207 the resources being returned. 1208 1209 :returns: A generator of load balancer objects 1210 :rtype: :class:`~openstack.network.v2.load_balancer.LoadBalancer` 1211 """ 1212 return self._list(_load_balancer.LoadBalancer, **query) 1213 1214 def update_load_balancer(self, load_balancer, **attrs): 1215 """Update a load balancer 1216 1217 :param load_balancer: Either the id of a load balancer or a 1218 :class:`~openstack.network.v2.load_balancer.LoadBalancer` 1219 instance. 1220 :param dict attrs: The attributes to update on the load balancer 1221 represented by ``load_balancer``. 1222 1223 :returns: The updated load balancer 1224 :rtype: :class:`~openstack.network.v2.load_balancer.LoadBalancer` 1225 """ 1226 return self._update(_load_balancer.LoadBalancer, load_balancer, 1227 **attrs) 1228 1229 def create_metering_label(self, **attrs): 1230 """Create a new metering label from attributes 1231 1232 :param dict attrs: Keyword arguments which will be used to create 1233 a :class:`~openstack.network.v2.metering_label.MeteringLabel`, 1234 comprised of the properties on the MeteringLabel class. 1235 1236 :returns: The results of metering label creation 1237 :rtype: :class:`~openstack.network.v2.metering_label.MeteringLabel` 1238 """ 1239 return self._create(_metering_label.MeteringLabel, **attrs) 1240 1241 def delete_metering_label(self, metering_label, ignore_missing=True): 1242 """Delete a metering label 1243 1244 :param metering_label: 1245 The value can be either the ID of a metering label or a 1246 :class:`~openstack.network.v2.metering_label.MeteringLabel` 1247 instance. 1248 :param bool ignore_missing: When set to ``False`` 1249 :class:`~openstack.exceptions.ResourceNotFound` will be 1250 raised when the metering label does not exist. 1251 When set to ``True``, no exception will be set when 1252 attempting to delete a nonexistent metering label. 1253 1254 :returns: ``None`` 1255 """ 1256 self._delete(_metering_label.MeteringLabel, metering_label, 1257 ignore_missing=ignore_missing) 1258 1259 def find_metering_label(self, name_or_id, ignore_missing=True, **args): 1260 """Find a single metering label 1261 1262 :param name_or_id: The name or ID of a metering label. 1263 :param bool ignore_missing: When set to ``False`` 1264 :class:`~openstack.exceptions.ResourceNotFound` will be 1265 raised when the resource does not exist. 1266 When set to ``True``, None will be returned when 1267 attempting to find a nonexistent resource. 1268 :param dict args: Any additional parameters to be passed into 1269 underlying methods. such as query filters. 1270 :returns: One :class:`~openstack.network.v2.metering_label. 1271 MeteringLabel` or None 1272 """ 1273 return self._find(_metering_label.MeteringLabel, name_or_id, 1274 ignore_missing=ignore_missing, **args) 1275 1276 def get_metering_label(self, metering_label): 1277 """Get a single metering label 1278 1279 :param metering_label: The value can be the ID of a metering label or a 1280 :class:`~openstack.network.v2.metering_label.MeteringLabel` 1281 instance. 1282 1283 :returns: One 1284 :class:`~openstack.network.v2.metering_label.MeteringLabel` 1285 :raises: :class:`~openstack.exceptions.ResourceNotFound` 1286 when no resource can be found. 1287 """ 1288 return self._get(_metering_label.MeteringLabel, metering_label) 1289 1290 def metering_labels(self, **query): 1291 """Return a generator of metering labels 1292 1293 :param dict query: Optional query parameters to be sent to limit 1294 the resources being returned. Valid parameters are: 1295 1296 * ``description``: Description of a metering label. 1297 * ``name``: Name of a metering label. 1298 * ``is_shared``: Boolean indicating whether a metering label is 1299 shared. 1300 * ``project_id``: The ID of the project a metering label is 1301 associated with. 1302 1303 :returns: A generator of metering label objects 1304 :rtype: :class:`~openstack.network.v2.metering_label.MeteringLabel` 1305 """ 1306 return self._list(_metering_label.MeteringLabel, **query) 1307 1308 def update_metering_label(self, metering_label, **attrs): 1309 """Update a metering label 1310 1311 :param metering_label: Either the id of a metering label or a 1312 :class:`~openstack.network.v2.metering_label. 1313 MeteringLabel` instance. 1314 :param dict attrs: The attributes to update on the metering label 1315 represented by ``metering_label``. 1316 1317 :returns: The updated metering label 1318 :rtype: :class:`~openstack.network.v2.metering_label.MeteringLabel` 1319 """ 1320 return self._update(_metering_label.MeteringLabel, metering_label, 1321 **attrs) 1322 1323 def create_metering_label_rule(self, **attrs): 1324 """Create a new metering label rule from attributes 1325 1326 :param dict attrs: Keyword arguments which will be used to create a 1327 :class:`~openstack.network.v2.metering_label_rule.\ 1328 MeteringLabelRule`, comprised of the properties on 1329 the MeteringLabelRule class. 1330 1331 :returns: The results of metering label rule creation 1332 :rtype: :class:`~openstack.network.v2.metering_label_rule.\ 1333 MeteringLabelRule` 1334 """ 1335 return self._create(_metering_label_rule.MeteringLabelRule, **attrs) 1336 1337 def delete_metering_label_rule(self, metering_label_rule, 1338 ignore_missing=True): 1339 """Delete a metering label rule 1340 1341 :param metering_label_rule: 1342 The value can be either the ID of a metering label rule 1343 or a :class:`~openstack.network.v2.metering_label_rule.\ 1344 MeteringLabelRule` instance. 1345 :param bool ignore_missing: When set to ``False`` 1346 :class:`~openstack.exceptions.ResourceNotFound` will be raised 1347 when the metering label rule does not exist. When set to ``True``, 1348 no exception will be set when attempting to delete a nonexistent 1349 metering label rule. 1350 1351 :returns: ``None`` 1352 """ 1353 self._delete(_metering_label_rule.MeteringLabelRule, 1354 metering_label_rule, ignore_missing=ignore_missing) 1355 1356 def find_metering_label_rule(self, name_or_id, ignore_missing=True, 1357 **args): 1358 """Find a single metering label rule 1359 1360 :param name_or_id: The name or ID of a metering label rule. 1361 :param bool ignore_missing: When set to ``False`` 1362 :class:`~openstack.exceptions.ResourceNotFound` will be 1363 raised when the resource does not exist. 1364 When set to ``True``, None will be returned when 1365 attempting to find a nonexistent resource. 1366 :param dict args: Any additional parameters to be passed into 1367 underlying methods. such as query filters. 1368 :returns: One :class:`~openstack.network.v2.metering_label_rule. 1369 MeteringLabelRule` or None 1370 """ 1371 return self._find(_metering_label_rule.MeteringLabelRule, name_or_id, 1372 ignore_missing=ignore_missing, **args) 1373 1374 def get_metering_label_rule(self, metering_label_rule): 1375 """Get a single metering label rule 1376 1377 :param metering_label_rule: 1378 The value can be the ID of a metering label rule or a 1379 :class:`~openstack.network.v2.metering_label_rule.\ 1380 MeteringLabelRule` instance. 1381 1382 :returns: One 1383 :class:`~openstack.network.v2.metering_label_rule.\ 1384 MeteringLabelRule` 1385 :raises: :class:`~openstack.exceptions.ResourceNotFound` 1386 when no resource can be found. 1387 """ 1388 return self._get(_metering_label_rule.MeteringLabelRule, 1389 metering_label_rule) 1390 1391 def metering_label_rules(self, **query): 1392 """Return a generator of metering label rules 1393 1394 :param dict query: Optional query parameters to be sent to limit 1395 the resources being returned. Valid parameters are: 1396 1397 * ``direction``: The direction in which metering label rule is 1398 applied. 1399 * ``metering_label_id``: The ID of a metering label this rule is 1400 associated with. 1401 * ``project_id``: The ID of the project the metering label rule is 1402 associated with. 1403 * ``remote_ip_prefix``: The remote IP prefix to be associated with 1404 this metering label rule. 1405 1406 :returns: A generator of metering label rule objects 1407 :rtype: :class:`~openstack.network.v2.metering_label_rule. 1408 MeteringLabelRule` 1409 """ 1410 return self._list(_metering_label_rule.MeteringLabelRule, **query) 1411 1412 def update_metering_label_rule(self, metering_label_rule, **attrs): 1413 """Update a metering label rule 1414 1415 :param metering_label_rule: 1416 Either the id of a metering label rule or a 1417 :class:`~openstack.network.v2.metering_label_rule. 1418 MeteringLabelRule` instance. 1419 :param dict attrs: The attributes to update on the metering label rule 1420 represented by ``metering_label_rule``. 1421 1422 :returns: The updated metering label rule 1423 :rtype: :class:`~openstack.network.v2.metering_label_rule. 1424 MeteringLabelRule` 1425 """ 1426 return self._update(_metering_label_rule.MeteringLabelRule, 1427 metering_label_rule, **attrs) 1428 1429 def create_network(self, **attrs): 1430 """Create a new network from attributes 1431 1432 :param dict attrs: Keyword arguments which will be used to create 1433 a :class:`~openstack.network.v2.network.Network`, 1434 comprised of the properties on the Network class. 1435 1436 :returns: The results of network creation 1437 :rtype: :class:`~openstack.network.v2.network.Network` 1438 """ 1439 return self._create(_network.Network, **attrs) 1440 1441 def delete_network(self, network, ignore_missing=True, if_revision=None): 1442 """Delete a network 1443 1444 :param network: 1445 The value can be either the ID of a network or a 1446 :class:`~openstack.network.v2.network.Network` instance. 1447 :param bool ignore_missing: When set to ``False`` 1448 :class:`~openstack.exceptions.ResourceNotFound` will be 1449 raised when the network does not exist. 1450 When set to ``True``, no exception will be set when 1451 attempting to delete a nonexistent network. 1452 :param int if_revision: Revision to put in If-Match header of update 1453 request to perform compare-and-swap update. 1454 1455 :returns: ``None`` 1456 """ 1457 self._delete(_network.Network, network, ignore_missing=ignore_missing, 1458 if_revision=if_revision) 1459 1460 def find_network(self, name_or_id, ignore_missing=True, **args): 1461 """Find a single network 1462 1463 :param name_or_id: The name or ID of a network. 1464 :param bool ignore_missing: When set to ``False`` 1465 :class:`~openstack.exceptions.ResourceNotFound` will be 1466 raised when the resource does not exist. 1467 When set to ``True``, None will be returned when 1468 attempting to find a nonexistent resource. 1469 :param dict args: Any additional parameters to be passed into 1470 underlying methods. such as query filters. 1471 :returns: One :class:`~openstack.network.v2.network.Network` or None 1472 """ 1473 return self._find(_network.Network, name_or_id, 1474 ignore_missing=ignore_missing, **args) 1475 1476 def get_network(self, network): 1477 """Get a single network 1478 1479 :param network: 1480 The value can be the ID of a network or a 1481 :class:`~openstack.network.v2.network.Network` instance. 1482 1483 :returns: One :class:`~openstack.network.v2.network.Network` 1484 :raises: :class:`~openstack.exceptions.ResourceNotFound` 1485 when no resource can be found. 1486 """ 1487 return self._get(_network.Network, network) 1488 1489 def networks(self, **query): 1490 """Return a generator of networks 1491 1492 :param kwargs query: Optional query parameters to be sent to limit 1493 the resources being returned. Available parameters include: 1494 1495 * ``description``: The network description. 1496 * ``ipv4_address_scope_id``: The ID of the IPv4 address scope for 1497 the network. 1498 * ``ipv6_address_scope_id``: The ID of the IPv6 address scope for 1499 the network. 1500 * ``is_admin_state_up``: Network administrative state 1501 * ``is_port_security_enabled``: The port security status. 1502 * ``is_router_external``: Network is external or not. 1503 * ``is_shared``: Whether the network is shared across projects. 1504 * ``name``: The name of the network. 1505 * ``status``: Network status 1506 * ``project_id``: Owner tenant ID 1507 * ``provider_network_type``: Network physical mechanism 1508 * ``provider_physical_network``: Physical network 1509 * ``provider_segmentation_id``: VLAN ID for VLAN networks or Tunnel 1510 ID for GENEVE/GRE/VXLAN networks 1511 1512 :returns: A generator of network objects 1513 :rtype: :class:`~openstack.network.v2.network.Network` 1514 """ 1515 return self._list(_network.Network, **query) 1516 1517 def update_network(self, network, if_revision=None, **attrs): 1518 """Update a network 1519 1520 :param network: Either the id of a network or an instance of type 1521 :class:`~openstack.network.v2.network.Network`. 1522 :param int if_revision: Revision to put in If-Match header of update 1523 request to perform compare-and-swap update. 1524 :param dict attrs: The attributes to update on the network represented 1525 by ``network``. 1526 1527 :returns: The updated network 1528 :rtype: :class:`~openstack.network.v2.network.Network` 1529 """ 1530 return self._update(_network.Network, network, if_revision=if_revision, 1531 **attrs) 1532 1533 def find_network_ip_availability(self, name_or_id, ignore_missing=True, 1534 **args): 1535 """Find IP availability of a network 1536 1537 :param name_or_id: The name or ID of a network. 1538 :param bool ignore_missing: When set to ``False`` 1539 :class:`~openstack.exceptions.ResourceNotFound` will be 1540 raised when the resource does not exist. 1541 When set to ``True``, None will be returned when 1542 attempting to find a nonexistent resource. 1543 :param dict args: Any additional parameters to be passed into 1544 underlying methods. such as query filters. 1545 :returns: One :class:`~openstack.network.v2.network_ip_availability. 1546 NetworkIPAvailability` or None 1547 """ 1548 return self._find(network_ip_availability.NetworkIPAvailability, 1549 name_or_id, ignore_missing=ignore_missing, **args) 1550 1551 def get_network_ip_availability(self, network): 1552 """Get IP availability of a network 1553 1554 :param network: 1555 The value can be the ID of a network or a 1556 :class:`~openstack.network.v2.network.Network` instance. 1557 1558 :returns: One :class:`~openstack.network.v2.network_ip_availability. 1559 NetworkIPAvailability` 1560 :raises: :class:`~openstack.exceptions.ResourceNotFound` 1561 when no resource can be found. 1562 """ 1563 return self._get(network_ip_availability.NetworkIPAvailability, 1564 network) 1565 1566 def network_ip_availabilities(self, **query): 1567 """Return a generator of network ip availabilities 1568 1569 :param kwargs query: Optional query parameters to be sent to limit 1570 the resources being returned. Available parameters include: 1571 1572 * ``ip_version``: IP version of the network 1573 * ``network_id``: ID of network to use when listening network IP 1574 availability. 1575 * ``network_name``: The name of the network for the particular 1576 network IP availability. 1577 * ``project_id``: Owner tenant ID 1578 1579 :returns: A generator of network ip availability objects 1580 :rtype: :class:`~openstack.network.v2.network_ip_availability. 1581 NetworkIPAvailability` 1582 """ 1583 return self._list(network_ip_availability.NetworkIPAvailability, 1584 **query) 1585 1586 def create_network_segment_range(self, **attrs): 1587 """Create a new network segment range from attributes 1588 1589 :param dict attrs: Keyword arguments which will be used to create a 1590 :class:`~openstack.network.v2. 1591 network_segment_range.NetworkSegmentRange`, 1592 comprised of the properties on the 1593 NetworkSegmentRange class. 1594 1595 :returns: The results of network segment range creation 1596 :rtype: :class:`~openstack.network.v2.network_segment_range 1597 .NetworkSegmentRange` 1598 """ 1599 return self._create(_network_segment_range.NetworkSegmentRange, 1600 **attrs) 1601 1602 def delete_network_segment_range(self, network_segment_range, 1603 ignore_missing=True): 1604 """Delete a network segment range 1605 1606 :param network_segment_range: The value can be either the ID of a 1607 network segment range or a 1608 :class:`~openstack.network.v2.network_segment_range. 1609 NetworkSegmentRange` instance. 1610 :param bool ignore_missing: When set to ``False`` 1611 :class:`~openstack.exceptions.ResourceNotFound` will be 1612 raised when the network segment range does not exist. 1613 When set to ``True``, no exception will be set when 1614 attempting to delete a nonexistent network segment range. 1615 1616 :returns: ``None`` 1617 """ 1618 self._delete(_network_segment_range.NetworkSegmentRange, 1619 network_segment_range, ignore_missing=ignore_missing) 1620 1621 def find_network_segment_range(self, name_or_id, ignore_missing=True, 1622 **args): 1623 """Find a single network segment range 1624 1625 :param name_or_id: The name or ID of a network segment range. 1626 :param bool ignore_missing: When set to ``False`` 1627 :class:`~openstack.exceptions.ResourceNotFound` will be 1628 raised when the resource does not exist. 1629 When set to ``True``, None will be returned when 1630 attempting to find a nonexistent resource. 1631 :param dict args: Any additional parameters to be passed into 1632 underlying methods. such as query filters. 1633 :returns: One :class:`~openstack.network.v2.network_segment_range 1634 .NetworkSegmentRange` or None 1635 """ 1636 return self._find(_network_segment_range.NetworkSegmentRange, 1637 name_or_id, ignore_missing=ignore_missing, **args) 1638 1639 def get_network_segment_range(self, network_segment_range): 1640 """Get a single network segment range 1641 1642 :param network_segment_range: The value can be the ID of a network 1643 segment range or a :class:`~openstack.network.v2. 1644 network_segment_range.NetworkSegmentRange` instance. 1645 1646 :returns: One :class:`~openstack.network.v2._network_segment_range. 1647 NetworkSegmentRange` 1648 :raises: :class:`~openstack.exceptions.ResourceNotFound` 1649 when no resource can be found. 1650 """ 1651 return self._get(_network_segment_range.NetworkSegmentRange, 1652 network_segment_range) 1653 1654 def network_segment_ranges(self, **query): 1655 """Return a generator of network segment ranges 1656 1657 :param kwargs query: Optional query parameters to be sent to limit 1658 the resources being returned. Available parameters include: 1659 1660 * ``name``: Name of the segments 1661 * ``default``: The network segment range is loaded from the host 1662 configuration file. 1663 * ``shared``: The network segment range is shared with other 1664 projects 1665 * ``project_id``: ID of the project that owns the network 1666 segment range 1667 * ``network_type``: Network type for the network segment ranges 1668 * ``physical_network``: Physical network name for the network 1669 segment ranges 1670 * ``minimum``: Minimum segmentation ID for the network segment 1671 ranges 1672 * ``maximum``: Maximum Segmentation ID for the network segment 1673 ranges 1674 * ``used``: Mapping of which segmentation ID in the range is 1675 used by which tenant 1676 * ``available``: List of available segmentation IDs in this 1677 network segment range 1678 1679 :returns: A generator of network segment range objects 1680 :rtype: :class:`~openstack.network.v2._network_segment_range. 1681 NetworkSegmentRange` 1682 """ 1683 return self._list(_network_segment_range.NetworkSegmentRange, **query) 1684 1685 def update_network_segment_range(self, network_segment_range, **attrs): 1686 """Update a network segment range 1687 1688 :param network_segment_range: Either the id of a network segment range 1689 or a :class:`~openstack.network.v2._network_segment_range. 1690 NetworkSegmentRange` instance. 1691 :attrs kwargs: The attributes to update on the network segment range 1692 represented by ``value``. 1693 1694 :returns: The updated network segment range 1695 :rtype: :class:`~openstack.network.v2._network_segment_range. 1696 NetworkSegmentRange` 1697 """ 1698 return self._update(_network_segment_range.NetworkSegmentRange, 1699 network_segment_range, **attrs) 1700 1701 def create_pool(self, **attrs): 1702 """Create a new pool from attributes 1703 1704 :param dict attrs: Keyword arguments which will be used to create 1705 a :class:`~openstack.network.v2.pool.Pool`, 1706 comprised of the properties on the Pool class. 1707 1708 :returns: The results of pool creation 1709 :rtype: :class:`~openstack.network.v2.pool.Pool` 1710 """ 1711 return self._create(_pool.Pool, **attrs) 1712 1713 def delete_pool(self, pool, ignore_missing=True): 1714 """Delete a pool 1715 1716 :param pool: The value can be either the ID of a pool or a 1717 :class:`~openstack.network.v2.pool.Pool` instance. 1718 :param bool ignore_missing: When set to ``False`` 1719 :class:`~openstack.exceptions.ResourceNotFound` will be 1720 raised when the pool does not exist. 1721 When set to ``True``, no exception will be set when 1722 attempting to delete a nonexistent pool. 1723 1724 :returns: ``None`` 1725 """ 1726 self._delete(_pool.Pool, pool, ignore_missing=ignore_missing) 1727 1728 def find_pool(self, name_or_id, ignore_missing=True, **args): 1729 """Find a single pool 1730 1731 :param name_or_id: The name or ID of a pool. 1732 :param bool ignore_missing: When set to ``False`` 1733 :class:`~openstack.exceptions.ResourceNotFound` will be 1734 raised when the resource does not exist. 1735 When set to ``True``, None will be returned when 1736 attempting to find a nonexistent resource. 1737 :param dict args: Any additional parameters to be passed into 1738 underlying methods. such as query filters. 1739 :returns: One :class:`~openstack.network.v2.pool.Pool` or None 1740 """ 1741 return self._find(_pool.Pool, name_or_id, 1742 ignore_missing=ignore_missing, **args) 1743 1744 def get_pool(self, pool): 1745 """Get a single pool 1746 1747 :param pool: The value can be the ID of a pool or a 1748 :class:`~openstack.network.v2.pool.Pool` instance. 1749 1750 :returns: One :class:`~openstack.network.v2.pool.Pool` 1751 :raises: :class:`~openstack.exceptions.ResourceNotFound` 1752 when no resource can be found. 1753 """ 1754 return self._get(_pool.Pool, pool) 1755 1756 def pools(self, **query): 1757 """Return a generator of pools 1758 1759 :param dict query: Optional query parameters to be sent to limit 1760 the resources being returned. Valid parameters are: 1761 1762 * ``description``: The description for the pool. 1763 * ``is_admin_state_up``: The administrative state of the pool. 1764 * ``lb_algorithm``: The load-balancer algorithm used, which is one 1765 of ``round-robin``, ``least-connections`` and so on. 1766 * ``name``: The name of the node pool. 1767 * ``project_id``: The ID of the project the pool is associated 1768 with. 1769 * ``protocol``: The protocol used by the pool, which is one of 1770 ``TCP``, ``HTTP`` or ``HTTPS``. 1771 * ``provider``: The name of the provider of the load balancer 1772 service. 1773 * ``subnet_id``: The subnet on which the members of the pool are 1774 located. 1775 * ``virtual_ip_id``: The ID of the virtual IP used. 1776 1777 :returns: A generator of pool objects 1778 :rtype: :class:`~openstack.network.v2.pool.Pool` 1779 """ 1780 return self._list(_pool.Pool, **query) 1781 1782 def update_pool(self, pool, **attrs): 1783 """Update a pool 1784 1785 :param pool: Either the id of a pool or a 1786 :class:`~openstack.network.v2.pool.Pool` instance. 1787 :param dict attrs: The attributes to update on the pool represented 1788 by ``pool``. 1789 1790 :returns: The updated pool 1791 :rtype: :class:`~openstack.network.v2.pool.Pool` 1792 """ 1793 return self._update(_pool.Pool, pool, **attrs) 1794 1795 def create_pool_member(self, pool, **attrs): 1796 """Create a new pool member from attributes 1797 1798 :param pool: The pool can be either the ID of a pool or a 1799 :class:`~openstack.network.v2.pool.Pool` instance that 1800 the member will be created in. 1801 :param dict attrs: Keyword arguments which will be used to create 1802 a :class:`~openstack.network.v2.pool_member.PoolMember`, 1803 comprised of the properties on the PoolMember class. 1804 1805 :returns: The results of pool member creation 1806 :rtype: :class:`~openstack.network.v2.pool_member.PoolMember` 1807 """ 1808 poolobj = self._get_resource(_pool.Pool, pool) 1809 return self._create(_pool_member.PoolMember, pool_id=poolobj.id, 1810 **attrs) 1811 1812 def delete_pool_member(self, pool_member, pool, ignore_missing=True): 1813 """Delete a pool member 1814 1815 :param pool_member: 1816 The member can be either the ID of a pool member or a 1817 :class:`~openstack.network.v2.pool_member.PoolMember` instance. 1818 :param pool: The pool can be either the ID of a pool or a 1819 :class:`~openstack.network.v2.pool.Pool` instance that 1820 the member belongs to. 1821 :param bool ignore_missing: When set to ``False`` 1822 :class:`~openstack.exceptions.ResourceNotFound` will be 1823 raised when the pool member does not exist. 1824 When set to ``True``, no exception will be set when 1825 attempting to delete a nonexistent pool member. 1826 1827 :returns: ``None`` 1828 """ 1829 poolobj = self._get_resource(_pool.Pool, pool) 1830 self._delete(_pool_member.PoolMember, pool_member, 1831 ignore_missing=ignore_missing, pool_id=poolobj.id) 1832 1833 def find_pool_member(self, name_or_id, pool, ignore_missing=True, **args): 1834 """Find a single pool member 1835 1836 :param str name_or_id: The name or ID of a pool member. 1837 :param pool: The pool can be either the ID of a pool or a 1838 :class:`~openstack.network.v2.pool.Pool` instance that 1839 the member belongs to. 1840 :param bool ignore_missing: When set to ``False`` 1841 :class:`~openstack.exceptions.ResourceNotFound` will be 1842 raised when the resource does not exist. 1843 When set to ``True``, None will be returned when 1844 attempting to find a nonexistent resource. 1845 :param dict args: Any additional parameters to be passed into 1846 underlying methods. such as query filters. 1847 :returns: One :class:`~openstack.network.v2.pool_member.PoolMember` 1848 or None 1849 """ 1850 poolobj = self._get_resource(_pool.Pool, pool) 1851 return self._find(_pool_member.PoolMember, name_or_id, 1852 ignore_missing=ignore_missing, pool_id=poolobj.id, 1853 **args) 1854 1855 def get_pool_member(self, pool_member, pool): 1856 """Get a single pool member 1857 1858 :param pool_member: The member can be the ID of a pool member or a 1859 :class:`~openstack.network.v2.pool_member.PoolMember` 1860 instance. 1861 :param pool: The pool can be either the ID of a pool or a 1862 :class:`~openstack.network.v2.pool.Pool` instance that 1863 the member belongs to. 1864 1865 :returns: One :class:`~openstack.network.v2.pool_member.PoolMember` 1866 :raises: :class:`~openstack.exceptions.ResourceNotFound` 1867 when no resource can be found. 1868 """ 1869 poolobj = self._get_resource(_pool.Pool, pool) 1870 return self._get(_pool_member.PoolMember, pool_member, 1871 pool_id=poolobj.id) 1872 1873 def pool_members(self, pool, **query): 1874 """Return a generator of pool members 1875 1876 :param pool: The pool can be either the ID of a pool or a 1877 :class:`~openstack.network.v2.pool.Pool` instance that 1878 the member belongs to. 1879 :param dict query: Optional query parameters to be sent to limit 1880 the resources being returned. Valid parameters are: 1881 1882 * ``address``: The IP address of the pool member. 1883 * ``is_admin_state_up``: The administrative state of the pool 1884 member. 1885 * ``name``: Name of the pool member. 1886 * ``project_id``: The ID of the project this pool member is 1887 associated with. 1888 * ``protocol_port``: The port on which the application is hosted. 1889 * ``subnet_id``: Subnet ID in which to access this pool member. 1890 * ``weight``: A positive integer value that indicates the relative 1891 portion of traffic that this member should receive from the 1892 pool. 1893 1894 :returns: A generator of pool member objects 1895 :rtype: :class:`~openstack.network.v2.pool_member.PoolMember` 1896 """ 1897 poolobj = self._get_resource(_pool.Pool, pool) 1898 return self._list(_pool_member.PoolMember, pool_id=poolobj.id, **query) 1899 1900 def update_pool_member(self, pool_member, pool, **attrs): 1901 """Update a pool member 1902 1903 :param pool_member: Either the ID of a pool member or a 1904 :class:`~openstack.network.v2.pool_member.PoolMember` 1905 instance. 1906 :param pool: The pool can be either the ID of a pool or a 1907 :class:`~openstack.network.v2.pool.Pool` instance that 1908 the member belongs to. 1909 :param dict attrs: The attributes to update on the pool member 1910 represented by ``pool_member``. 1911 1912 :returns: The updated pool member 1913 :rtype: :class:`~openstack.network.v2.pool_member.PoolMember` 1914 """ 1915 poolobj = self._get_resource(_pool.Pool, pool) 1916 return self._update(_pool_member.PoolMember, pool_member, 1917 pool_id=poolobj.id, **attrs) 1918 1919 def create_port(self, **attrs): 1920 """Create a new port from attributes 1921 1922 :param dict attrs: Keyword arguments which will be used to create 1923 a :class:`~openstack.network.v2.port.Port`, 1924 comprised of the properties on the Port class. 1925 1926 :returns: The results of port creation 1927 :rtype: :class:`~openstack.network.v2.port.Port` 1928 """ 1929 return self._create(_port.Port, **attrs) 1930 1931 def create_ports(self, data): 1932 """Create ports from the list of attributes 1933 1934 :param list data: List of dicts of attributes which will be used to 1935 create a :class:`~openstack.network.v2.port.Port`, 1936 comprised of the properties on the Port class. 1937 1938 :returns: A generator of port objects 1939 :rtype: :class:`~openstack.network.v2.port.Port` 1940 """ 1941 return self._bulk_create(_port.Port, data) 1942 1943 def delete_port(self, port, ignore_missing=True, if_revision=None): 1944 """Delete a port 1945 1946 :param port: The value can be either the ID of a port or a 1947 :class:`~openstack.network.v2.port.Port` instance. 1948 :param bool ignore_missing: When set to ``False`` 1949 :class:`~openstack.exceptions.ResourceNotFound` will be 1950 raised when the port does not exist. 1951 When set to ``True``, no exception will be set when 1952 attempting to delete a nonexistent port. 1953 :param int if_revision: Revision to put in If-Match header of update 1954 request to perform compare-and-swap update. 1955 1956 :returns: ``None`` 1957 """ 1958 self._delete(_port.Port, port, ignore_missing=ignore_missing, 1959 if_revision=if_revision) 1960 1961 def find_port(self, name_or_id, ignore_missing=True, **args): 1962 """Find a single port 1963 1964 :param name_or_id: The name or ID of a port. 1965 :param bool ignore_missing: When set to ``False`` 1966 :class:`~openstack.exceptions.ResourceNotFound` will be 1967 raised when the resource does not exist. 1968 When set to ``True``, None will be returned when 1969 attempting to find a nonexistent resource. 1970 :param dict args: Any additional parameters to be passed into 1971 underlying methods. such as query filters. 1972 :returns: One :class:`~openstack.network.v2.port.Port` or None 1973 """ 1974 return self._find(_port.Port, name_or_id, 1975 ignore_missing=ignore_missing, **args) 1976 1977 def get_port(self, port): 1978 """Get a single port 1979 1980 :param port: The value can be the ID of a port or a 1981 :class:`~openstack.network.v2.port.Port` instance. 1982 1983 :returns: One :class:`~openstack.network.v2.port.Port` 1984 :raises: :class:`~openstack.exceptions.ResourceNotFound` 1985 when no resource can be found. 1986 """ 1987 return self._get(_port.Port, port) 1988 1989 def ports(self, **query): 1990 """Return a generator of ports 1991 1992 :param kwargs query: Optional query parameters to be sent to limit 1993 the resources being returned. Available parameters include: 1994 1995 * ``description``: The port description. 1996 * ``device_id``: Port device ID. 1997 * ``device_owner``: Port device owner (e.g. ``network:dhcp``). 1998 * ``ip_address``: IP addresses of an allowed address pair. 1999 * ``is_admin_state_up``: The administrative state of the port. 2000 * ``is_port_security_enabled``: The port security status. 2001 * ``mac_address``: Port MAC address. 2002 * ``name``: The port name. 2003 * ``network_id``: ID of network that owns the ports. 2004 * ``project_id``: The ID of the project who owns the network. 2005 * ``status``: The port status. Value is ``ACTIVE`` or ``DOWN``. 2006 * ``subnet_id``: The ID of the subnet. 2007 2008 :returns: A generator of port objects 2009 :rtype: :class:`~openstack.network.v2.port.Port` 2010 """ 2011 return self._list(_port.Port, **query) 2012 2013 def update_port(self, port, if_revision=None, **attrs): 2014 """Update a port 2015 2016 :param port: Either the id of a port or a 2017 :class:`~openstack.network.v2.port.Port` instance. 2018 :param int if_revision: Revision to put in If-Match header of update 2019 request to perform compare-and-swap update. 2020 :param dict attrs: The attributes to update on the port represented 2021 by ``port``. 2022 2023 :returns: The updated port 2024 :rtype: :class:`~openstack.network.v2.port.Port` 2025 """ 2026 return self._update(_port.Port, port, if_revision=if_revision, 2027 **attrs) 2028 2029 def add_ip_to_port(self, port, ip): 2030 ip.port_id = port.id 2031 return ip.commit(self) 2032 2033 def remove_ip_from_port(self, ip): 2034 ip.port_id = None 2035 return ip.commit(self) 2036 2037 def get_subnet_ports(self, subnet_id): 2038 result = [] 2039 ports = self.ports() 2040 for puerta in ports: 2041 for fixed_ip in puerta.fixed_ips: 2042 if fixed_ip['subnet_id'] == subnet_id: 2043 result.append(puerta) 2044 return result 2045 2046 def create_qos_bandwidth_limit_rule(self, qos_policy, **attrs): 2047 """Create a new bandwidth limit rule 2048 2049 :param dict attrs: Keyword arguments which will be used to create 2050 a :class:`~openstack.network.v2. 2051 qos_bandwidth_limit_rule.QoSBandwidthLimitRule`, 2052 comprised of the properties on the 2053 QoSBandwidthLimitRule class. 2054 :param qos_policy: The value can be the ID of the QoS policy that the 2055 rule belongs or a :class:`~openstack.network.v2. 2056 qos_policy.QoSPolicy` instance. 2057 2058 :returns: The results of resource creation 2059 :rtype: :class:`~openstack.network.v2.qos_bandwidth_limit_rule. 2060 QoSBandwidthLimitRule` 2061 """ 2062 policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) 2063 return self._create(_qos_bandwidth_limit_rule.QoSBandwidthLimitRule, 2064 qos_policy_id=policy.id, **attrs) 2065 2066 def delete_qos_bandwidth_limit_rule(self, qos_rule, qos_policy, 2067 ignore_missing=True): 2068 """Delete a bandwidth limit rule 2069 2070 :param qos_rule: The value can be either the ID of a bandwidth limit 2071 rule or a :class:`~openstack.network.v2. 2072 qos_bandwidth_limit_rule.QoSBandwidthLimitRule` 2073 instance. 2074 :param qos_policy: The value can be the ID of the QoS policy that the 2075 rule belongs or a :class:`~openstack.network.v2. 2076 qos_policy.QoSPolicy` instance. 2077 :param bool ignore_missing: When set to ``False`` 2078 :class:`~openstack.exceptions.ResourceNotFound` will be 2079 raised when the resource does not exist. 2080 When set to ``True``, no exception will be set when 2081 attempting to delete a nonexistent bandwidth limit rule. 2082 2083 :returns: ``None`` 2084 """ 2085 policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) 2086 self._delete(_qos_bandwidth_limit_rule.QoSBandwidthLimitRule, 2087 qos_rule, ignore_missing=ignore_missing, 2088 qos_policy_id=policy.id) 2089 2090 def find_qos_bandwidth_limit_rule(self, qos_rule_id, qos_policy, 2091 ignore_missing=True, **args): 2092 """Find a bandwidth limit rule 2093 2094 :param qos_rule_id: The ID of a bandwidth limit rule. 2095 :param qos_policy: The value can be the ID of the QoS policy that the 2096 rule belongs or a :class:`~openstack.network.v2. 2097 qos_policy.QoSPolicy` instance. 2098 :param bool ignore_missing: When set to ``False`` 2099 :class:`~openstack.exceptions.ResourceNotFound` will be 2100 raised when the resource does not exist. 2101 When set to ``True``, None will be returned when 2102 attempting to find a nonexistent resource. 2103 :param dict args: Any additional parameters to be passed into 2104 underlying methods. such as query filters. 2105 :returns: One :class:`~openstack.network.v2.qos_bandwidth_limit_rule. 2106 QoSBandwidthLimitRule` or None 2107 """ 2108 policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) 2109 return self._find(_qos_bandwidth_limit_rule.QoSBandwidthLimitRule, 2110 qos_rule_id, ignore_missing=ignore_missing, 2111 qos_policy_id=policy.id, **args) 2112 2113 def get_qos_bandwidth_limit_rule(self, qos_rule, qos_policy): 2114 """Get a single bandwidth limit rule 2115 2116 :param qos_rule: The value can be the ID of a minimum bandwidth rule or 2117 a :class:`~openstack.network.v2. 2118 qos_bandwidth_limit_rule.QoSBandwidthLimitRule` 2119 instance. 2120 :param qos_policy: The value can be the ID of the QoS policy that the 2121 rule belongs or a :class:`~openstack.network.v2. 2122 qos_policy.QoSPolicy` instance. 2123 :returns: One :class:`~openstack.network.v2.qos_bandwidth_limit_rule. 2124 QoSBandwidthLimitRule` 2125 :raises: :class:`~openstack.exceptions.ResourceNotFound` 2126 when no resource can be found. 2127 """ 2128 policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) 2129 return self._get(_qos_bandwidth_limit_rule.QoSBandwidthLimitRule, 2130 qos_rule, qos_policy_id=policy.id) 2131 2132 def qos_bandwidth_limit_rules(self, qos_policy, **query): 2133 """Return a generator of bandwidth limit rules 2134 2135 :param qos_policy: The value can be the ID of the QoS policy that the 2136 rule belongs or a :class:`~openstack.network.v2. 2137 qos_policy.QoSPolicy` instance. 2138 :param kwargs query: Optional query parameters to be sent to limit 2139 the resources being returned. 2140 :returns: A generator of bandwidth limit rule objects 2141 :rtype: :class:`~openstack.network.v2.qos_bandwidth_limit_rule. 2142 QoSBandwidthLimitRule` 2143 """ 2144 policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) 2145 return self._list(_qos_bandwidth_limit_rule.QoSBandwidthLimitRule, 2146 qos_policy_id=policy.id, **query) 2147 2148 def update_qos_bandwidth_limit_rule(self, qos_rule, qos_policy, 2149 **attrs): 2150 """Update a bandwidth limit rule 2151 2152 :param qos_rule: Either the id of a bandwidth limit rule or a 2153 :class:`~openstack.network.v2. 2154 qos_bandwidth_limit_rule.QoSBandwidthLimitRule` 2155 instance. 2156 :param qos_policy: The value can be the ID of the QoS policy that the 2157 rule belongs or a :class:`~openstack.network.v2. 2158 qos_policy.QoSPolicy` instance. 2159 :attrs kwargs: The attributes to update on the bandwidth limit rule 2160 represented by ``value``. 2161 2162 :returns: The updated minimum bandwidth rule 2163 :rtype: :class:`~openstack.network.v2.qos_bandwidth_limit_rule. 2164 QoSBandwidthLimitRule` 2165 """ 2166 policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) 2167 return self._update(_qos_bandwidth_limit_rule.QoSBandwidthLimitRule, 2168 qos_rule, qos_policy_id=policy.id, **attrs) 2169 2170 def create_qos_dscp_marking_rule(self, qos_policy, **attrs): 2171 """Create a new QoS DSCP marking rule 2172 2173 :param dict attrs: Keyword arguments which will be used to create 2174 a :class:`~openstack.network.v2. 2175 qos_dscp_marking_rule.QoSDSCPMarkingRule`, 2176 comprised of the properties on the 2177 QosDscpMarkingRule class. 2178 :param qos_policy: The value can be the ID of the QoS policy that the 2179 rule belongs or a :class:`~openstack.network.v2. 2180 qos_policy.QoSPolicy` instance. 2181 2182 :returns: The results of router creation 2183 :rtype: :class:`~openstack.network.v2.qos_dscp_marking_rule. 2184 QoSDSCPMarkingRule` 2185 """ 2186 policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) 2187 return self._create(_qos_dscp_marking_rule.QoSDSCPMarkingRule, 2188 qos_policy_id=policy.id, **attrs) 2189 2190 def delete_qos_dscp_marking_rule(self, qos_rule, qos_policy, 2191 ignore_missing=True): 2192 """Delete a QoS DSCP marking rule 2193 2194 :param qos_rule: The value can be either the ID of a minimum bandwidth 2195 rule or a :class:`~openstack.network.v2. 2196 qos_dscp_marking_rule.QoSDSCPMarkingRule` 2197 instance. 2198 :param qos_policy: The value can be the ID of the QoS policy that the 2199 rule belongs or a :class:`~openstack.network.v2. 2200 qos_policy.QoSPolicy` instance. 2201 :param bool ignore_missing: When set to ``False`` 2202 :class:`~openstack.exceptions.ResourceNotFound` will be 2203 raised when the resource does not exist. 2204 When set to ``True``, no exception will be set when 2205 attempting to delete a nonexistent minimum bandwidth rule. 2206 2207 :returns: ``None`` 2208 """ 2209 policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) 2210 self._delete(_qos_dscp_marking_rule.QoSDSCPMarkingRule, 2211 qos_rule, ignore_missing=ignore_missing, 2212 qos_policy_id=policy.id) 2213 2214 def find_qos_dscp_marking_rule(self, qos_rule_id, qos_policy, 2215 ignore_missing=True, **args): 2216 """Find a QoS DSCP marking rule 2217 2218 :param qos_rule_id: The ID of a QoS DSCP marking rule. 2219 :param qos_policy: The value can be the ID of the QoS policy that the 2220 rule belongs or a :class:`~openstack.network.v2. 2221 qos_policy.QoSPolicy` instance. 2222 :param bool ignore_missing: When set to ``False`` 2223 :class:`~openstack.exceptions.ResourceNotFound` will be 2224 raised when the resource does not exist. 2225 When set to ``True``, None will be returned when 2226 attempting to find a nonexistent resource. 2227 :param dict args: Any additional parameters to be passed into 2228 underlying methods. such as query filters. 2229 :returns: One :class:`~openstack.network.v2.qos_dscp_marking_rule. 2230 QoSDSCPMarkingRule` or None 2231 """ 2232 policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) 2233 return self._find(_qos_dscp_marking_rule.QoSDSCPMarkingRule, 2234 qos_rule_id, ignore_missing=ignore_missing, 2235 qos_policy_id=policy.id, **args) 2236 2237 def get_qos_dscp_marking_rule(self, qos_rule, qos_policy): 2238 """Get a single QoS DSCP marking rule 2239 2240 :param qos_rule: The value can be the ID of a minimum bandwidth rule or 2241 a :class:`~openstack.network.v2.qos_dscp_marking_rule. 2242 QoSDSCPMarkingRule` instance. 2243 :param qos_policy: The value can be the ID of the QoS policy that the 2244 rule belongs or a :class:`~openstack.network.v2. 2245 qos_policy.QoSPolicy` instance. 2246 :returns: One :class:`~openstack.network.v2.qos_dscp_marking_rule. 2247 QoSDSCPMarkingRule` 2248 :raises: :class:`~openstack.exceptions.ResourceNotFound` 2249 when no resource can be found. 2250 """ 2251 policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) 2252 return self._get(_qos_dscp_marking_rule.QoSDSCPMarkingRule, 2253 qos_rule, qos_policy_id=policy.id) 2254 2255 def qos_dscp_marking_rules(self, qos_policy, **query): 2256 """Return a generator of QoS DSCP marking rules 2257 2258 :param qos_policy: The value can be the ID of the QoS policy that the 2259 rule belongs or a :class:`~openstack.network.v2. 2260 qos_policy.QoSPolicy` instance. 2261 :param kwargs query: Optional query parameters to be sent to limit 2262 the resources being returned. 2263 :returns: A generator of QoS DSCP marking rule objects 2264 :rtype: :class:`~openstack.network.v2.qos_dscp_marking_rule. 2265 QoSDSCPMarkingRule` 2266 """ 2267 policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) 2268 return self._list(_qos_dscp_marking_rule.QoSDSCPMarkingRule, 2269 qos_policy_id=policy.id, **query) 2270 2271 def update_qos_dscp_marking_rule(self, qos_rule, qos_policy, **attrs): 2272 """Update a QoS DSCP marking rule 2273 2274 :param qos_rule: Either the id of a minimum bandwidth rule or a 2275 :class:`~openstack.network.v2.qos_dscp_marking_rule. 2276 QoSDSCPMarkingRule` instance. 2277 :param qos_policy: The value can be the ID of the QoS policy that the 2278 rule belongs or a :class:`~openstack.network.v2. 2279 qos_policy.QoSPolicy` instance. 2280 :attrs kwargs: The attributes to update on the QoS DSCP marking rule 2281 represented by ``value``. 2282 2283 :returns: The updated QoS DSCP marking rule 2284 :rtype: :class:`~openstack.network.v2.qos_dscp_marking_rule. 2285 QoSDSCPMarkingRule` 2286 """ 2287 policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) 2288 return self._update(_qos_dscp_marking_rule.QoSDSCPMarkingRule, 2289 qos_rule, qos_policy_id=policy.id, **attrs) 2290 2291 def create_qos_minimum_bandwidth_rule(self, qos_policy, **attrs): 2292 """Create a new minimum bandwidth rule 2293 2294 :param dict attrs: Keyword arguments which will be used to create 2295 a :class:`~openstack.network.v2. 2296 qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule`, 2297 comprised of the properties on the 2298 QoSMinimumBandwidthRule class. 2299 :param qos_policy: The value can be the ID of the QoS policy that the 2300 rule belongs or a :class:`~openstack.network.v2. 2301 qos_policy.QoSPolicy` instance. 2302 2303 :returns: The results of resource creation 2304 :rtype: :class:`~openstack.network.v2.qos_minimum_bandwidth_rule. 2305 QoSMinimumBandwidthRule` 2306 """ 2307 policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) 2308 return self._create( 2309 _qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule, 2310 qos_policy_id=policy.id, **attrs) 2311 2312 def delete_qos_minimum_bandwidth_rule(self, qos_rule, qos_policy, 2313 ignore_missing=True): 2314 """Delete a minimum bandwidth rule 2315 2316 :param qos_rule: The value can be either the ID of a minimum bandwidth 2317 rule or a :class:`~openstack.network.v2. 2318 qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule` 2319 instance. 2320 :param qos_policy: The value can be the ID of the QoS policy that the 2321 rule belongs or a :class:`~openstack.network.v2. 2322 qos_policy.QoSPolicy` instance. 2323 :param bool ignore_missing: When set to ``False`` 2324 :class:`~openstack.exceptions.ResourceNotFound` will be 2325 raised when the resource does not exist. 2326 When set to ``True``, no exception will be set when 2327 attempting to delete a nonexistent minimum bandwidth rule. 2328 2329 :returns: ``None`` 2330 """ 2331 policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) 2332 self._delete(_qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule, 2333 qos_rule, ignore_missing=ignore_missing, 2334 qos_policy_id=policy.id) 2335 2336 def find_qos_minimum_bandwidth_rule(self, qos_rule_id, qos_policy, 2337 ignore_missing=True, **args): 2338 """Find a minimum bandwidth rule 2339 2340 :param qos_rule_id: The ID of a minimum bandwidth rule. 2341 :param qos_policy: The value can be the ID of the QoS policy that the 2342 rule belongs or a :class:`~openstack.network.v2. 2343 qos_policy.QoSPolicy` instance. 2344 :param bool ignore_missing: When set to ``False`` 2345 :class:`~openstack.exceptions.ResourceNotFound` will be 2346 raised when the resource does not exist. 2347 When set to ``True``, None will be returned when 2348 attempting to find a nonexistent resource. 2349 :param dict args: Any additional parameters to be passed into 2350 underlying methods. such as query filters. 2351 :returns: One :class:`~openstack.network.v2.qos_minimum_bandwidth_rule. 2352 QoSMinimumBandwidthRule` or None 2353 """ 2354 policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) 2355 return self._find(_qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule, 2356 qos_rule_id, ignore_missing=ignore_missing, 2357 qos_policy_id=policy.id, **args) 2358 2359 def get_qos_minimum_bandwidth_rule(self, qos_rule, qos_policy): 2360 """Get a single minimum bandwidth rule 2361 2362 :param qos_rule: The value can be the ID of a minimum bandwidth rule or 2363 a :class:`~openstack.network.v2. 2364 qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule` 2365 instance. 2366 :param qos_policy: The value can be the ID of the QoS policy that the 2367 rule belongs or a :class:`~openstack.network.v2. 2368 qos_policy.QoSPolicy` instance. 2369 :returns: One :class:`~openstack.network.v2.qos_minimum_bandwidth_rule. 2370 QoSMinimumBandwidthRule` 2371 :raises: :class:`~openstack.exceptions.ResourceNotFound` 2372 when no resource can be found. 2373 """ 2374 policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) 2375 return self._get(_qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule, 2376 qos_rule, qos_policy_id=policy.id) 2377 2378 def qos_minimum_bandwidth_rules(self, qos_policy, **query): 2379 """Return a generator of minimum bandwidth rules 2380 2381 :param qos_policy: The value can be the ID of the QoS policy that the 2382 rule belongs or a :class:`~openstack.network.v2. 2383 qos_policy.QoSPolicy` instance. 2384 :param kwargs query: Optional query parameters to be sent to limit 2385 the resources being returned. 2386 :returns: A generator of minimum bandwidth rule objects 2387 :rtype: :class:`~openstack.network.v2.qos_minimum_bandwidth_rule. 2388 QoSMinimumBandwidthRule` 2389 """ 2390 policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) 2391 return self._list(_qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule, 2392 qos_policy_id=policy.id, **query) 2393 2394 def update_qos_minimum_bandwidth_rule(self, qos_rule, qos_policy, 2395 **attrs): 2396 """Update a minimum bandwidth rule 2397 2398 :param qos_rule: Either the id of a minimum bandwidth rule or a 2399 :class:`~openstack.network.v2. 2400 qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule` 2401 instance. 2402 :param qos_policy: The value can be the ID of the QoS policy that the 2403 rule belongs or a :class:`~openstack.network.v2. 2404 qos_policy.QoSPolicy` instance. 2405 :attrs kwargs: The attributes to update on the minimum bandwidth rule 2406 represented by ``value``. 2407 2408 :returns: The updated minimum bandwidth rule 2409 :rtype: :class:`~openstack.network.v2.qos_minimum_bandwidth_rule. 2410 QoSMinimumBandwidthRule` 2411 """ 2412 policy = self._get_resource(_qos_policy.QoSPolicy, qos_policy) 2413 return self._update(_qos_minimum_bandwidth_rule. 2414 QoSMinimumBandwidthRule, qos_rule, 2415 qos_policy_id=policy.id, **attrs) 2416 2417 def create_qos_policy(self, **attrs): 2418 """Create a new QoS policy from attributes 2419 2420 :param dict attrs: Keyword arguments which will be used to create 2421 a :class:`~openstack.network.v2.qos_policy. 2422 QoSPolicy`, comprised of the properties on the 2423 QoSPolicy class. 2424 2425 :returns: The results of QoS policy creation 2426 :rtype: :class:`~openstack.network.v2.qos_policy.QoSPolicy` 2427 """ 2428 return self._create(_qos_policy.QoSPolicy, **attrs) 2429 2430 def delete_qos_policy(self, qos_policy, ignore_missing=True): 2431 """Delete a QoS policy 2432 2433 :param qos_policy: The value can be either the ID of a QoS policy or a 2434 :class:`~openstack.network.v2.qos_policy.QoSPolicy` 2435 instance. 2436 :param bool ignore_missing: When set to ``False`` 2437 :class:`~openstack.exceptions.ResourceNotFound` will be 2438 raised when the QoS policy does not exist. 2439 When set to ``True``, no exception will be set when 2440 attempting to delete a nonexistent QoS policy. 2441 2442 :returns: ``None`` 2443 """ 2444 self._delete(_qos_policy.QoSPolicy, qos_policy, 2445 ignore_missing=ignore_missing) 2446 2447 def find_qos_policy(self, name_or_id, ignore_missing=True, **args): 2448 """Find a single QoS policy 2449 2450 :param name_or_id: The name or ID of a QoS policy. 2451 :param bool ignore_missing: When set to ``False`` 2452 :class:`~openstack.exceptions.ResourceNotFound` will be 2453 raised when the resource does not exist. 2454 When set to ``True``, None will be returned when 2455 attempting to find a nonexistent resource. 2456 :param dict args: Any additional parameters to be passed into 2457 underlying methods. such as query filters. 2458 :returns: One :class:`~openstack.network.v2.qos_policy.QoSPolicy` or 2459 None 2460 """ 2461 return self._find(_qos_policy.QoSPolicy, name_or_id, 2462 ignore_missing=ignore_missing, **args) 2463 2464 def get_qos_policy(self, qos_policy): 2465 """Get a single QoS policy 2466 2467 :param qos_policy: The value can be the ID of a QoS policy or a 2468 :class:`~openstack.network.v2.qos_policy.QoSPolicy` 2469 instance. 2470 2471 :returns: One :class:`~openstack.network.v2.qos_policy.QoSPolicy` 2472 :raises: :class:`~openstack.exceptions.ResourceNotFound` 2473 when no resource can be found. 2474 """ 2475 return self._get(_qos_policy.QoSPolicy, qos_policy) 2476 2477 def qos_policies(self, **query): 2478 """Return a generator of QoS policies 2479 2480 :param dict query: Optional query parameters to be sent to limit 2481 the resources being returned. Valid parameters are: 2482 2483 * ``description``: The description of a QoS policy. 2484 * ``is_shared``: Whether the policy is shared among projects. 2485 * ``name``: The name of a QoS policy. 2486 * ``project_id``: The ID of the project who owns the network. 2487 2488 :returns: A generator of QoS policy objects 2489 :rtype: :class:`~openstack.network.v2.qos_policy.QoSPolicy` 2490 """ 2491 return self._list(_qos_policy.QoSPolicy, **query) 2492 2493 def update_qos_policy(self, qos_policy, **attrs): 2494 """Update a QoS policy 2495 2496 :param qos_policy: Either the id of a QoS policy or a 2497 :class:`~openstack.network.v2.qos_policy.QoSPolicy` 2498 instance. 2499 :attrs kwargs: The attributes to update on the QoS policy represented 2500 by ``value``. 2501 2502 :returns: The updated QoS policy 2503 :rtype: :class:`~openstack.network.v2.qos_policy.QoSPolicy` 2504 """ 2505 return self._update(_qos_policy.QoSPolicy, qos_policy, **attrs) 2506 2507 def find_qos_rule_type(self, rule_type_name, ignore_missing=True): 2508 """Find a single QoS rule type details 2509 2510 :param rule_type_name: The name of a QoS rule type. 2511 :param bool ignore_missing: When set to ``False`` 2512 :class:`~openstack.exceptions.ResourceNotFound` will be 2513 raised when the resource does not exist. 2514 When set to ``True``, None will be returned when 2515 attempting to find a nonexistent resource. 2516 :returns: One :class:`~openstack.network.v2.qos_rule_type.QoSRuleType` 2517 or None 2518 """ 2519 return self._find(_qos_rule_type.QoSRuleType, rule_type_name, 2520 ignore_missing=ignore_missing) 2521 2522 def get_qos_rule_type(self, qos_rule_type): 2523 """Get details about single QoS rule type 2524 2525 :param qos_rule_type: The value can be the name of a QoS policy 2526 rule type or a 2527 :class:`~openstack.network.v2. 2528 qos_rule_type.QoSRuleType` 2529 instance. 2530 2531 :returns: One :class:`~openstack.network.v2.qos_rule_type.QoSRuleType` 2532 :raises: :class:`~openstack.exceptions.ResourceNotFound` 2533 when no resource can be found. 2534 """ 2535 return self._get(_qos_rule_type.QoSRuleType, qos_rule_type) 2536 2537 def qos_rule_types(self, **query): 2538 """Return a generator of QoS rule types 2539 2540 :param dict query: Optional query parameters to be sent to limit the 2541 resources returned. Valid parameters include: 2542 2543 * ``type``: The type of the QoS rule type. 2544 2545 :returns: A generator of QoS rule type objects 2546 :rtype: :class:`~openstack.network.v2.qos_rule_type.QoSRuleType` 2547 """ 2548 return self._list(_qos_rule_type.QoSRuleType, **query) 2549 2550 def delete_quota(self, quota, ignore_missing=True): 2551 """Delete a quota (i.e. reset to the default quota) 2552 2553 :param quota: The value can be either the ID of a quota or a 2554 :class:`~openstack.network.v2.quota.Quota` instance. 2555 The ID of a quota is the same as the project ID 2556 for the quota. 2557 :param bool ignore_missing: When set to ``False`` 2558 :class:`~openstack.exceptions.ResourceNotFound` will be 2559 raised when quota does not exist. 2560 When set to ``True``, no exception will be set when 2561 attempting to delete a nonexistent quota. 2562 2563 :returns: ``None`` 2564 """ 2565 self._delete(_quota.Quota, quota, ignore_missing=ignore_missing) 2566 2567 def get_quota(self, quota, details=False): 2568 """Get a quota 2569 2570 :param quota: The value can be the ID of a quota or a 2571 :class:`~openstack.network.v2.quota.Quota` instance. 2572 The ID of a quota is the same as the project ID 2573 for the quota. 2574 :param details: If set to True, details about quota usage will 2575 be returned. 2576 2577 :returns: One :class:`~openstack.network.v2.quota.Quota` 2578 :raises: :class:`~openstack.exceptions.ResourceNotFound` 2579 when no resource can be found. 2580 """ 2581 if details: 2582 quota_obj = self._get_resource(_quota.Quota, quota) 2583 quota = self._get(_quota.QuotaDetails, project=quota_obj.id, 2584 requires_id=False) 2585 else: 2586 quota = self._get(_quota.Quota, quota) 2587 return quota 2588 2589 def get_quota_default(self, quota): 2590 """Get a default quota 2591 2592 :param quota: The value can be the ID of a default quota or a 2593 :class:`~openstack.network.v2.quota.QuotaDefault` 2594 instance. The ID of a default quota is the same 2595 as the project ID for the default quota. 2596 2597 :returns: One :class:`~openstack.network.v2.quota.QuotaDefault` 2598 :raises: :class:`~openstack.exceptions.ResourceNotFound` 2599 when no resource can be found. 2600 """ 2601 quota_obj = self._get_resource(_quota.Quota, quota) 2602 return self._get(_quota.QuotaDefault, project=quota_obj.id, 2603 requires_id=False) 2604 2605 def quotas(self, **query): 2606 """Return a generator of quotas 2607 2608 :param dict query: Optional query parameters to be sent to limit 2609 the resources being returned. Currently no query 2610 parameter is supported. 2611 2612 :returns: A generator of quota objects 2613 :rtype: :class:`~openstack.network.v2.quota.Quota` 2614 """ 2615 return self._list(_quota.Quota, **query) 2616 2617 def update_quota(self, quota, **attrs): 2618 """Update a quota 2619 2620 :param quota: Either the ID of a quota or a 2621 :class:`~openstack.network.v2.quota.Quota` instance. 2622 The ID of a quota is the same as the project ID 2623 for the quota. 2624 :param dict attrs: The attributes to update on the quota represented 2625 by ``quota``. 2626 2627 :returns: The updated quota 2628 :rtype: :class:`~openstack.network.v2.quota.Quota` 2629 """ 2630 return self._update(_quota.Quota, quota, **attrs) 2631 2632 def create_rbac_policy(self, **attrs): 2633 """Create a new RBAC policy from attributes 2634 2635 :param dict attrs: Keyword arguments which will be used to create a 2636 :class:`~openstack.network.v2.rbac_policy.RBACPolicy`, 2637 comprised of the properties on the RBACPolicy class. 2638 2639 :return: The results of RBAC policy creation 2640 :rtype: :class:`~openstack.network.v2.rbac_policy.RBACPolicy` 2641 """ 2642 return self._create(_rbac_policy.RBACPolicy, **attrs) 2643 2644 def delete_rbac_policy(self, rbac_policy, ignore_missing=True): 2645 """Delete a RBAC policy 2646 2647 :param rbac_policy: The value can be either the ID of a RBAC policy or 2648 a :class:`~openstack.network.v2.rbac_policy.RBACPolicy` instance. 2649 :param bool ignore_missing: When set to ``False`` 2650 :class:`~openstack.exceptions.ResourceNotFound` will be 2651 raised when the RBAC policy does not exist. 2652 When set to ``True``, no exception will be set when 2653 attempting to delete a nonexistent RBAC policy. 2654 2655 :returns: ``None`` 2656 """ 2657 self._delete(_rbac_policy.RBACPolicy, rbac_policy, 2658 ignore_missing=ignore_missing) 2659 2660 def find_rbac_policy(self, rbac_policy, ignore_missing=True, **args): 2661 """Find a single RBAC policy 2662 2663 :param rbac_policy: The ID of a RBAC policy. 2664 :param bool ignore_missing: When set to ``False`` 2665 :class:`~openstack.exceptions.ResourceNotFound` will be 2666 raised when the resource does not exist. 2667 When set to ``True``, None will be returned when 2668 attempting to find a nonexistent resource. 2669 :param dict args: Any additional parameters to be passed into 2670 underlying methods. such as query filters. 2671 :returns: One 2672 :class:`~openstack.network.v2.rbac_policy.RBACPolicy` or None 2673 """ 2674 return self._find(_rbac_policy.RBACPolicy, rbac_policy, 2675 ignore_missing=ignore_missing, **args) 2676 2677 def get_rbac_policy(self, rbac_policy): 2678 """Get a single RBAC policy 2679 2680 :param rbac_policy: The value can be the ID of a RBAC policy or a 2681 :class:`~openstack.network.v2.rbac_policy.RBACPolicy` instance. 2682 2683 :returns: One :class:`~openstack.network.v2.rbac_policy.RBACPolicy` 2684 :raises: :class:`~openstack.exceptions.ResourceNotFound` 2685 when no resource can be found. 2686 """ 2687 return self._get(_rbac_policy.RBACPolicy, rbac_policy) 2688 2689 def rbac_policies(self, **query): 2690 """Return a generator of RBAC policies 2691 2692 :param dict query: Optional query parameters to be sent to limit 2693 the resources being returned. Available parameters 2694 include: 2695 2696 * ``action``: RBAC policy action 2697 * ``object_type``: Type of the object that the RBAC policy affects 2698 * ``target_project_id``: ID of the tenant that the RBAC policy 2699 affects 2700 * ``project_id``: Owner tenant ID 2701 2702 :returns: A generator of rbac objects 2703 :rtype: :class:`~openstack.network.v2.rbac_policy.RBACPolicy` 2704 """ 2705 return self._list(_rbac_policy.RBACPolicy, **query) 2706 2707 def update_rbac_policy(self, rbac_policy, **attrs): 2708 """Update a RBAC policy 2709 2710 :param rbac_policy: Either the id of a RBAC policy or a 2711 :class:`~openstack.network.v2.rbac_policy.RBACPolicy` instance. 2712 :param dict attrs: The attributes to update on the RBAC policy 2713 represented by ``rbac_policy``. 2714 2715 :returns: The updated RBAC policy 2716 :rtype: :class:`~openstack.network.v2.rbac_policy.RBACPolicy` 2717 """ 2718 return self._update(_rbac_policy.RBACPolicy, rbac_policy, **attrs) 2719 2720 def create_router(self, **attrs): 2721 """Create a new router from attributes 2722 2723 :param dict attrs: Keyword arguments which will be used to create 2724 a :class:`~openstack.network.v2.router.Router`, 2725 comprised of the properties on the Router class. 2726 2727 :returns: The results of router creation 2728 :rtype: :class:`~openstack.network.v2.router.Router` 2729 """ 2730 return self._create(_router.Router, **attrs) 2731 2732 def delete_router(self, router, ignore_missing=True, if_revision=None): 2733 """Delete a router 2734 2735 :param router: The value can be either the ID of a router or a 2736 :class:`~openstack.network.v2.router.Router` instance. 2737 :param bool ignore_missing: When set to ``False`` 2738 :class:`~openstack.exceptions.ResourceNotFound` will be 2739 raised when the router does not exist. 2740 When set to ``True``, no exception will be set when 2741 attempting to delete a nonexistent router. 2742 :param int if_revision: Revision to put in If-Match header of update 2743 request to perform compare-and-swap update. 2744 2745 :returns: ``None`` 2746 """ 2747 self._delete(_router.Router, router, ignore_missing=ignore_missing, 2748 if_revision=if_revision) 2749 2750 def find_router(self, name_or_id, ignore_missing=True, **args): 2751 """Find a single router 2752 2753 :param name_or_id: The name or ID of a router. 2754 :param bool ignore_missing: When set to ``False`` 2755 :class:`~openstack.exceptions.ResourceNotFound` will be 2756 raised when the resource does not exist. 2757 When set to ``True``, None will be returned when 2758 attempting to find a nonexistent resource. 2759 :param dict args: Any additional parameters to be passed into 2760 underlying methods. such as query filters. 2761 :returns: One :class:`~openstack.network.v2.router.Router` or None 2762 """ 2763 return self._find(_router.Router, name_or_id, 2764 ignore_missing=ignore_missing, **args) 2765 2766 def get_router(self, router): 2767 """Get a single router 2768 2769 :param router: The value can be the ID of a router or a 2770 :class:`~openstack.network.v2.router.Router` instance. 2771 2772 :returns: One :class:`~openstack.network.v2.router.Router` 2773 :raises: :class:`~openstack.exceptions.ResourceNotFound` 2774 when no resource can be found. 2775 """ 2776 return self._get(_router.Router, router) 2777 2778 def routers(self, **query): 2779 """Return a generator of routers 2780 2781 :param dict query: Optional query parameters to be sent to limit 2782 the resources being returned. Valid parameters are: 2783 2784 * ``description``: The description of a router. 2785 * ``flavor_id``: The ID of the flavor. 2786 * ``is_admin_state_up``: Router administrative state is up or not 2787 * ``is_distributed``: The distributed state of a router 2788 * ``is_ha``: The highly-available state of a router 2789 * ``name``: Router name 2790 * ``project_id``: The ID of the project this router is associated 2791 with. 2792 * ``status``: The status of the router. 2793 2794 :returns: A generator of router objects 2795 :rtype: :class:`~openstack.network.v2.router.Router` 2796 """ 2797 return self._list(_router.Router, **query) 2798 2799 def update_router(self, router, if_revision=None, **attrs): 2800 """Update a router 2801 2802 :param router: Either the id of a router or a 2803 :class:`~openstack.network.v2.router.Router` instance. 2804 :param int if_revision: Revision to put in If-Match header of update 2805 request to perform compare-and-swap update. 2806 :param dict attrs: The attributes to update on the router represented 2807 by ``router``. 2808 2809 :returns: The updated router 2810 :rtype: :class:`~openstack.network.v2.router.Router` 2811 """ 2812 return self._update(_router.Router, router, if_revision=if_revision, 2813 **attrs) 2814 2815 def add_interface_to_router(self, router, subnet_id=None, port_id=None): 2816 """Add Interface to a router 2817 2818 :param router: Either the router ID or an instance of 2819 :class:`~openstack.network.v2.router.Router` 2820 :param subnet_id: ID of the subnet 2821 :param port_id: ID of the port 2822 :returns: Router with updated interface 2823 :rtype: :class: `~openstack.network.v2.router.Router` 2824 """ 2825 body = {} 2826 if port_id: 2827 body = {'port_id': port_id} 2828 else: 2829 body = {'subnet_id': subnet_id} 2830 router = self._get_resource(_router.Router, router) 2831 return router.add_interface(self, **body) 2832 2833 def remove_interface_from_router(self, router, subnet_id=None, 2834 port_id=None): 2835 """Remove Interface from a router 2836 2837 :param router: Either the router ID or an instance of 2838 :class:`~openstack.network.v2.router.Router` 2839 :param subnet: ID of the subnet 2840 :param port: ID of the port 2841 :returns: Router with updated interface 2842 :rtype: :class: `~openstack.network.v2.router.Router` 2843 """ 2844 2845 body = {} 2846 if port_id: 2847 body = {'port_id': port_id} 2848 else: 2849 body = {'subnet_id': subnet_id} 2850 router = self._get_resource(_router.Router, router) 2851 return router.remove_interface(self, **body) 2852 2853 def add_extra_routes_to_router(self, router, body): 2854 """Add extra routes to a router 2855 2856 :param router: Either the router ID or an instance of 2857 :class:`~openstack.network.v2.router.Router` 2858 :param body: The request body as documented in the api-ref. 2859 :returns: Router with updated extra routes 2860 :rtype: :class: `~openstack.network.v2.router.Router` 2861 """ 2862 router = self._get_resource(_router.Router, router) 2863 return router.add_extra_routes(self, body=body) 2864 2865 def remove_extra_routes_from_router(self, router, body): 2866 """Remove extra routes from a router 2867 2868 :param router: Either the router ID or an instance of 2869 :class:`~openstack.network.v2.router.Router` 2870 :param body: The request body as documented in the api-ref. 2871 :returns: Router with updated extra routes 2872 :rtype: :class: `~openstack.network.v2.router.Router` 2873 """ 2874 router = self._get_resource(_router.Router, router) 2875 return router.remove_extra_routes(self, body=body) 2876 2877 def add_gateway_to_router(self, router, **body): 2878 """Add Gateway to a router 2879 2880 :param router: Either the router ID or an instance of 2881 :class:`~openstack.network.v2.router.Router` 2882 :param body: Body with the gateway information 2883 :returns: Router with updated interface 2884 :rtype: :class: `~openstack.network.v2.router.Router` 2885 """ 2886 router = self._get_resource(_router.Router, router) 2887 return router.add_gateway(self, **body) 2888 2889 def remove_gateway_from_router(self, router, **body): 2890 """Remove Gateway from a router 2891 2892 :param router: Either the router ID or an instance of 2893 :class:`~openstack.network.v2.router.Router` 2894 :param body: Body with the gateway information 2895 :returns: Router with updated interface 2896 :rtype: :class: `~openstack.network.v2.router.Router` 2897 """ 2898 router = self._get_resource(_router.Router, router) 2899 return router.remove_gateway(self, **body) 2900 2901 def routers_hosting_l3_agents(self, router, **query): 2902 """Return a generator of L3 agent hosting a router 2903 2904 :param router: Either the router id or an instance of 2905 :class:`~openstack.network.v2.router.Router` 2906 :param kwargs query: Optional query parameters to be sent to limit 2907 the resources returned 2908 2909 :returns: A generator of Router L3 Agents 2910 :rtype: :class:`~openstack.network.v2.router.RouterL3Agents` 2911 """ 2912 router = self._get_resource(_router.Router, router) 2913 return self._list(_agent.RouterL3Agent, router_id=router.id, **query) 2914 2915 def agent_hosted_routers(self, agent, **query): 2916 """Return a generator of routers hosted by a L3 agent 2917 2918 :param agent: Either the agent id of an instance of 2919 :class:`~openstack.network.v2.network_agent.Agent` 2920 :param kwargs query: Optional query parameters to be sent to limit 2921 the resources returned 2922 2923 :returns: A generator of routers 2924 :rtype: :class:`~openstack.network.v2.agent.L3AgentRouters` 2925 """ 2926 agent = self._get_resource(_agent.Agent, agent) 2927 return self._list(_router.L3AgentRouter, agent_id=agent.id, **query) 2928 2929 def add_router_to_agent(self, agent, router): 2930 """Add router to L3 agent 2931 2932 :param agent: Either the id of an agent 2933 :class:`~openstack.network.v2.agent.Agent` instance 2934 :param router: A router instance 2935 :returns: Agent with attached router 2936 :rtype: :class:`~openstack.network.v2.agent.Agent` 2937 """ 2938 agent = self._get_resource(_agent.Agent, agent) 2939 router = self._get_resource(_router.Router, router) 2940 return agent.add_router_to_agent(self, router.id) 2941 2942 def remove_router_from_agent(self, agent, router): 2943 """Remove router from L3 agent 2944 2945 :param agent: Either the id of an agent or an 2946 :class:`~openstack.network.v2.agent.Agent` instance 2947 :param router: A router instance 2948 :returns: Agent with removed router 2949 :rtype: :class:`~openstack.network.v2.agent.Agent` 2950 """ 2951 agent = self._get_resource(_agent.Agent, agent) 2952 router = self._get_resource(_router.Router, router) 2953 return agent.remove_router_from_agent(self, router.id) 2954 2955 def create_firewall_group(self, **attrs): 2956 """Create a new firewall group from attributes 2957 2958 :param dict attrs: Keyword arguments which will be used to create 2959 a :class:`~openstack.network.v2.firewall_group.FirewallGroup`, 2960 comprised of the properties on the FirewallGroup class. 2961 2962 :returns: The results of firewall group creation 2963 :rtype: :class:`~openstack.network.v2.firewall_group.FirewallGroup` 2964 """ 2965 return self._create(_firewall_group.FirewallGroup, **attrs) 2966 2967 def delete_firewall_group(self, firewall_group, ignore_missing=True): 2968 """Delete a firewall group 2969 2970 :param firewall_group: 2971 The value can be either the ID of a firewall group or a 2972 :class:`~openstack.network.v2.firewall_group.FirewallGroup` 2973 instance. 2974 :param bool ignore_missing: When set to ``False`` 2975 :class:`~openstack.exceptions.ResourceNotFound` will be 2976 raised when the firewall group does not exist. 2977 When set to ``True``, no exception will be set when 2978 attempting to delete a nonexistent firewall group. 2979 2980 :returns: ``None`` 2981 """ 2982 self._delete(_firewall_group.FirewallGroup, firewall_group, 2983 ignore_missing=ignore_missing) 2984 2985 def find_firewall_group(self, name_or_id, ignore_missing=True, **args): 2986 """Find a single firewall group 2987 2988 :param name_or_id: The name or ID of a firewall group. 2989 :param bool ignore_missing: When set to ``False`` 2990 :class:`~openstack.exceptions.ResourceNotFound` will be 2991 raised when the resource does not exist. 2992 When set to ``True``, None will be returned when 2993 attempting to find a nonexistent resource. 2994 :param dict args: Any additional parameters to be passed into 2995 underlying methods. such as query filters. 2996 :returns: One :class:`~openstack.network.v2.firewall_group. 2997 FirewallGroup` or None 2998 """ 2999 return self._find(_firewall_group.FirewallGroup, 3000 name_or_id, ignore_missing=ignore_missing, **args) 3001 3002 def get_firewall_group(self, firewall_group): 3003 """Get a single firewall group 3004 3005 :param firewall_group: The value can be the ID of a firewall group or a 3006 :class:`~openstack.network.v2.firewall_group.FirewallGroup` 3007 instance. 3008 3009 :returns: One 3010 :class:`~openstack.network.v2.firewall_group.FirewallGroup` 3011 :raises: :class:`~openstack.exceptions.ResourceNotFound` 3012 when no resource can be found. 3013 """ 3014 return self._get(_firewall_group.FirewallGroup, firewall_group) 3015 3016 def firewall_groups(self, **query): 3017 """Return a generator of firewall_groups 3018 3019 :param dict query: Optional query parameters to be sent to limit 3020 the resources being returned. Valid parameters are: 3021 3022 * ``description``: Firewall group description 3023 * ``egress_policy_id``: The ID of egress firewall policy 3024 * ``ingress_policy_id``: The ID of ingress firewall policy 3025 * ``name``: The name of a firewall group 3026 * ``shared``: Indicates whether this firewall group is shared 3027 across all projects. 3028 * ``status``: The status of the firewall group. Valid values are 3029 ACTIVE, INACTIVE, ERROR, PENDING_UPDATE, or 3030 PENDING_DELETE. 3031 * ``ports``: A list of the IDs of the ports associated with the 3032 firewall group. 3033 * ``project_id``: The ID of the project this firewall group is 3034 associated with. 3035 3036 :returns: A generator of firewall group objects 3037 """ 3038 return self._list(_firewall_group.FirewallGroup, **query) 3039 3040 def update_firewall_group(self, firewall_group, **attrs): 3041 """Update a firewall group 3042 3043 :param firewall_group: Either the id of a firewall group or a 3044 :class:`~openstack.network.v2.firewall_group.FirewallGroup` 3045 instance. 3046 :param dict attrs: The attributes to update on the firewall group 3047 represented by ``firewall_group``. 3048 3049 :returns: The updated firewall group 3050 :rtype: :class:`~openstack.network.v2.firewall_group.FirewallGroup` 3051 """ 3052 return self._update(_firewall_group.FirewallGroup, firewall_group, 3053 **attrs) 3054 3055 def create_firewall_policy(self, **attrs): 3056 """Create a new firewall policy from attributes 3057 3058 :param dict attrs: Keyword arguments which will be used to create 3059 a :class:`~openstack.network.v2.firewall_policy.FirewallPolicy`, 3060 comprised of the properties on the FirewallPolicy class. 3061 3062 :returns: The results of firewall policy creation 3063 :rtype: :class:`~openstack.network.v2.firewall_policy.FirewallPolicy` 3064 """ 3065 return self._create(_firewall_policy.FirewallPolicy, **attrs) 3066 3067 def delete_firewall_policy(self, firewall_policy, ignore_missing=True): 3068 """Delete a firewall policy 3069 3070 :param firewall_policy: 3071 The value can be either the ID of a firewall policy or a 3072 :class:`~openstack.network.v2.firewall_policy.FirewallPolicy` 3073 instance. 3074 :param bool ignore_missing: When set to ``False`` 3075 :class:`~openstack.exceptions.ResourceNotFound` will be 3076 raised when the firewall policy does not exist. 3077 When set to ``True``, no exception will be set when 3078 attempting to delete a nonexistent firewall policy. 3079 3080 :returns: ``None`` 3081 """ 3082 self._delete(_firewall_policy.FirewallPolicy, firewall_policy, 3083 ignore_missing=ignore_missing) 3084 3085 def find_firewall_policy(self, name_or_id, ignore_missing=True, **args): 3086 """Find a single firewall policy 3087 3088 :param name_or_id: The name or ID of a firewall policy. 3089 :param bool ignore_missing: When set to ``False`` 3090 :class:`~openstack.exceptions.ResourceNotFound` will be 3091 raised when the resource does not exist. 3092 When set to ``True``, None will be returned when 3093 attempting to find a nonexistent resource. 3094 :param dict args: Any additional parameters to be passed into 3095 underlying methods. such as query filters. 3096 :returns: One :class:`~openstack.network.v2.firewall_policy. 3097 FirewallPolicy` or None 3098 """ 3099 return self._find(_firewall_policy.FirewallPolicy, 3100 name_or_id, ignore_missing=ignore_missing, **args) 3101 3102 def get_firewall_policy(self, firewall_policy): 3103 """Get a single firewall policy 3104 3105 :param firewall_policy: The value can be the ID of a firewall policy 3106 or a 3107 :class:`~openstack.network.v2.firewall_policy.FirewallPolicy` 3108 instance. 3109 3110 :returns: One 3111 :class:`~openstack.network.v2.firewall_policy.FirewallPolicy` 3112 :raises: :class:`~openstack.exceptions.ResourceNotFound` 3113 when no resource can be found. 3114 """ 3115 return self._get(_firewall_policy.FirewallPolicy, firewall_policy) 3116 3117 def firewall_policies(self, **query): 3118 """Return a generator of firewall_policies 3119 3120 :param dict query: Optional query parameters to be sent to limit 3121 the resources being returned. Valid parameters are: 3122 3123 * ``description``: Firewall policy description 3124 * ``firewall_rule``: A list of the IDs of the firewall rules 3125 associated with the firewall policy. 3126 * ``name``: The name of a firewall policy 3127 * ``shared``: Indicates whether this firewall policy is shared 3128 across all projects. 3129 * ``project_id``: The ID of the project that owns the resource. 3130 3131 :returns: A generator of firewall policy objects 3132 """ 3133 return self._list(_firewall_policy.FirewallPolicy, **query) 3134 3135 def update_firewall_policy(self, firewall_policy, **attrs): 3136 """Update a firewall policy 3137 3138 :param firewall_policy: Either the id of a firewall policy or a 3139 :class:`~openstack.network.v2.firewall_policy.FirewallPolicy` 3140 instance. 3141 :param dict attrs: The attributes to update on the firewall policy 3142 represented by ``firewall_policy``. 3143 3144 :returns: The updated firewall policy 3145 :rtype: :class:`~openstack.network.v2.firewall_policy.FirewallPolicy` 3146 """ 3147 return self._update(_firewall_policy.FirewallPolicy, firewall_policy, 3148 **attrs) 3149 3150 def insert_rule_into_policy(self, firewall_policy_id, firewall_rule_id, 3151 insert_after=None, insert_before=None): 3152 """Insert a firewall_rule into a firewall_policy in order 3153 3154 :param firewall_policy_id: The ID of the firewall policy. 3155 :param firewall_rule_id: The ID of the firewall rule. 3156 :param insert_after: The ID of the firewall rule to insert the new 3157 rule after. It will be worked only when 3158 insert_before is none. 3159 :param insert_before: The ID of the firewall rule to insert the new 3160 rule before. 3161 3162 :returns: The updated firewall policy 3163 :rtype: :class:`~openstack.network.v2.firewall_policy.FirewallPolicy` 3164 """ 3165 body = {'firewall_rule_id': firewall_rule_id, 3166 'insert_after': insert_after, 3167 'insert_before': insert_before} 3168 policy = self._get_resource(_firewall_policy.FirewallPolicy, 3169 firewall_policy_id) 3170 return policy.insert_rule(self, **body) 3171 3172 def remove_rule_from_policy(self, firewall_policy_id, firewall_rule_id): 3173 """Remove a firewall_rule from a firewall_policy. 3174 3175 :param firewall_policy_id: The ID of the firewall policy. 3176 :param firewall_rule_id: The ID of the firewall rule. 3177 3178 :returns: The updated firewall policy 3179 :rtype: :class:`~openstack.network.v2.firewall_policy.FirewallPolicy` 3180 """ 3181 body = {'firewall_rule_id': firewall_rule_id} 3182 policy = self._get_resource(_firewall_policy.FirewallPolicy, 3183 firewall_policy_id) 3184 return policy.remove_rule(self, **body) 3185 3186 def create_firewall_rule(self, **attrs): 3187 """Create a new firewall rule from attributes 3188 3189 :param dict attrs: Keyword arguments which will be used to create 3190 a :class:`~openstack.network.v2.firewall_rule.FirewallRule`, 3191 comprised of the properties on the FirewallRule class. 3192 3193 :returns: The results of firewall rule creation 3194 :rtype: :class:`~openstack.network.v2.firewall_rule.FirewallRule` 3195 """ 3196 return self._create(_firewall_rule.FirewallRule, **attrs) 3197 3198 def delete_firewall_rule(self, firewall_rule, ignore_missing=True): 3199 """Delete a firewall rule 3200 3201 :param firewall_rule: 3202 The value can be either the ID of a firewall rule or a 3203 :class:`~openstack.network.v2.firewall_rule.FirewallRule` 3204 instance. 3205 :param bool ignore_missing: When set to ``False`` 3206 :class:`~openstack.exceptions.ResourceNotFound` will be 3207 raised when the firewall rule does not exist. 3208 When set to ``True``, no exception will be set when 3209 attempting to delete a nonexistent firewall rule. 3210 3211 :returns: ``None`` 3212 """ 3213 self._delete(_firewall_rule.FirewallRule, firewall_rule, 3214 ignore_missing=ignore_missing) 3215 3216 def find_firewall_rule(self, name_or_id, ignore_missing=True, **args): 3217 """Find a single firewall rule 3218 3219 :param name_or_id: The name or ID of a firewall rule. 3220 :param bool ignore_missing: When set to ``False`` 3221 :class:`~openstack.exceptions.ResourceNotFound` will be 3222 raised when the resource does not exist. 3223 When set to ``True``, None will be returned when 3224 attempting to find a nonexistent resource. 3225 :param dict args: Any additional parameters to be passed into 3226 underlying methods. such as query filters. 3227 :returns: One :class:`~openstack.network.v2.firewall_rule. 3228 FirewallRule` or None 3229 """ 3230 return self._find(_firewall_rule.FirewallRule, 3231 name_or_id, ignore_missing=ignore_missing, **args) 3232 3233 def get_firewall_rule(self, firewall_rule): 3234 """Get a single firewall rule 3235 3236 :param firewall_rule: The value can be the ID of a firewall rule or a 3237 :class:`~openstack.network.v2.firewall_rule.FirewallRule` 3238 instance. 3239 3240 :returns: One 3241 :class:`~openstack.network.v2.firewall_rule.FirewallRule` 3242 :raises: :class:`~openstack.exceptions.ResourceNotFound` 3243 when no resource can be found. 3244 """ 3245 return self._get(_firewall_rule.FirewallRule, firewall_rule) 3246 3247 def firewall_rules(self, **query): 3248 """Return a generator of firewall_rules 3249 3250 :param dict query: Optional query parameters to be sent to limit 3251 the resources being returned. Valid parameters are: 3252 3253 * ``action``: The action that the API performs on traffic that 3254 matches the firewall rule. 3255 * ``description``: Firewall rule description 3256 * ``name``: The name of a firewall group 3257 * ``destination_ip_address``: The destination IPv4 or IPv6 address 3258 or CIDR for the firewall rule. 3259 * ``destination_port``: The destination port or port range for 3260 the firewall rule. 3261 * ``enabled``: Facilitates selectively turning off rules. 3262 * ``shared``: Indicates whether this firewall group is shared 3263 across all projects. 3264 * ``ip_version``: The IP protocol version for the firewall rule. 3265 * ``protocol``: The IP protocol for the firewall rule. 3266 * ``source_ip_address``: The source IPv4 or IPv6 address or CIDR 3267 for the firewall rule. 3268 * ``source_port``: The source port or port range for the firewall 3269 rule. 3270 * ``project_id``: The ID of the project this firewall group is 3271 associated with. 3272 3273 :returns: A generator of firewall rule objects 3274 """ 3275 return self._list(_firewall_rule.FirewallRule, **query) 3276 3277 def update_firewall_rule(self, firewall_rule, **attrs): 3278 """Update a firewall rule 3279 3280 :param firewall_rule: Either the id of a firewall rule or a 3281 :class:`~openstack.network.v2.firewall_rule.FirewallRule` 3282 instance. 3283 :param dict attrs: The attributes to update on the firewall rule 3284 represented by ``firewall_rule``. 3285 3286 :returns: The updated firewall rule 3287 :rtype: :class:`~openstack.network.v2.firewall_rule.FirewallRule` 3288 """ 3289 return self._update(_firewall_rule.FirewallRule, firewall_rule, 3290 **attrs) 3291 3292 def create_security_group(self, **attrs): 3293 """Create a new security group from attributes 3294 3295 :param dict attrs: Keyword arguments which will be used to create 3296 a :class:`~openstack.network.v2.security_group.SecurityGroup`, 3297 comprised of the properties on the SecurityGroup class. 3298 3299 :returns: The results of security group creation 3300 :rtype: :class:`~openstack.network.v2.security_group.SecurityGroup` 3301 """ 3302 return self._create(_security_group.SecurityGroup, **attrs) 3303 3304 def delete_security_group(self, security_group, ignore_missing=True, 3305 if_revision=None): 3306 """Delete a security group 3307 3308 :param security_group: 3309 The value can be either the ID of a security group or a 3310 :class:`~openstack.network.v2.security_group.SecurityGroup` 3311 instance. 3312 :param bool ignore_missing: When set to ``False`` 3313 :class:`~openstack.exceptions.ResourceNotFound` will be 3314 raised when the security group does not exist. 3315 When set to ``True``, no exception will be set when 3316 attempting to delete a nonexistent security group. 3317 :param int if_revision: Revision to put in If-Match header of update 3318 request to perform compare-and-swap update. 3319 3320 :returns: ``None`` 3321 """ 3322 self._delete(_security_group.SecurityGroup, security_group, 3323 ignore_missing=ignore_missing, if_revision=if_revision) 3324 3325 def find_security_group(self, name_or_id, ignore_missing=True, **args): 3326 """Find a single security group 3327 3328 :param name_or_id: The name or ID of a security group. 3329 :param bool ignore_missing: When set to ``False`` 3330 :class:`~openstack.exceptions.ResourceNotFound` will be 3331 raised when the resource does not exist. 3332 When set to ``True``, None will be returned when 3333 attempting to find a nonexistent resource. 3334 :param dict args: Any additional parameters to be passed into 3335 underlying methods. such as query filters. 3336 :returns: One :class:`~openstack.network.v2.security_group. 3337 SecurityGroup` or None 3338 """ 3339 return self._find(_security_group.SecurityGroup, name_or_id, 3340 ignore_missing=ignore_missing, **args) 3341 3342 def get_security_group(self, security_group): 3343 """Get a single security group 3344 3345 :param security_group: The value can be the ID of a security group or a 3346 :class:`~openstack.network.v2.security_group.SecurityGroup` 3347 instance. 3348 3349 :returns: One 3350 :class:`~openstack.network.v2.security_group.SecurityGroup` 3351 :raises: :class:`~openstack.exceptions.ResourceNotFound` 3352 when no resource can be found. 3353 """ 3354 return self._get(_security_group.SecurityGroup, security_group) 3355 3356 def security_groups(self, **query): 3357 """Return a generator of security groups 3358 3359 :param dict query: Optional query parameters to be sent to limit 3360 the resources being returned. Valid parameters are: 3361 3362 * ``description``: Security group description 3363 * ``ìd``: The id of a security group, or list of security group ids 3364 * ``name``: The name of a security group 3365 * ``project_id``: The ID of the project this security group is 3366 associated with. 3367 3368 :returns: A generator of security group objects 3369 :rtype: :class:`~openstack.network.v2.security_group.SecurityGroup` 3370 """ 3371 return self._list(_security_group.SecurityGroup, **query) 3372 3373 def update_security_group(self, security_group, if_revision=None, **attrs): 3374 """Update a security group 3375 3376 :param security_group: Either the id of a security group or a 3377 :class:`~openstack.network.v2.security_group.SecurityGroup` 3378 instance. 3379 :param int if_revision: Revision to put in If-Match header of update 3380 request to perform compare-and-swap update. 3381 :param dict attrs: The attributes to update on the security group 3382 represented by ``security_group``. 3383 3384 :returns: The updated security group 3385 :rtype: :class:`~openstack.network.v2.security_group.SecurityGroup` 3386 """ 3387 return self._update(_security_group.SecurityGroup, security_group, 3388 if_revision=if_revision, **attrs) 3389 3390 def create_security_group_rule(self, **attrs): 3391 """Create a new security group rule from attributes 3392 3393 :param dict attrs: Keyword arguments which will be used to create a 3394 :class:`~openstack.network.v2.security_group_rule. 3395 SecurityGroupRule`, comprised of the properties on the 3396 SecurityGroupRule class. 3397 3398 :returns: The results of security group rule creation 3399 :rtype: :class:`~openstack.network.v2.security_group_rule.\ 3400 SecurityGroupRule` 3401 """ 3402 return self._create(_security_group_rule.SecurityGroupRule, **attrs) 3403 3404 def create_security_group_rules(self, data): 3405 """Create new security group rules from the list of attributes 3406 3407 :param list data: List of dicts of attributes which will be used to 3408 create a :class:`~openstack.network.v2.\ 3409 security_group_rule.SecurityGroupRule`, 3410 comprised of the properties on the SecurityGroupRule 3411 class. 3412 3413 :returns: A generator of security group rule objects 3414 :rtype: :class:`~openstack.network.v2.security_group_rule.\ 3415 SecurityGroupRule` 3416 """ 3417 return self._bulk_create(_security_group_rule.SecurityGroupRule, data) 3418 3419 def delete_security_group_rule(self, security_group_rule, 3420 ignore_missing=True, if_revision=None): 3421 """Delete a security group rule 3422 3423 :param security_group_rule: 3424 The value can be either the ID of a security group rule 3425 or a :class:`~openstack.network.v2.security_group_rule. 3426 SecurityGroupRule` instance. 3427 :param bool ignore_missing: When set to ``False`` 3428 :class:`~openstack.exceptions.ResourceNotFound` will be 3429 raised when the security group rule does not exist. 3430 When set to ``True``, no exception will be set when 3431 attempting to delete a nonexistent security group rule. 3432 :param int if_revision: Revision to put in If-Match header of update 3433 request to perform compare-and-swap update. 3434 3435 :returns: ``None`` 3436 """ 3437 self._delete(_security_group_rule.SecurityGroupRule, 3438 security_group_rule, ignore_missing=ignore_missing, 3439 if_revision=if_revision) 3440 3441 def find_security_group_rule(self, name_or_id, ignore_missing=True, 3442 **args): 3443 """Find a single security group rule 3444 3445 :param str name_or_id: The ID of a security group rule. 3446 :param bool ignore_missing: When set to ``False`` 3447 :class:`~openstack.exceptions.ResourceNotFound` will be 3448 raised when the resource does not exist. 3449 When set to ``True``, None will be returned when 3450 attempting to find a nonexistent resource. 3451 :param dict args: Any additional parameters to be passed into 3452 underlying methods. such as query filters. 3453 :returns: One :class:`~openstack.network.v2.security_group_rule. 3454 SecurityGroupRule` or None 3455 """ 3456 return self._find(_security_group_rule.SecurityGroupRule, 3457 name_or_id, ignore_missing=ignore_missing, **args) 3458 3459 def get_security_group_rule(self, security_group_rule): 3460 """Get a single security group rule 3461 3462 :param security_group_rule: 3463 The value can be the ID of a security group rule or a 3464 :class:`~openstack.network.v2.security_group_rule.\ 3465 SecurityGroupRule` instance. 3466 3467 :returns: :class:`~openstack.network.v2.security_group_rule.\ 3468 SecurityGroupRule` 3469 :raises: :class:`~openstack.exceptions.ResourceNotFound` 3470 when no resource can be found. 3471 """ 3472 return self._get(_security_group_rule.SecurityGroupRule, 3473 security_group_rule) 3474 3475 def security_group_rules(self, **query): 3476 """Return a generator of security group rules 3477 3478 :param kwargs query: Optional query parameters to be sent to limit 3479 the resources being returned. Available parameters include: 3480 3481 * ``description``: The security group rule description 3482 * ``direction``: Security group rule direction 3483 * ``ether_type``: Must be IPv4 or IPv6, and addresses represented 3484 in CIDR must match the ingress or egress rule. 3485 * ``project_id``: The ID of the project this security group rule 3486 is associated with. 3487 * ``protocol``: Security group rule protocol 3488 * ``remote_group_id``: ID of a remote security group 3489 * ``security_group_id``: ID of security group that owns the rules 3490 3491 :returns: A generator of security group rule objects 3492 :rtype: :class:`~openstack.network.v2.security_group_rule. 3493 SecurityGroupRule` 3494 """ 3495 return self._list(_security_group_rule.SecurityGroupRule, **query) 3496 3497 def create_segment(self, **attrs): 3498 """Create a new segment from attributes 3499 3500 :param dict attrs: Keyword arguments which will be used to create 3501 a :class:`~openstack.network.v2.segment.Segment`, 3502 comprised of the properties on the Segment class. 3503 3504 :returns: The results of segment creation 3505 :rtype: :class:`~openstack.network.v2.segment.Segment` 3506 """ 3507 return self._create(_segment.Segment, **attrs) 3508 3509 def delete_segment(self, segment, ignore_missing=True): 3510 """Delete a segment 3511 3512 :param segment: The value can be either the ID of a segment or a 3513 :class:`~openstack.network.v2.segment.Segment` 3514 instance. 3515 :param bool ignore_missing: When set to ``False`` 3516 :class:`~openstack.exceptions.ResourceNotFound` will be 3517 raised when the segment does not exist. 3518 When set to ``True``, no exception will be set when 3519 attempting to delete a nonexistent segment. 3520 3521 :returns: ``None`` 3522 """ 3523 self._delete(_segment.Segment, segment, ignore_missing=ignore_missing) 3524 3525 def find_segment(self, name_or_id, ignore_missing=True, **args): 3526 """Find a single segment 3527 3528 :param name_or_id: The name or ID of a segment. 3529 :param bool ignore_missing: When set to ``False`` 3530 :class:`~openstack.exceptions.ResourceNotFound` will be 3531 raised when the resource does not exist. 3532 When set to ``True``, None will be returned when 3533 attempting to find a nonexistent resource. 3534 :param dict args: Any additional parameters to be passed into 3535 underlying methods. such as query filters. 3536 :returns: One :class:`~openstack.network.v2.segment.Segment` or None 3537 """ 3538 return self._find(_segment.Segment, name_or_id, 3539 ignore_missing=ignore_missing, **args) 3540 3541 def get_segment(self, segment): 3542 """Get a single segment 3543 3544 :param segment: The value can be the ID of a segment or a 3545 :class:`~openstack.network.v2.segment.Segment` 3546 instance. 3547 3548 :returns: One :class:`~openstack.network.v2.segment.Segment` 3549 :raises: :class:`~openstack.exceptions.ResourceNotFound` 3550 when no resource can be found. 3551 """ 3552 return self._get(_segment.Segment, segment) 3553 3554 def segments(self, **query): 3555 """Return a generator of segments 3556 3557 :param kwargs query: Optional query parameters to be sent to limit 3558 the resources being returned. Available parameters include: 3559 3560 * ``description``: The segment description 3561 * ``name``: Name of the segments 3562 * ``network_id``: ID of the network that owns the segments 3563 * ``network_type``: Network type for the segments 3564 * ``physical_network``: Physical network name for the segments 3565 * ``segmentation_id``: Segmentation ID for the segments 3566 3567 :returns: A generator of segment objects 3568 :rtype: :class:`~openstack.network.v2.segment.Segment` 3569 """ 3570 return self._list(_segment.Segment, **query) 3571 3572 def update_segment(self, segment, **attrs): 3573 """Update a segment 3574 3575 :param segment: Either the id of a segment or a 3576 :class:`~openstack.network.v2.segment.Segment` 3577 instance. 3578 :attrs kwargs: The attributes to update on the segment represented 3579 by ``value``. 3580 3581 :returns: The update segment 3582 :rtype: :class:`~openstack.network.v2.segment.Segment` 3583 """ 3584 return self._update(_segment.Segment, segment, **attrs) 3585 3586 def service_providers(self, **query): 3587 """Return a generator of service providers 3588 3589 :param kwargs query: Optional query parameters to be sent to limit 3590 the resources being returned. 3591 3592 :returns: A generator of service provider objects 3593 :rtype: :class:`~openstack.network.v2.service_provider.ServiceProvider` 3594 """ 3595 3596 return self._list(_service_provider.ServiceProvider, **query) 3597 3598 def create_service_profile(self, **attrs): 3599 """Create a new network service flavor profile from attributes 3600 3601 :param dict attrs: Keyword arguments which will be used to create 3602 a :class:`~openstack.network.v2.service_profile 3603 .ServiceProfile`, 3604 comprised of the properties on the ServiceProfile 3605 class. 3606 3607 :returns: The results of service profile creation 3608 :rtype: :class:`~openstack.network.v2.service_profile.ServiceProfile` 3609 """ 3610 return self._create(_service_profile.ServiceProfile, **attrs) 3611 3612 def delete_service_profile(self, service_profile, ignore_missing=True): 3613 """Delete a network service flavor profile 3614 3615 :param service_profile: The value can be either the ID of a service 3616 profile or a 3617 :class:`~openstack.network.v2.service_profile 3618 .ServiceProfile` instance. 3619 :param bool ignore_missing: When set to ``False`` 3620 :class:`~openstack.exceptions.ResourceNotFound` will be 3621 raised when the service profile does not exist. 3622 When set to ``True``, no exception will be set when 3623 attempting to delete a nonexistent service profile. 3624 3625 :returns: ``None`` 3626 """ 3627 self._delete(_service_profile.ServiceProfile, service_profile, 3628 ignore_missing=ignore_missing) 3629 3630 def find_service_profile(self, name_or_id, ignore_missing=True, **args): 3631 """Find a single network service flavor profile 3632 3633 :param name_or_id: The name or ID of a service profile. 3634 :param bool ignore_missing: When set to ``False`` 3635 :class:`~openstack.exceptions.ResourceNotFound` will be 3636 raised when the resource does not exist. 3637 When set to ``True``, None will be returned when 3638 attempting to find a nonexistent resource. 3639 :param dict args: Any additional parameters to be passed into 3640 underlying methods. such as query filters. 3641 :returns: One :class:`~openstack.network.v2.service_profile 3642 .ServiceProfile` or None 3643 """ 3644 return self._find(_service_profile.ServiceProfile, name_or_id, 3645 ignore_missing=ignore_missing, **args) 3646 3647 def get_service_profile(self, service_profile): 3648 """Get a single network service flavor profile 3649 3650 :param service_profile: The value can be the ID of a service_profile or 3651 a :class:`~openstack.network.v2.service_profile.ServiceProfile` 3652 instance. 3653 3654 :returns: One :class:`~openstack.network.v2.service_profile 3655 .ServiceProfile` 3656 :raises: :class:`~openstack.exceptions.ResourceNotFound` 3657 when no resource can be found. 3658 """ 3659 return self._get(_service_profile.ServiceProfile, service_profile) 3660 3661 def service_profiles(self, **query): 3662 """Return a generator of network service flavor profiles 3663 3664 :param dict query: Optional query parameters to be sent to limit the 3665 resources returned. Available parameters inclue: 3666 3667 * ``description``: The description of the service flavor profile 3668 * ``driver``: Provider driver for the service flavor profile 3669 * ``is_enabled``: Whether the profile is enabled 3670 * ``project_id``: The owner project ID 3671 3672 :returns: A generator of service profile objects 3673 :rtype: :class:`~openstack.network.v2.service_profile.ServiceProfile` 3674 """ 3675 return self._list(_service_profile.ServiceProfile, **query) 3676 3677 def update_service_profile(self, service_profile, **attrs): 3678 """Update a network flavor service profile 3679 3680 :param service_profile: Either the id of a service profile or a 3681 :class:`~openstack.network.v2.service_profile 3682 .ServiceProfile` instance. 3683 :attrs kwargs: The attributes to update on the service profile 3684 represented by ``value``. 3685 3686 :returns: The updated service profile 3687 :rtype: :class:`~openstack.network.v2.service_profile.ServiceProfile` 3688 """ 3689 return self._update(_service_profile.ServiceProfile, service_profile, 3690 **attrs) 3691 3692 def create_subnet(self, **attrs): 3693 """Create a new subnet from attributes 3694 3695 :param dict attrs: Keyword arguments which will be used to create 3696 a :class:`~openstack.network.v2.subnet.Subnet`, 3697 comprised of the properties on the Subnet class. 3698 3699 :returns: The results of subnet creation 3700 :rtype: :class:`~openstack.network.v2.subnet.Subnet` 3701 """ 3702 return self._create(_subnet.Subnet, **attrs) 3703 3704 def delete_subnet(self, subnet, ignore_missing=True, if_revision=None): 3705 """Delete a subnet 3706 3707 :param subnet: The value can be either the ID of a subnet or a 3708 :class:`~openstack.network.v2.subnet.Subnet` instance. 3709 :param bool ignore_missing: When set to ``False`` 3710 :class:`~openstack.exceptions.ResourceNotFound` will be 3711 raised when the subnet does not exist. 3712 When set to ``True``, no exception will be set when 3713 attempting to delete a nonexistent subnet. 3714 :param int if_revision: Revision to put in If-Match header of update 3715 request to perform compare-and-swap update. 3716 3717 :returns: ``None`` 3718 """ 3719 self._delete(_subnet.Subnet, subnet, ignore_missing=ignore_missing, 3720 if_revision=if_revision) 3721 3722 def find_subnet(self, name_or_id, ignore_missing=True, **args): 3723 """Find a single subnet 3724 3725 :param name_or_id: The name or ID of a subnet. 3726 :param bool ignore_missing: When set to ``False`` 3727 :class:`~openstack.exceptions.ResourceNotFound` will be 3728 raised when the resource does not exist. 3729 When set to ``True``, None will be returned when 3730 attempting to find a nonexistent resource. 3731 :param dict args: Any additional parameters to be passed into 3732 underlying methods. such as query filters. 3733 :returns: One :class:`~openstack.network.v2.subnet.Subnet` or None 3734 """ 3735 return self._find(_subnet.Subnet, name_or_id, 3736 ignore_missing=ignore_missing, **args) 3737 3738 def get_subnet(self, subnet): 3739 """Get a single subnet 3740 3741 :param subnet: The value can be the ID of a subnet or a 3742 :class:`~openstack.network.v2.subnet.Subnet` instance. 3743 3744 :returns: One :class:`~openstack.network.v2.subnet.Subnet` 3745 :raises: :class:`~openstack.exceptions.ResourceNotFound` 3746 when no resource can be found. 3747 """ 3748 return self._get(_subnet.Subnet, subnet) 3749 3750 def subnets(self, **query): 3751 """Return a generator of subnets 3752 3753 :param dict query: Optional query parameters to be sent to limit 3754 the resources being returned. Available parameters include: 3755 3756 * ``cidr``: Subnet CIDR 3757 * ``description``: The subnet description 3758 * ``gateway_ip``: Subnet gateway IP address 3759 * ``ip_version``: Subnet IP address version 3760 * ``ipv6_address_mode``: The IPv6 address mode 3761 * ``ipv6_ra_mode``: The IPv6 router advertisement mode 3762 * ``is_dhcp_enabled``: Subnet has DHCP enabled (boolean) 3763 * ``name``: Subnet name 3764 * ``network_id``: ID of network that owns the subnets 3765 * ``project_id``: Owner tenant ID 3766 * ``subnet_pool_id``: The subnet pool ID from which to obtain a 3767 CIDR. 3768 3769 :returns: A generator of subnet objects 3770 :rtype: :class:`~openstack.network.v2.subnet.Subnet` 3771 """ 3772 return self._list(_subnet.Subnet, **query) 3773 3774 def update_subnet(self, subnet, if_revision=None, **attrs): 3775 """Update a subnet 3776 3777 :param subnet: Either the id of a subnet or a 3778 :class:`~openstack.network.v2.subnet.Subnet` instance. 3779 :param int if_revision: Revision to put in If-Match header of update 3780 request to perform compare-and-swap update. 3781 :param dict attrs: The attributes to update on the subnet represented 3782 by ``subnet``. 3783 3784 :returns: The updated subnet 3785 :rtype: :class:`~openstack.network.v2.subnet.Subnet` 3786 """ 3787 return self._update(_subnet.Subnet, subnet, if_revision=if_revision, 3788 **attrs) 3789 3790 def create_subnet_pool(self, **attrs): 3791 """Create a new subnet pool from attributes 3792 3793 :param dict attrs: Keyword arguments which will be used to create 3794 a :class:`~openstack.network.v2.subnet_pool.SubnetPool`, 3795 comprised of the properties on the SubnetPool class. 3796 3797 :returns: The results of subnet pool creation 3798 :rtype: :class:`~openstack.network.v2.subnet_pool.SubnetPool` 3799 """ 3800 return self._create(_subnet_pool.SubnetPool, **attrs) 3801 3802 def delete_subnet_pool(self, subnet_pool, ignore_missing=True): 3803 """Delete a subnet pool 3804 3805 :param subnet_pool: The value can be either the ID of a subnet pool or 3806 a :class:`~openstack.network.v2.subnet_pool.SubnetPool` instance. 3807 :param bool ignore_missing: When set to ``False`` 3808 :class:`~openstack.exceptions.ResourceNotFound` will be 3809 raised when the subnet pool does not exist. 3810 When set to ``True``, no exception will be set when 3811 attempting to delete a nonexistent subnet pool. 3812 3813 :returns: ``None`` 3814 """ 3815 self._delete(_subnet_pool.SubnetPool, subnet_pool, 3816 ignore_missing=ignore_missing) 3817 3818 def find_subnet_pool(self, name_or_id, ignore_missing=True, **args): 3819 """Find a single subnet pool 3820 3821 :param name_or_id: The name or ID of a subnet pool. 3822 :param bool ignore_missing: When set to ``False`` 3823 :class:`~openstack.exceptions.ResourceNotFound` will be 3824 raised when the resource does not exist. 3825 When set to ``True``, None will be returned when 3826 attempting to find a nonexistent resource. 3827 :param dict args: Any additional parameters to be passed into 3828 underlying methods. such as query filters. 3829 :returns: One :class:`~openstack.network.v2.subnet_pool.SubnetPool` 3830 or None 3831 """ 3832 return self._find(_subnet_pool.SubnetPool, name_or_id, 3833 ignore_missing=ignore_missing, **args) 3834 3835 def get_subnet_pool(self, subnet_pool): 3836 """Get a single subnet pool 3837 3838 :param subnet_pool: The value can be the ID of a subnet pool or a 3839 :class:`~openstack.network.v2.subnet_pool.SubnetPool` instance. 3840 3841 :returns: One :class:`~openstack.network.v2.subnet_pool.SubnetPool` 3842 :raises: :class:`~openstack.exceptions.ResourceNotFound` 3843 when no resource can be found. 3844 """ 3845 return self._get(_subnet_pool.SubnetPool, subnet_pool) 3846 3847 def subnet_pools(self, **query): 3848 """Return a generator of subnet pools 3849 3850 :param kwargs query: Optional query parameters to be sent to limit 3851 the resources being returned. Available parameters include: 3852 3853 * ``address_scope_id``: Subnet pool address scope ID 3854 * ``description``: The subnet pool description 3855 * ``ip_version``: The IP address family 3856 * ``is_default``: Subnet pool is the default (boolean) 3857 * ``is_shared``: Subnet pool is shared (boolean) 3858 * ``name``: Subnet pool name 3859 * ``project_id``: Owner tenant ID 3860 3861 :returns: A generator of subnet pool objects 3862 :rtype: :class:`~openstack.network.v2.subnet_pool.SubnetPool` 3863 """ 3864 return self._list(_subnet_pool.SubnetPool, **query) 3865 3866 def update_subnet_pool(self, subnet_pool, **attrs): 3867 """Update a subnet pool 3868 3869 :param subnet_pool: Either the ID of a subnet pool or a 3870 :class:`~openstack.network.v2.subnet_pool.SubnetPool` instance. 3871 :param dict attrs: The attributes to update on the subnet pool 3872 represented by ``subnet_pool``. 3873 3874 :returns: The updated subnet pool 3875 :rtype: :class:`~openstack.network.v2.subnet_pool.SubnetPool` 3876 """ 3877 return self._update(_subnet_pool.SubnetPool, subnet_pool, **attrs) 3878 3879 @staticmethod 3880 def _check_tag_support(resource): 3881 try: 3882 # Check 'tags' attribute exists 3883 resource.tags 3884 except AttributeError: 3885 raise exceptions.InvalidRequest( 3886 '%s resource does not support tag' % 3887 resource.__class__.__name__) 3888 3889 def set_tags(self, resource, tags): 3890 """Replace tags of a specified resource with specified tags 3891 3892 :param resource: 3893 :class:`~openstack.resource.Resource` instance. 3894 :param tags: New tags to be set. 3895 :type tags: "list" 3896 3897 :returns: The updated resource 3898 :rtype: :class:`~openstack.resource.Resource` 3899 """ 3900 self._check_tag_support(resource) 3901 return resource.set_tags(self, tags) 3902 3903 def create_trunk(self, **attrs): 3904 """Create a new trunk from attributes 3905 3906 :param dict attrs: Keyword arguments which will be used to create 3907 a :class:`~openstack.network.v2.trunk.Trunk, 3908 comprised of the properties on the Trunk class. 3909 3910 :returns: The results of trunk creation 3911 :rtype: :class:`~openstack.network.v2.trunk.Trunk` 3912 """ 3913 return self._create(_trunk.Trunk, **attrs) 3914 3915 def delete_trunk(self, trunk, ignore_missing=True): 3916 """Delete a trunk 3917 3918 :param trunk: The value can be either the ID of trunk or a 3919 :class:`openstack.network.v2.trunk.Trunk` instance 3920 3921 :returns: ``None`` 3922 """ 3923 self._delete(_trunk.Trunk, trunk, ignore_missing=ignore_missing) 3924 3925 def find_trunk(self, name_or_id, ignore_missing=True, **args): 3926 """Find a single trunk 3927 3928 :param name_or_id: The name or ID of a trunk. 3929 :param bool ignore_missing: When set to ``False`` 3930 :class:`~openstack.exceptions.ResourceNotFound` will be 3931 raised when the resource does not exist. 3932 When set to ``True``, None will be returned when 3933 attempting to find a nonexistent resource. 3934 :param dict args: Any additional parameters to be passed into 3935 underlying methods. such as query filters. 3936 :returns: One :class:`~openstack.network.v2.trunk.Trunk` 3937 or None 3938 """ 3939 return self._find(_trunk.Trunk, name_or_id, 3940 ignore_missing=ignore_missing, **args) 3941 3942 def get_trunk(self, trunk): 3943 """Get a single trunk 3944 3945 :param trunk: The value can be the ID of a trunk or a 3946 :class:`~openstack.network.v2.trunk.Trunk` instance. 3947 3948 :returns: One 3949 :class:`~openstack.network.v2.trunk.Trunk` 3950 :raises: :class:`~openstack.exceptions.ResourceNotFound` 3951 when no resource can be found. 3952 """ 3953 return self._get(_trunk.Trunk, trunk) 3954 3955 def trunks(self, **query): 3956 """Return a generator of trunks 3957 3958 :param dict query: Optional query parameters to be sent to limit 3959 the resources being returned. 3960 3961 :returns: A generator of trunk objects 3962 :rtype: :class:`~openstack.network.v2.trunk.trunk` 3963 """ 3964 return self._list(_trunk.Trunk, **query) 3965 3966 def update_trunk(self, trunk, **attrs): 3967 """Update a trunk 3968 3969 :param trunk: Either the id of a trunk or a 3970 :class:`~openstack.network.v2.trunk.Trunk` instance. 3971 :param dict attrs: The attributes to update on the trunk 3972 represented by ``trunk``. 3973 3974 :returns: The updated trunk 3975 :rtype: :class:`~openstack.network.v2.trunk.Trunk` 3976 """ 3977 return self._update(_trunk.Trunk, trunk, **attrs) 3978 3979 def add_trunk_subports(self, trunk, subports): 3980 """Set sub_ports on trunk 3981 3982 :param trunk: The value can be the ID of a trunk or a 3983 :class:`~openstack.network.v2.trunk.Trunk` instance. 3984 :param subports: New subports to be set. 3985 :type subports: "list" 3986 3987 :returns: The updated trunk 3988 :rtype: :class:`~openstack.network.v2.trunk.Trunk` 3989 """ 3990 trunk = self._get_resource(_trunk.Trunk, trunk) 3991 return trunk.add_subports(self, subports) 3992 3993 def delete_trunk_subports(self, trunk, subports): 3994 """Remove sub_ports from trunk 3995 3996 :param trunk: The value can be the ID of a trunk or a 3997 :class:`~openstack.network.v2.trunk.Trunk` instance. 3998 :param subports: Subports to be removed. 3999 :type subports: "list" 4000 4001 :returns: The updated trunk 4002 :rtype: :class:`~openstack.network.v2.trunk.Trunk` 4003 """ 4004 trunk = self._get_resource(_trunk.Trunk, trunk) 4005 return trunk.delete_subports(self, subports) 4006 4007 def get_trunk_subports(self, trunk): 4008 """Get sub_ports configured on trunk 4009 4010 :param trunk: The value can be the ID of a trunk or a 4011 :class:`~openstack.network.v2.trunk.Trunk` instance. 4012 4013 :returns: Trunk sub_ports 4014 :rtype: "list" 4015 """ 4016 trunk = self._get_resource(_trunk.Trunk, trunk) 4017 return trunk.get_subports(self) 4018 4019 def create_vpn_service(self, **attrs): 4020 """Create a new vpn service from attributes 4021 4022 :param dict attrs: Keyword arguments which will be used to create 4023 a :class:`~openstack.network.v2.vpn_service.VPNService`, 4024 comprised of the properties on the VPNService class. 4025 4026 :returns: The results of vpn service creation 4027 :rtype: :class:`~openstack.network.v2.vpn_service.VPNService` 4028 """ 4029 return self._create(_vpn_service.VPNService, **attrs) 4030 4031 def delete_vpn_service(self, vpn_service, ignore_missing=True): 4032 """Delete a vpn service 4033 4034 :param vpn_service: 4035 The value can be either the ID of a vpn service or a 4036 :class:`~openstack.network.v2.vpn_service.VPNService` instance. 4037 :param bool ignore_missing: When set to ``False`` 4038 :class:`~openstack.exceptions.ResourceNotFound` will be 4039 raised when the vpn service does not exist. 4040 When set to ``True``, no exception will be set when 4041 attempting to delete a nonexistent vpn service. 4042 4043 :returns: ``None`` 4044 """ 4045 self._delete(_vpn_service.VPNService, vpn_service, 4046 ignore_missing=ignore_missing) 4047 4048 def find_vpn_service(self, name_or_id, ignore_missing=True, **args): 4049 """Find a single vpn service 4050 4051 :param name_or_id: The name or ID of a vpn service. 4052 :param bool ignore_missing: When set to ``False`` 4053 :class:`~openstack.exceptions.ResourceNotFound` will be 4054 raised when the resource does not exist. 4055 When set to ``True``, None will be returned when 4056 attempting to find a nonexistent resource. 4057 :param dict args: Any additional parameters to be passed into 4058 underlying methods. such as query filters. 4059 :returns: One :class:`~openstack.network.v2.vpn_service.VPNService` 4060 or None 4061 """ 4062 return self._find(_vpn_service.VPNService, name_or_id, 4063 ignore_missing=ignore_missing, **args) 4064 4065 def get_vpn_service(self, vpn_service): 4066 """Get a single vpn service 4067 4068 :param vpn_service: The value can be the ID of a vpn service or a 4069 :class:`~openstack.network.v2.vpn_service.VPNService` 4070 instance. 4071 4072 :returns: One 4073 :class:`~openstack.network.v2.vpn_service.VPNService` 4074 :raises: :class:`~openstack.exceptions.ResourceNotFound` 4075 when no resource can be found. 4076 """ 4077 return self._get(_vpn_service.VPNService, vpn_service) 4078 4079 def vpn_services(self, **query): 4080 """Return a generator of vpn services 4081 4082 :param dict query: Optional query parameters to be sent to limit 4083 the resources being returned. 4084 4085 :returns: A generator of vpn service objects 4086 :rtype: :class:`~openstack.network.v2.vpn_service.VPNService` 4087 """ 4088 return self._list(_vpn_service.VPNService, **query) 4089 4090 def update_vpn_service(self, vpn_service, **attrs): 4091 """Update a vpn service 4092 4093 :param vpn_service: Either the id of a vpn service or a 4094 :class:`~openstack.network.v2.vpn_service.VPNService` instance. 4095 :param dict attrs: The attributes to update on the VPN service 4096 represented by ``vpn_service``. 4097 4098 :returns: The updated vpnservice 4099 :rtype: :class:`~openstack.network.v2.vpn_service.VPNService` 4100 """ 4101 return self._update(_vpn_service.VPNService, vpn_service, **attrs) 4102 4103 def create_floating_ip_port_forwarding(self, floating_ip, **attrs): 4104 """Create a new floating ip port forwarding from attributes 4105 4106 :param floating_ip: The value can be either the ID of a floating ip 4107 or a :class:`~openstack.network.v2.floating_ip.FloatingIP` 4108 instance. 4109 :param dict attrs:Keyword arguments which will be used to create 4110 a:class:`~openstack.network.v2.port_forwarding.PortForwarding`, 4111 comprised of the properties on the PortForwarding class. 4112 4113 :returns: The results of port forwarding creation 4114 :rtype: :class:`~openstack.network.v2.port_forwarding.PortForwarding` 4115 """ 4116 floatingip = self._get_resource(_floating_ip.FloatingIP, floating_ip) 4117 return self._create(_port_forwarding.PortForwarding, 4118 floatingip_id=floatingip.id, **attrs) 4119 4120 def delete_floating_ip_port_forwarding(self, floating_ip, port_forwarding, 4121 ignore_missing=True): 4122 """Delete a floating IP port forwarding. 4123 4124 :param floating_ip: The value can be either the ID of a floating ip 4125 or a :class:`~openstack.network.v2.floating_ip.FloatingIP` 4126 instance. 4127 :param port_forwarding: The value can be either the ID of a port 4128 forwarding or a :class:`~openstack.network.v2. 4129 port_forwarding.PortForwarding`instance. 4130 :param bool ignore_missing: When set to ``False`` 4131 :class:`~openstack.exceptions.ResourceNotFound` will be 4132 raised when the floating ip does not exist. 4133 When set to ``True``, no exception will be set when 4134 attempting to delete a nonexistent ip. 4135 4136 :returns: ``None`` 4137 """ 4138 floatingip = self._get_resource(_floating_ip.FloatingIP, floating_ip) 4139 self._delete(_port_forwarding.PortForwarding, 4140 port_forwarding, ignore_missing=ignore_missing, 4141 floatingip_id=floatingip.id) 4142 4143 def find_floating_ip_port_forwarding(self, floating_ip, port_forwarding_id, 4144 ignore_missing=True, **args): 4145 """Find a floating ip port forwarding 4146 4147 :param floating_ip: The value can be the ID of the Floating IP that the 4148 port forwarding belongs or a :class:`~openstack. 4149 network.v2.floating_ip.FloatingIP` instance. 4150 :param port_forwarding_id: The ID of a port forwarding. 4151 :param bool ignore_missing: When set to ``False`` 4152 :class:`~openstack.exceptions.ResourceNotFound` will be 4153 raised when the resource does not exist. 4154 When set to ``True``, None will be returned when 4155 attempting to find a nonexistent resource. 4156 :param dict args: Any additional parameters to be passed into 4157 underlying methods. such as query filters. 4158 :returns: One :class:`~openstack.network.v2.port_forwarding. 4159 PortForwarding` or None 4160 """ 4161 floatingip = self._get_resource(_floating_ip.FloatingIP, floating_ip) 4162 return self._find(_port_forwarding.PortForwarding, 4163 port_forwarding_id, ignore_missing=ignore_missing, 4164 floatingip_id=floatingip.id, **args) 4165 4166 def get_floating_ip_port_forwarding(self, floating_ip, port_forwarding): 4167 """Get a floating ip port forwarding 4168 4169 :param floating_ip: The value can be the ID of the Floating IP that the 4170 port forwarding belongs or a :class:`~openstack. 4171 network.v2.floating_ip.FloatingIP` instance. 4172 :param port_forwarding: The value can be the ID of a port forwarding 4173 or a :class:`~openstack.network.v2. 4174 port_forwarding.PortForwarding` instance. 4175 :returns: One :class:`~openstack.network.v2.port_forwarding. 4176 PortForwarding` 4177 :raises: :class:`~openstack.exceptions.ResourceNotFound` 4178 when no resource can be found. 4179 """ 4180 floatingip = self._get_resource(_floating_ip.FloatingIP, floating_ip) 4181 return self._get(_port_forwarding.PortForwarding, port_forwarding, 4182 floatingip_id=floatingip.id) 4183 4184 def floating_ip_port_forwardings(self, floating_ip, **query): 4185 """Return a generator of floating ip port forwarding 4186 4187 :param floating_ip: The value can be the ID of the Floating IP that the 4188 port forwarding belongs or a :class:`~openstack. 4189 network.v2.floating_ip.FloatingIP` instance. 4190 :param kwargs **query: Optional query parameters to be sent to limit 4191 the resources being returned. 4192 :returns: A generator of floating ip port forwarding objects 4193 :rtype: :class:`~openstack.network.v2.port_forwarding. 4194 PortForwarding` 4195 """ 4196 floatingip = self._get_resource(_floating_ip.FloatingIP, floating_ip) 4197 return self._list(_port_forwarding.PortForwarding, 4198 floatingip_id=floatingip.id, **query) 4199 4200 def update_floating_ip_port_forwarding(self, floating_ip, port_forwarding, 4201 **attrs): 4202 """Update a floating ip port forwarding 4203 4204 :param floating_ip: The value can be the ID of the Floating IP that the 4205 port forwarding belongs or a :class:`~openstack. 4206 network.v2.floating_ip.FloatingIP` instance. 4207 :param port_forwarding: Either the id of a floating ip port forwarding 4208 or a :class:`~openstack.network.v2. 4209 port_forwarding.PortForwarding`instance. 4210 :attrs kwargs: The attributes to update on the floating ip port 4211 forwarding represented by ``value``. 4212 4213 :returns: The updated floating ip port forwarding 4214 :rtype: :class:`~openstack.network.v2.port_forwarding.PortForwarding` 4215 """ 4216 floatingip = self._get_resource(_floating_ip.FloatingIP, floating_ip) 4217 return self._update(_port_forwarding.PortForwarding, port_forwarding, 4218 floatingip_id=floatingip.id, **attrs) 4219 4220 def create_conntrack_helper(self, router, **attrs): 4221 """Create a new L3 conntrack helper from attributes 4222 4223 :param router: Either the router ID or an instance of 4224 :class:`~openstack.network.v2.router.Router` 4225 :param dict attrs: Keyword arguments which will be used to create a 4226 :class:`~openstack.network.v2.l3_conntrack_helper.ConntrackHelper`, 4227 comprised of the properties on the ConntrackHelper class. 4228 4229 :returns: The results of conntrack helper creation 4230 :rtype: 4231 :class: `~openstack.network.v2.l3_conntrack_helper.ConntrackHelper` 4232 """ 4233 router = self._get_resource(_router.Router, router) 4234 return self._create(_l3_conntrack_helper.ConntrackHelper, 4235 router_id=router.id, **attrs) 4236 4237 def conntrack_helpers(self, router, **query): 4238 """Return a generator of conntrack helpers 4239 4240 :param router: Either the router ID or an instance of 4241 :class:`~openstack.network.v2.router.Router` 4242 :param kwargs query: Optional query parameters to be sent to limit 4243 the resources being returned. 4244 :returns: A generator of conntrack helper objects 4245 :rtype: 4246 :class: `~openstack.network.v2.l3_conntrack_helper.ConntrackHelper` 4247 """ 4248 router = self._get_resource(_router.Router, router) 4249 return self._list(_l3_conntrack_helper.ConntrackHelper, 4250 router_id=router.id, **query) 4251 4252 def get_conntrack_helper(self, conntrack_helper, router): 4253 """Get a single L3 conntrack helper 4254 4255 :param conntrack_helper: The value can be the ID of a L3 conntrack 4256 helper or a 4257 :class:`~openstack.network.v2.l3_conntrack_helper.ConntrackHelper`, 4258 instance. 4259 :param router: The value can be the ID of a Router or a 4260 :class:`~openstack.network.v2.router.Router` instance. 4261 4262 :returns: One 4263 :class:`~openstack.network.v2.l3_conntrack_helper.ConntrackHelper` 4264 :raises: :class:`~openstack.exceptions.ResourceNotFound` 4265 when no resource can be found. 4266 """ 4267 router = self._get_resource(_router.Router, router) 4268 return self._get(_l3_conntrack_helper.ConntrackHelper, 4269 conntrack_helper, router_id=router.id) 4270 4271 def update_conntrack_helper(self, conntrack_helper, router, **attrs): 4272 """Update a L3 conntrack_helper 4273 4274 :param conntrack_helper: The value can be the ID of a L3 conntrack 4275 helper or a 4276 :class:`~openstack.network.v2.l3_conntrack_helper.ConntrackHelper`, 4277 instance. 4278 :param router: The value can be the ID of a Router or a 4279 :class:`~openstack.network.v2.router.Router` instance. 4280 :attrs kwargs: The attributes to update on the L3 conntrack helper 4281 represented by ``value``. 4282 4283 :returns: The updated conntrack helper 4284 :rtype: 4285 :class: `~openstack.network.v2.l3_conntrack_helper.ConntrackHelper` 4286 4287 """ 4288 router = self._get_resource(_router.Router, router) 4289 return self._update(_l3_conntrack_helper.ConntrackHelper, 4290 conntrack_helper, router_id=router.id, **attrs) 4291 4292 def delete_conntrack_helper(self, conntrack_helper, router, 4293 ignore_missing=True): 4294 """Delete a L3 conntrack_helper 4295 4296 :param conntrack_helper: The value can be the ID of a L3 conntrack 4297 helper or a 4298 :class:`~openstack.network.v2.l3_conntrack_helper.ConntrackHelper`, 4299 instance. 4300 :param router: The value can be the ID of a Router or a 4301 :class:`~openstack.network.v2.router.Router` instance. 4302 :param bool ignore_missing: When set to ``False`` 4303 :class:`~openstack.exceptions.ResourceNotFound` will be 4304 raised when the floating ip does not exist. 4305 When set to ``True``, no exception will be set when 4306 attempting to delete a nonexistent ip. 4307 4308 :returns: ``None`` 4309 """ 4310 router = self._get_resource(_router.Router, router) 4311 self._delete(_l3_conntrack_helper.ConntrackHelper, 4312 conntrack_helper, router_id=router.id, 4313 ignore_missing=ignore_missing) 4314 4315 def _get_cleanup_dependencies(self): 4316 return { 4317 'network': { 4318 'before': ['identity'] 4319 } 4320 } 4321 4322 def _service_cleanup(self, dry_run=True, client_status_queue=None, 4323 identified_resources=None, 4324 filters=None, resource_evaluation_fn=None): 4325 project_id = self.get_project_id() 4326 # Delete floating_ips in the project if no filters defined OR all 4327 # filters are matching and port_id is empty 4328 for obj in self.ips(project_id=project_id): 4329 self._service_cleanup_del_res( 4330 self.delete_ip, 4331 obj, 4332 dry_run=dry_run, 4333 client_status_queue=client_status_queue, 4334 identified_resources=identified_resources, 4335 filters=filters, 4336 resource_evaluation_fn=fip_cleanup_evaluation) 4337 4338 # Delete (try to delete) all security groups in the project 4339 # Let's hope we can't drop SG in use 4340 for obj in self.security_groups(project_id=project_id): 4341 if obj.name != 'default': 4342 self._service_cleanup_del_res( 4343 self.delete_security_group, 4344 obj, 4345 dry_run=dry_run, 4346 client_status_queue=client_status_queue, 4347 identified_resources=identified_resources, 4348 filters=filters, 4349 resource_evaluation_fn=resource_evaluation_fn) 4350 4351 # Networks are crazy, try to delete router+net+subnet 4352 # if there are no "other" ports allocated on the net 4353 for net in self.networks(project_id=project_id): 4354 network_has_ports_allocated = False 4355 router_if = list() 4356 for port in self.ports( 4357 project_id=project_id, 4358 network_id=net.id 4359 ): 4360 self.log.debug('Looking at port %s' % port) 4361 if port.device_owner in [ 4362 'network:router_interface', 4363 'network:router_interface_distributed' 4364 ]: 4365 router_if.append(port) 4366 elif port.device_owner == 'network:dhcp': 4367 # we don't treat DHCP as a real port 4368 continue 4369 elif ( 4370 identified_resources 4371 and port.device_id not in identified_resources 4372 ): 4373 # It seems some no other service identified this resource 4374 # to be deleted. We can assume it doesn't count 4375 network_has_ports_allocated = True 4376 if network_has_ports_allocated: 4377 # If some ports are on net - we cannot delete it 4378 continue 4379 self.log.debug('Network %s should be deleted' % net) 4380 # __Check__ if we need to drop network according to filters 4381 network_must_be_deleted = self._service_cleanup_del_res( 4382 self.delete_network, 4383 net, 4384 dry_run=True, 4385 client_status_queue=None, 4386 identified_resources=None, 4387 filters=filters, 4388 resource_evaluation_fn=resource_evaluation_fn) 4389 if not network_must_be_deleted: 4390 # If not - check another net 4391 continue 4392 # otherwise disconnect router, drop net, subnet, router 4393 # Disconnect 4394 for port in router_if: 4395 if client_status_queue: 4396 client_status_queue.put(port) 4397 if not dry_run: 4398 try: 4399 self.remove_interface_from_router( 4400 router=port.device_id, 4401 port_id=port.id) 4402 except exceptions.SDKException: 4403 self.log.error('Cannot delete object %s' % obj) 4404 # router disconnected, drop it 4405 self._service_cleanup_del_res( 4406 self.delete_router, 4407 self.get_router(port.device_id), 4408 dry_run=dry_run, 4409 client_status_queue=client_status_queue, 4410 identified_resources=identified_resources, 4411 filters=None, 4412 resource_evaluation_fn=None) 4413 # Drop all subnets in the net (no further conditions) 4414 for obj in self.subnets( 4415 project_id=project_id, 4416 network_id=net.id 4417 ): 4418 self._service_cleanup_del_res( 4419 self.delete_subnet, 4420 obj, 4421 dry_run=dry_run, 4422 client_status_queue=client_status_queue, 4423 identified_resources=identified_resources, 4424 filters=None, 4425 resource_evaluation_fn=None) 4426 4427 # And now the network itself (we are here definitely only if we 4428 # need that) 4429 self._service_cleanup_del_res( 4430 self.delete_network, 4431 net, 4432 dry_run=dry_run, 4433 client_status_queue=client_status_queue, 4434 identified_resources=identified_resources, 4435 filters=None, 4436 resource_evaluation_fn=None) 4437 4438 # It might happen, that we have routers not attached to anything 4439 for obj in self.routers(): 4440 ports = list(self.ports(device_id=obj.id)) 4441 if len(ports) == 0: 4442 self._service_cleanup_del_res( 4443 self.delete_router, 4444 obj, 4445 dry_run=dry_run, 4446 client_status_queue=client_status_queue, 4447 identified_resources=identified_resources, 4448 filters=None, 4449 resource_evaluation_fn=None) 4450 4451 4452def fip_cleanup_evaluation(obj, identified_resources=None, filters=None): 4453 """Determine whether Floating IP should be deleted 4454 4455 :param Resource obj: Floating IP object 4456 :param dict identified_resources: Optional dictionary with resources 4457 identified by other services for deletion. 4458 :param dict filters: dictionary with parameters 4459 """ 4460 if ( 4461 filters is not None 4462 and ( 4463 obj.port_id is not None 4464 and identified_resources 4465 and obj.port_id not in identified_resources 4466 ) 4467 ): 4468 # If filters are set, but port is not empty and will not be empty - 4469 # skip 4470 return False 4471 else: 4472 return True 4473