Пример #1
0
    def main(self):
        options = ['--ignore']
        parser = Transport(self.argv, options=options, check_version=False)
        parser.catch_help = self._help()

        parser.parse_args()
        if len(self.argv) < 1:
            return parser.print_help()

        # populate the nodes metadata with the configured nodes
        for daemon in ceph_medic.config.nodes.keys():
            ceph_medic.metadata['nodes'][daemon] = []
        for daemon, nodes in ceph_medic.config.nodes.items():
            for node in nodes:
                ceph_medic.metadata['nodes'][daemon].append(
                    {'host': node['host']})

        collector.collect()
        test = runner.Runner()
        results = test.run()
        runner.report(results)
        #XXX might want to make this configurable to not bark on warnings for
        # example, setting forcefully for now, but the results object doesn't
        # make a distinction between error and warning (!)
        if results.errors or results.warnings:
            sys.exit(1)
Пример #2
0
    def main(self):
        options = ['--ignore']
        config_ignores = ceph_medic.config.file.get_list('check', '--ignore')
        parser = Transport(self.argv, options=options, check_version=False)
        parser.catch_help = self._help()
        parser.parse_args()
        ignored_codes = as_list(parser.get('--ignore', ''))
        # fallback to the configuration if nothing is defined in the CLI
        if not ignored_codes:
            ignored_codes = config_ignores

        if len(self.argv) < 1:
            return parser.print_help()

        # populate the nodes metadata with the configured nodes
        for daemon in ceph_medic.config.nodes.keys():
            ceph_medic.metadata['nodes'][daemon] = []
        for daemon, nodes in ceph_medic.config.nodes.items():
            for node in nodes:
                node_metadata = {'host': node['host']}
                if 'container' in node:
                    node_metadata['container'] = node['container']
                ceph_medic.metadata['nodes'][daemon].append(node_metadata)

        collector.collect()
        test = runner.Runner()
        test.ignore = ignored_codes
        results = test.run()
        runner.report(results)
        #XXX might want to make this configurable to not bark on warnings for
        # example, setting forcefully for now, but the results object doesn't
        # make a distinction between error and warning (!)
        if results.errors or results.warnings:
            sys.exit(1)
Пример #3
0
 def test_collects_node_metadata(self, monkeypatch):
     def mock_metadata(conn, hostname, cluster_nodes):
         return dict(meta="data")
     monkeypatch.setattr(collector, "get_connection", lambda host: Mock())
     monkeypatch.setattr(collector, "get_node_metadata", mock_metadata)
     collector.collect()
     assert "mon0" in metadata["mons"]
     assert "meta" in metadata["mons"]["mon0"]
Пример #4
0
 def test_collects_node_metadata(self, monkeypatch):
     metadata["nodes"] = {
         "mons": [{"host": "mon0"}],
         "osds": [{"host": "osd0"}],
     }
     metadata["cluster_name"] = "ceph"
     def mock_metadata(conn, hostname, cluster_nodes):
         return dict(meta="data")
     monkeypatch.setattr(collector, "get_connection", lambda host: Mock())
     monkeypatch.setattr(collector, "get_node_metadata", mock_metadata)
     collector.collect()
     assert "mon0" in metadata["mons"]
     assert "meta" in metadata["mons"]["mon0"]
Пример #5
0
    def main(self):
        options = ['--ignore']
        parser = Transport(self.argv, options=options, check_version=False)
        parser.catch_help = self._help()

        parser.parse_args()
        if len(self.argv) < 1:
            return parser.print_help()

        # populate the nodes metadata with the configured nodes
        for daemon in ceph_medic.config['nodes'].keys():
            ceph_medic.metadata['nodes'][daemon] = []
        for daemon, nodes in ceph_medic.config['nodes'].items():
            for node in nodes:
                ceph_medic.metadata['nodes'][daemon].append(
                    {'host': node['host']})

        collector.collect()
        test = runner.Runner()
        results = test.run()
        runner.report(results)
Пример #6
0
 def test_ignores_unknown_group(self):
     metadata["nodes"] = dict(test=[])
     # raises a RuntimeError because all nodes fail to connect
     with pytest.raises(RuntimeError):
         collector.collect()