Esempio n. 1
0
def get_mongo_dump_executable(version_info):
    dump_exe = get_mongo_executable(version_info,
                                    'mongodump',
                                    version_check_pref=
                                    VersionPreference.LATEST_MINOR)
    # Warn the user if it is not an exact match (minor match)
    if version_info and version_info != dump_exe.version:
        log_warning("Using mongodump '%s' that does not exactly match "
                    "server version '%s'" % (dump_exe.version, version_info))

    return dump_exe.path
Esempio n. 2
0
def get_mongo_dump_executable(server_version):
    dump_exe = get_mongo_executable(server_version,
                                    'mongodump',
                                    version_check_pref=
                                    VERSION_PREF_EXACT_OR_MINOR)
    # Warn the user if it is not an exact match (minor match)
    if server_version and version_obj(server_version) != dump_exe.version:
        log_warning("Using mongodump '%s' that does not exactly match "
                    "server version '%s'" % (dump_exe.version, server_version))

    return dump_exe.path
Esempio n. 3
0
def get_mongo_dump_executable(server_version):
    dump_exe = get_mongo_executable(
        server_version,
        'mongodump',
        version_check_pref=VERSION_PREF_EXACT_OR_MINOR)
    # Warn the user if it is not an exact match (minor match)
    if server_version and version_obj(server_version) != dump_exe.version:
        log_warning("Using mongodump '%s' that does not exactly match "
                    "server version '%s'" % (dump_exe.version, server_version))

    return dump_exe.path
Esempio n. 4
0
 def timeout_maybe_db_command(self, cmd, dbname):
     try:
         result = self.db_command(cmd, dbname)
         return result
     except Exception, e:
         log_exception(e)
         if "timed out" in str(e):
             log_warning("Command %s is taking a while to complete. "
                         "This is not necessarily bad. " %
                         document_pretty_string(cmd))
         else:
             raise
Esempio n. 5
0
 def timeout_maybe_db_command(self, cmd, dbname):
     try:
         result = self.db_command(cmd, dbname)
         return result
     except Exception, e:
         log_exception(e)
         if "timed out" in str(e):
             log_warning("Command %s is taking a while to complete. "
                         "This is not necessarily bad. " %
                         document_pretty_string(cmd))
         else:
             raise
Esempio n. 6
0
def get_mongo_restore_executable(version_info):
    restore_exe = get_mongo_executable(version_info,
                                       'mongorestore',
                                       version_check_pref=
                                       VERSION_PREF_EXACT_OR_MINOR)
    # Warn the user if it is not an exact match (minor match)
    if version_info and version_info != restore_exe.version:
        log_warning("Using mongorestore '%s' that does not exactly match"
                    "server version '%s'" % (restore_exe.version,
                                             version_info))

    return restore_exe.path
Esempio n. 7
0
def get_mongo_restore_executable(version_info):
    restore_exe = get_mongo_executable(
        version_info,
        'mongorestore',
        version_check_pref=VERSION_PREF_EXACT_OR_MINOR)
    # Warn the user if it is not an exact match (minor match)
    if version_info and version_info != restore_exe.version:
        log_warning("Using mongorestore '%s' that does not exactly match"
                    "server version '%s'" %
                    (restore_exe.version, version_info))

    return restore_exe.path
Esempio n. 8
0
    def get_pid(self):
        pid_file_path = self.get_pid_file_path()
        if os.path.exists(pid_file_path):
            pid_file = open(pid_file_path, 'r')
            pid = pid_file.readline().strip('\n')
            if pid and pid.isdigit():
                return int(pid)
            else:
                log_warning("Unable to determine pid for server '%s'. "
                            "Not a valid number in '%s"'' %
                            (self.id, pid_file_path))
        else:
            log_warning("Unable to determine pid for server '%s'. "
                        "pid file '%s' does not exist" %
                        (self.id, pid_file_path))

        return None
Esempio n. 9
0
    def get_pid(self):
        pid_file_path = self.get_pid_file_path()
        if os.path.exists(pid_file_path):
            pid_file = open(pid_file_path, 'r')
            pid = pid_file.readline().strip('\n')
            if pid and pid.isdigit():
                return int(pid)
            else:
                log_warning("Unable to determine pid for server '%s'. "
                            "Not a valid number in '%s"'' %
                            (self.id, pid_file_path))
        else:
            log_warning("Unable to determine pid for server '%s'. "
                        "pid file '%s' does not exist" %
                        (self.id, pid_file_path))

        return None
Esempio n. 10
0
def get_mongo_restore_executable(version_info):

    version_check_pref = VersionPreference.EXACT_OR_MINOR

    if version_info and version_info.equals_ignore_edition(make_version_info("3.0.7")):
        log_info("Requiring version 3.0.6 instead of 3.0.7 b/c of mongorestore "
                 "bug TOOLS-939")
        version_info = make_version_info("3.0.6", version_info.edition)
        version_check_pref = VersionPreference.EXACT

    restore_exe = get_mongo_executable(version_info,
                                       'mongorestore',
                                       version_check_pref=
                                       version_check_pref)

    # Warn the user if it is not an exact match (minor match)
    if version_info and version_info != restore_exe.version:
        log_warning("Using mongorestore '%s' that does not exactly match"
                    "server version '%s'" % (restore_exe.version,
                                             version_info))

    return restore_exe.path
Esempio n. 11
0
def get_mongo_restore_executable(version_info):

    version_check_pref = VersionPreference.EXACT_OR_MINOR

    if version_info and version_info.equals_ignore_edition(
            make_version_info("3.0.7")):
        log_info(
            "Requiring version 3.0.6 instead of 3.0.7 b/c of mongorestore "
            "bug TOOLS-939")
        version_info = make_version_info("3.0.6", version_info.edition)
        version_check_pref = VersionPreference.EXACT

    restore_exe = get_mongo_executable(version_info,
                                       'mongorestore',
                                       version_check_pref=version_check_pref)

    # Warn the user if it is not an exact match (minor match)
    if version_info and version_info != restore_exe.version:
        log_warning("Using mongorestore '%s' that does not exactly match"
                    "server version '%s'" %
                    (restore_exe.version, version_info))

    return restore_exe.path