Foreman hammer plugin help

I'm writing a basic hammer plugin to get facts about hosts. I want to show
different information about hosts than what the default foreman plugins
provide.

I went through some of the documents and am able to get something that
shows host information

output do
field :name, _("Name")
field :ip, _("Ip")
field :owner, _("Owner")
end

A question I have and couldn't find an example for is if there is an easy
way to show host facts. My first thought was I would have to retrieve all
facts about a host and then grep through those facts and show them in the
output. It would be easier if there's a way to reference facts directly
with something like

field :fact[hostname], _("Hostname")

Is this possible? or does someone have an example plugin that does this?

I was looking through the foreman host.rb plugin but still couldn't find an
example of looking up hosts except for facts.rb which attemps to list ALL
facts and not just select facts I want to filter on.

Thanks to stbenjam in irc for helping me with a simple example on how this
works https://gist.github.com/stbenjam/eb523feb1a1d71d7a3af

I have two problems with that example

When calling all_facts =
HammerCLIForeman.foreman_resource!(:fact_values).call(:index, :host_id =>
host_id, :per_page => 99999) I am returned nil and I'm not sure why. I've
tried with satellite 6.1.3 and katello 2.3.0-6

The other problem is when I call param = data['parameters'].find { |param|
param['name'] == 'my_param' } if my_param is inherited from the host group
it is not available because it is not assigned to the host. I know this is
because of the new all_parameters api missing in my version of satellite
and katlelo but I'm curious if that parameter will be used once the
functionality exists in those products.

ยทยทยท On Thursday, December 10, 2015 at 2:47:37 PM UTC-8, Justin Garrison wrote: > > I'm writing a basic hammer plugin to get facts about hosts. I want to show > different information about hosts than what the default foreman plugins > provide. > > I went through some of the documents and am able to get something that > shows host information > > output do > field :name, _("Name") > field :ip, _("Ip") > field :owner, _("Owner") > end > > A question I have and couldn't find an example for is if there is an easy > way to show host facts. My first thought was I would have to retrieve all > facts about a host and then grep through those facts and show them in the > output. It would be easier if there's a way to reference facts directly > with something like > > field :fact[hostname], _("Hostname") > > Is this possible? or does someone have an example plugin that does this? > > I was looking through the foreman host.rb plugin but still couldn't find > an example of looking up hosts except for facts.rb which attemps to list > ALL facts and not just select facts I want to filter on. >