Class: Actions::ForemanVirtWhoConfigure::Config::Report

Inherits:
EntryAction
  • Object
show all
Defined in:
app/lib/actions/foreman_virt_who_configure/config/report.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.subscribeObject



7
8
9
# File 'app/lib/actions/foreman_virt_who_configure/config/report.rb', line 7

def self.subscribe
  Actions::Katello::Host::HypervisorsUpdate
end

Instance Method Details

#plan(hypervisors) ⇒ Object



11
12
13
# File 'app/lib/actions/foreman_virt_who_configure/config/report.rb', line 11

def plan(hypervisors)
  plan_self(:hypervisors => hypervisors) if User.current.try(:id)
end

#runObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/lib/actions/foreman_virt_who_configure/config/report.rb', line 15

def run
  # this is how we could do mapping to hypervisor hosts based on UUID provided by candelpin
  # input['hypervisors'].each do |hv_attrs|
  #   # should always exist, Actions::Katello::Host::HypervisorsUpdate should create it
  #   # but we should be careful anyway
  #   hypervisor = ::Host.joins(:subscription_facet).where(:'katello_subscription_facets.uuid' => hv_attrs['uuid']).first
  # end
  configs = ::ForemanVirtWhoConfigure::ServiceUser.find_by_user_id(User.current.id).try(:configs)
  configs&.each do |config|
    config.virt_who_touch!
  end

  # if config was not found, the report is coming from unknown virt-who reporter, we could create a notification
  # that this plugin can be used for configuration

  # this could be used for mapping to existing compute resource
  # config.hypervisor_server
end