예제 #1
0
    def _read_engines(self):
        engines_conf = self._get_config_value("engines")
        if not engines_conf:
            raise MBSError("No 'engines' configured")

        engines = self._maker.make(engines_conf)
        return engines
예제 #2
0
    def _read_engines(self):
        engines_conf = self._get_config_value("engines")
        if not engines_conf:
            raise MBSError("No 'engines' configured")

        engines = self._maker.make(engines_conf)
        for engine in engines:
            engine.notification_handler = self._notification_handler

        return engines
예제 #3
0
    def dump_backup(self,
                    backup,
                    uri,
                    destination,
                    log_file_name,
                    options=None):
        mongoctl_exe = which("mongoctl")
        if not mongoctl_exe:
            raise MBSError("mongoctl exe not found in PATH")

        dump_cmd = [
            mongoctl_exe, "--noninteractive", "dump", uri, "-o", destination
        ]

        if options:
            dump_cmd.extend(options)

        dump_cmd_display = dump_cmd[:]
        # mask mongo uri
        dump_cmd_display[3] = mask_mongo_uri(uri)

        logger.info("Running dump command: %s" % " ".join(dump_cmd_display))

        workspace = self.get_task_workspace_dir(backup)
        log_path = os.path.join(workspace, destination, log_file_name)
        last_error_line = {"line": ""}

        def capture_last_error(line):
            if is_mongo_error_log_line(line):
                last_error_line["line"] = line

        # execute dump command
        return_code = execute_command_wrapper(dump_cmd,
                                              cwd=workspace,
                                              output_path=log_path,
                                              on_output=capture_last_error)

        # raise an error if return code is not 0
        if return_code:
            errors.raise_dump_error(return_code, last_error_line["line"])
예제 #4
0
 def get_engine(self, engine_id):
     engine = filter(lambda eng: eng.id == engine_id, self.engines)
     if engine:
         return engine[0]
     else:
         raise MBSError("No such engine '%s'" % engine_id)