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
].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
# File 'lib/puppet_x/enterprisemodules/ora_install/command.rb', line 27

def command_string(arguments = '', command_options)
  if command_options[:oracle_home] && command_options[:os_user]
    oracle_home = command_options[:oracle_home]
    @os_user = command_options[:os_user]
  else
    fail "oracle_home not specfied"              
  end
  "su - #{@os_user} -c \"cd #{working_dir}; export ORACLE_HOME=#{oracle_home}; export PATH=$PATH:#{oracle_home}/bin:#{oracle_home}/OPatch; #{@command} #{arguments}\""
end

#execute(arguments) ⇒ Object



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

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