Example #1
0
    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)
Example #2
0
    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)
Example #3
0
    def get_class(api_name, version, version_map):
        """Returns the client class for the requested API version

        :param api_name: the name of the API, e.g. 'compute', 'image', etc
        :param version: the requested API version
        :param version_map: a dict of client classes keyed by version
        :rtype: a client class for the requested API version
        """
        try:
            client_path = version_map[str(version)]
        except (KeyError, ValueError):
            msg = "Invalid %s client version '%s'. must be one of: %s" % (
                (api_name, version, ', '.join(version_map.keys())))
            raise exceptions.UnsupportedVersion(msg)

        return importutils.import_class(client_path)
Example #4
0
    def get_class(api_name, version, version_map):
        """Returns the client class for the requested API version

        :param api_name: the name of the API, e.g. 'compute', 'image', etc
        :param version: the requested API version
        :param version_map: a dict of client classes keyed by version
        :rtype: a client class for the requested API version
        """
        try:
            client_path = version_map[str(version)]
        except (KeyError, ValueError):
            msg = "Invalid %s client version '%s'. must be one of: %s" % (
                  (api_name, version, ', '.join(version_map.keys())))
            raise exceptions.UnsupportedVersion(msg)

        return importutils.import_class(client_path)