Exemple #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)
 def test_reports_errors(self, monkeypatch):
     fake_writer = FakeWriter()
     monkeypatch.setattr(runner.terminal, 'write', fake_writer)
     self.results.errors = ['I am an error']
     runner.report(self.results)
     assert 'While running checks, ceph-medic had unhandled errors' in fake_writer.calls[
         -1]
Exemple #3
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)
Exemple #4
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)
Exemple #5
0
 def test_reports_no_errors(self, terminal):
     runner.report(self.results)
     assert terminal.calls[0] == '\n0 passed, on 0 hosts'
Exemple #6
0
 def test_reports_errors(self, terminal):
     self.results.errors = ['I am an error']
     runner.report(self.results)
     assert 'While running checks, ceph-medic had unhandled errors' in terminal.calls[-1]
 def test_reports_no_errors(self, monkeypatch):
     fake_writer = FakeWriter()
     monkeypatch.setattr(runner.terminal, 'write', fake_writer)
     runner.report(self.results)
     assert fake_writer.calls[0] == '\n0 passed, on 0 hosts'
Exemple #8
0
 def test_reports_internal_errors(self, terminal):
     self.results.internal_errors = ['error 1', 'error 2']
     self.results.warnings = 2
     runner.report(self.results)
     assert terminal.calls[
         0] == '\n0 passed, 2 warnings, 2 internal errors, on 0 hosts'
Exemple #9
0
 def test_reports_errors_and_warnings(self, terminal):
     self.results.errors = 2
     self.results.warnings = 2
     runner.report(self.results)
     assert terminal.calls[
         0] == '\n0 passed, 2 errors, 2 warnings, on 0 hosts'
Exemple #10
0
 def test_reports_error_and_warning(self, terminal):
     self.results.errors = 1
     self.results.warnings = 1
     runner.report(self.results)
     assert terminal.calls[
         0] == '\n0 passed, 1 error, 1 warning, on 0 hosts'
Exemple #11
0
 def test_reports_error(self, terminal):
     self.results.errors = 1
     runner.report(self.results)
     assert terminal.calls[0] == '\n0 passed, 1 error, on 0 hosts'