Class: ForemanMco::Command::Base
- Inherits:
-
Object
- Object
- ForemanMco::Command::Base
- Includes:
- ActiveModel::Validations
- Defined in:
- app/models/foreman_mco/command/base.rb
Direct Known Subclasses
BasePackage, Ping, PuppetDisable, PuppetEnable, PuppetRunOnce, ServiceBase
Instance Attribute Summary collapse
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(attrs = {}) ⇒ Base
constructor
A new instance of Base.
- #mco_proxy ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ Base
Returns a new instance of Base.
6 7 8 |
# File 'app/models/foreman_mco/command/base.rb', line 6 def initialize(attrs = {}) @filters = attrs[:filters] || [] end |
Instance Attribute Details
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
4 5 6 |
# File 'app/models/foreman_mco/command/base.rb', line 4 def filters @filters end |
Instance Method Details
#execute ⇒ Object
10 11 12 13 |
# File 'app/models/foreman_mco/command/base.rb', line 10 def execute response = remote_call ::ForemanMco::CommandStatus.create!(:command => self.to_s, :jid => response.split("/tasks/")[1]) end |
#mco_proxy ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'app/models/foreman_mco/command/base.rb', line 15 def mco_proxy return @mco_proxy if @mco_proxy db_proxy_record = SmartProxy.joins(:features).where("features.name" => "MCollective").first raise ::Foreman::Exception.new(N_("There are no configured mcollective proxies")) unless db_proxy_record @mco_proxy = ForemanMco::McoProxyApi.new(:url => db_proxy_record.url) end |