Class: PuppetX::EnterpriseModules::OraInstall::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet_x/enterprisemodules/ora_install/command.rb

Overview

docs

Direct Known Subclasses

OpatchCommand, OpatchautoCommand

Constant Summary collapse

DEFAULT_TIMEOUT =

include Settings

300
VALID_OPTIONS =

5 minutes

[
  :os_user,
  :oracle_home,
  :cwd
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(command, options, valid_options = VALID_OPTIONS) ⇒ Command

Returns a new instance of Command.



21
22
23
24
25
# File 'lib/puppet_x/enterprisemodules/ora_install/command.rb', line 21

def initialize(command, options, valid_options = VALID_OPTIONS)
  @valid_options = valid_options
  check_options(options)
  @command = command
end

Instance Method Details

#command_string(arguments = '', command_options) ⇒ Object



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

def command_string(arguments = '', command_options)
  fail 'oracle_home not specfied' unless command_options[:oracle_home]
  fail 'os_user not specified' unless command_options[:os_user]

  oracle_home = command_options[:oracle_home]
  @os_user = command_options[:os_user]
  if Facter.value(:kernel) == 'windows'
    "#{oracle_home}\\OPatch\\#{@command}.bat #{arguments}"
  else
    "su - #{@os_user} -c \"cd #{working_dir(command_options)}; export ORACLE_HOME=#{oracle_home}; export PATH=$PATH:#{oracle_home}/bin:#{oracle_home}/OPatch; #{@command} #{arguments}\""
  end
end

#execute(arguments) ⇒ Object



40
41
42
43
44
# File 'lib/puppet_x/enterprisemodules/ora_install/command.rb', line 40

def execute(arguments)
  options = { :failonfail => true, :combine => true }
  Puppet.debug "Executing #{@command} command: #{arguments} on #{@sid} as #{os_user}, connected as #{username}"
  Puppet::Util::Execution.execute(command_string(arguments), options)
end