コード例 #1
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)
コード例 #2
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)
コード例 #3
0
ファイル: maxdb_discoverer.py プロジェクト: deezeesms/dd-git
def findDbmCliPath(fs, mainProcessPath):
    '''
    checks existence of dbmcli commands in following paths:
    /sapdb/<SID>/db/pgm/
    /sapdb/<SID>/db/bin/
    /sapdb/programs/bin/
    /sapdb/clients/<SID>/bin/
    Main process "kernel" has following path:
    /sapdb/<SID>/db/pgm/kernel
    @types: file_system.FileSystem, mainProcessPath -> str:

    '''
    if mainProcessPath:
        possibleDbmcliPaths = []
        pathTool = file_system.getPath(fs)
        # expecting /sapdb/<SID>/db/pgm/kernel
        pathList = mainProcessPath.split(fs.FileSeparator)
        if fs._shell.isWinOs():
            dbmCliBin = 'dbmcli.exe'
        else:
            dbmCliBin = 'dbmcli'
        if (len(pathList) >= 5 and pathList[-2] == 'pgm'
                and pathList[-3] == 'db'):
            # get maxDB home dir from kernel process:
            maxDbSid = pathList[-4]
            logger.debug('Found maxDB instance %s from kernel process path' %
                         maxDbSid)
            # get maxDB base dir from kernel process:
            maxDbHomeDir = pathTool.dirName(
                pathTool.dirName(
                    pathTool.dirName(pathTool.dirName(mainProcessPath))))
            logger.debug(
                'Found maxDB home folder %s from kernel process path' %
                maxDbHomeDir)
            possibleDbmcliPaths = (pathTool.join(maxDbHomeDir, maxDbSid, 'db',
                                                 'pgm', dbmCliBin),
                                   pathTool.join(maxDbHomeDir, maxDbSid, 'db',
                                                 'bin', dbmCliBin),
                                   pathTool.join(maxDbHomeDir, 'programs',
                                                 'bin', dbmCliBin),
                                   pathTool.join(maxDbHomeDir, 'clients',
                                                 maxDbSid, 'bin', dbmCliBin))
        else:
            mainProcessPath = pathTool.dirName(mainProcessPath).strip('" ')
            path_ = file_system.Path(mainProcessPath, pathTool) + dbmCliBin
            path_ = shell_interpreter.normalizePath(path_)
            possibleDbmcliPaths = (path_, )

    return findFirst(fs.exists, possibleDbmcliPaths) or __DEFAULT_DBMCLI_PATH
コード例 #4
0
def findDbmCliPath(fs, mainProcessPath):
    """
    checks existence of dbmcli commands in following paths:
    /sapdb/<SID>/db/pgm/
    /sapdb/<SID>/db/bin/
    /sapdb/programs/bin/
    /sapdb/clients/<SID>/bin/
    Main process "kernel" has following path:
    /sapdb/<SID>/db/pgm/kernel
    @types: file_system.FileSystem, mainProcessPath -> str:

    """
    if mainProcessPath:
        possibleDbmcliPaths = []
        pathTool = file_system.getPath(fs)
        # expecting /sapdb/<SID>/db/pgm/kernel
        pathList = mainProcessPath.split(fs.FileSeparator)
        if fs._shell.isWinOs():
            dbmCliBin = "dbmcli.exe"
        else:
            dbmCliBin = "dbmcli"
        if len(pathList) >= 5 and pathList[-2] == "pgm" and pathList[-3] == "db":
            # get maxDB home dir from kernel process:
            maxDbSid = pathList[-4]
            logger.debug("Found maxDB instance %s from kernel process path" % maxDbSid)
            # get maxDB base dir from kernel process:
            maxDbHomeDir = pathTool.dirName(pathTool.dirName(pathTool.dirName(pathTool.dirName(mainProcessPath))))
            logger.debug("Found maxDB home folder %s from kernel process path" % maxDbHomeDir)
            possibleDbmcliPaths = (
                pathTool.join(maxDbHomeDir, maxDbSid, "db", "pgm", dbmCliBin),
                pathTool.join(maxDbHomeDir, maxDbSid, "db", "bin", dbmCliBin),
                pathTool.join(maxDbHomeDir, "programs", "bin", dbmCliBin),
                pathTool.join(maxDbHomeDir, "clients", maxDbSid, "bin", dbmCliBin),
            )
        else:
            mainProcessPath = pathTool.dirName(mainProcessPath).strip('" ')
            path_ = file_system.Path(mainProcessPath, pathTool) + dbmCliBin
            path_ = shell_interpreter.normalizePath(path_)
            possibleDbmcliPaths = (path_,)

    return findFirst(fs.exists, possibleDbmcliPaths) or __DEFAULT_DBMCLI_PATH
コード例 #5
0
def findBinPathBySid(binName, mainProcessPath, dbSid, fs):
    if fs._shell.isWinOs():
        binName = '%s.exe' % binName

    alternatives = ()
    if mainProcessPath:
        pathTool = file_system.getPath(fs)
        maxDbHomePath = getMaxDbHomeDir(mainProcessPath, dbSid)
        if maxDbHomePath:
            alternatives = (file_system.Path(maxDbHomePath, pathTool) +
                            'programs' + 'bin' + binName,
                            file_system.Path(maxDbHomePath, pathTool) +
                            'globalprograms' + 'bin' + binName)
        else:
            mainProcessFolder = pathTool.dirName(mainProcessPath).strip('" ')
            alternatives = (file_system.Path(mainProcessFolder, pathTool) +
                            binName, )

    alternatives = (shell_interpreter.normalizePath(path_)
                    for path_ in alternatives)
    return findFirst(Sfn(fs.exists), alternatives) or binName
コード例 #6
0
def findBinPathBySid(binName, mainProcessPath, dbSid, fs):
    if fs._shell.isWinOs():
        binName = '%s.exe' % binName

    alternatives = ()
    if mainProcessPath:
        pathTool = file_system.getPath(fs)
        maxDbHomePath = getMaxDbHomeDir(mainProcessPath, dbSid)
        if maxDbHomePath:
            alternatives = (
                            file_system.Path(maxDbHomePath, pathTool) + 'programs' + 'bin' + binName,
                            file_system.Path(maxDbHomePath, pathTool) + 'globalprograms' + 'bin' + binName
                            )
        else:
            mainProcessFolder = pathTool.dirName(mainProcessPath).strip('" ')
            alternatives = (
                            file_system.Path(mainProcessFolder, pathTool) + binName,
                            )

    alternatives = (shell_interpreter.normalizePath(path_)
                                        for path_ in alternatives)
    return findFirst(Sfn(fs.exists), alternatives) or binName
コード例 #7
0
def get_version_by_instance_home(executor, instance_home):
    bin_path = compose_db2_bin_path(instance_home)
    cmdline = shell_interpreter.normalizePath(bin_path + Db2Level.BIN_NAME)
    db2level = Db2Level(cmdline)
    return db2level | executor | parse_version_from_db2level_result
コード例 #8
0
def get_version_by_instance_home(executor, instance_home):
    bin_path = compose_db2_bin_path(instance_home)
    cmdline = shell_interpreter.normalizePath(bin_path + Db2Level.BIN_NAME)
    db2level = Db2Level(cmdline)
    return db2level | executor | parse_version_from_db2level_result