Exemplo n.º 1
0
    def check(self, _):
        server = self.get_server()
        if self.checker is None:
            name = self.instance.get('name', server)
            tags = ["instance:{0}".format(name)] + self.get_config_tags()

            try:
                version = self.get(self.get_server(), tags, True)['version']
                if version is not None:
                    self.set_metadata('version', version)
                else:
                    self.log.debug("Could not parse CouchDB version: %s",
                                   version)

            except Exception as e:
                raise errors.ConnectionError(
                    "Unable to talk to the server: {}".format(e))

            major_version = int(version.split('.')[0])
            if major_version == 0:
                raise errors.BadVersionError(
                    "Unknown version {}".format(version))
            elif major_version <= 1:
                self.checker = CouchDB1(self)
            else:
                # v2 of the CouchDB check supports versions 2 and higher of Couch
                self.checker = CouchDB2(self)

        self.checker.check()
Exemplo n.º 2
0
    def check(self, instance):
        server = self.get_server(instance)
        if self.checker is None:
            name = instance.get('name', server)
            tags = ["instance:{0}".format(name)
                    ] + self.get_config_tags(instance)

            try:
                version = self.get(self.get_server(instance), tags,
                                   True)['version']
                if version is not None:
                    self.set_metadata('version', version)
                else:
                    self.log.debug("Could not parse CouchDB version: %s",
                                   version)

            except Exception as e:
                raise errors.ConnectionError(
                    "Unable to talk to the server: {}".format(e))

            if version.startswith('1.'):
                self.checker = CouchDB1(self)
            elif version.startswith('2.'):
                self.checker = CouchDB2(self)
            else:
                raise errors.BadVersionError(
                    "Unkown version {0}".format(version))

        self.checker.check(instance)