Class: RHN::Operation
- Inherits:
-
Object
- Object
- RHN::Operation
- Defined in:
- lib/satops/rhsat.rb
Direct Known Subclasses
Activationkey, Channel, ChannelSoftware, Configchannel, Kickstart, KickstartFilepreservation, KickstartKeys, KickstartProfile, KickstartProfileSoftware, KickstartProfileSystem, KickstartSnippet, Org, OrgTrusts, System, SystemConfig, SystemCustominfo, Systemgroup, User
Instance Method Summary collapse
-
#action(cmd, *args) ⇒ Object
Standard call.
-
#action_list(cmd, *args) ⇒ Object
List call.
- #define(stub, type = nil) ⇒ Object
-
#initialize(sat) ⇒ Operation
constructor
A new instance of Operation.
- #trace_info(*params) ⇒ Object
- #trace_warn(*params) ⇒ Object
Constructor Details
#initialize(sat) ⇒ Operation
Returns a new instance of Operation.
66 67 68 |
# File 'lib/satops/rhsat.rb', line 66 def initialize(sat) @sat=sat end |
Instance Method Details
#action(cmd, *args) ⇒ Object
Standard call
73 74 75 76 77 78 79 80 81 |
# File 'lib/satops/rhsat.rb', line 73 def action(cmd, *args) result=@sat.run(cmd, *args) if result trace_info(cmd, args[0]) else trace_warn(cmd, args[0], @sat.get_exception) end result end |
#action_list(cmd, *args) ⇒ Object
List call
84 85 86 87 88 89 90 91 92 |
# File 'lib/satops/rhsat.rb', line 84 def action_list(cmd, *args) list=Array.new if list=@sat.run(cmd, *args) trace_info(cmd, list.size) else trace_warn(cmd, @sat.get_exception) end list end |
#define(stub, type = nil) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/satops/rhsat.rb', line 94 def define(stub, type=nil) return if stub.nil? stubs=stub.split('.') method_name=stubs[stubs.size-1].to_sym self.class.class_eval do case type when :list define_method(method_name) do |*args| action_list(stub, *args) end when :boolean define_method(method_name) do |*args| if action(stub, *args) == 1 return true else return false end end else define_method(method_name) do |*args| action(stub, *args) end end end end |
#trace_info(*params) ⇒ Object
121 122 123 124 125 |
# File 'lib/satops/rhsat.rb', line 121 def trace_info(*params) str="" params.each { |p| str << "#{p}:" } @sat.log.info("#{@sat.host.login}@#{@sat.host.name}:#{str}") end |
#trace_warn(*params) ⇒ Object
127 128 129 130 131 |
# File 'lib/satops/rhsat.rb', line 127 def trace_warn(*params) str="" params.each { |p| str << "#{p}:" } @sat.log.warn("#{@sat.host.login}@#{@sat.host.name}:#{str}") end |