Module: OraUtils::OracleAccess
- Included in:
- TitleParser, Resources::Generic
- Defined in:
- lib/orabase/utils/oracle_access.rb
Constant Summary collapse
- OS_USER_NAME =
'ASM_OS_USER'
Class Method Summary collapse
Instance Method Summary collapse
- #add_sid_to(elements, sid) ⇒ Object
- #execute_on_sid(sid, command_builder) ⇒ Object
- #sid_from(source) ⇒ Object
- #sid_from_resource ⇒ Object
-
#sql(command, options = {}) ⇒ Object
Use this function to execute Oracle statements.
-
#sql_on(sids, command, parameters = {}) ⇒ Object
Use this function to execute Oracle statements on a set of specfied sids.
-
#sql_on_all_asm_sids(command, parameters = {}) ⇒ Object
Use this function to execute Oracle statements on all running asm sids.
-
#sql_on_all_database_sids(command, parameters = {}) ⇒ Object
Use this function to execute Oracle statements on all running databases.
-
#sql_on_all_sids(command, parameters = {}) ⇒ Object
Use this function to execute Oracle statements on all running sid.
-
#sql_on_sids(sids, command, parameters = {}) ⇒ Object
Run the sql commmand on all specified sids.
-
#timeout_specified ⇒ Object
This is a little hack to get a specified timeout value.
Class Method Details
.included(parent) ⇒ Object
10 11 12 |
# File 'lib/orabase/utils/oracle_access.rb', line 10 def self.included(parent) parent.extend(OracleAccess) end |
Instance Method Details
#add_sid_to(elements, sid) ⇒ Object
105 106 107 |
# File 'lib/orabase/utils/oracle_access.rb', line 105 def add_sid_to(elements, sid) elements.collect{|e| e['SID'] = sid; e} end |
#execute_on_sid(sid, command_builder) ⇒ Object
100 101 102 103 |
# File 'lib/orabase/utils/oracle_access.rb', line 100 def execute_on_sid(sid, command_builder) command_builder..merge!(:sid => sid) nil end |
#sid_from(source) ⇒ Object
123 124 125 126 |
# File 'lib/orabase/utils/oracle_access.rb', line 123 def sid_from(source) oratab = OraUtils::OraTab.new source.sid.empty? ? oratab.default_database_sid : source.sid end |
#sid_from_resource ⇒ Object
118 119 120 |
# File 'lib/orabase/utils/oracle_access.rb', line 118 def sid_from_resource sid_from(resource) end |
#sql(command, options = {}) ⇒ Object
Use this function to execute Oracle statements
92 93 94 95 96 97 98 |
# File 'lib/orabase/utils/oracle_access.rb', line 92 def sql( command, = {}) .merge!(:timeout => self[:timeout]) if timeout_specified @sql = Sql.new() sid = @sql.sid csv_string = @sql.execute(command) add_sid_to(convert_csv_data_to_hash(csv_string, [], :converters=> lambda {|f| f ? f.strip : nil}),sid) end |
#sql_on(sids, command, parameters = {}) ⇒ Object
Use this function to execute Oracle statements on a set of specfied sids
22 23 24 25 26 27 28 |
# File 'lib/orabase/utils/oracle_access.rb', line 22 def sql_on( sids, command, parameters = {}) results = [] sids.each do |sid| results = results + sql(command, {:sid => sid}.merge(parameters)) end results end |
#sql_on_all_asm_sids(command, parameters = {}) ⇒ Object
Use this function to execute Oracle statements on all running asm sids.
51 52 53 54 55 |
# File 'lib/orabase/utils/oracle_access.rb', line 51 def sql_on_all_asm_sids( command, parameters = {}) oratab = OraTab.new sids = oratab.running_asm_sids sql_on_sids(sids, command, parameters) end |
#sql_on_all_database_sids(command, parameters = {}) ⇒ Object
Use this function to execute Oracle statements on all running databases. This excludes asm database
38 39 40 41 42 |
# File 'lib/orabase/utils/oracle_access.rb', line 38 def sql_on_all_database_sids( command, parameters = {}) oratab = OraTab.new sids = oratab.running_database_sids sql_on_sids(sids, command, parameters) end |
#sql_on_all_sids(command, parameters = {}) ⇒ Object
Use this function to execute Oracle statements on all running sid. This includes asm database
65 66 67 68 69 70 |
# File 'lib/orabase/utils/oracle_access.rb', line 65 def sql_on_all_sids( command, parameters = {}) oratab = OraTab.new oratab = OraTab.new sids = oratab.running_sids sql_on_sids(sids, command, parameters) end |
#sql_on_sids(sids, command, parameters = {}) ⇒ Object
Run the sql commmand on all specified sids
76 77 78 79 80 81 82 83 |
# File 'lib/orabase/utils/oracle_access.rb', line 76 def sql_on_sids( sids, command, parameters = {}) results = [] sids.each do |sid| Puppet.debug "executing #{command} on #{sid}" results = results + sql(command, {:sid => sid}.merge(parameters)) end results end |
#timeout_specified ⇒ Object
This is a little hack to get a specified timeout value
110 111 112 113 114 115 116 |
# File 'lib/orabase/utils/oracle_access.rb', line 110 def timeout_specified if respond_to?(:to_hash) to_hash.fetch(:timeout) { nil} # else nil end end |