def inventory(self, **kwargs): """Get Node and Fact information with an alternative query syntax for structured facts instead of using the facts, fact-contents and factsets endpoints for many fact-related queries. :param \*\*kwargs: The rest of the keyword arguments are passed to the _query function. :returns: A generator yielding Inventory :rtype: :class:`pypuppetdb.types.Inventory` """ inventory = self._query('inventory', **kwargs) for inv in inventory: yield Inventory.create_from_dict(inv)
def inventory(self, **kwargs): """Get Node and Fact information with an alternative query syntax for structured facts instead of using the facts, fact-contents and factsets endpoints for many fact-related queries. :param \*\*kwargs: The rest of the keyword arguments are passed to the _query function. :returns: A generator yielding Inventory :rtype: :class:`pypuppetdb.types.Inventory` """ inventory = self._query('inventory', **kwargs) for inv in inventory: yield Inventory(node=inv['certname'], time=inv['timestamp'], environment=inv['environment'], facts=inv['facts'], trusted=inv['trusted'])
def test_inventory(self): inv = Inventory(node="test1.test.com", environment="production", time='2016-08-18T21:00:00.000Z', facts={ "hostname": "test1.test.com", "domain": "test.com", "puppetversion": "4.6.0" }, trusted={ "authenticated": "remote", "domain": "test.com", "certname": "test1.test.com", "extensions": {}, "hostname": "test1" }) assert inv.node == "test1.test.com" assert inv.environment == "production" assert inv.time == json_to_datetime('2016-08-18T21:00:00.000Z') assert inv.facts == { "hostname": "test1.test.com", "domain": "test.com", "puppetversion": "4.6.0" } assert inv.trusted == { "authenticated": "remote", "domain": "test.com", "certname": "test1.test.com", "extensions": {}, "hostname": "test1" } assert str(inv) == str("test1.test.com") assert str(inv) == str("test1.test.com") assert repr(inv) == str("<Inventory: test1.test.com>")