Module: PuppetX::EnterpriseModules::OraInstall::WindowsCore

Includes:
EasyType::Encryption, EasyType::Template, PuppetX::EnterpriseModules::Oracle::Settings
Included in:
Facts
Defined in:
lib/puppet_x/enterprisemodules/ora_install/windows_core.rb

Overview

docs

Instance Method Summary collapse

Instance Method Details

#execute_sql(db, sql) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/puppet_x/enterprisemodules/ora_install/windows_core.rb', line 17

def execute_sql(db, sql)
  # Execute
  @sid ||= db
  @os_user ||= configuration_value_for(@sid, 'os_user')
  @oracle_home ||= configuration_value_for(@sid, 'oracle_home')
  @os_user_pwd = decrypted_value(configuration_value_for(@sid, 'os_user_pwd'))
  options = { :failonfail => true, :combine => true }
  powershell_command = %(powershell -File "#{powershell_script(sql_script(sql))}")
  Puppet::Util::Execution.execute(powershell_command, options)
end

#powershell_script(sql_script) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/puppet_x/enterprisemodules/ora_install/windows_core.rb', line 40

def powershell_script(sql_script)
  # Generate powershell script
  powershell_file = Tempfile.new(['command', '.ps1'])
  ObjectSpace.undefine_finalizer(powershell_file)
  powershell_content = template('ora_install/ora_install/sqlplus_command.ps1.erb', binding)
  powershell_file.write(powershell_content)
  powershell_file.close
  powershell_file.path
end

#sql_script(sql) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/puppet_x/enterprisemodules/ora_install/windows_core.rb', line 28

def sql_script(sql)
  # Generate sql script
  command_file = Tempfile.new(['command', '.sql'])
  ObjectSpace.undefine_finalizer(command_file)
  command = %(connect / as sysdba
              #{sql})
  content = template('ora_install/ora_install/execute.sql.erb', binding)
  command_file.write(content)
  command_file.close
  command_file.path
end