Feature #1890
closedImplement a host status API call
Description
Currently it is not possible to obtain host status for a particular host via API.
I mean host status like it is displayed in the host list screen:
- out of sync (S)
- building (B)
- active (A)
- no changes (O)
- error (E)
Something like: /hosts/FQDN/status
Updated by Rytis Sileika about 12 years ago
But that only returns puppet report status, ie number of failed modules, stuff like that. It doesn't tell whether node is in "build" state, or haven't checked in for a long time (ie 'out of sync')?
I might be making up things as I speak from memory, can't check it right now - will check the reports/status url output when back in the office....
Updated by Rytis Sileika about 12 years ago
So /hosts/FQDN/reports/last
gives me this:
{"report":
{"host":"FQDN",
"id":409,
"logs":[
{"log":{"messages":
{"message":"Finished catalog run in 3.25 seconds"},
"sources":{"source":"//FQDN/Puppet"}}},
{"log":{"messages":{"message":"Could not intern from pson: source '\"#<Puppet::Node:0x7f' not in PSON!"},
"sources":{"source":"//FQDN/Puppet"}}},
{"log":{"messages":{"message":"Unable to fetch my node definition, but the agent run will continue:"},
"sources":{"source":"//FQDN/Puppet"}}}],
"summary":"Success",
"status":{"skipped":6,
"failed_restarts":0,
"applied":0,
"pending":0,
"restarted":0,
"failed":0},
"reported_at":"2012-10-08T07:21:14Z",
"metrics":{"events":
{"total":0,
"success":0,
"failure":0},
"resources":
{"skipped":6,
"total":23,
"changed":0,
"out_of_sync":0,
"scheduled":0,
"failed_to_restart":0,
"restarted":0,
"failed":0},
"changes":{"total":0},
"time":{"total":4.13812288578796,
"config_retrieval":1.55275988578796,
"exec":0.409399,
"filebucket":0.000166,
"service":1.815179,
"file":0.355286,
"package":0.005333}}}}
Which is perhaps OK for the hosts that are already built. But it does not tell me whether the host is set to be built. If I click on build, all reports are deleted, and I don't even get the info above.
Here's what I wanted to do, may be that would serve as a use case: I want to schedule a periodic host rebuild task:- Create an empty VM object in VMware
- Register in Foreman
- PXE boot
- Wait for the node to finish building
- Do something else with the built VM
So steps 1-3 are easy to implement, but I got stuck at checking when the build is completely finished. There are ways of doing that, but just having a simple API call that would tell me various states (Building, Active, No changes, etc) would be very helpful... :)
Updated by Greg Sutcliffe about 12 years ago
I think there are other good use cases for this as well. For example, it would be trivial to use this to build a set of Nagios checks that report if hosts stay in a certain state too long.
Updated by Joseph Magen about 12 years ago
- Status changed from New to Ready For Testing
- Assignee set to Joseph Magen
I submitted a pull request with status names
https://github.com/theforeman/foreman/pull/315
- missing
- failed
- pending
- changed
- unchanged
- unreported
I don't have a status yet for "building"
Updated by Joseph Magen almost 12 years ago
New status names. Sames is UI hover hints on List of Hosts page.
"Pending Installation"
"Alerts disabled"
"No reports"
"Out of sync"
"Error"
"Active"
"Pending"
"No changes"
Updated by Ohad Levy almost 12 years ago
- Category set to API
- Target version set to 1.1
Updated by Anonymous almost 12 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset 8dc8a9acf0d12e8ad9e57ffbfc981d47707c9f0a.