def get_local_databases(executor,
                        shell_interpreter,
                        instance_name,
                        db2_home_path=None):
    multiple_db2_instances = GeneralSettingsConfigFile.getInstance(
    ).getPropertyBooleanValue('multipleDB2Instances', 0)
    if multiple_db2_instances:
        file_name = '/tmp/ucmdb-temp-shell-' + str(int(
            time.time() * 1000)) + '.sh'
        db2cmdline = base_shell_discoverer.Db2.BIN_NAME
        if db2_home_path:
            db2path = base_shell_discoverer.compose_db2_bin_path(
                db2_home_path) + db2cmdline
            db2cmdline = shell_interpreter.getEnvironment().normalizePath(
                db2path)
        db2cmdline = '\'%s list db directory\'' % db2cmdline
        sh_db2cmdline = 'sh ' + file_name
        try:
            save_cmd_to_file(db2cmdline, file_name, executor)
            return base_shell_discoverer.get_local_databases(
                executor, shell_interpreter, instance_name, db2_home_path,
                sh_db2cmdline)
        except:
            return base_shell_discoverer.get_local_databases(
                executor, shell_interpreter, instance_name, db2_home_path)
        finally:
            try:
                remove_file(file_name, executor)
            except:
                logger.debug("Failed to remove temp file %s" % file_name)
    else:
        return base_shell_discoverer.get_local_databases(
            executor, shell_interpreter, instance_name, db2_home_path)
    def wrapper(executor, *args, **kwargs):
        db2_home_path = kwargs.get('db2_home_path')
        cmdline = None
        if db2_home_path:
            bin_path = compose_db2_bin_path(db2_home_path)
            bin_name = Db2Cmd.BIN_NAME
            cmdline = shell_interpreter.normalizePath(bin_path + bin_name)

        db2cmd = Db2Cmd(cmdline).c.w.i
        executor = command.ChainedCmdlet(db2cmd, executor)
        return original_fn(executor, *args, **kwargs)
Beispiel #3
0
    def wrapper(executor, *args, **kwargs):
        db2_home_path = kwargs.get('db2_home_path')
        cmdline = None
        if db2_home_path:
            bin_path = compose_db2_bin_path(db2_home_path)
            bin_name = Db2Cmd.BIN_NAME
            cmdline = shell_interpreter.normalizePath(bin_path + bin_name)

        db2cmd = Db2Cmd(cmdline).c.w.i
        executor = command.ChainedCmdlet(db2cmd, executor)
        return original_fn(executor, *args, **kwargs)
def get_local_databases(executor, shell_interpreter, instance_name, db2_home_path=None):
    multiple_db2_instances = GeneralSettingsConfigFile.getInstance().getPropertyBooleanValue('multipleDB2Instances', 0)
    if multiple_db2_instances:
        file_name = '/tmp/ucmdb-temp-shell-' + str(int(time.time() * 1000)) + '.sh'
        db2cmdline = base_shell_discoverer.Db2.BIN_NAME
        if db2_home_path:
            db2path = base_shell_discoverer.compose_db2_bin_path(db2_home_path) + db2cmdline
            db2cmdline = shell_interpreter.getEnvironment().normalizePath(db2path)
        db2cmdline = '\'%s list db directory\'' % db2cmdline
        sh_db2cmdline = 'sh ' + file_name
        try:
            save_cmd_to_file(db2cmdline, file_name, executor)
            return base_shell_discoverer.get_local_databases(executor, shell_interpreter, instance_name, db2_home_path, sh_db2cmdline)
        except:
            return base_shell_discoverer.get_local_databases(executor, shell_interpreter, instance_name, db2_home_path)
        finally:
            try:
                remove_file(file_name, executor)
            except:
                logger.debug("Failed to remove temp file %s" % file_name)
    else:
        return base_shell_discoverer.get_local_databases(executor, shell_interpreter, instance_name, db2_home_path)