Merge pull request #157 from corey-hammerton/inventory
puppetboard/app.py: Optimizing the inventory page
This commit is contained in:
@@ -201,9 +201,6 @@ def inventory():
|
|||||||
# facts indexed by node name
|
# facts indexed by node name
|
||||||
nodelist = set() # a set of node names
|
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
|
# load the list of items/facts we want in our inventory
|
||||||
try:
|
try:
|
||||||
inv_facts = app.config['INVENTORY_FACTS']
|
inv_facts = app.config['INVENTORY_FACTS']
|
||||||
@@ -220,6 +217,13 @@ def inventory():
|
|||||||
fact_desc.append(description)
|
fact_desc.append(description)
|
||||||
fact_names.append(name)
|
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
|
# convert the json in easy to access data structure
|
||||||
for fact in facts:
|
for fact in facts:
|
||||||
factvalues[fact.node,fact.name] = fact.value
|
factvalues[fact.node,fact.name] = fact.value
|
||||||
|
|||||||
Reference in New Issue
Block a user