コード例 #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
コード例 #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
コード例 #3
0
ファイル: test_cache.py プロジェクト: appliedcode/keystone
    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)
コード例 #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)
コード例 #5
0
ファイル: core.py プロジェクト: UTSA-ICS/keystone-kerberos
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.

    """
コード例 #6
0
ファイル: core.py プロジェクト: atheendra/keystone
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')
コード例 #7
0
ファイル: core.py プロジェクト: ygkim93/OpenStackInAction
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'
コード例 #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.
コード例 #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)
コード例 #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:
コード例 #11
0
ファイル: core.py プロジェクト: ntt-sic/keystone
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
コード例 #12
0
ファイル: core.py プロジェクト: UTSA-ICS/keystone-kerberos
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'
コード例 #13
0
ファイル: core.py プロジェクト: reeshupatel/demo
    '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.
コード例 #14
0
ファイル: core.py プロジェクト: UTSA-ICS/keystone-kerberos
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(
コード例 #15
0
ファイル: core.py プロジェクト: openstackorg/keystone
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:
コード例 #16
0
ファイル: core.py プロジェクト: ging/keystone
    "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.
コード例 #17
0
ファイル: core.py プロジェクト: UTSA-ICS/keystone-kerberos
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__ + '()',
コード例 #18
0
ファイル: core.py プロジェクト: iele/keystone
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.
コード例 #19
0
ファイル: core.py プロジェクト: UTSA-ICS/keystone-kerberos
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')