mirror of
https://github.com/inspec/inspec
synced 2024-11-16 01:38:03 +00:00
IBM Db2 connection failure fix for error Reason Code 3
Signed-off-by: Vasu1105 <vasundhara.jagdale@chef.io>
This commit is contained in:
parent
65852c2970
commit
39432f29e5
2 changed files with 14 additions and 5 deletions
|
@ -29,13 +29,18 @@ module Inspec::Resources
|
||||||
private
|
private
|
||||||
|
|
||||||
def run_command
|
def run_command
|
||||||
|
|
||||||
cmd = inspec.command("#{@db2_executable_file_path} attach to #{@db_instance}\;")
|
cmd = inspec.command("#{@db2_executable_file_path} attach to #{@db_instance}\;")
|
||||||
out = cmd.stdout + "\n" + cmd.stderr
|
out = cmd.stdout + "\n" + cmd.stderr
|
||||||
if cmd.exit_status != 0 || out =~ /Can't connect to IBM Db2 instance/ || out.downcase =~ /^error:.*/
|
# check if following specific error is there. Sourcing the db2profile to resolve the error.
|
||||||
|
if cmd.exit_status != 0 && out =~ /SQL10007N Message "-1390" could not be retrieved. Reason code: "3"/
|
||||||
|
cmd = inspec.command(". ~/sqllib/db2profile\; #{@db2_executable_file_path} attach to #{@db_instance}\; #{@db2_executable_file_path} get database manager configuration")
|
||||||
|
elsif cmd.exit_status != 0 || out =~ /Can't connect to IBM Db2 instance/ || out.downcase =~ /^error:.*/
|
||||||
raise Inspec::Exceptions::ResourceFailed, "IBM Db2 connection error: #{out}"
|
raise Inspec::Exceptions::ResourceFailed, "IBM Db2 connection error: #{out}"
|
||||||
|
else
|
||||||
|
cmd = inspec.command("#{@db2_executable_file_path} get database manager configuration")
|
||||||
end
|
end
|
||||||
|
|
||||||
cmd = inspec.command("#{@db2_executable_file_path} get database manager configuration")
|
|
||||||
out = cmd.stdout + "\n" + cmd.stderr
|
out = cmd.stdout + "\n" + cmd.stderr
|
||||||
if cmd.exit_status != 0 || out =~ /Can't connect to IBM Db2 server/ || out.downcase =~ /^error:.*/
|
if cmd.exit_status != 0 || out =~ /Can't connect to IBM Db2 server/ || out.downcase =~ /^error:.*/
|
||||||
raise Inspec::Exceptions::ResourceFailed, "IBM Db2 query with error: #{out}"
|
raise Inspec::Exceptions::ResourceFailed, "IBM Db2 query with error: #{out}"
|
||||||
|
|
|
@ -38,12 +38,16 @@ module Inspec::Resources
|
||||||
# connect to the db
|
# connect to the db
|
||||||
cmd = inspec.command("#{@db2_executable_file_path} attach to #{@db_instance}\; #{@db2_executable_file_path} connect to #{@db_name}\;")
|
cmd = inspec.command("#{@db2_executable_file_path} attach to #{@db_instance}\; #{@db2_executable_file_path} connect to #{@db_name}\;")
|
||||||
out = cmd.stdout + "\n" + cmd.stderr
|
out = cmd.stdout + "\n" + cmd.stderr
|
||||||
if cmd.exit_status != 0 || out =~ /Can't connect to IBM Db2 / || out.downcase =~ /^error:.*/
|
# check if following specific error is there. Sourcing the db2profile to resolve the error.
|
||||||
|
if cmd.exit_status != 0 && out =~ /SQL10007N Message "-1390" could not be retrieved. Reason code: "3"/
|
||||||
|
cmd = inspec.command(". ~/sqllib/db2profile\; #{@db2_executable_file_path} attach to #{@db_instance}\; #{@db2_executable_file_path} connect to #{@db_name}\; #{@db2_executable_file_path} #{q}\;")
|
||||||
|
elsif cmd.exit_status != 0 || out =~ /Can't connect to IBM Db2 / || out.downcase =~ /^error:.*/
|
||||||
raise Inspec::Exceptions::ResourceFailed, "IBM Db2 connection error: #{out}"
|
raise Inspec::Exceptions::ResourceFailed, "IBM Db2 connection error: #{out}"
|
||||||
end
|
else
|
||||||
|
|
||||||
# query on the database
|
# query on the database
|
||||||
cmd = inspec.command("#{@db2_executable_file_path} #{q}\;")
|
cmd = inspec.command("#{@db2_executable_file_path} #{q}\;")
|
||||||
|
end
|
||||||
|
|
||||||
out = cmd.stdout + "\n" + cmd.stderr
|
out = cmd.stdout + "\n" + cmd.stderr
|
||||||
if cmd.exit_status != 0 || out =~ /Can't connect to IBM Db2 server/ || out.downcase =~ /^error:.*/
|
if cmd.exit_status != 0 || out =~ /Can't connect to IBM Db2 server/ || out.downcase =~ /^error:.*/
|
||||||
raise Inspec::Exceptions::ResourceFailed, "IBM Db2 query with error: #{out}"
|
raise Inspec::Exceptions::ResourceFailed, "IBM Db2 query with error: #{out}"
|
||||||
|
|
Loading…
Reference in a new issue