• Loading...

Common Functions

Page description

From version 8.2 ADDM has option that all patterns can import functions from other *.tpl modules. Current page contains descriptions of all common functions, which are used by the pattern modules from Common_Functions.tpl file.

dsn_rdbms_servers

This function returns a list of the related RDBMS SIs by the DSN.

Input variables

  • host - Host node, the pattern is running on.
  • dsn_name - Data Source Name, used by the product

Output variables

  • db_srvs - List of the related RDBM servers. Currently Oracle Database Server, Microsoft SQL Server and IBM DB2 Database Server are supported.

Function functionality

The function queries 'HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\<DSN_NAME>\Driver' registry key and parses the output with the regexes:

RDBMS typeRegular Expression
Oracle Database Serverregex '\\SQORA'
Microsoft SQL Serverregex '\\SQLSRV'
IBM DB2 Database Serverregex '\\DB2CLI'

Then the function deploys approaches, specific to the RDBMS type and searches for related SIs.
The following scenarios are used:

Oracle

If DSN type is 'Oracle Database Server', the function extracts Oracle home from driver key with help of regex:

  • '(?i)^(\w:\\.+)BIN\\SQORA.*\.dll'

Then it reads '<ORACLE_HOME>network\admin\tnsnames.ora' file and extracts DB host and port with respective regexes:

RDBMS attributeRegular Expression
Oracle hostregex '(?is)\s*%global_name%\s*=\s*\(\s*DESCRIPTION.*?HOST\s*=\s*(\S+)\)'
Oracle portregex '(?is)\s*%global_name%\s*=\s*\(\s*DESCRIPTION.*?PORT\s*=\s*(\d+\s*)\)'

Global name, used in above regexes is extracted from the following registry key:

  • 'HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\<DSN_NAME>\ServerName'

DB2

In case of IBM DB2 Database Server, the function launches 'db2cmd -c -i -w db2 list system odbc data sources | findstr /C:"<DSN>"' command to extract DB2 Copy name from its output using regex:

  • '(?i)IBM DB2 ODBC DRIVER - (\S+)'

It then looks for the profile file (db2cli.ini) location in registry:

  • 'HKEY_LOCAL_MACHINE\SOFTWARE\IBM\DB2\InstalledCopies\<COPY_NAME>\PROFILES\<PROFILE_NAME>\DB2INSTPROF'

This file contains DB2 instance alias, which is extracted with help of regular expression:

  • '(?i)%dsn_name%\]\r*\n\s*DBALIAS=(\S+)'

If DB2 alias was successfully obtained, the function runs 'db2cmd -c -i -w db2 list database directory' command, to find related Node name by matching the output against regex:

  • '(?i)Database\salias\s*=\s*%db_alias%(?:\r*\n.*?)+Node\sname\s*=\s*(\S+)'

If successful, the last command 'db2cmd -c -i -w db2 list node directory' is launched to extract database host and port with respective regexes:

RDBMS attributeRegular Expression
DB2 hostregex '(?i)Node\sname\s+=\s+%node_name%(?:\r+\n.+)+?Hostname\s+=\s+(\S+)'
DB2 portregex '(?i)Node\sname\s+=\s+%node_name%(?:\r+\n.+)+?Service\sname\s+=\s+(\d+)'

MS SQL

In case of MS SQL Server, the function queries the following registry key:

  • 'HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\<DSN_NAME>\ServerName'

Then it extracts related RDBM Server instance details:

RDBMS attributeRegular Expression
MSSQL hostregex '(\S+)\\'
MSSQL portregex '\\(\S+)'

If regexes failed to extract the host and instance, the function considers that default MS SQL instance is used and sets key value as DB host. Instance name is set to 'MSSQLSERVER' in this case.

Open Issues

There are no known open issues with this pattern.

TOP


Created by: Alex Kashkevich 19 Apr 2011

Skip to end of metadata
Go to start of metadata
Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.