Merge pull request #157 from corey-hammerton/inventory

puppetboard/app.py: Optimizing the inventory page
This commit is contained in:
Spencer Krum
2015-10-05 18:18:59 -04:00

View File

@@ -201,9 +201,6 @@ def inventory():
# facts indexed by node name
nodelist = set() # a set of node names
# get all the facts from PuppetDB
facts = puppetdb.facts()
# load the list of items/facts we want in our inventory
try:
inv_facts = app.config['INVENTORY_FACTS']
@@ -220,6 +217,13 @@ def inventory():
fact_desc.append(description)
fact_names.append(name)
query = '["or", {0}]'.format(
', '.join('["=", "name", "{0}"]'.format(name)
for name in fact_names))
# get all the facts from PuppetDB
facts = puppetdb.facts(query=query)
# convert the json in easy to access data structure
for fact in facts:
factvalues[fact.node,fact.name] = fact.value