Repository URL to install this package:
Version:
4.1.94.1.dev4 ▾
|
# Copyright 2018 TrilioData Inc.
# All Rights Reserved.
from oslo_db import concurrency
from oslo_log import log as logging
import dmapi.conf
CONF = dmapi.conf.CONF
_BACKEND_MAPPING = {'sqlalchemy': 'dmapi.db.sqlalchemy.api'}
IMPL = concurrency.TpoolDbapiWrapper(CONF, backend_mapping=_BACKEND_MAPPING)
LOG = logging.getLogger(__name__)
MAX_INT = 0x7FFFFFFF
def instance_get_by_uuid(context, uuid, columns_to_join=None):
"""Get an instance or raise if it does not exist."""
return IMPL.instance_get_by_uuid(context, uuid, columns_to_join)
def create_context_manager(connection):
"""Return a context manager for a cell database connection."""
return IMPL.create_context_manager(connection=connection)
###################
def select_db_reader_mode(f):
"""Decorator to select synchronous or asynchronous reader mode.
The kwarg argument 'use_slave' defines reader mode. Asynchronous reader
will be used if 'use_slave' is True and synchronous reader otherwise.
"""
return IMPL.select_db_reader_mode(f)
###################
def service_destroy(context, service_id):
"""Destroy the service or raise if it does not exist."""
return IMPL.service_destroy(context, service_id)
def service_get(context, service_id):
"""Get a service or raise if it does not exist."""
return IMPL.service_get(context, service_id)
def service_get_by_uuid(context, service_uuid):
"""Get a service by it's uuid or raise ServiceNotFound if it does not
exist.
"""
return IMPL.service_get_by_uuid(context, service_uuid)
def service_get_minimum_version(context, binary):
"""Get the minimum service version in the database."""
return IMPL.service_get_minimum_version(context, binary)
def service_get_by_host_and_topic(context, host, topic):
"""Get a service by hostname and topic it listens to."""
return IMPL.service_get_by_host_and_topic(context, host, topic)
def service_get_by_host_and_binary(context, host, binary):
"""Get a service by hostname and binary."""
return IMPL.service_get_by_host_and_binary(context, host, binary)
def service_get_all(context, disabled=None):
"""Get all services."""
return IMPL.service_get_all(context, disabled)
def service_get_all_by_topic(context, topic):
"""Get all services for a given topic."""
return IMPL.service_get_all_by_topic(context, topic)
def service_get_all_by_binary(context, binary, include_disabled=False):
"""Get services for a given binary.
Includes disabled services if 'include_disabled' parameter is True
"""
return IMPL.service_get_all_by_binary(context, binary,
include_disabled=include_disabled)
def service_get_all_computes_by_hv_type(context, hv_type,
include_disabled=False):
"""Get all compute services for a given hypervisor type.
Includes disabled services if 'include_disabled' parameter is True.
"""
return IMPL.service_get_all_computes_by_hv_type(context, hv_type,
include_disabled=include_disabled)
def service_get_all_by_host(context, host):
"""Get all services for a given host."""
return IMPL.service_get_all_by_host(context, host)
def service_get_by_compute_host(context, host):
"""Get the service entry for a given compute host.
Returns the service entry joined with the compute_node entry.
"""
return IMPL.service_get_by_compute_host(context, host)
def service_create(context, values):
"""Create a service from the values dictionary."""
return IMPL.service_create(context, values)
def service_update(context, service_id, values):
"""Set the given properties on a service and update it.
Raises NotFound if service does not exist.
"""
return IMPL.service_update(context, service_id, values)