Esempio n. 1
0
    def add_arguments(self, parser):
        """Add custom arguments."""
        parser.add_argument("--clean-frequency",
                            help="How much time to wait between two clean.",
                            default=24 * 60 * 60,
                            type=int)
        parser.add_argument("--repair-frequency",
                            help="How much time to wait between two repair.",
                            default=24 * 60 * 60,
                            type=int)
        parser.add_argument("--listen-on",
                            help="Port on which the http server will listen",
                            default=8080,
                            type=int)

        # To avoid to fail to add the same option twice
        old_fn = parser.add_argument

        def add_arg(*args, **kwargs):
            try:
                old_fn(*args, **kwargs)
            except Exception:
                pass

        parser.add_argument = add_arg
        command_repair.CommandRepair.add_arguments(
            command_repair.CommandRepair(), parser)
        command_clean.CommandClean.add_arguments(command_clean.CommandClean(),
                                                 parser)
Esempio n. 2
0
    def _run_clean(self, worker, accessor, opts):
        logging.info("Clean started at %s" % time.strftime("%c"))

        clean = command_clean.CommandClean()
        clean.run(accessor, opts)

        logging.info("Clean finished at %s" % time.strftime("%c"))
        logging.info("Going to sleep for %d seconds" % opts.clean_frequency)
        time.sleep(opts.clean_frequency)
Esempio n. 3
0
    def test_run(self):
        cmd = command_clean.CommandClean()

        parser = argparse.ArgumentParser()
        bg_utils.add_argparse_arguments(parser)
        cmd.add_arguments(parser)
        opts = parser.parse_args([
            '--shard=0',
            '--nshards=5',
            '--clean-cache',
            '--clean-backend',
            '--clean-corrupted',
        ])
        cmd.run(self.accessor, opts)
    def test_run(self):
        cmd = command_clean.CommandClean()

        parser = argparse.ArgumentParser()
        bg_settings.add_argparse_arguments(parser)
        cmd.add_arguments(parser)
        opts = parser.parse_args([
            "--shard=0",
            "--nshards=5",
            "--clean-cache",
            "--clean-backend",
            "--clean-corrupted",
        ])
        cmd.run(self.accessor, opts)
Esempio n. 5
0
    command_delete,
    command_du,
    command_graphite_web,
    command_info,
    command_list,
    command_read,
    command_repair,
    command_shell,
    command_stats,
    command_syncdb,
    command_test,
    command_write,
)

COMMANDS = [
    command_clean.CommandClean(),
    command_copy.CommandCopy(),
    command_daemon.CommandDaemon(),
    command_delete.CommandDelete(),
    command_du.CommandDu(),
    command_graphite_web.CommandGraphiteWeb(),
    command_info.CommandInfo(),
    command_list.CommandList(),
    command_read.CommandRead(),
    command_repair.CommandRepair(),
    command_shell.CommandShell(),
    command_stats.CommandStats(),
    command_syncdb.CommandSyncdb(),
    command_test.CommandTest(),
    command_write.CommandWrite(),
]