Class: PuppetX::EnterpriseModules::Oracle::Command
- Inherits:
-
Object
- Object
- PuppetX::EnterpriseModules::Oracle::Command
- Includes:
- Settings
- Defined in:
- lib/puppet_x/enterprisemodules/oracle/command.rb
Overview
docs
Direct Known Subclasses
AcfsutilCommand, AsmcmdCommand, OrapwdCommand, RmanCommand, SqlplusCommand, SrvctlCommand
Instance Attribute Summary collapse
-
#os_user ⇒ Object
readonly
Returns the value of attribute os_user.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#sid ⇒ Object
readonly
Returns the value of attribute sid.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #command_string(arguments = '') ⇒ Object
- #execute(arguments) ⇒ Object
-
#initialize(command, options, valid_options = COMMAND_VALID_OPTIONS) ⇒ Command
constructor
A new instance of Command.
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
Constructor Details
#initialize(command, options, valid_options = COMMAND_VALID_OPTIONS) ⇒ Command
Returns a new instance of Command.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/puppet_x/enterprisemodules/oracle/command.rb', line 27 def initialize(command, , = COMMAND_VALID_OPTIONS) @valid_options = () @command = command @password = [:password] # may be empty @timeout = .fetch(:timeout) { DEFAULT_TIMEOUT } @sid = .fetch(:sid) { raise ArgumentError, 'you need to specify a sid for oracle access' } @os_user = .fetch(:os_user) { configuration_value_for(@sid, 'os_user') } @username = .fetch(:username, nil) end |
Instance Attribute Details
#os_user ⇒ Object (readonly)
Returns the value of attribute os_user.
25 26 27 |
# File 'lib/puppet_x/enterprisemodules/oracle/command.rb', line 25 def os_user @os_user end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
25 26 27 |
# File 'lib/puppet_x/enterprisemodules/oracle/command.rb', line 25 def password @password end |
#sid ⇒ Object (readonly)
Returns the value of attribute sid.
25 26 27 |
# File 'lib/puppet_x/enterprisemodules/oracle/command.rb', line 25 def sid @sid end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
25 26 27 |
# File 'lib/puppet_x/enterprisemodules/oracle/command.rb', line 25 def timeout @timeout end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
25 26 27 |
# File 'lib/puppet_x/enterprisemodules/oracle/command.rb', line 25 def username @username end |
Instance Method Details
#command_string(arguments = '') ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/puppet_x/enterprisemodules/oracle/command.rb', line 38 def command_string(arguments = '') config = @configuration.fetch(@sid) { fail "#{sid} not found in settings" } oracle_home = config.fetch('oracle_home') { fail "oracle_home not specified for #{sid}" } # TODO: what mechanisme do we need for Windows if Puppet::Util::Platform.windows? # TODO: Do we need to set ORACLE_HOME? "cd #{working_dir} & set ORACLE_SID=#{@host_sid} & #{@command} #{arguments}\"" else "su - #{@os_user} -c \"cd #{working_dir}; export ORACLE_SID=#{@sid}; export ORACLE_HOME=#{oracle_home}; export PATH=$PATH:#{oracle_home}/bin; #{@command} #{arguments}\"" end end |
#execute(arguments) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/puppet_x/enterprisemodules/oracle/command.rb', line 50 def execute(arguments) = { :failonfail => true, :combine => true } value = '' within_time(@timeout) do Puppet.debug "command.rb: Executing #{@command} command: #{arguments} on #{@sid} as #{os_user}, connected as #{username}" value = if Puppet::Util::Platform.windows? `command_string(arguments)` else Puppet::Util::Execution.execute(command_string(arguments), ) end end value end |