# octavia.db package

## Submodules

## octavia.db.api module

`get_engine`()

`get_lock_session`()

  Context manager for using a locking (not auto-commit) session.

`get_session`(expire_on_commit=True, autocommit=True)

  Helper method to grab session.

`wait_for_connection`(exit_event)

  Helper method to wait for DB connection

## octavia.db.base_models module

class `IdMixin`

  Bases: `object`

  Id mixin, add to subclasses that have an id.

  `id` = Column(None, String(length=36), table=None, primary_key=True, nullable=False, default=ColumnDefault(<function generate_uuid>))

class `LookupTableMixin`

  Bases: `object`

  Mixin to add to classes that are lookup tables.

  `description` = Column(None, String(length=255), table=None)
  `name` = Column(None, String(length=255), table=None, primary_key=True, nullable=False)

class `NameMixin`

  Bases: `object`

  Name mixin to add to classes which need a name.

  `name` = Column(None, String(length=255), table=None)

class `OctaviaBase`

  Bases: `oslo_db.sqlalchemy.models.ModelBase`

  static `apply_filter`(query, model, filters)
  `to_data_model`(_graph_nodes=None)

    Converts to a data model graph.

    In order to make the resulting data model graph usable no matter how many internal references are followed, we generate a complete graph of OctaviaBase nodes connected to the object passed to this method.

    Parameters: | _graph_nodes – Used only for internal recursion of this method. Should not be called from the outside. Contains a dictionary of all OctaviaBase type objects in the generated graph

class `ProjectMixin`

  Bases: `object`

  Tenant mixin, add to subclasses that have a project.

  `project_id` = Column(None, String(length=36), table=None)

class `TagMixin`

  Bases: `object`

  Tags mixin to add to classes which need tags.

  The class must realize the specified db relationship as well.

  `tags`

class `Tags`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`

  `resource_id`
  `tag`

## octavia.db.healthcheck module

`check_database_connection`(session)

  This is a simple database connection check function.

  It will do a simple no-op query (low overhead) against the sqlalchemy session passed in.

  Parameters: | session – A Sql Alchemy database session.
  Returns: | True if the connection check is successful, False if not.

## octavia.db.models module

class `Algorithm`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`, `octavia.db.base_models.LookupTableMixin`

  `description`
  `name`

class `Amphora`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`, `octavia.db.base_models.IdMixin`, `oslo_db.sqlalchemy.models.TimestampMixin`

  `cached_zone`
  `cert_busy`
  `cert_expiration`
  `compute_flavor`
  `compute_id`
  `created_at`
  `ha_ip`
  `ha_port_id`
  `id`
  `image_id`
  `lb_network_ip`
  `load_balancer`
  `load_balancer_id`
  `role`
  `status`
  `updated_at`
  `vrrp_id`
  `vrrp_interface`
  `vrrp_ip`
  `vrrp_port_id`
  `vrrp_priority`

class `AmphoraBuildRequest`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`

  `amphora_id`
  `created_time`
  `priority`
  `status`

class `AmphoraBuildSlots`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`

  `id`
  `slots_used`

class `AmphoraHealth`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`

  `amphora_id`
  `busy`
  `last_update`

class `AmphoraRoles`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`, `octavia.db.base_models.LookupTableMixin`

  `description`
  `name`

class `AvailabilityZone`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`, `octavia.db.base_models.NameMixin`

  `availability_zone_profile_id`
  `description`
  `enabled`
  `name`

class `AvailabilityZoneProfile`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`, `octavia.db.base_models.IdMixin`, `octavia.db.base_models.NameMixin`

  `availability_zone_data`
  `id`
  `name`
  `provider_name`

class `ClientAuthenticationMode`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`

  `name`

class `Flavor`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`, `octavia.db.base_models.IdMixin`, `octavia.db.base_models.NameMixin`

  `description`
  `enabled`
  `flavor_profile_id`
  `id`
  `name`

class `FlavorProfile`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`, `octavia.db.base_models.IdMixin`, `octavia.db.base_models.NameMixin`

  `flavor_data`
  `id`
  `name`
  `provider_name`

class `HealthMonitor`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`, `octavia.db.base_models.IdMixin`, `octavia.db.base_models.ProjectMixin`, `oslo_db.sqlalchemy.models.TimestampMixin`, `octavia.db.base_models.NameMixin`, `octavia.db.base_models.TagMixin`

  `created_at`
  `delay`
  `domain_name`
  `enabled`
  `expected_codes`
  `fall_threshold`
  `http_method`
  `http_version`
  `id`
  `name`
  `operating_status`
  `pool`
  `pool_id`
  `project_id`
  `provisioning_status`
  `rise_threshold`
  `timeout`
  `type`
  `updated_at`
  `url_path`

class `HealthMonitorType`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`, `octavia.db.base_models.LookupTableMixin`

  `description`
  `name`

class `L7Policy`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`, `octavia.db.base_models.IdMixin`, `octavia.db.base_models.ProjectMixin`, `oslo_db.sqlalchemy.models.TimestampMixin`, `octavia.db.base_models.NameMixin`, `octavia.db.base_models.TagMixin`

  `action`
  `created_at`
  `description`
  `enabled`
  `id`
  `l7rules`
  `listener`
  `listener_id`
  `name`
  `operating_status`
  `position`
  `project_id`
  `provisioning_status`
  `redirect_http_code`
  `redirect_pool`
  `redirect_pool_id`
  `redirect_prefix`
  `redirect_url`
  `updated_at`

class `L7PolicyAction`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`, `octavia.db.base_models.LookupTableMixin`

  `description`
  `name`

class `L7Rule`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`, `octavia.db.base_models.IdMixin`, `octavia.db.base_models.ProjectMixin`, `oslo_db.sqlalchemy.models.TimestampMixin`, `octavia.db.base_models.TagMixin`

  `compare_type`
  `created_at`
  `enabled`
  `id`
  `invert`
  `key`
  `l7policy`
  `l7policy_id`
  `operating_status`
  `project_id`
  `provisioning_status`
  `type`
  `updated_at`
  `value`

class `L7RuleCompareType`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`, `octavia.db.base_models.LookupTableMixin`

  `description`
  `name`

class `L7RuleType`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`, `octavia.db.base_models.LookupTableMixin`

  `description`
  `name`

class `LBTopology`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`, `octavia.db.base_models.LookupTableMixin`

  `description`
  `name`

class `Listener`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`, `octavia.db.base_models.IdMixin`, `octavia.db.base_models.ProjectMixin`, `oslo_db.sqlalchemy.models.TimestampMixin`, `octavia.db.base_models.NameMixin`, `octavia.db.base_models.TagMixin`

  `allowed_cidrs`
  `client_authentication`
  `client_ca_tls_certificate_id`
  `client_crl_container_id`
  `connection_limit`
  `created_at`
  `default_pool`
  `default_pool_id`
  `description`
  `enabled`
  `id`
  `insert_headers`
  `l7policies`
  `load_balancer`
  `load_balancer_id`
  `name`
  `operating_status`
  `peer_port`
  `pools`
  `project_id`
  `protocol`
  `protocol_port`
  `provisioning_status`
  `sni_containers`
  `timeout_client_data`
  `timeout_member_connect`
  `timeout_member_data`
  `timeout_tcp_inspect`
  `tls_certificate_id`
  `tls_ciphers`
  `updated_at`

class `ListenerCidr`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`

  `cidr`
  `listener`
  `listener_id`

class `ListenerStatistics`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`

  `active_connections`
  `amphora_id`
  `bytes_in`
  `bytes_out`
  `listener_id`
  `request_errors`
  `total_connections`
  `validate_non_negative_int`(key, value)

class `LoadBalancer`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`, `octavia.db.base_models.IdMixin`, `octavia.db.base_models.ProjectMixin`, `oslo_db.sqlalchemy.models.TimestampMixin`, `octavia.db.base_models.NameMixin`, `octavia.db.base_models.TagMixin`

  `amphorae`
  `availability_zone`
  `created_at`
  `description`
  `enabled`
  `flavor_id`
  `id`
  `listeners`
  `name`
  `operating_status`
  `pools`
  `project_id`
  `provider`
  `provisioning_status`
  `server_group_id`
  `topology`
  `updated_at`
  `vip`
  `vrrp_group`

class `Member`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`, `octavia.db.base_models.IdMixin`, `octavia.db.base_models.ProjectMixin`, `oslo_db.sqlalchemy.models.TimestampMixin`, `octavia.db.base_models.NameMixin`, `octavia.db.base_models.TagMixin`

  `backup`
  `created_at`
  `enabled`
  `id`
  `ip_address`
  `monitor_address`
  `monitor_port`
  `name`
  `operating_status`
  `pool`
  `pool_id`
  `project_id`
  `protocol_port`
  `provisioning_status`
  `subnet_id`
  `updated_at`
  `weight`

class `OperatingStatus`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`, `octavia.db.base_models.LookupTableMixin`

  `description`
  `name`

class `Pool`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`, `octavia.db.base_models.IdMixin`, `octavia.db.base_models.ProjectMixin`, `oslo_db.sqlalchemy.models.TimestampMixin`, `octavia.db.base_models.NameMixin`, `octavia.db.base_models.TagMixin`

  `ca_tls_certificate_id`
  `created_at`
  `crl_container_id`
  `description`
  `enabled`
  `health_monitor`
  `id`
  `l7policies`
  `lb_algorithm`
  `listeners`
  `load_balancer`
  `load_balancer_id`
  `members`
  `name`
  `operating_status`
  `project_id`
  `protocol`
  `provisioning_status`
  `session_persistence`
  `tls_certificate_id`
  `tls_ciphers`
  `tls_enabled`
  `updated_at`

class `Protocol`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`, `octavia.db.base_models.LookupTableMixin`

  `description`
  `name`

class `ProvisioningStatus`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`, `octavia.db.base_models.LookupTableMixin`

  `description`
  `name`

class `Quotas`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`

  `health_monitor`
  `in_use_health_monitor`
  `in_use_listener`
  `in_use_load_balancer`
  `in_use_member`
  `in_use_pool`
  `listener`
  `load_balancer`
  `member`
  `pool`
  `project_id`

class `SNI`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`

  `listener`
  `listener_id`
  `position`
  `tls_container_id`

class `SessionPersistence`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`

  `cookie_name`
  `persistence_granularity`
  `persistence_timeout`
  `pool`
  `pool_id`
  `type`

class `SessionPersistenceType`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`, `octavia.db.base_models.LookupTableMixin`

  `description`
  `name`

class `SparesPool`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`

  `updated_at`

class `VRRPAuthMethod`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`, `octavia.db.base_models.LookupTableMixin`

  `description`
  `name`

class `VRRPGroup`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`

  `advert_int`
  `load_balancer`
  `load_balancer_id`
  `vrrp_auth_pass`
  `vrrp_auth_type`
  `vrrp_group_name`

class `Vip`(**kwargs)

  Bases: `sqlalchemy.ext.declarative.api.Base`

  `ip_address`
  `load_balancer`
  `load_balancer_id`
  `network_id`
  `octavia_owned`
  `port_id`
  `qos_policy_id`
  `subnet_id`

## octavia.db.prepare module

`create_health_monitor`(hm_dict, pool_id=None)

`create_l7policy`(l7policy_dict, lb_id, listener_id)

`create_l7rule`(l7rule_dict, l7policy_id)

`create_listener`(listener_dict, lb_id)

`create_load_balancer`(lb_dict)

`create_load_balancer_tree`(lb_dict)

`create_member`(member_dict, pool_id, has_health_monitor=False)

`create_pool`(pool_dict, lb_id=None)

## octavia.db.repositories module

Defines interface for DB access that Resource or Octavia Controllers may reference

class `AmphoraBuildReqRepository`

  Bases: `octavia.db.repositories.BaseRepository`

  `add_to_build_queue`(session, amphora_id=None, priority=None)

    Adds the build request to the table.

  `delete_all`(session)

    Deletes all the build requests.

  `get_highest_priority_build_req`(session)

    Fetches build request with highest priority and least created_time.

    priority 20 = failover (highest) priority 40 = create_loadbalancer priority 60 = sparespool (least) :param session: A Sql Alchemy database session. :returns amphora_id corresponding to highest priority and least created time in ‘WAITING’ status.

  `model_class`

    alias of `octavia.db.models.AmphoraBuildRequest`

  `update_req_status`(session, amphora_id=None)

    Updates the request status.

class `AmphoraBuildSlotsRepository`

  Bases: `octavia.db.repositories.BaseRepository`

  `get_used_build_slots_count`(session)

    Gets the number of build slots in use.

    Returns: | Number of current build slots.

  `model_class`

    alias of `octavia.db.models.AmphoraBuildSlots`

  `update_count`(session, action='increment')

    Increments/Decrements/Resets the number of build_slots used.

class `AmphoraHealthRepository`

  Bases: `octavia.db.repositories.BaseRepository`

  `check_amphora_health_expired`(session, amphora_id, exp_age=None)

    check if a specific amphora is expired in the amphora_health table

    Parameters:

    - session – A Sql Alchemy database session.
    - amphora_id – id of an amphora object
    - exp_age – A standard datetime delta which is used to see for how long can an amphora live without updates before it is considered expired (default: CONF.house_keeping.amphora_expiry_age)

    Returns: | boolean

  `get_stale_amphora`(session)

    Retrieves a stale amphora from the health manager database.

    Parameters: | session – A Sql Alchemy database session.
    Returns: | [octavia.common.data_model]

  `model_class`

    alias of `octavia.db.models.AmphoraHealth`

  `replace`(session, amphora_id, **model_kwargs)

    replace or insert amphora into database.

  `update`(session, amphora_id, **model_kwargs)

    Updates a healthmanager entity in the database by amphora_id.

class `AmphoraRepository`

  Bases: `octavia.db.repositories.BaseRepository`

  `allocate_and_associate`(session, load_balancer_id, availability_zone=None)

    Allocate an amphora for a load balancer.

    For v0.5 this is simple, find a free amp and associate the lb. In the future this needs to be enhanced.

    Parameters:

    - session – A Sql Alchemy database session.
    - load_balancer_id – The load balancer id to associate

    Returns: | The amphora ID for the load balancer or None

  `associate`(session, load_balancer_id, amphora_id)

    Associates an amphora with a load balancer.

    Parameters:

    - session – A Sql Alchemy database session.
    - load_balancer_id – The load balancer id to associate
    - amphora_id – The amphora id to associate

  `get_all_API_list`(session, pagination_helper=None, **filters)

    Get a list of amphorae for the API list call.

    This get_all returns a data set that is only one level deep in the data graph. This is an optimized query for the API amphora list method.

    Parameters:

    - session – A Sql Alchemy database session.
    - pagination_helper – Helper to apply pagination and sorting.
    - filters – Filters to decide which entities should be retrieved.

    Returns: | [octavia.common.data_model]

  `get_cert_expiring_amphora`(session)

    Retrieves an amphora whose cert is close to expiring..

    Parameters: | session – A Sql Alchemy database session.
    Returns: | one amphora with expiring certificate

  static `get_lb_for_amphora`(session, amphora_id)

    Get all of the load balancers on an amphora.

    Parameters:

    - session – A Sql Alchemy database session.
    - amphora_id – The amphora id to list the load balancers from

    Returns: | [octavia.common.data_model]

  `get_lb_for_health_update`(session, amphora_id)

    This method is for the health manager status update process.

    This is a time sensitive query that occurs often. It is an explicit query as the ORM produces a poorly optimized query.

    Use extreme caution making any changes to this query as it can impact the scalability of the health manager. All changes should be analyzed using SQL “EXPLAIN” to make sure only indexes are being used. Changes should also be evaluated using the stressHM tool.

    Note: The returned object is flat and not a graph representation
      of the load balancer as it is not needed. This is on purpose to optimize the processing time. This is not in the normal data model objects.

    Parameters:

    - session – A Sql Alchemy database session.
    - amphora_id – The amphora ID to lookup the load balancer for.

    Returns: | A dictionary containing the required load balancer details.

  `get_spare_amphora_count`(session, availability_zone=None, check_booting_amphora=False)

    Get the count of the spare amphora.

    Returns: | Number of current spare amphora.

  `model_class`

    alias of `octavia.db.models.Amphora`

class `AvailabilityZoneProfileRepository`

  Bases: `octavia.db.repositories._GetALLExceptDELETEDIdMixin`, `octavia.db.repositories.BaseRepository`

  `model_class`

    alias of `octavia.db.models.AvailabilityZoneProfile`

class `AvailabilityZoneRepository`

  Bases: `octavia.db.repositories._GetALLExceptDELETEDIdMixin`, `octavia.db.repositories.BaseRepository`

  `delete`(serial_session, **filters)

    Special delete method for availability_zone.

    Sets DELETED LBs availability_zone to NIL_UUID, then removes the availability_zone.

    Parameters:

    - serial_session – A Sql Alchemy database transaction session.
    - filters – Filters to decide which entity should be deleted.

    Returns: | None
    Raises: | odb_exceptions.DBReferenceError
    Raises: | sqlalchemy.orm.exc.NoResultFound

  `get_availability_zone_metadata_dict`(session, availability_zone_name)
  `get_availability_zone_provider`(session, availability_zone_name)
  `model_class`

    alias of `octavia.db.models.AvailabilityZone`

  `update`(session, name, **model_kwargs)

    Updates an entity in the database.

    Parameters:

    - session – A Sql Alchemy database session.
    - model_kwargs – Entity attributes that should be updates.

    Returns: | octavia.common.data_model

class `BaseRepository`

  Bases: `object`

  `count`(session, **filters)

    Retrieves a count of entities from the database.

    Parameters:

    - session – A Sql Alchemy database session.
    - filters – Filters to decide which entities should be retrieved.

    Returns: | int

  `create`(session, **model_kwargs)

    Base create method for a database entity.

    Parameters:

    - session – A Sql Alchemy database session.
    - model_kwargs – Attributes of the model to insert.

    Returns: | octavia.common.data_model

  `delete`(session, **filters)

    Deletes an entity from the database.

    Parameters:

    - session – A Sql Alchemy database session.
    - filters – Filters to decide which entity should be deleted.

    Returns: | None
    Raises: | sqlalchemy.orm.exc.NoResultFound

  `delete_batch`(session, ids=None)

    Batch deletes by entity ids.

  `exists`(session, id)

    Determines whether an entity exists in the database by its id.

    Parameters:

    - session – A Sql Alchemy database session.
    - id – id of entity to check for existence.

    Returns: | octavia.common.data_model

  `get`(session, **filters)

    Retrieves an entity from the database.

    Parameters:

    - session – A Sql Alchemy database session.
    - filters – Filters to decide which entity should be retrieved.

    Returns: | octavia.common.data_model

  `get_all`(session, pagination_helper=None, query_options=None, **filters)

    Retrieves a list of entities from the database.

    Parameters:

    - session – A Sql Alchemy database session.
    - pagination_helper – Helper to apply pagination and sorting.
    - query_options – Optional query options to apply.
    - filters – Filters to decide which entities should be retrieved.

    Returns: | [octavia.common.data_model]

  `get_all_deleted_expiring`(session, exp_age)

    Get all previously deleted resources that are now expiring.

    Parameters:

    - session – A Sql Alchemy database session.
    - exp_age – A standard datetime delta which is used to see for how long can a resource live without updates before it is considered expired

    Returns: | A list of resource IDs

  `model_class` = None
  `update`(session, id, **model_kwargs)

    Updates an entity in the database.

    Parameters:

    - session – A Sql Alchemy database session.
    - model_kwargs – Entity attributes that should be updates.

    Returns: | octavia.common.data_model

class `FlavorProfileRepository`

  Bases: `octavia.db.repositories._GetALLExceptDELETEDIdMixin`, `octavia.db.repositories.BaseRepository`

  `model_class`

    alias of `octavia.db.models.FlavorProfile`

class `FlavorRepository`

  Bases: `octavia.db.repositories._GetALLExceptDELETEDIdMixin`, `octavia.db.repositories.BaseRepository`

  `delete`(serial_session, **filters)

    Sets DELETED LBs flavor_id to NIL_UUID, then removes the flavor

    Parameters:

    - serial_session – A Sql Alchemy database transaction session.
    - filters – Filters to decide which entity should be deleted.

    Returns: | None
    Raises: | odb_exceptions.DBReferenceError
    Raises: | sqlalchemy.orm.exc.NoResultFound

  `get_flavor_metadata_dict`(session, flavor_id)
  `get_flavor_provider`(session, flavor_id)
  `model_class`

    alias of `octavia.db.models.Flavor`

class `HealthMonitorRepository`

  Bases: `octavia.db.repositories.BaseRepository`

  `get_all_API_list`(session, pagination_helper=None, **filters)

    Get a list of health monitors for the API list call.

    This get_all returns a data set that is only one level deep in the data graph. This is an optimized query for the API health monitor list method.

    Parameters:

    - session – A Sql Alchemy database session.
    - pagination_helper – Helper to apply pagination and sorting.
    - filters – Filters to decide which entities should be retrieved.

    Returns: | [octavia.common.data_model]

  `model_class`

    alias of `octavia.db.models.HealthMonitor`

class `L7PolicyRepository`

  Bases: `octavia.db.repositories.BaseRepository`

  `create`(session, **model_kwargs)

    Base create method for a database entity.

    Parameters:

    - session – A Sql Alchemy database session.
    - model_kwargs – Attributes of the model to insert.

    Returns: | octavia.common.data_model

  `delete`(session, id, **filters)

    Deletes an entity from the database.

    Parameters:

    - session – A Sql Alchemy database session.
    - filters – Filters to decide which entity should be deleted.

    Returns: | None
    Raises: | sqlalchemy.orm.exc.NoResultFound

  `get_all`(session, pagination_helper=None, **filters)

    Retrieves a list of entities from the database.

    Parameters:

    - session – A Sql Alchemy database session.
    - pagination_helper – Helper to apply pagination and sorting.
    - query_options – Optional query options to apply.
    - filters – Filters to decide which entities should be retrieved.

    Returns: | [octavia.common.data_model]

  `get_all_API_list`(session, pagination_helper=None, **filters)
  `model_class`

    alias of `octavia.db.models.L7Policy`

  `update`(session, id, **model_kwargs)

    Updates an entity in the database.

    Parameters:

    - session – A Sql Alchemy database session.
    - model_kwargs – Entity attributes that should be updates.

    Returns: | octavia.common.data_model

class `L7RuleRepository`

  Bases: `octavia.db.repositories.BaseRepository`

  `create`(session, **model_kwargs)

    Base create method for a database entity.

    Parameters:

    - session – A Sql Alchemy database session.
    - model_kwargs – Attributes of the model to insert.

    Returns: | octavia.common.data_model

  `get_all_API_list`(session, pagination_helper=None, **filters)

    Get a list of L7 Rules for the API list call.

    This get_all returns a data set that is only one level deep in the data graph. This is an optimized query for the API L7 Rule list method.

    Parameters:

    - session – A Sql Alchemy database session.
    - pagination_helper – Helper to apply pagination and sorting.
    - filters – Filters to decide which entities should be retrieved.

    Returns: | [octavia.common.data_model]

  `model_class`

    alias of `octavia.db.models.L7Rule`

  `update`(session, id, **model_kwargs)

    Updates an entity in the database.

    Parameters:

    - session – A Sql Alchemy database session.
    - model_kwargs – Entity attributes that should be updates.

    Returns: | octavia.common.data_model

class `ListenerCidrRepository`

  Bases: `octavia.db.repositories.BaseRepository`

  `create`(session, listener_id, allowed_cidrs)

    Base create method for a database entity.

    Parameters:

    - session – A Sql Alchemy database session.
    - model_kwargs – Attributes of the model to insert.

    Returns: | octavia.common.data_model

  `model_class`

    alias of `octavia.db.models.ListenerCidr`

  `update`(session, listener_id, allowed_cidrs)

    Updates allowed CIDRs in the database by listener_id.

class `ListenerRepository`

  Bases: `octavia.db.repositories.BaseRepository`

  `create`(session, **model_kwargs)

    Creates a new Listener with some validation.

  `get_all_API_list`(session, pagination_helper=None, **filters)

    Get a list of listeners for the API list call.

    This get_all returns a data set that is only one level deep in the data graph. This is an optimized query for the API listener list method.

    Parameters:

    - session – A Sql Alchemy database session.
    - pagination_helper – Helper to apply pagination and sorting.
    - filters – Filters to decide which entities should be retrieved.

    Returns: | [octavia.common.data_model]

  `has_default_pool`(session, id)

    Checks if a listener has a default pool.

  `model_class`

    alias of `octavia.db.models.Listener`

  `prov_status_active_if_not_error`(session, listener_id)

    Update provisioning_status to ACTIVE if not already in ERROR.

  `update`(session, id, **model_kwargs)

    Updates an entity in the database.

    Parameters:

    - session – A Sql Alchemy database session.
    - model_kwargs – Entity attributes that should be updates.

    Returns: | octavia.common.data_model

class `ListenerStatisticsRepository`

  Bases: `octavia.db.repositories.BaseRepository`

  `model_class`

    alias of `octavia.db.models.ListenerStatistics`

  `replace`(session, listener_id, amphora_id, **model_kwargs)

    replace or insert listener into database.

  `update`(session, listener_id, **model_kwargs)

    Updates a listener’s statistics by a listener’s id.

class `LoadBalancerRepository`

  Bases: `octavia.db.repositories.BaseRepository`

  `get_all_API_list`(session, pagination_helper=None, **filters)

    Get a list of load balancers for the API list call.

    This get_all returns a data set that is only one level deep in the data graph. This is an optimized query for the API load balancer list method.

    Parameters:

    - session – A Sql Alchemy database session.
    - pagination_helper – Helper to apply pagination and sorting.
    - filters – Filters to decide which entities should be retrieved.

    Returns: | [octavia.common.data_model]

  `model_class`

    alias of `octavia.db.models.LoadBalancer`

  `set_status_for_failover`(session, id, status, raise_exception=False)

    Tests and sets a load balancer provisioning status.

    Puts a lock on the load balancer table to check the status of a load balancer. If the status is ACTIVE or ERROR then the status of the load balancer is updated and the method returns True. If the status is not ACTIVE, then nothing is done and False is returned.

    Parameters:

    - session – A Sql Alchemy database session.
    - id – id of Load Balancer
    - status – Status to set Load Balancer if check passes.
    - raise_exception – If True, raise ImmutableObject on failure

    Returns: | bool

  `test_and_set_provisioning_status`(session, id, status, raise_exception=False)

    Tests and sets a load balancer and provisioning status.

    Puts a lock on the load balancer table to check the status of a load balancer. If the status is ACTIVE then the status of the load balancer is updated and the method returns True. If the status is not ACTIVE, then nothing is done and False is returned.

    Parameters:

    - session – A Sql Alchemy database session.
    - id – id of Load Balancer
    - status – Status to set Load Balancer if check passes.
    - raise_exception – If True, raise ImmutableObject on failure

    Returns: | bool

class `MemberRepository`

  Bases: `octavia.db.repositories.BaseRepository`

  `delete_members`(session, member_ids)

    Batch deletes members from a pool.

  `get_all_API_list`(session, pagination_helper=None, **filters)

    Get a list of members for the API list call.

    This get_all returns a data set that is only one level deep in the data graph. This is an optimized query for the API member list method.

    Parameters:

    - session – A Sql Alchemy database session.
    - pagination_helper – Helper to apply pagination and sorting.
    - filters – Filters to decide which entities should be retrieved.

    Returns: | [octavia.common.data_model]

  `model_class`

    alias of `octavia.db.models.Member`

  `update_pool_members`(session, pool_id, **model_kwargs)

    Updates all of the members of a pool.

    Parameters:

    - session – A Sql Alchemy database session.
    - pool_id – ID of the pool to update members on.
    - model_kwargs – Entity attributes that should be updates.

    Returns: | octavia.common.data_model

class `PoolRepository`

  Bases: `octavia.db.repositories.BaseRepository`

  `get_all_API_list`(session, pagination_helper=None, **filters)

    Get a list of pools for the API list call.

    This get_all returns a data set that is only one level deep in the data graph. This is an optimized query for the API pool list method.

    Parameters:

    - session – A Sql Alchemy database session.
    - pagination_helper – Helper to apply pagination and sorting.
    - filters – Filters to decide which entities should be retrieved.

    Returns: | [octavia.common.data_model]

  `model_class`

    alias of `octavia.db.models.Pool`

class `QuotasRepository`

  Bases: `octavia.db.repositories.BaseRepository`

  `delete`(session, project_id)

    Deletes an entity from the database.

    Parameters:

    - session – A Sql Alchemy database session.
    - filters – Filters to decide which entity should be deleted.

    Returns: | None
    Raises: | sqlalchemy.orm.exc.NoResultFound

  `model_class`

    alias of `octavia.db.models.Quotas`

  `update`(session, project_id, **model_kwargs)

    Updates an entity in the database.

    Parameters:

    - session – A Sql Alchemy database session.
    - model_kwargs – Entity attributes that should be updates.

    Returns: | octavia.common.data_model

class `Repositories`

  Bases: `object`

  `check_quota_met`(session, lock_session, _class, project_id, count=1)

    Checks and updates object quotas.

    This method makes sure the project has available quota for the resource and updates the quota to reflect the new ussage.

    Parameters:

    - session – Context database session
    - lock_session – Locking database session (autocommit=False)
    - _class – Data model object requesting quota
    - project_id – Project ID requesting quota
    - count – Number of objects we’re going to create (default=1)

    Returns: | True if quota is met, False if quota was available

  `create_load_balancer_and_vip`(session, lb_dict, vip_dict)

    Inserts load balancer and vip entities into the database.

    Inserts load balancer and vip entities into the database in one transaction and returns the data model of the load balancer.

    Parameters:

    - session – A Sql Alchemy database session.
    - lb_dict – Dictionary representation of a load balancer
    - vip_dict – Dictionary representation of a vip

    Returns: | octavia.common.data_models.LoadBalancer

  `create_load_balancer_tree`(session, lock_session, lb_dict)
  `create_pool_on_load_balancer`(session, pool_dict, listener_id=None)

    Inserts a pool and session persistence entity into the database.

    Parameters:

    - session – A Sql Alchemy database session.
    - pool_dict – Dictionary representation of a pool
    - listener_id – Optional listener id that will reference this pool as its default_pool_id

    Returns: | octavia.common.data_models.Pool

  `decrement_quota`(lock_session, _class, project_id, quantity=1)

    Decrements the object quota for a project

    Parameters:

    - lock_session – Locking database session (autocommit=False)
    - _class – Data model object to decrement quota
    - project_id – Project ID to decrement quota on
    - quantity – Quantity of quota to decrement

    Returns: | None

  `get_amphora_stats`(session, amp_id)

    Gets the statistics for all listeners on an amphora.

    Parameters:

    - session – A Sql Alchemy database session.
    - amp_id – The amphora ID to query.

    Returns: | An amphora stats dictionary

  `test_and_set_lb_and_listeners_prov_status`(session, lb_id, lb_prov_status, listener_prov_status, listener_ids=None, pool_id=None, l7policy_id=None)

    Tests and sets a load balancer and listener provisioning status.

    Puts a lock on the load balancer table to check the status of a load balancer. If the status is ACTIVE then the status of the load balancer and listener is updated and the method returns True. If the status is not ACTIVE, then nothing is done and False is returned.

    Parameters:

    - session – A Sql Alchemy database session.
    - lb_id – ID of the Load Balancer to check and lock
    - lb_prov_status – Status to set Load Balancer and Listener if check passes.
    - listener_prov_status – Status to set Listeners if check passes
    - listener_ids – List of IDs of listeners to check and lock (only use this when relevant to the operation)
    - pool_id – ID of the Pool to check and lock (only use this when relevant to the operation)
    - l7policy_id – ID of the L7Policy to check and lock (only use this when relevant to the operation)

    Returns: | bool

  `update_pool_and_sp`(session, pool_id, pool_dict)

    Updates a pool and session persistence entity in the database.

    Parameters:

    - session – A Sql Alchemy database session.
    - pool_dict – Dictionary representation of a pool

    Returns: | octavia.common.data_models.Pool

class `SNIRepository`

  Bases: `octavia.db.repositories.BaseRepository`

  `model_class`

    alias of `octavia.db.models.SNI`

  `update`(session, listener_id=None, tls_container_id=None, **model_kwargs)

    Updates an SNI entity in the database.

class `SessionPersistenceRepository`

  Bases: `octavia.db.repositories.BaseRepository`

  `exists`(session, pool_id)

    Checks if session persistence exists on a pool.

  `model_class`

    alias of `octavia.db.models.SessionPersistence`

  `update`(session, pool_id, **model_kwargs)

    Updates a session persistence entity in the database by pool_id.

class `SparesPoolRepository`

  Bases: `octavia.db.repositories.BaseRepository`

  `get_for_update`(lock_session)

    Queries and locks the SparesPool record.

    This call will query for the SparesPool table record and lock it so that other processes cannot read or write it. :returns: expected_spares_count, updated_at

  `model_class`

    alias of `octavia.db.models.SparesPool`

class `VRRPGroupRepository`

  Bases: `octavia.db.repositories.BaseRepository`

  `model_class`

    alias of `octavia.db.models.VRRPGroup`

  `update`(session, load_balancer_id, **model_kwargs)

    Updates a VRRPGroup entry for by load_balancer_id.

class `VipRepository`

  Bases: `octavia.db.repositories.BaseRepository`

  `model_class`

    alias of `octavia.db.models.Vip`

  `update`(session, load_balancer_id, **model_kwargs)

    Updates a vip entity in the database by load_balancer_id.

## Module contents

this page last updated: 2020-04-10 18:17:54

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.

found an error? report a bug questions?