summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Reports
diff options
context:
space:
mode:
authorSol Jerome <sol.jerome@gmail.com>2012-04-27 18:51:15 -0500
committerSol Jerome <sol.jerome@gmail.com>2012-04-27 18:56:11 -0500
commit10eb57597eecdb42e931a5f817af58b508e2fff9 (patch)
tree82428c7c080f21e69f3869a3195e7db4979d9123 /src/lib/Bcfg2/Server/Reports
parentc00d0c1d1a57895451bb479bf11a33d59cdf8635 (diff)
downloadbcfg2-10eb57597eecdb42e931a5f817af58b508e2fff9.tar.gz
bcfg2-10eb57597eecdb42e931a5f817af58b508e2fff9.tar.bz2
bcfg2-10eb57597eecdb42e931a5f817af58b508e2fff9.zip
DBStats: Add unpruned entry reporting (#659)
Path type='directory' entries previously had no 'reason' associated with their 'dirty' state. This change adds a database field for unpruned entries which are present in a pruned directory and displays that list in the web reporting interface. There is also a change made to the POSIX client tool which forces it to display the extra entry list when running in interactive mode without debugging enabled. Signed-off-by: Sol Jerome <sol.jerome@gmail.com>
Diffstat (limited to 'src/lib/Bcfg2/Server/Reports')
-rwxr-xr-xsrc/lib/Bcfg2/Server/Reports/importscript.py8
-rw-r--r--src/lib/Bcfg2/Server/Reports/reports/models.py1
-rw-r--r--src/lib/Bcfg2/Server/Reports/reports/templates/config_items/item.html15
-rw-r--r--src/lib/Bcfg2/Server/Reports/reports/templatetags/split.py8
-rw-r--r--src/lib/Bcfg2/Server/Reports/updatefix.py1
5 files changed, 32 insertions, 1 deletions
diff --git a/src/lib/Bcfg2/Server/Reports/importscript.py b/src/lib/Bcfg2/Server/Reports/importscript.py
index ea89c70cd..16df86a9b 100755
--- a/src/lib/Bcfg2/Server/Reports/importscript.py
+++ b/src/lib/Bcfg2/Server/Reports/importscript.py
@@ -40,6 +40,7 @@ from Bcfg2.Bcfg2Py3k import ConfigParser
def build_reason_kwargs(r_ent, encoding, logger):
binary_file = False
sensitive_file = False
+ unpruned_entries = ''
if r_ent.get('sensitive') in ['true', 'True']:
sensitive_file = True
rc_diff = ''
@@ -57,6 +58,10 @@ def build_reason_kwargs(r_ent, encoding, logger):
rc_diff = r_ent.get('current_diff')
else:
rc_diff = ''
+ # detect unmanaged entries in pruned directories
+ if r_ent.get('prune', 'false') == 'true' and r_ent.get('qtest'):
+ unpruned_elist = [e.get('path') for e in r_ent.findall('Prune')]
+ unpruned_entries = "\n".join(unpruned_elist)
if not binary_file:
try:
rc_diff = rc_diff.decode(encoding)
@@ -78,7 +83,8 @@ def build_reason_kwargs(r_ent, encoding, logger):
current_exists=r_ent.get('current_exists', default="True").capitalize() == "True",
current_diff=rc_diff,
is_binary=binary_file,
- is_sensitive=sensitive_file)
+ is_sensitive=sensitive_file,
+ unpruned=unpruned_entries)
def load_stats(cdata, sdata, encoding, vlevel, logger, quick=False, location=''):
diff --git a/src/lib/Bcfg2/Server/Reports/reports/models.py b/src/lib/Bcfg2/Server/Reports/reports/models.py
index d141846a2..0438ea133 100644
--- a/src/lib/Bcfg2/Server/Reports/reports/models.py
+++ b/src/lib/Bcfg2/Server/Reports/reports/models.py
@@ -277,6 +277,7 @@ class Reason(models.Model):
current_diff = models.TextField(max_length=1280, blank=True)
is_binary = models.BooleanField(default=False)
is_sensitive = models.BooleanField(default=False)
+ unpruned = models.TextField(max_length=1280, blank=True)
def _str_(self):
return "Reason"
diff --git a/src/lib/Bcfg2/Server/Reports/reports/templates/config_items/item.html b/src/lib/Bcfg2/Server/Reports/reports/templates/config_items/item.html
index cc99ef503..cadc178a7 100644
--- a/src/lib/Bcfg2/Server/Reports/reports/templates/config_items/item.html
+++ b/src/lib/Bcfg2/Server/Reports/reports/templates/config_items/item.html
@@ -1,4 +1,5 @@
{% extends "base.html" %}
+{% load split %}
{% load syntax_coloring %}
@@ -91,6 +92,20 @@ div.entry_list h3 {
</div>
{% endif %}
+ <!-- display extra directory entries -->
+ {% if item.reason.unpruned %}
+ <div class='entry_list'>
+ <div class='entry_list_head'>
+ <h3>Extra entries found</h3>
+ </div>
+ <table class='entry_list' cellpadding='3'>
+ {% for unpruned_item in item.reason.unpruned|split %}
+ <tr><td>{{ unpruned_item }}</td></tr>
+ {% endfor %}
+ </table>
+ </div>
+ {% endif %}
+
<div class='entry_list'>
<div class='entry_list_head'>
diff --git a/src/lib/Bcfg2/Server/Reports/reports/templatetags/split.py b/src/lib/Bcfg2/Server/Reports/reports/templatetags/split.py
new file mode 100644
index 000000000..a9b4f0371
--- /dev/null
+++ b/src/lib/Bcfg2/Server/Reports/reports/templatetags/split.py
@@ -0,0 +1,8 @@
+from django import template
+register = template.Library()
+
+
+@register.filter
+def split(s):
+ """split by newlines"""
+ return s.split('\n')
diff --git a/src/lib/Bcfg2/Server/Reports/updatefix.py b/src/lib/Bcfg2/Server/Reports/updatefix.py
index 90eaacf89..39fc10b56 100644
--- a/src/lib/Bcfg2/Server/Reports/updatefix.py
+++ b/src/lib/Bcfg2/Server/Reports/updatefix.py
@@ -171,6 +171,7 @@ _fixes = [_merge_database_table_entries,
'alter table reports_reason add is_binary bool NOT NULL default False;',
'alter table reports_reason add is_sensitive bool NOT NULL default False;',
_remove_table_column('reports_interaction', 'client_version'),
+ "alter table reports_reason add unpruned varchar(1280) not null default 'N/A';",
]
# this will calculate the last possible version of the database