octavia.db package

Submodules

octavia.db.api module

get_engine()[source]
get_session()[source]

Helper method to grab session.

session()[source]
wait_for_connection(exit_event)[source]

Helper method to wait for DB connection

octavia.db.base_models module

class IdMixin[source]

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[source]

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[source]

Bases: object

Name mixin to add to classes which need a name.

name = Column(None, String(length=255), table=None)
class OctaviaBase[source]

Bases: ModelBase

static apply_filter(query, model, filters)[source]
to_data_model(_graph_nodes=None)[source]

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[source]

Bases: object

Tenant mixin, add to subclasses that have a project.

project_id = Column(None, String(length=36), table=None)
class TagMixin[source]

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)[source]

Bases: Base

resource_id
tag

octavia.db.healthcheck module

check_database_connection(session)[source]

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)[source]

Bases: Base

ip_address
load_balancer
load_balancer_id
network_id
port_id
subnet_id
class Algorithm(**kwargs)[source]

Bases: Base, LookupTableMixin

description
name
class Amphora(**kwargs)[source]

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)[source]

Bases: Base

amphora_id
created_time
priority
status
class AmphoraBuildSlots(**kwargs)[source]

Bases: Base

id
slots_used
class AmphoraHealth(**kwargs)[source]

Bases: Base

amphora_id
busy
last_update
class AmphoraRoles(**kwargs)[source]

Bases: Base, LookupTableMixin

description
name
class AvailabilityZone(**kwargs)[source]

Bases: Base, NameMixin

availability_zone_profile: Mapped[AvailabilityZoneProfile]
availability_zone_profile_id
description
enabled
name
class AvailabilityZoneProfile(**kwargs)[source]

Bases: Base, IdMixin, NameMixin

availability_zone_data
id
name
provider_name
class ClientAuthenticationMode(**kwargs)[source]

Bases: Base

name
class Flavor(**kwargs)[source]

Bases: Base, IdMixin, NameMixin

description
enabled
flavor_profile: Mapped[FlavorProfile]
flavor_profile_id
id
name
class FlavorProfile(**kwargs)[source]

Bases: Base, IdMixin, NameMixin

flavor_data
id
name
provider_name
class HealthMonitor(**kwargs)[source]

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)[source]

Bases: Base, LookupTableMixin

description
name
class L7Policy(**kwargs)[source]

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)[source]

Bases: Base, LookupTableMixin

description
name
class L7Rule(**kwargs)[source]

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)[source]

Bases: Base, LookupTableMixin

description
name
class L7RuleType(**kwargs)[source]

Bases: Base, LookupTableMixin

description
name
class LBTopology(**kwargs)[source]

Bases: Base, LookupTableMixin

description
name
class Listener(**kwargs)[source]

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)[source]

Bases: Base

cidr
listener
listener_id
class ListenerStatistics(**kwargs)[source]

Bases: Base

active_connections
amphora_id
bytes_in
bytes_out
listener_id
request_errors
total_connections
validate_non_negative_int(key, value)[source]
class LoadBalancer(**kwargs)[source]

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)[source]

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
weight
class OperatingStatus(**kwargs)[source]

Bases: Base, LookupTableMixin

description
name
class Pool(**kwargs)[source]

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)[source]

Bases: Base, LookupTableMixin

description
name
class ProvisioningStatus(**kwargs)[source]

Bases: Base, LookupTableMixin

description
name
class Quotas(**kwargs)[source]

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)[source]

Bases: Base

listener
listener_id
position
tls_container_id
class SessionPersistence(**kwargs)[source]

Bases: Base

cookie_name
persistence_granularity
persistence_timeout
pool
pool_id
type
class SessionPersistenceType(**kwargs)[source]

Bases: Base, LookupTableMixin

description
name
class VRRPAuthMethod(**kwargs)[source]

Bases: Base, LookupTableMixin

description
name
class VRRPGroup(**kwargs)[source]

Bases: Base

advert_int
load_balancer
load_balancer_id
vrrp_auth_pass
vrrp_auth_type
vrrp_group_name
class Vip(**kwargs)[source]

Bases: Base

ip_address
load_balancer
load_balancer_id
network_id
octavia_owned
port_id
qos_policy_id
subnet_id
vnic_type

octavia.db.prepare module

create_health_monitor(hm_dict, pool_id=None)[source]
create_l7policy(l7policy_dict, lb_id, listener_id)[source]
create_l7rule(l7rule_dict, l7policy_id)[source]
create_listener(listener_dict, lb_id)[source]
create_load_balancer(lb_dict)[source]
create_member(member_dict, pool_id, has_health_monitor=False)[source]
create_pool(pool_dict, lb_id=None)[source]

octavia.db.repositories module

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

class AdditionalVipRepository[source]

Bases: BaseRepository

model_class

alias of AdditionalVip

update(session, load_balancer_id, subnet_id, **model_kwargs)[source]

Updates an additional vip entity in the database.

Uses load_balancer_id + subnet_id.

class AmphoraBuildReqRepository[source]

Bases: BaseRepository

add_to_build_queue(session, amphora_id=None, priority=None)[source]

Adds the build request to the table.

delete_all(session)[source]

Deletes all the build requests.

get_highest_priority_build_req(session)[source]

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)[source]

Updates the request status.

class AmphoraBuildSlotsRepository[source]

Bases: BaseRepository

get_used_build_slots_count(session)[source]

Gets the number of build slots in use.

Returns:

Number of current build slots.

model_class

alias of AmphoraBuildSlots

update_count(session, action='increment')[source]

Increments/Decrements/Resets the number of build_slots used.

class AmphoraHealthRepository[source]

Bases: BaseRepository

check_amphora_health_expired(session, amphora_id, exp_age=None)[source]

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[source]

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)[source]

replace or insert amphora into database.

update(session, amphora_id, **model_kwargs)[source]

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.10/datetime.py'>) None[source]

Updates the status of amps that are FAILOVER_STOPPED.

class AmphoraRepository[source]

Bases: BaseRepository

allocate_and_associate(session, load_balancer_id, availability_zone=None)[source]

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)[source]

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)[source]

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)[source]

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)[source]

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)[source]

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)[source]

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[source]

Bases: _GetALLExceptDELETEDIdMixin, BaseRepository

model_class

alias of AvailabilityZoneProfile

class AvailabilityZoneRepository[source]

Bases: _GetALLExceptDELETEDIdMixin, BaseRepository

delete(serial_session, **filters)[source]

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)[source]
get_availability_zone_provider(session, availability_zone_name)[source]
model_class

alias of AvailabilityZone

update(session, name, **model_kwargs)[source]

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[source]

Bases: object

count(session, **filters)[source]

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)[source]

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)[source]

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)[source]

Batch deletes by entity ids.

exists(session, id)[source]

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)[source]

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)[source]

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)[source]

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)[source]

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[source]

Bases: _GetALLExceptDELETEDIdMixin, BaseRepository

model_class

alias of FlavorProfile

class FlavorRepository[source]

Bases: _GetALLExceptDELETEDIdMixin, BaseRepository

delete(serial_session, **filters)[source]

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)[source]
get_flavor_provider(session, flavor_id)[source]
model_class

alias of Flavor

class HealthMonitorRepository[source]

Bases: BaseRepository

get_all_API_list(session, pagination_helper=None, **filters)[source]

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[source]

Bases: BaseRepository

create(session, **model_kwargs)[source]

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)[source]

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)[source]

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)[source]
model_class

alias of L7Policy

update(session, id, **model_kwargs)[source]

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[source]

Bases: BaseRepository

create(session, **model_kwargs)[source]

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)[source]

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)[source]

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[source]

Bases: BaseRepository

create(session, listener_id, allowed_cidrs)[source]

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)[source]

Updates allowed CIDRs in the database by listener_id.

class ListenerRepository[source]

Bases: BaseRepository

create(session, **model_kwargs)[source]

Creates a new Listener with some validation.

get_all_API_list(session, pagination_helper=None, **filters)[source]

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)[source]
has_default_pool(session, id)[source]

Checks if a listener has a default pool.

model_class

alias of Listener

prov_status_active_if_not_error(session, listener_id)[source]

Update provisioning_status to ACTIVE if not already in ERROR.

update(session, id, **model_kwargs)[source]

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[source]

Bases: BaseRepository

increment(session, delta_stats)[source]

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

Parameters:
model_class

alias of ListenerStatistics

replace(session, stats_obj)[source]

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

Parameters:
update(session, listener_id, **model_kwargs)[source]

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[source]

Bases: BaseRepository

get_all_API_list(session, pagination_helper=None, **filters)[source]

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)[source]

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)[source]

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[source]

Bases: BaseRepository

delete_members(session, member_ids)[source]

Batch deletes members from a pool.

get_all_API_list(session, pagination_helper=None, **filters)[source]

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 Member

update_pool_members(session, pool_id, **model_kwargs)[source]

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[source]

Bases: BaseRepository

get_all_API_list(session, pagination_helper=None, **filters)[source]

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)[source]
model_class

alias of Pool

class QuotasRepository[source]

Bases: BaseRepository

delete(session, project_id)[source]

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)[source]
model_class

alias of Quotas

update(session, project_id, **model_kwargs)[source]

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[source]

Bases: object

check_quota_met(session: Session, _class, project_id, count=1)[source]

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)[source]

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)[source]

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)[source]

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)[source]

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)[source]

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)[source]

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[source]

Bases: BaseRepository

model_class

alias of SNI

update(session, listener_id=None, tls_container_id=None, **model_kwargs)[source]

Updates an SNI entity in the database.

class SessionPersistenceRepository[source]

Bases: BaseRepository

exists(session, pool_id)[source]

Checks if session persistence exists on a pool.

model_class

alias of SessionPersistence

update(session, pool_id, **model_kwargs)[source]

Updates a session persistence entity in the database by pool_id.

class VRRPGroupRepository[source]

Bases: BaseRepository

model_class

alias of VRRPGroup

update(session, load_balancer_id, **model_kwargs)[source]

Updates a VRRPGroup entry for by load_balancer_id.

class VipRepository[source]

Bases: BaseRepository

model_class

alias of Vip

update(session, load_balancer_id, **model_kwargs)[source]

Updates a vip entity in the database by load_balancer_id.

Module contents