Foreman api not showing all facts?

Hello,

I have a fresh installation of foreman 1.2 (installed via provided puppet
scripts). I have just added some hosts and now I wish to develop something
to query the facts of these hosts externally (via the api).

I am currently testing with curl, however the 'facts' call doesn't return
all of the facts for my hosts. I am using the following;

curl -u api_user:api_user -H 'Accept:application/json,version=2'
http://foreman/api/hosts/client.fqdn/facts

The output of this command is ('sensitive' information has been removed);

{"client.fqdn":{"macaddress_eth0":"","macaddress":"","bios_release_date":"07/09/2012","augeasversion":"0.9.0","processorcount":"1","physicalprocessorcount":"1","blockdevice_sr0_size":"1073741312","network_lo":"127.0.0.0","ipaddress_lo":"127.0.0.1","network_eth0":"","ipaddress_eth0":"","ipaddress":"","mtu_eth0":"1500","mtu_lo":"16436","facterversion":"1.7.2","rubyversion":"1.8.7","uptime_days":"2","ipaddress6_eth0":"","ipaddress6":"","blockdevice_sda_size":"21474836480"}}

However, if I browse to the host in the foreman UI (as 'api_user') I see
around 100 facts for this host.

I don't understand why I only see a subset of the hosts from the api?

The 'api_user' has 'Viewer' permissions assigned.

Can anyone shed any light on what I am experiencing?

Any hints are much appreciated!

Cheers,

Ben

Hi Ben,

Both the UI and API paginate the results, but but it probably wasn't obvious with the API. For API v2, which still isn't final, I plan to add meta data to the results such as

{
"total": 10,
"limit": 2,
"offset" 3,
"results": [

Then, it will be obvious how much of the results were returned.

You can add URL parameters :page and :per_page, so to get all the facts in one call, you can do this

http://foreman/api/hosts/client.fqdn/facts?per_page=10000

The default per_page can be changed in Settings::General.entries_per_page

Regards,

Joseph Magen
Redhat

¡¡¡ ----- Original Message ----- From: "bmorrice" To: foreman-users@googlegroups.com Sent: Friday, July 26, 2013 6:43:58 PM Subject: [foreman-users] foreman api not showing all facts?

Hello,

I have a fresh installation of foreman 1.2 (installed via provided puppet
scripts). I have just added some hosts and now I wish to develop something
to query the facts of these hosts externally (via the api).

I am currently testing with curl, however the ‘facts’ call doesn’t return
all of the facts for my hosts. I am using the following;

curl -u api_user:api_user -H 'Accept:application/json,version=2’
http://foreman/api/hosts/client.fqdn/facts

The output of this command is (‘sensitive’ information has been removed);

{“client.fqdn”:{“macaddress_eth0”:"",“macaddress”:"",“bios_release_date”:“07/09/2012”,“augeasversion”:“0.9.0”,“processorcount”:“1”,“physicalprocessorcount”:“1”,“blockdevice_sr0_size”:“1073741312”,“network_lo”:“127.0.0.0”,“ipaddress_lo”:“127.0.0.1”,“network_eth0”:"",“ipaddress_eth0”:"",“ipaddress”:"",“mtu_eth0”:“1500”,“mtu_lo”:“16436”,“facterversion”:“1.7.2”,“rubyversion”:“1.8.7”,“uptime_days”:“2”,“ipaddress6_eth0”:"",“ipaddress6”:"",“blockdevice_sda_size”:“21474836480”}}

However, if I browse to the host in the foreman UI (as ‘api_user’) I see
around 100 facts for this host.

I don’t understand why I only see a subset of the hosts from the api?

The ‘api_user’ has ‘Viewer’ permissions assigned.

Can anyone shed any light on what I am experiencing?

Any hints are much appreciated!

Cheers,

Ben

–
You received this message because you are subscribed to the Google Groups “Foreman users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/groups/opt_out.

2 Likes

This is great Joseph. Thank-you for your explanation!

Cheers,

Ben

¡¡¡ On Sunday, 28 July 2013 09:24:37 UTC+2, Joseph Magen wrote: > > Hi Ben, > > Both the UI and API paginate the results, but but it probably wasn't > obvious with the API. For API v2, which still isn't final, I plan to add > meta data to the results such as > > { > "total": 10, > "limit": 2, > "offset" 3, > "results": [ > > Then, it will be obvious how much of the results were returned. > > You can add URL parameters :page and :per_page, so to get all the facts in > one call, you can do this > > http://foreman/api/hosts/client.fqdn/facts?per_page=10000 > > The default per_page can be changed in Settings::General.entries_per_page > > Regards, > > Joseph Magen > Redhat > > > > ----- Original Message ----- > From: "bmorrice" <ben.m...@gmail.com > > To: forema...@googlegroups.com > Sent: Friday, July 26, 2013 6:43:58 PM > Subject: [foreman-users] foreman api not showing all facts? > > Hello, > > I have a fresh installation of foreman 1.2 (installed via provided puppet > scripts). I have just added some hosts and now I wish to develop something > to query the facts of these hosts externally (via the api). > > I am currently testing with curl, however the 'facts' call doesn't return > all of the facts for my hosts. I am using the following; > > curl -u api_user:api_user -H 'Accept:application/json,version=2' > http://foreman/api/hosts/client.fqdn/facts > > The output of this command is ('sensitive' information has been removed); > > {"client.fqdn":{"macaddress_eth0":"","macaddress":"","bios_release_date":"07/09/2012","augeasversion":"0.9.0","processorcount":"1","physicalprocessorcount":"1","blockdevice_sr0_size":"1073741312","network_lo":"127.0.0.0","ipaddress_lo":"127.0.0.1","network_eth0":"","ipaddress_eth0":"","ipaddress":"","mtu_eth0":"1500","mtu_lo":"16436","facterversion":"1.7.2","rubyversion":"1.8.7","uptime_days":"2","ipaddress6_eth0":"","ipaddress6":"","blockdevice_sda_size":"21474836480"}} > > > However, if I browse to the host in the foreman UI (as 'api_user') I see > around 100 facts for this host. > > I don't understand why I only see a subset of the hosts from the api? > > The 'api_user' has 'Viewer' permissions assigned. > > Can anyone shed any light on what I am experiencing? > > Any hints are much appreciated! > > Cheers, > > Ben > > -- > You received this message because you are subscribed to the Google Groups > "Foreman users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to foreman-user...@googlegroups.com . > To post to this group, send email to forema...@googlegroups.com. > > Visit this group at http://groups.google.com/group/foreman-users. > For more options, visit https://groups.google.com/groups/opt_out. > >

Hi,

I have fresh install foreman 1.5.1. I see some hosts in foreman UI does not
show facts, however http://foreman/api/hosts/client.fqdn/facts return the
facts. Not sure why UI does not show facts.

-DD

¡¡¡ On Monday, July 29, 2013 12:02:54 AM UTC-7, bmorrice wrote: > > This is great Joseph. Thank-you for your explanation! > > Cheers, > > Ben > > On Sunday, 28 July 2013 09:24:37 UTC+2, Joseph Magen wrote: >> >> Hi Ben, >> >> Both the UI and API paginate the results, but but it probably wasn't >> obvious with the API. For API v2, which still isn't final, I plan to add >> meta data to the results such as >> >> { >> "total": 10, >> "limit": 2, >> "offset" 3, >> "results": [ >> >> Then, it will be obvious how much of the results were returned. >> >> You can add URL parameters :page and :per_page, so to get all the facts >> in one call, you can do this >> >> http://foreman/api/hosts/client.fqdn/facts?per_page=10000 >> >> The default per_page can be changed in Settings::General.entries_per_page >> >> Regards, >> >> Joseph Magen >> Redhat >> >> >> >> ----- Original Message ----- >> From: "bmorrice" >> To: forema...@googlegroups.com >> Sent: Friday, July 26, 2013 6:43:58 PM >> Subject: [foreman-users] foreman api not showing all facts? >> >> Hello, >> >> I have a fresh installation of foreman 1.2 (installed via provided puppet >> scripts). I have just added some hosts and now I wish to develop >> something >> to query the facts of these hosts externally (via the api). >> >> I am currently testing with curl, however the 'facts' call doesn't return >> all of the facts for my hosts. I am using the following; >> >> curl -u api_user:api_user -H 'Accept:application/json,version=2' >> http://foreman/api/hosts/client.fqdn/facts >> >> The output of this command is ('sensitive' information has been removed); >> >> {"client.fqdn":{"macaddress_eth0":"","macaddress":"","bios_release_date":"07/09/2012","augeasversion":"0.9.0","processorcount":"1","physicalprocessorcount":"1","blockdevice_sr0_size":"1073741312","network_lo":"127.0.0.0","ipaddress_lo":"127.0.0.1","network_eth0":"","ipaddress_eth0":"","ipaddress":"","mtu_eth0":"1500","mtu_lo":"16436","facterversion":"1.7.2","rubyversion":"1.8.7","uptime_days":"2","ipaddress6_eth0":"","ipaddress6":"","blockdevice_sda_size":"21474836480"}} >> >> >> However, if I browse to the host in the foreman UI (as 'api_user') I see >> around 100 facts for this host. >> >> I don't understand why I only see a subset of the hosts from the api? >> >> The 'api_user' has 'Viewer' permissions assigned. >> >> Can anyone shed any light on what I am experiencing? >> >> Any hints are much appreciated! >> >> Cheers, >> >> Ben >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Foreman users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to foreman-user...@googlegroups.com. >> To post to this group, send email to forema...@googlegroups.com. >> Visit this group at http://groups.google.com/group/foreman-users. >> For more options, visit https://groups.google.com/groups/opt_out. >> >>