puppetboard: Reloading the available environments on every page load.
Moving the global environment list from a global context to a functional context because octomike reported that the environment list in his environment was not being refreshed. Adding CHANGELOG entries for 0.1.1 and this new change.
This commit is contained in:
@@ -4,6 +4,20 @@ Changelog
|
|||||||
|
|
||||||
This is the changelog for Puppetboard.
|
This is the changelog for Puppetboard.
|
||||||
|
|
||||||
|
0.1.2
|
||||||
|
====
|
||||||
|
|
||||||
|
* Add configuration option to set the default environment, defaults to
|
||||||
|
'production' (https://github.com/puppet-community/puppetboard/pull/185)
|
||||||
|
* Loading all available environments with every page load. (Issue:
|
||||||
|
https://github.com/puppet-community/puppetboard/issues/186)
|
||||||
|
|
||||||
|
0.1.1
|
||||||
|
====
|
||||||
|
|
||||||
|
* Fix bug where the reports template was not generating the report links
|
||||||
|
with the right environment
|
||||||
|
|
||||||
0.1.0
|
0.1.0
|
||||||
====
|
====
|
||||||
|
|
||||||
|
|||||||
@@ -78,15 +78,13 @@ def environments():
|
|||||||
|
|
||||||
return x
|
return x
|
||||||
|
|
||||||
def check_env(env):
|
def check_env(env, envs):
|
||||||
if env != '*' and env not in envs:
|
if env != '*' and env not in envs:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
app.jinja_env.globals['url_for_pagination'] = url_for_pagination
|
app.jinja_env.globals['url_for_pagination'] = url_for_pagination
|
||||||
app.jinja_env.globals['url_for_environments'] = url_for_environments
|
app.jinja_env.globals['url_for_environments'] = url_for_environments
|
||||||
|
|
||||||
envs = environments()
|
|
||||||
|
|
||||||
@app.context_processor
|
@app.context_processor
|
||||||
def utility_processor():
|
def utility_processor():
|
||||||
def now(format='%m/%d/%Y %H:%M:%S'):
|
def now(format='%m/%d/%Y %H:%M:%S'):
|
||||||
@@ -131,7 +129,8 @@ def index(env):
|
|||||||
:param env: Search for nodes in this (Catalog and Fact) environment
|
:param env: Search for nodes in this (Catalog and Fact) environment
|
||||||
:type env: :obj:`string`
|
:type env: :obj:`string`
|
||||||
"""
|
"""
|
||||||
check_env(env)
|
envs = environments()
|
||||||
|
check_env(env, envs)
|
||||||
|
|
||||||
# TODO: Would be great if we could parallelize this somehow, doing these
|
# TODO: Would be great if we could parallelize this somehow, doing these
|
||||||
# requests in sequence is rather pointless.
|
# requests in sequence is rather pointless.
|
||||||
@@ -212,7 +211,8 @@ def nodes(env):
|
|||||||
:param env: Search for nodes in this (Catalog and Fact) environment
|
:param env: Search for nodes in this (Catalog and Fact) environment
|
||||||
:type env: :obj:`string`
|
:type env: :obj:`string`
|
||||||
"""
|
"""
|
||||||
check_env(env)
|
envs = environments()
|
||||||
|
check_env(env, envs)
|
||||||
|
|
||||||
if env == '*':
|
if env == '*':
|
||||||
query = None
|
query = None
|
||||||
@@ -255,7 +255,8 @@ def inventory(env):
|
|||||||
:param env: Search for facts in this environment
|
:param env: Search for facts in this environment
|
||||||
:type env: :obj:`string`
|
:type env: :obj:`string`
|
||||||
"""
|
"""
|
||||||
check_env(env)
|
envs = environments()
|
||||||
|
check_env(env, envs)
|
||||||
|
|
||||||
fact_desc = [] # a list of fact descriptions to go
|
fact_desc = [] # a list of fact descriptions to go
|
||||||
# in the table header
|
# in the table header
|
||||||
@@ -327,7 +328,8 @@ def node(env, node_name):
|
|||||||
:param env: Ensure that the node, facts and reports are in this environment
|
:param env: Ensure that the node, facts and reports are in this environment
|
||||||
:type env: :obj:`string`
|
:type env: :obj:`string`
|
||||||
"""
|
"""
|
||||||
check_env(env)
|
envs = environments()
|
||||||
|
check_env(env, envs)
|
||||||
|
|
||||||
if env == '*':
|
if env == '*':
|
||||||
query = '["=", "certname", "{0}"]]'.format(node_name)
|
query = '["=", "certname", "{0}"]]'.format(node_name)
|
||||||
@@ -380,7 +382,8 @@ def reports(env, page):
|
|||||||
and this value
|
and this value
|
||||||
:type page: :obj:`int`
|
:type page: :obj:`int`
|
||||||
"""
|
"""
|
||||||
check_env(env)
|
envs = environments()
|
||||||
|
check_env(env, envs)
|
||||||
|
|
||||||
if env == '*':
|
if env == '*':
|
||||||
reports_query = None
|
reports_query = None
|
||||||
@@ -444,7 +447,8 @@ def reports_node(env, node_name, page):
|
|||||||
and this value
|
and this value
|
||||||
:type page: :obj:`int`
|
:type page: :obj:`int`
|
||||||
"""
|
"""
|
||||||
check_env(env)
|
envs = environments()
|
||||||
|
check_env(env, envs)
|
||||||
|
|
||||||
if env == '*':
|
if env == '*':
|
||||||
query = '["=", "certname", "{0}"]]'.format(node_name)
|
query = '["=", "certname", "{0}"]]'.format(node_name)
|
||||||
@@ -502,7 +506,8 @@ def report_latest(env, node_name):
|
|||||||
:param node_name: Find the reports whose certname match this value
|
:param node_name: Find the reports whose certname match this value
|
||||||
:type node_name: :obj:`string`
|
:type node_name: :obj:`string`
|
||||||
"""
|
"""
|
||||||
check_env(env)
|
envs = environments()
|
||||||
|
check_env(env, envs)
|
||||||
|
|
||||||
if env == '*':
|
if env == '*':
|
||||||
query='["and",' \
|
query='["and",' \
|
||||||
@@ -544,7 +549,8 @@ def report(env, node_name, report_id):
|
|||||||
report
|
report
|
||||||
:type report_id: :obj:`string`
|
:type report_id: :obj:`string`
|
||||||
"""
|
"""
|
||||||
check_env(env)
|
envs = environments()
|
||||||
|
check_env(env, envs)
|
||||||
|
|
||||||
if env == '*':
|
if env == '*':
|
||||||
query = '["and", ["=", "certname", "{0}"],' \
|
query = '["and", ["=", "certname", "{0}"],' \
|
||||||
@@ -581,7 +587,8 @@ def facts(env):
|
|||||||
sake
|
sake
|
||||||
:type env: :obj:`string`
|
:type env: :obj:`string`
|
||||||
"""
|
"""
|
||||||
check_env(env)
|
envs = environments()
|
||||||
|
check_env(env, envs)
|
||||||
|
|
||||||
facts_dict = collections.defaultdict(list)
|
facts_dict = collections.defaultdict(list)
|
||||||
facts = get_or_abort(puppetdb.fact_names)
|
facts = get_or_abort(puppetdb.fact_names)
|
||||||
@@ -609,7 +616,8 @@ def fact(env, fact):
|
|||||||
:param fact: Find all facts with this name
|
:param fact: Find all facts with this name
|
||||||
:type fact: :obj:`string`
|
:type fact: :obj:`string`
|
||||||
"""
|
"""
|
||||||
check_env(env)
|
envs = environments()
|
||||||
|
check_env(env, envs)
|
||||||
|
|
||||||
# we can only consume the generator once, lists can be doubly consumed
|
# we can only consume the generator once, lists can be doubly consumed
|
||||||
# om nom nom
|
# om nom nom
|
||||||
@@ -643,7 +651,8 @@ def fact_value(env, fact, value):
|
|||||||
:param value: Filter facts whose value is equal to this
|
:param value: Filter facts whose value is equal to this
|
||||||
:type value: :obj:`string`
|
:type value: :obj:`string`
|
||||||
"""
|
"""
|
||||||
check_env(env)
|
envs = environments()
|
||||||
|
check_env(env, envs)
|
||||||
|
|
||||||
if env == '*':
|
if env == '*':
|
||||||
query = None
|
query = None
|
||||||
@@ -676,7 +685,8 @@ def query(env):
|
|||||||
select field in the environment block
|
select field in the environment block
|
||||||
:type env: :obj:`string`
|
:type env: :obj:`string`
|
||||||
"""
|
"""
|
||||||
check_env(env)
|
envs = environments()
|
||||||
|
check_env(env, envs)
|
||||||
|
|
||||||
if app.config['ENABLE_QUERY']:
|
if app.config['ENABLE_QUERY']:
|
||||||
form = QueryForm()
|
form = QueryForm()
|
||||||
@@ -712,7 +722,8 @@ def metrics(env):
|
|||||||
for the environments template block
|
for the environments template block
|
||||||
:type env: :obj:`string`
|
:type env: :obj:`string`
|
||||||
"""
|
"""
|
||||||
check_env(env)
|
envs = environments()
|
||||||
|
check_env(env, envs)
|
||||||
|
|
||||||
metrics = get_or_abort(puppetdb._query, 'mbean')
|
metrics = get_or_abort(puppetdb._query, 'mbean')
|
||||||
for key, value in metrics.items():
|
for key, value in metrics.items():
|
||||||
@@ -732,7 +743,8 @@ def metric(env, metric):
|
|||||||
for the environments template block
|
for the environments template block
|
||||||
:type env: :obj:`string`
|
:type env: :obj:`string`
|
||||||
"""
|
"""
|
||||||
check_env(env)
|
envs = environments()
|
||||||
|
check_env(env, envs)
|
||||||
|
|
||||||
name = unquote(metric)
|
name = unquote(metric)
|
||||||
metric = puppetdb.metric(metric)
|
metric = puppetdb.metric(metric)
|
||||||
@@ -751,7 +763,8 @@ def catalogs(env):
|
|||||||
:param env: Find the nodes with this catalog_environment value
|
:param env: Find the nodes with this catalog_environment value
|
||||||
:type env: :obj:`string`
|
:type env: :obj:`string`
|
||||||
"""
|
"""
|
||||||
check_env(env)
|
envs = environments()
|
||||||
|
check_env(env, envs)
|
||||||
|
|
||||||
if app.config['ENABLE_CATALOG']:
|
if app.config['ENABLE_CATALOG']:
|
||||||
nodenames = []
|
nodenames = []
|
||||||
@@ -806,7 +819,8 @@ def catalog_node(env, node_name):
|
|||||||
:param env: Find the catalog with this environment value
|
:param env: Find the catalog with this environment value
|
||||||
:type env: :obj:`string`
|
:type env: :obj:`string`
|
||||||
"""
|
"""
|
||||||
check_env(env)
|
envs = environments()
|
||||||
|
check_env(env, envs)
|
||||||
|
|
||||||
if app.config['ENABLE_CATALOG']:
|
if app.config['ENABLE_CATALOG']:
|
||||||
catalog = get_or_abort(puppetdb.catalog,
|
catalog = get_or_abort(puppetdb.catalog,
|
||||||
@@ -831,7 +845,8 @@ def catalog_submit(env):
|
|||||||
catalogs page with the right environment.
|
catalogs page with the right environment.
|
||||||
:type env: :obj:`string`
|
:type env: :obj:`string`
|
||||||
"""
|
"""
|
||||||
check_env(env)
|
envs = environments()
|
||||||
|
check_env(env, envs)
|
||||||
|
|
||||||
if app.config['ENABLE_CATALOG']:
|
if app.config['ENABLE_CATALOG']:
|
||||||
form = CatalogForm(request.form)
|
form = CatalogForm(request.form)
|
||||||
@@ -859,7 +874,8 @@ def catalog_compare(env, compare, against):
|
|||||||
:param env: Ensure that the 2 catalogs are in the same environment
|
:param env: Ensure that the 2 catalogs are in the same environment
|
||||||
:type env: :obj:`string`
|
:type env: :obj:`string`
|
||||||
"""
|
"""
|
||||||
check_env(env)
|
envs = environments()
|
||||||
|
check_env(env, envs)
|
||||||
|
|
||||||
if app.config['ENABLE_CATALOG']:
|
if app.config['ENABLE_CATALOG']:
|
||||||
compare_cat = get_or_abort(puppetdb.catalog,
|
compare_cat = get_or_abort(puppetdb.catalog,
|
||||||
|
|||||||
Reference in New Issue
Block a user