def __discoverAliasInfo(self, scope, db2_home, shell, instance_name=None):
        # get version using db2level
        # User scope:
        # %USERPROFILE%\db2cli.ini
        # System scope:
        # < 9.7
        # <db2 home>\db2cli.ini
        # > 9.7
        # %ALLUSERSPROFILE%\IBM\DB2\<instance name>\CFG\db2cli.ini
        executor = db2_base_shell_discoverer.get_command_executor(shell)
        major, minor = db2_base_shell_discoverer.get_version_by_instance_home(executor, db2_home)
        iniFile = None
        user_path = r"%USERPROFILE%\db2cli.ini"
        system_path = None
        if major == 9 and minor < 7:
            system_path = r"%s\db2cli.ini" % db2_home
        elif major == 9 and minor >= 7 and instance_name:
            system_path = r"%%ALLUSERSPROFILE%%\IBM\DB2\%s\cfg\db2cli.ini" % instance_name

        fs = file_system.createFileSystem(shell)
        if scope == ScopeEnum.USER:
            iniFile = fs.getFileContent(user_path)
        elif scope == ScopeEnum.SYSTEM and system_path:
            iniFile = fs.getFileContent(system_path)

        if iniFile:
            return self.__parse_db2cli_ini(iniFile.content)

        raise flow.DiscoveryException("Cannot parse db2 information for %s" % self._name)
def get_version_by_instance_name(shell, instance_name):
    instance_home = get_instance_home_by_instance_name(shell,
                                                      instance_name)
    executor = base_shell_discoverer.get_command_executor(shell)
    base_shell_discoverer.set_env_by_instance_name(shell, instance_name)
    return base_shell_discoverer.get_version_by_instance_home(executor,
                                                             instance_home)
Example #3
0
    def __discoverAliasInfo(self, scope, db2_home, shell, instance_name=None):
        # get version using db2level
        # User scope:
        # %USERPROFILE%\db2cli.ini
        # System scope:
        # < 9.7
        # <db2 home>\db2cli.ini
        # > 9.7
        # %ALLUSERSPROFILE%\IBM\DB2\<instance name>\CFG\db2cli.ini
        executor = db2_base_shell_discoverer.get_command_executor(shell)
        major, minor = db2_base_shell_discoverer.get_version_by_instance_home(
            executor, db2_home)
        iniFile = None
        user_path = r"%USERPROFILE%\db2cli.ini"
        system_path = None
        if major == 9 and minor < 7:
            system_path = r"%s\db2cli.ini" % db2_home
        elif major == 9 and minor >= 7 and instance_name:
            system_path = r"%%ALLUSERSPROFILE%%\IBM\DB2\%s\cfg\db2cli.ini" % instance_name

        fs = file_system.createFileSystem(shell)
        if scope == ScopeEnum.USER:
            iniFile = fs.getFileContent(user_path)
        elif scope == ScopeEnum.SYSTEM and system_path:
            iniFile = fs.getFileContent(system_path)

        if iniFile:
            return self.__parse_db2cli_ini(iniFile.content)

        raise flow.DiscoveryException("Cannot parse db2 information for %s" %
                                      self._name)
def get_version_by_instance_name(shell, instance_name):
    instance_home = get_instance_home_by_instance_name(shell, instance_name)
    executor = base_shell_discoverer.get_command_executor(shell)
    base_shell_discoverer.set_env_by_instance_name(shell, instance_name)
    return base_shell_discoverer.get_version_by_instance_home(
        executor, instance_home)