nedap/pypuppetdb — pull request #18 by juliushaertl (2013-10-29 15:16:06+00:00)
Title: Add nodes_with_status method to v3 api

This method returns queried nodes and adds information on their
status and the events of the latest report. The status is saved
as string and can have the following values:

- unreported
- changed
- unchanged
- failed

A node gets unreported by default after two hours without report.
This can be changed with the `unreported` parameter of the
`nodes_with_status` method.

Node objects now have new instance variables:

- status: containing node status string
- events: dict of event counts as returned from event-counts endpoint
- unreported_time: time since last report as string

Here is an example how to use the new method:
```
failed = []
nodes = db.nodes_with_status()
for node in nodes:
if node.status == 'failed':
failed.append(node)

for node in failed:
print node.name
print node.events['failures']
print "\n"
```