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)
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_userhome_by_username(shell, username): r'shellutils.Shell, basestring -> file_system.Path?' pathtool = file_system.getPathToolByShell(shell) safe_executor = fptools.safeFunc( base_shell_discoverer.get_command_executor(shell)) return safe_executor( base_shell_discoverer.GetUserHomeOnUnix(username, pathtool))
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_db2_version(self, context): home_path = self.get_db2_home_path(context) executor = base_shell_discoverer.get_command_executor(context.client) return winshell_discoverer.get_db2_version_by_home_path(executor, home_path)
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)
def get_db2_command_executor(shell, home_path=None): executor = base_shell_discoverer.get_command_executor(shell) return executor
def get_userhome_by_username(shell, username): r'shellutils.Shell, basestring -> file_system.Path?' pathtool = file_system.getPathToolByShell(shell) safe_executor = fptools.safeFunc(base_shell_discoverer.get_command_executor(shell)) return safe_executor(base_shell_discoverer.GetUserHomeOnUnix(username, pathtool))