예제 #1
0
def get_backend(type_, target):
    # TODO(kiall): Type is attached to the target, use it.
    LOG.debug("Loading backend driver: %s" % type_)

    cls = Backend.get_driver(type_)

    return cls(target)
예제 #2
0
    def _load_support_matrix(self):
        """Reads the support-matrix.ini file and populates an instance
        of the SupportMatrix class with all the data.

        :returns: SupportMatrix instance
        """

        # SafeConfigParser was deprecated in Python 3.2
        if sys.version_info >= (3, 2):
            cfg = config_parser.ConfigParser()
        else:
            cfg = config_parser.SafeConfigParser()
        env = self.state.document.settings.env
        fname = self.options.get("support-matrix", "support-matrix.ini")
        rel_fpath, fpath = env.relfn2path(fname)
        with open(fpath) as fp:
            cfg.readfp(fp)

        # This ensures that the docs are rebuilt whenever the
        # .ini file changes
        env.note_dependency(rel_fpath)

        matrix = SupportMatrix()

        # The 'targets' section is special - it lists all the
        # hypervisors that this file records data for
        for item in cfg.options("backends"):
            if not item.startswith("backend-impl-"):
                continue

            # The driver string will optionally contain
            # a hypervisor and architecture qualifier
            # so we expect between 1 and 3 components
            # in the name
            key = item[13:]
            title = cfg.get("backends", item)
            name = key.split("-")

            try:
                status = cfg.get("backends.%s" % item, "status")
            except config_parser.NoOptionError:
                if cfg.get("backends.%s" % item, "type") == "xfr":
                    backend = Backend.get_driver(name[0])
                elif cfg.get("backends.%s" % item, "type") == "agent":
                    backend = AgentBackend.get_driver(name[0])
                status = backend.__backend_status__

            if len(name) == 1:
                backend = SupportMatrixBackend(key, title, status, name[0])
            elif len(name) == 2:
                backend = SupportMatrixBackend(key,
                                               title,
                                               status,
                                               name[0],
                                               variations=name[1])
            else:
                raise Exception("'%s' field is malformed in '[%s]' section" %
                                (item, "DEFAULT"))

            backend.in_tree = cfg.getboolean("backends.%s" % item, "in-tree")
            backend.type = cfg.get("backends.%s" % item, "type")
            backend.notes = cfg.get("backends.%s" % item, "notes")
            backend.repository = cfg.get("backends.%s" % item, "repository")
            backend.maintainers = cfg.get("backends.%s" % item, "maintainers")

            matrix.backends[key] = backend

        grades = cfg.get("grades", "valid-grades")

        grades = grades.split(",")

        for grade in grades:
            title = cfg.get("grades.%s" % grade, "title")
            notes = cfg.get("grades.%s" % grade, "notes")
            in_tree = cfg.get("grades.%s" % grade, "in-tree")
            css_class = cfg.get("grades.%s" % grade, "css-class")

            matrix.grade_names[grade] = title
            matrix.grade_classes[grade] = css_class

            grade = SupportMatrixGrade(grade, title, notes, in_tree, css_class)

            matrix.grades.append(grade)

        return matrix
예제 #3
0
    def _load_support_matrix(self):
        """Reads the support-matrix.ini file and populates an instance
        of the SupportMatrix class with all the data.

        :returns: SupportMatrix instance
        """

        cfg = config_parser.SafeConfigParser()
        env = self.state.document.settings.env
        fname = self.options.get("support-matrix",
                                 "support-matrix.ini")
        rel_fpath, fpath = env.relfn2path(fname)
        with open(fpath) as fp:
            cfg.readfp(fp)

        # This ensures that the docs are rebuilt whenever the
        # .ini file changes
        env.note_dependency(rel_fpath)

        matrix = SupportMatrix()

        # The 'targets' section is special - it lists all the
        # hypervisors that this file records data for
        for item in cfg.options("backends"):
            if not item.startswith("backend-impl-"):
                continue

            # The driver string will optionally contain
            # a hypervisor and architecture qualifier
            # so we expect between 1 and 3 components
            # in the name
            key = item[13:]
            title = cfg.get("backends", item)
            name = key.split("-")

            try:
                status = cfg.get("backends.%s" % item, "status")
            except config_parser.NoOptionError:
                if cfg.get("backends.%s" % item, "type") == "xfr":
                    backend = Backend.get_driver(name[0])
                elif cfg.get("backends.%s" % item, "type") == "agent":
                    backend = AgentBackend.get_driver(name[0])
                status = backend.__backend_status__

            if len(name) == 1:
                backend = SupportMatrixBackend(
                    key, title, status, name[0])
            elif len(name) == 2:
                backend = SupportMatrixBackend(
                    key, title, status, name[0], variations=name[1])
            else:
                raise Exception("'%s' field is malformed in '[%s]' section" %
                                (item, "DEFAULT"))

            backend.in_tree = cfg.getboolean(
                "backends.%s" % item, "in-tree")
            backend.type = cfg.get(
                "backends.%s" % item, "type")
            backend.notes = cfg.get(
                "backends.%s" % item, "notes")
            backend.repository = cfg.get(
                "backends.%s" % item, "repository")
            backend.maintainers = cfg.get(
                "backends.%s" % item, "maintainers")

            matrix.backends[key] = backend

        grades = cfg.get("grades", "valid-grades")

        grades = grades.split(",")

        for grade in grades:
            title = cfg.get("grades.%s" % grade, "title")
            notes = cfg.get("grades.%s" % grade, "notes")
            in_tree = cfg.get("grades.%s" % grade, "in-tree")

            matrix.grade_names[grade] = title

            grade = SupportMatrixGrade(
                grade, title, notes, in_tree)

            matrix.grades.append(grade)

        return matrix
예제 #4
0
def get_backend(backend_driver, central_service):
    LOG.debug("Loading backend driver: %s" % backend_driver)

    cls = Backend.get_driver(backend_driver)

    return cls(central_service=central_service)
예제 #5
0
def get_server_object(backend_driver, server_id):
    LOG.debug("Loading backend driver: %s" % backend_driver)
    cls = Backend.get_driver(backend_driver)

    return cls.get_server_object(backend_driver, server_id)
예제 #6
0
def get_backend(backend_driver, backend_options):
    LOG.debug("Loading backend driver: %s" % backend_driver)
    cls = Backend.get_driver(backend_driver)

    return cls(backend_options)