Ejemplo n.º 1
0
    def _get_cacheable_function(self):
        SHOULD_CACHE_FN = cache.should_cache_fn('cache')

        @self.region.cache_on_arguments(should_cache_fn=SHOULD_CACHE_FN)
        def cacheable_function(value):
            return value

        return cacheable_function
Ejemplo n.º 2
0
    def _get_cacheable_function(self):
        SHOULD_CACHE_FN = cache.should_cache_fn('cache')

        @self.region.cache_on_arguments(should_cache_fn=SHOULD_CACHE_FN)
        def cacheable_function(value):
            return value

        return cacheable_function
Ejemplo n.º 3
0
    def test_should_cache_fn(self):
        # Verify should_cache_fn generates a sane function for subsystem
        # toggle.
        SHOULD_CACHE = cache.should_cache_fn('cache')
        test_value = TestProxyValue('Decorator Test')

        @self.region.cache_on_arguments(should_cache_fn=SHOULD_CACHE)
        def cacheable_function(value):
            return value

        setattr(CONF.cache, 'caching', False)
        cacheable_function(test_value)
        cached_value = cacheable_function(test_value)
        self.assertFalse(cached_value.cached)

        setattr(CONF.cache, 'caching', True)
        cacheable_function(test_value)
        cached_value = cacheable_function(test_value)
        self.assertTrue(cached_value.cached)
Ejemplo n.º 4
0
    def test_should_cache_fn(self):
        # Verify should_cache_fn generates a sane function for subsystem
        # toggle.
        SHOULD_CACHE = cache.should_cache_fn('cache')
        test_value = TestProxyValue('Decorator Test')

        @self.region.cache_on_arguments(should_cache_fn=SHOULD_CACHE)
        def cacheable_function(value):
            return value

        setattr(CONF.cache, 'caching', False)
        cacheable_function(test_value)
        cached_value = cacheable_function(test_value)
        self.assertFalse(cached_value.cached)

        setattr(CONF.cache, 'caching', True)
        cacheable_function(test_value)
        cached_value = cacheable_function(test_value)
        self.assertTrue(cached_value.cached)
Ejemplo n.º 5
0
from oslo_config import cfg
from oslo_log import log
from oslo_utils import timeutils
import six

from keystone.common import cache
from keystone.common import dependency
from keystone.common import manager
from keystone import exception
from keystone.i18n import _LW
from keystone.openstack.common import versionutils


CONF = cfg.CONF
LOG = log.getLogger(__name__)
SHOULD_CACHE = cache.should_cache_fn("token")

# NOTE(blk-u): The config options are not available at import time.
EXPIRATION_TIME = lambda: CONF.token.cache_time
REVOCATION_CACHE_EXPIRATION_TIME = lambda: CONF.token.revocation_cache_time


@dependency.requires("assignment_api", "identity_api", "resource_api", "token_provider_api", "trust_api")
class PersistenceManager(manager.Manager):
    """Default pivot point for the Token backend.

    See :mod:`keystone.common.manager.Manager` for more details on how this
    dynamically calls the backend.

    """
Ejemplo n.º 6
0
import six

from keystone import clean
from keystone.common import cache
from keystone.common import dependency
from keystone.common import driver_hints
from keystone.common import manager
from keystone import config
from keystone import exception
from keystone import notifications
from keystone.openstack.common import log


CONF = config.CONF
LOG = log.getLogger(__name__)
SHOULD_CACHE = cache.should_cache_fn('assignment')

# NOTE(blk-u): The config option is not available at import time.
EXPIRATION_TIME = lambda: CONF.assignment.cache_time


def calc_default_domain():
    return {'description':
            (u'Owns users and tenants (i.e. projects)'
                ' available on Identity API v2.'),
            'enabled': True,
            'id': CONF.identity.default_domain_id,
            'name': u'Default'}


@dependency.provider('assignment_api')
Ejemplo n.º 7
0
import six

from keystone import clean
from keystone.common import cache
from keystone.common import dependency
from keystone.common import driver_hints
from keystone.common import manager
from keystone import config
from keystone import exception
from keystone import notifications
from keystone.openstack.common.gettextutils import _
from keystone.openstack.common import log

CONF = config.CONF
LOG = log.getLogger(__name__)
SHOULD_CACHE = cache.should_cache_fn('assignment')

# NOTE(blk-u): The config option is not available at import time.
EXPIRATION_TIME = lambda: CONF.assignment.cache_time


def calc_default_domain():
    return {
        'description': (u'Owns users and tenants (i.e. projects)'
                        ' available on Identity API v2.'),
        'enabled':
        True,
        'id':
        CONF.identity.default_domain_id,
        'name':
        u'Default'
Ejemplo n.º 8
0
    'description':
    'OpenStack revoked token reporting mechanism.',
    'links': [{
        'rel':
        'describedby',
        'type':
        'text/html',
        'href': ('https://github.com/openstack/identity-api/blob/master/'
                 'openstack-identity-api/v3/src/markdown/'
                 'identity-api-v3-os-revoke-ext.md'),
    }]
}
extension.register_admin_extension(EXTENSION_DATA['alias'], EXTENSION_DATA)
extension.register_public_extension(EXTENSION_DATA['alias'], EXTENSION_DATA)

SHOULD_CACHE = cache.should_cache_fn('revoke')
# TODO(ayoung): migrate from the token section
REVOCATION_CACHE_EXPIRATION_TIME = lambda: CONF.token.revocation_cache_time


def revoked_before_cutoff_time():
    expire_delta = datetime.timedelta(seconds=CONF.token.expiration +
                                      CONF.revoke.expiration_buffer)
    oldest = timeutils.utcnow() - expire_delta
    return oldest


@dependency.provider('revoke_api')
class Manager(manager.Manager):
    """Revoke API Manager.
Ejemplo n.º 9
0
import six

from keystone.common import cache
from keystone.common import cms
from keystone.common import dependency
from keystone.common import manager
from keystone import config
from keystone import exception
from keystone.openstack.common import log
from keystone.openstack.common import timeutils
from keystone.openstack.common import versionutils

CONF = config.CONF
LOG = log.getLogger(__name__)
SHOULD_CACHE = cache.should_cache_fn('token')

# NOTE(blk-u): The config options are not available at import time.
EXPIRATION_TIME = lambda: CONF.token.cache_time
REVOCATION_CACHE_EXPIRATION_TIME = lambda: CONF.token.revocation_cache_time


def default_expire_time():
    """Determine when a fresh token should expire.

    Expiration time varies based on configuration (see ``[token] expiration``).

    :returns: a naive UTC datetime.datetime object

    """
    expire_delta = datetime.timedelta(seconds=CONF.token.expiration)
Ejemplo n.º 10
0
from keystone.common import cache
from keystone.common import dependency
from keystone.common import driver_hints
from keystone.common import manager
from keystone.common import utils
from keystone import config
from keystone import exception
from keystone.i18n import _
from keystone.i18n import _LE
from keystone import notifications
from keystone.openstack.common import log

CONF = config.CONF
LOG = log.getLogger(__name__)
SHOULD_CACHE = cache.should_cache_fn('catalog')

EXPIRATION_TIME = lambda: CONF.catalog.cache_time


def format_url(url, substitutions):
    """Formats a user-defined URL with the given substitutions.

    :param string url: the URL to be formatted
    :param dict substitutions: the dictionary used for substitution
    :returns: a formatted URL

    """
    substitutions = utils.WhiteListedItemFilter(
        CONF.catalog.endpoint_substitution_whitelist, substitutions)
    try:
Ejemplo n.º 11
0
import six

from keystone import clean
from keystone.common import cache
from keystone.common import dependency
from keystone.common import manager
from keystone import config
from keystone import exception
from keystone import notifications
from keystone.openstack.common import log as logging


CONF = config.CONF
LOG = logging.getLogger(__name__)
SHOULD_CACHE = cache.should_cache_fn("assignment")

DEFAULT_DOMAIN = {
    "description": (u"Owns users and tenants (i.e. projects)" " available on Identity API v2."),
    "enabled": True,
    "id": CONF.identity.default_domain_id,
    "name": u"Default",
}


@dependency.provider("assignment_api")
@dependency.requires("identity_api")
class Manager(manager.Manager):
    """Default pivot point for the Assignment backend.

    See :mod:`keystone.common.manager.Manager` for more details on how this
Ejemplo n.º 12
0
from oslo_log import log
import six

from keystone import clean
from keystone.common import cache
from keystone.common import dependency
from keystone.common import driver_hints
from keystone.common import manager
from keystone.contrib import federation
from keystone import exception
from keystone.i18n import _, _LE
from keystone import notifications

CONF = cfg.CONF
LOG = log.getLogger(__name__)
SHOULD_CACHE = cache.should_cache_fn('resource')

# NOTE(blk-u): The config options are not available at import time.
EXPIRATION_TIME = lambda: CONF.resource.cache_time


def calc_default_domain():
    return {
        'description': (u'Owns users and tenants (i.e. projects)'
                        ' available on Identity API v2.'),
        'enabled':
        True,
        'id':
        CONF.identity.default_domain_id,
        'name':
        u'Default'
Ejemplo n.º 13
0
    'alias': 'OS-REVOKE',
    'updated': '2014-02-24T20:51:0-00:00',
    'description': 'OpenStack revoked token reporting mechanism.',
    'links': [
        {
            'rel': 'describedby',
            'type': 'text/html',
            'href': ('https://github.com/openstack/identity-api/blob/master/'
                     'openstack-identity-api/v3/src/markdown/'
                     'identity-api-v3-os-revoke-ext.md'),
        }
    ]}
extension.register_admin_extension(EXTENSION_DATA['alias'], EXTENSION_DATA)
extension.register_public_extension(EXTENSION_DATA['alias'], EXTENSION_DATA)

SHOULD_CACHE = cache.should_cache_fn('revoke')
# TODO(ayoung): migrate from the token section
REVOCATION_CACHE_EXPIRATION_TIME = lambda: CONF.token.revocation_cache_time


def revoked_before_cutoff_time():
    expire_delta = datetime.timedelta(
        seconds=CONF.token.expiration + CONF.revoke.expiration_buffer)
    oldest = timeutils.utcnow() - expire_delta
    return oldest


@dependency.provider('revoke_api')
class Manager(manager.Manager):
    """Revoke API Manager.
Ejemplo n.º 14
0
import six

from keystone.common import cache
from keystone.common import dependency
from keystone.common import driver_hints
from keystone.common import manager
from keystone import exception
from keystone.i18n import _
from keystone.i18n import _LI
from keystone import notifications
from keystone.openstack.common import versionutils


CONF = cfg.CONF
LOG = log.getLogger(__name__)
SHOULD_CACHE = cache.should_cache_fn('role')

# NOTE(blk-u): The config option is not available at import time.
EXPIRATION_TIME = lambda: CONF.role.cache_time


def deprecated_to_role_api(f):
    """Specialized deprecation wrapper for assignment to role api.

    This wraps the standard deprecation wrapper and fills in the method
    names automatically.

    """
    @six.wraps(f)
    def wrapper(*args, **kwargs):
        x = versionutils.deprecated(
Ejemplo n.º 15
0
import six

from keystone.common import cache
from keystone.common import dependency
from keystone.common import driver_hints
from keystone.common import manager
from keystone import config
from keystone import exception
from keystone.i18n import _
from keystone import notifications
from keystone.openstack.common import log


CONF = config.CONF
LOG = log.getLogger(__name__)
SHOULD_CACHE = cache.should_cache_fn('catalog')

EXPIRATION_TIME = lambda: CONF.catalog.cache_time


def format_url(url, substitutions):
    """Formats a user-defined URL with the given substitutions.

    :param string url: the URL to be formatted
    :param dict substitutions: the dictionary used for substitution
    :returns: a formatted URL

    """
    try:
        result = url.replace('$(', '%(') % substitutions
    except AttributeError:
Ejemplo n.º 16
0
    "links": [
        {
            "rel": "describedby",
            "type": "text/html",
            "href": (
                "https://github.com/openstack/identity-api/blob/master/"
                "openstack-identity-api/v3/src/markdown/"
                "identity-api-v3-os-revoke-ext.md"
            ),
        }
    ],
}
extension.register_admin_extension(EXTENSION_DATA["alias"], EXTENSION_DATA)
extension.register_public_extension(EXTENSION_DATA["alias"], EXTENSION_DATA)

SHOULD_CACHE = cache.should_cache_fn("revoke")
# TODO(ayoung): migrate from the token section
REVOCATION_CACHE_EXPIRATION_TIME = lambda: CONF.token.revocation_cache_time


def revoked_before_cutoff_time():
    expire_delta = datetime.timedelta(seconds=CONF.token.expiration + CONF.revoke.expiration_buffer)
    oldest = timeutils.utcnow() - expire_delta
    return oldest


@dependency.provider("revoke_api")
class Manager(manager.Manager):
    """Revoke API Manager.

    Performs common logic for recording revocations.
Ejemplo n.º 17
0
from oslo_log import log
import six

from keystone.common import cache
from keystone.common import dependency
from keystone.common import driver_hints
from keystone.common import manager
from keystone import exception
from keystone.i18n import _
from keystone.i18n import _LI
from keystone import notifications
from keystone.openstack.common import versionutils

CONF = cfg.CONF
LOG = log.getLogger(__name__)
SHOULD_CACHE = cache.should_cache_fn('role')

# NOTE(blk-u): The config option is not available at import time.
EXPIRATION_TIME = lambda: CONF.role.cache_time


def deprecated_to_role_api(f):
    """Specialized deprecation wrapper for assignment to role api.

    This wraps the standard deprecation wrapper and fills in the method
    names automatically.

    """
    @six.wraps(f)
    def wrapper(*args, **kwargs):
        x = versionutils.deprecated(what='assignment.' + f.__name__ + '()',
Ejemplo n.º 18
0
import six

from keystone.common import cache
from keystone.common import dependency
from keystone.common import manager
from keystone import config
from keystone import exception
from keystone.openstack.common import log
from keystone.openstack.common import timeutils
from keystone.openstack.common import versionutils


CONF = config.CONF
LOG = log.getLogger(__name__)
SHOULD_CACHE = cache.should_cache_fn('token')

# NOTE(blk-u): The config options are not available at import time.
EXPIRATION_TIME = lambda: CONF.token.cache_time
REVOCATION_CACHE_EXPIRATION_TIME = lambda: CONF.token.revocation_cache_time


@dependency.requires('assignment_api', 'identity_api', 'token_provider_api',
                     'trust_api')
@dependency.provider('token_api')
class Manager(manager.Manager):
    """Default pivot point for the Token backend.

    See :mod:`keystone.common.manager.Manager` for more details on how this
    dynamically calls the backend.
Ejemplo n.º 19
0
import six

from keystone import clean
from keystone.common import cache
from keystone.common import dependency
from keystone.common import driver_hints
from keystone.common import manager
from keystone.contrib import federation
from keystone import exception
from keystone.i18n import _, _LE
from keystone import notifications


CONF = cfg.CONF
LOG = log.getLogger(__name__)
SHOULD_CACHE = cache.should_cache_fn('resource')

# NOTE(blk-u): The config options are not available at import time.
EXPIRATION_TIME = lambda: CONF.resource.cache_time


def calc_default_domain():
    return {'description':
            (u'Owns users and tenants (i.e. projects)'
                ' available on Identity API v2.'),
            'enabled': True,
            'id': CONF.identity.default_domain_id,
            'name': u'Default'}


@dependency.provider('resource_api')