Class: PuppetX::EnterpriseModules::Oracle::OrapwdCommand

Inherits:
Command
  • Object
show all
Includes:
EasyType::Encryption, EasyType::Template, Settings
Defined in:
lib/puppet_x/enterprisemodules/oracle/orapwd_command.rb

Overview

docs

Instance Attribute Summary

Attributes inherited from Command

#os_user, #password, #sid, #timeout, #username

Instance Method Summary collapse

Methods included from Settings

#asm_sid?, #asm_sids, #configuration, #configuration_for, #configuration_value_for, #container_db?, #database_sid?, #database_sids, #default_asm_sid, #default_database_sid, #default_sids, included, #local_pdb?, #mgmt_sid?, #mgmt_sids, #normal_db?, #num_default_asm_sids, #num_default_database_sids, #read_from_yaml, #registered_sids, #remote_sid?, #running_asm_sids, #running_database_sids, #running_db?, #running_mgmt_sids, #running_mt_database_sids, #running_nopdb_database_sids, #running_normal_database_sids, #running_pdb?, #running_primary_database_sids, #running_sids, #settings_file, #valid_asm_sid?, #valid_database_sid, #valid_sid?

Methods included from Information

#cached_sid_value, #cluster?, #cluster_instances, #containerdb?, #database_properties, #database_version, #db_create_file_dest, #db_domain, #db_for, #diagnostic_dest, included, #local_sid_for_db, #open_pdbs, #oracle_major_version, #oracle_managed_files_enabled?, #pdb?, #primary?, #rootdb?, #seeddb?, #sid_for, #value_for_init_param

Methods inherited from Command

#command_string

Constructor Details

#initialize(options = {}) ⇒ OrapwdCommand

Returns a new instance of OrapwdCommand.



19
20
21
# File 'lib/puppet_x/enterprisemodules/oracle/orapwd_command.rb', line 19

def initialize(options = {})
  super(:orapwd, options)
end

Instance Method Details

#execute(arguments) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/puppet_x/enterprisemodules/oracle/orapwd_command.rb', line 33

def execute(arguments)
  options = { :failonfail => true, :combine => true }
  value = ''
  if Puppet::Util::Platform.windows?
    @oracle_home = configuration_value_for(@sid, 'oracle_home')
    @os_user_pwd = decrypted_value(configuration_value_for(@sid, 'os_user_pwd'))
    @executable = "#{@oracle_home}\\bin\\orapwd.exe"
    @arguments = arguments
    command = %(powershell -File "#{powershell_script}")
  else
    command = command_string(arguments)
  end
  within_time(@timeout) do
    if Puppet::Util::Platform.windows?
      Puppet.debug "orapwd_command.rb: Executing command: #{@command} #{@arguments} as #{@os_user}"
    else
      Puppet.debug "orapwd_command.rb: Executing #{@command} command: #{arguments} as #{os_user}"
    end
    value = Puppet::Util::Execution.execute(command, options)
  end
  value
end

#powershell_scriptObject



23
24
25
26
27
28
29
30
31
# File 'lib/puppet_x/enterprisemodules/oracle/orapwd_command.rb', line 23

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