Class: ForemanMco::Command::Base

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
app/models/foreman_mco/command/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#filtersObject (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

#executeObject



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_proxyObject

Raises:

  • (::Foreman::Exception)


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