コード例 #1
0
ファイル: context.py プロジェクト: vdialani/trove
    def make_context(self, *args, **kwargs):
        """
        Create a context with the given arguments.
        """

        # Determine the context class to use
        ctxcls = context.RequestContext
        if 'context_class' in self.options:
            ctxcls = importutils.import_class(self.options['context_class'])

        return ctxcls(*args, **kwargs)
コード例 #2
0
ファイル: context.py プロジェクト: neetugrewal/trove
    def make_context(self, *args, **kwargs):
        """
        Create a context with the given arguments.
        """

        # Determine the context class to use
        ctxcls = context.RequestContext
        if "context_class" in self.options:
            ctxcls = importutils.import_class(self.options["context_class"])

        return ctxcls(*args, **kwargs)
コード例 #3
0
ファイル: limits.py プロジェクト: tattabbum/trove
    def __init__(self, application, limits=None, limiter=None, **kwargs):
        """
        Initialize new `RateLimitingMiddleware`, which wraps the given WSGI
        application and sets up the given limits.

        @param application: WSGI application to wrap
        @param limits: String describing limits
        @param limiter: String identifying class for representing limits

        Other parameters are passed to the constructor for the limiter.
        """
        base_wsgi.Middleware.__init__(self, application)

        # Select the limiter class
        if limiter is None:
            limiter = Limiter
        else:
            limiter = importutils.import_class(limiter)

        # Parse the limits, if any are provided
        if limits is not None:
            limits = limiter.parse_limits(limits)

        self._limiter = limiter(limits or DEFAULT_LIMITS, **kwargs)
コード例 #4
0
ファイル: limits.py プロジェクト: AlexeyDeyneko/trove
    def __init__(self, application, limits=None, limiter=None, **kwargs):
        """
        Initialize new `RateLimitingMiddleware`, which wraps the given WSGI
        application and sets up the given limits.

        @param application: WSGI application to wrap
        @param limits: String describing limits
        @param limiter: String identifying class for representing limits

        Other parameters are passed to the constructor for the limiter.
        """
        base_wsgi.Middleware.__init__(self, application)

        # Select the limiter class
        if limiter is None:
            limiter = Limiter
        else:
            limiter = importutils.import_class(limiter)

        # Parse the limits, if any are provided
        if limits is not None:
            limits = limiter.parse_limits(limits)

        self._limiter = limiter(limits or DEFAULT_LIMITS, **kwargs)
コード例 #5
0
                                 auth_url=PROXY_AUTH_URL)
    client.client.auth_token = context.auth_token
    client.client.management_url = "%s/%s/" % (VOLUME_URL, context.tenant)
    return client


def heat_client(context):
    endpoint = "%s/%s/" % (HEAT_URL, context.tenant)
    client = HeatClient.Client(username=context.user,
                               password="******",
                               token=context.auth_token,
                               os_no_client_auth=True,
                               endpoint=endpoint)
    return client


def swift_client(context):
    client = Connection(preauthurl=OBJECT_STORE_URL + context.tenant,
                        preauthtoken=context.auth_token,
                        tenant_name=context.tenant,
                        snet=USE_SNET)
    return client


create_dns_client = import_class(CONF.remote_dns_client)
create_guest_client = import_class(CONF.remote_guest_client)
create_nova_client = import_class(CONF.remote_nova_client)
create_swift_client = import_class(CONF.remote_swift_client)
create_cinder_client = import_class(CONF.remote_cinder_client)
create_heat_client = import_class(CONF.remote_heat_client)
コード例 #6
0
 def get_driver(cls, context):
     if not cls.network_driver:
         cls.network_driver = import_class(CONF.network_driver)
     return cls.network_driver(context)
コード例 #7
0
ファイル: models.py プロジェクト: AlexeyDeyneko/trove
 def get_driver(cls, context):
     if not cls.network_driver:
         cls.network_driver = import_class(CONF.network_driver)
     return cls.network_driver(context)
コード例 #8
0
ファイル: remote.py プロジェクト: dfecker/trove
    """
    client = create_nova_client(context)
    client.client.auth_token = None
    return client


def nova_volume_client(context):
    # Quite annoying but due to a paste config loading bug.
    # TODO(hub-cap): talk to the openstack-common people about this
    client = Client(context.user, context.auth_token,
                    project_id=context.tenant, auth_url=PROXY_AUTH_URL)
    client.client.auth_token = context.auth_token
    client.client.management_url = "%s/%s/" % (VOLUME_URL, context.tenant)

    return client


def swift_client(context):
    client = Connection(preauthurl=OBJECT_STORE_URL + context.tenant,
                        preauthtoken=context.auth_token,
                        tenant_name=context.tenant,
                        snet=USE_SNET)
    return client


create_dns_client = import_class(CONF.remote_dns_client)
create_guest_client = import_class(CONF.remote_guest_client)
create_nova_client = import_class(CONF.remote_nova_client)
create_nova_volume_client = import_class(CONF.remote_nova_volume_client)
create_swift_client = import_class(CONF.remote_swift_client)