# octavia.db package

## Submodules

## octavia.db.api module

get_engine()

get_session()

  Helper method to grab session.

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=CallableColumnDefault(<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: `ModelBase`

  static apply_filter(query, model, filters)
  to_data_model(_graph_nodes=None, recursion_depth: int | None = 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

      - recursion_depth – Used only for configuring recursion. This option allows to limit recursion depth. It could be used when we need only main node and its first level relationships. It allows to save time on recursion calls for huge graphs, when only main object is necessary.

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.

  property tags

class Tags(**kwargs)

  Bases: `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 AdditionalVip(**kwargs)

  Bases: `Base`

  ip_address
  load_balancer
  load_balancer_id
  network_id
  port_id
  subnet_id

class Algorithm(**kwargs)

  Bases: `Base`, `LookupTableMixin`

  description
  name

class Amphora(**kwargs)

  Bases: `Base`, `IdMixin`, `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: `Base`

  amphora_id
  created_time
  priority
  status

class AmphoraBuildSlots(**kwargs)

  Bases: `Base`

  id
  slots_used

class AmphoraHealth(**kwargs)

  Bases: `Base`

  amphora_id
  busy
  last_update

class AmphoraMemberPort(**kwargs)

  Bases: `Base`, `TimestampMixin`

  amphora_id
  created_at
  network_id
  port_id
  updated_at

class AmphoraRoles(**kwargs)

  Bases: `Base`, `LookupTableMixin`

  description
  name

class AvailabilityZone(**kwargs)

  Bases: `Base`, `NameMixin`

  availability_zone_profile: Mapped[AvailabilityZoneProfile]
  availability_zone_profile_id
  description
  enabled
  name

class AvailabilityZoneProfile(**kwargs)

  Bases: `Base`, `IdMixin`, `NameMixin`

  availability_zone_data
  id
  name
  provider_name

class ClientAuthenticationMode(**kwargs)

  Bases: `Base`

  name

class Flavor(**kwargs)

  Bases: `Base`, `IdMixin`, `NameMixin`

  description
  enabled
  flavor_profile: Mapped[FlavorProfile]
  flavor_profile_id
  id
  name

class FlavorProfile(**kwargs)

  Bases: `Base`, `IdMixin`, `NameMixin`

  flavor_data
  id
  name
  provider_name

class HealthMonitor(**kwargs)

  Bases: `Base`, `IdMixin`, `ProjectMixin`, `TimestampMixin`, `NameMixin`, `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: `Base`, `LookupTableMixin`

  description
  name

class L7Policy(**kwargs)

  Bases: `Base`, `IdMixin`, `ProjectMixin`, `TimestampMixin`, `NameMixin`, `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: `Base`, `LookupTableMixin`

  description
  name

class L7Rule(**kwargs)

  Bases: `Base`, `IdMixin`, `ProjectMixin`, `TimestampMixin`, `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: `Base`, `LookupTableMixin`

  description
  name

class L7RuleType(**kwargs)

  Bases: `Base`, `LookupTableMixin`

  description
  name

class LBTopology(**kwargs)

  Bases: `Base`, `LookupTableMixin`

  description
  name

class Listener(**kwargs)

  Bases: `Base`, `IdMixin`, `ProjectMixin`, `TimestampMixin`, `NameMixin`, `TagMixin`

  allowed_cidrs
  alpn_protocols
  client_authentication
  client_ca_tls_certificate_id
  client_crl_container_id
  connection_limit
  created_at
  default_pool
  default_pool_id
  description
  enabled
  hsts_include_subdomains
  hsts_max_age
  hsts_preload
  id
  insert_headers
  l7policies
  load_balancer
  load_balancer_id
  name
  operating_status
  peer_port
  property 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
  tls_versions
  updated_at

class ListenerCidr(**kwargs)

  Bases: `Base`

  cidr
  listener
  listener_id

class ListenerStatistics(**kwargs)

  Bases: `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: `Base`, `IdMixin`, `ProjectMixin`, `TimestampMixin`, `NameMixin`, `TagMixin`

  additional_vips
  amphorae
  availability_zone
  created_at
  description
  enabled
  flavor: Mapped[Flavor]
  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: `Base`, `IdMixin`, `ProjectMixin`, `TimestampMixin`, `NameMixin`, `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
  vnic_type
  weight

class OperatingStatus(**kwargs)

  Bases: `Base`, `LookupTableMixin`

  description
  name

class Pool(**kwargs)

  Bases: `Base`, `IdMixin`, `ProjectMixin`, `TimestampMixin`, `NameMixin`, `TagMixin`

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

class Protocol(**kwargs)

  Bases: `Base`, `LookupTableMixin`

  description
  name

class ProvisioningStatus(**kwargs)

  Bases: `Base`, `LookupTableMixin`

  description
  name

class Quotas(**kwargs)

  Bases: `Base`

  health_monitor
  in_use_health_monitor
  in_use_l7policy
  in_use_l7rule
  in_use_listener
  in_use_load_balancer
  in_use_member
  in_use_pool
  l7policy
  l7rule
  listener
  load_balancer
  member
  pool
  project_id

class SNI(**kwargs)

  Bases: `Base`

  listener
  listener_id
  position
  tls_container_id

class SessionPersistence(**kwargs)

  Bases: `Base`

  cookie_name
  persistence_granularity
  persistence_timeout
  pool
  pool_id
  type

class SessionPersistenceType(**kwargs)

  Bases: `Base`, `LookupTableMixin`

  description
  name

class VRRPAuthMethod(**kwargs)

  Bases: `Base`, `LookupTableMixin`

  description
  name

class VRRPGroup(**kwargs)

  Bases: `Base`

  advert_int
  load_balancer
  load_balancer_id
  vrrp_auth_pass
  vrrp_auth_type
  vrrp_group_name

class Vip(**kwargs)

  Bases: `Base`

  ip_address
  load_balancer
  load_balancer_id
  network_id
  octavia_owned
  port_id
  qos_policy_id
  property sg_ids: list[str]
  sgs
  subnet_id
  vnic_type

class VipSecurityGroup(**kwargs)

  Bases: `Base`

  load_balancer_id
  sg_id
  vip

## 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_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 AdditionalVipRepository

  Bases: `BaseRepository`

  model_class

    alias of `AdditionalVip`

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

    Updates an additional vip entity in the database.

    Uses load_balancer_id + subnet_id.

class AmphoraBuildReqRepository

  Bases: `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 (lowest) :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 `AmphoraBuildRequest`

  update_req_status(session, amphora_id=None)

    Updates the request status.

class AmphoraBuildSlotsRepository

  Bases: `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 `AmphoraBuildSlots`

  update_count(session, action='increment')

    Increments/Decrements/Resets the number of build_slots used.

class AmphoraHealthRepository

  Bases: `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(lock_session: Session) → Amphora | None

    Retrieves a stale amphora from the health manager database.

    Parameters:

      lock_session – A Sql Alchemy database autocommit session.

    Returns:

      [octavia.common.data_model]

  model_class

    alias of `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.

  update_failover_stopped(lock_session: ~sqlalchemy.orm.session.Session, expired_time: <module 'datetime' from '/usr/lib/python3.13/datetime.py'>) → None

    Updates the status of amps that are FAILOVER_STOPPED.

class AmphoraMemberPortRepository

  Bases: `BaseRepository`

  get_port_ids(session, amphora_id)
  model_class

    alias of `AmphoraMemberPort`

class AmphoraRepository

  Bases: `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_amphorae_ids_on_lb(session, lb_id)

    Returns a list of amphora IDs associated with the load balancer

    Parameters:

      - session – A Sql Alchemy database session.

      - lb_id – A load balancer ID.

    Returns:

      A list of amphora IDs

  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.

  model_class

    alias of `Amphora`

  test_and_set_status_for_delete(lock_session, id)

    Tests and sets an amphora status.

    Puts a lock on the amphora table to check the status of the amphora. The status must be either AMPHORA_READY or ERROR to successfully update the amphora status.

    Parameters:

      - lock_session – A Sql Alchemy database session.

      - id – id of Load Balancer

    Raises:

      - ImmutableObject – The amphora is not in a state that can be deleted.

      - NoResultFound – The amphora was not found or already deleted.

    Returns:

      None

class AvailabilityZoneProfileRepository

  Bases: `_GetALLExceptDELETEDIdMixin`, `BaseRepository`

  model_class

    alias of `AvailabilityZoneProfile`

class AvailabilityZoneRepository

  Bases: `_GetALLExceptDELETEDIdMixin`, `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 `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, limited_graph=False, **filters)

    Retrieves an entity from the database.

    Parameters:

      - session – A Sql Alchemy database session.

      - limited_graph – Option controls number of processed nodes in the graph. Default (with False) behaviour is recursion iteration through all nodes in the graph via to_data_model. With True value recursion will stop at the first child node. It means, that only limited number of nodes be converted. This logic could be used for specific cases, where information about full graph is unnecessary.

      - filters – Filters to decide which entity should be retrieved.

    Returns:

      octavia.common.data_model

  get_all(session, pagination_helper=None, query_options=None, limited_graph=False, **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.

      - limited_graph – Option controls number of processed nodes in the graph. Default (with False) behaviour is recursion iteration through all nodes in the graph via to_data_model. With True value recursion will stop at the first child node. It means, that only limited number of nodes be converted. This logic could be used for specific cases, where information about full graph is unnecessary.

      - 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: `_GetALLExceptDELETEDIdMixin`, `BaseRepository`

  model_class

    alias of `FlavorProfile`

class FlavorRepository

  Bases: `_GetALLExceptDELETEDIdMixin`, `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 `Flavor`

class HealthMonitorRepository

  Bases: `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 `HealthMonitor`

class L7PolicyRepository

  Bases: `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.

      - limited_graph – Option controls number of processed nodes in the graph. Default (with False) behaviour is recursion iteration through all nodes in the graph via to_data_model. With True value recursion will stop at the first child node. It means, that only limited number of nodes be converted. This logic could be used for specific cases, where information about full graph is unnecessary.

      - 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 `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: `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 `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: `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 `ListenerCidr`

  update(session, listener_id, allowed_cidrs)

    Updates allowed CIDRs in the database by listener_id.

class ListenerRepository

  Bases: `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]

  get_port_protocol_cidr_for_lb(session, loadbalancer_id)
  has_default_pool(session, id)

    Checks if a listener has a default pool.

  model_class

    alias of `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: `BaseRepository`

  increment(session, delta_stats)

    Updates a listener’s statistics, incrementing by the passed deltas.

    Parameters:

      - session – A Sql Alchemy database session

      - delta_stats (octavia.common.data_models.ListenerStatistics) – Listener statistics deltas to add

  model_class

    alias of `ListenerStatistics`

  replace(session, stats_obj)

    Create or override a listener’s statistics (insert/update)

    Parameters:

      - session – A Sql Alchemy database session

      - stats_obj (octavia.common.data_models.ListenerStatistics) – Listener statistics object to store

  update(session, listener_id, **model_kwargs)

    Updates a listener’s statistics, overriding with the passed values.

    Parameters:

      - session – A Sql Alchemy database session

      - listener_id (str) – The UUID of the listener to update

      - model_kwargs – Entity attributes that should be updated

class LoadBalancerRepository

  Bases: `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 `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: `BaseRepository`

  delete_members(session, member_ids)

    Batch deletes members from a pool.

  get_all_API_list(session, pagination_helper=None, limited_graph=False, **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.

      - limited_graph – Option to avoid recursion iteration through all nodes in the graph via to_data_model

      - filters – Filters to decide which entities should be retrieved.

    Returns:

      [octavia.common.data_model]

  model_class

    alias of `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: `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]

  get_children_count(session, pool_id)
  model_class

    alias of `Pool`

class QuotasRepository

  Bases: `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

  ensure_project_exists(project_id)
  model_class

    alias of `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: 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

      - _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, additional_vip_dicts=None)

    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

      - additional_vip_dicts – Dict representations of additional vips

    Returns:

      octavia.common.data_models.LoadBalancer

  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: `BaseRepository`

  model_class

    alias of `SNI`

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

    Updates an SNI entity in the database.

class SessionPersistenceRepository

  Bases: `BaseRepository`

  exists(session, pool_id)

    Checks if session persistence exists on a pool.

  model_class

    alias of `SessionPersistence`

  update(session, pool_id, **model_kwargs)

    Updates a session persistence entity in the database by pool_id.

class VRRPGroupRepository

  Bases: `BaseRepository`

  model_class

    alias of `VRRPGroup`

  update(session, load_balancer_id, **model_kwargs)

    Updates a VRRPGroup entry for by load_balancer_id.

class VipRepository

  Bases: `BaseRepository`

  model_class

    alias of `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: 2025-04-03 17:35:57

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