From d80879415ba4f2b8697d9e2809f3b9e4f0cb159c Mon Sep 17 00:00:00 2001 From: Tim Laszlo Date: Tue, 19 Oct 2010 11:45:53 -0500 Subject: web_reports: determine static prefix automatically --- misc/bcfg2.spec | 54 +++++++++++++++++++++- src/lib/Server/Reports/reports/templates/base.html | 16 ++++--- .../Reports/reports/templatetags/bcfg2_tags.py | 35 ++++++++++++++ 3 files changed, 96 insertions(+), 9 deletions(-) diff --git a/misc/bcfg2.spec b/misc/bcfg2.spec index 72008435a..c38e52c3b 100644 --- a/misc/bcfg2.spec +++ b/misc/bcfg2.spec @@ -13,7 +13,7 @@ %define lxmldep %(rpm -q %{alt_lxml} 2>&1 > /dev/null && echo %{alt_lxml} || echo %{dfl_lxml}) Name: bcfg2 -Version: 1.1.0 +Version: 1.2.0 Release: %{release} Summary: Configuration management system @@ -93,6 +93,39 @@ systems are constantly changing; if required in your environment, Bcfg2 can enable the construction of complex change management and deployment strategies. +%package -n bcfg2-web +Version: %{version} +Summary: Bcfg2 Web Reporting Interface +Group: System Tools +Requires: bcfg2-server +Requires: httpd,mod_wsgi,Django + +%description -n bcfg2-web +Bcfg2 helps system administrators produce a consistent, reproducible, +and verifiable description of their environment, and offers +visualization and reporting tools to aid in day-to-day administrative +tasks. It is the fifth generation of configuration management tools +developed in the Mathematics and Computer Science Division of Argonne +National Laboratory. + +It is based on an operational model in which the specification can be +used to validate and optionally change the state of clients, but in a +feature unique to bcfg2 the client's response to the specification can +also be used to assess the completeness of the specification. Using +this feature, bcfg2 provides an objective measure of how good a job an +administrator has done in specifying the configuration of client +systems. Bcfg2 is therefore built to help administrators construct an +accurate, comprehensive specification. + +Bcfg2 has been designed from the ground up to support gentle +reconciliation between the specification and current client states. It +is designed to gracefully cope with manual system modifications. + +Finally, due to the rapid pace of updates on modern networks, client +systems are constantly changing; if required in your environment, +Bcfg2 can enable the construction of complex change management and +deployment strategies. + %prep %setup -q -n bcfg2-%{version} @@ -117,6 +150,11 @@ deployment strategies. %{__install} -m 755 debian/bcfg2.cron.hourly %{buildroot}%{_sysconfdir}/cron.hourly/bcfg2 %{__install} -m 755 tools/bcfg2-cron %{buildroot}%{_prefix}/lib/bcfg2/bcfg2-cron +%if "%{_vendor}" == "redhat" +%{__install} -d %{buildroot}%{_sysconfdir}/httpd/conf.d +%{__install} -m 644 misc/apache/bcfg2.conf %{buildroot}%{_sysconfdir}/httpd/conf.d/bcfg2.conf +%endif + %clean [ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot} || exit 2 @@ -147,7 +185,10 @@ deployment strategies. %{python_sitelib}/*egg-info %endif -%{_datadir}/bcfg2 +%dir %{_datadir}/bcfg2 +%{_datadir}/bcfg2/Hostbase +%{_datadir}/bcfg2/schemas +%{_datadir}/bcfg2/xsl-transforms %config(noreplace) %{_sysconfdir}/default/bcfg2-server %{_sbindir}/bcfg2-admin %{_sbindir}/bcfg2-build-reports @@ -160,6 +201,15 @@ deployment strategies. %{_mandir}/man8/*.8* %dir %{_prefix}/lib/bcfg2 +%files -n bcfg2-web +%defattr(-,root,root,-) + +%{_datadir}/bcfg2/site_media + +%if "%{_vendor}" == "redhat" +%config(noreplace) %{_sysconfdir}/httpd/conf.d/bcfg2.conf +%endif + %changelog * Mon Jun 21 2010 Fabian Affolter - 1.1.0rc3-0.1 - Changed source0 in order that it works with spectool diff --git a/src/lib/Server/Reports/reports/templates/base.html b/src/lib/Server/Reports/reports/templates/base.html index 7a36c9893..9bd9da218 100644 --- a/src/lib/Server/Reports/reports/templates/base.html +++ b/src/lib/Server/Reports/reports/templates/base.html @@ -1,3 +1,5 @@ +{% load bcfg2_tags %} + @@ -10,19 +12,19 @@ - - - - - - + + + + + + {% block extra_header_info %}{% endblock %} diff --git a/src/lib/Server/Reports/reports/templatetags/bcfg2_tags.py b/src/lib/Server/Reports/reports/templatetags/bcfg2_tags.py index 8285915bd..7fffe289d 100644 --- a/src/lib/Server/Reports/reports/templatetags/bcfg2_tags.py +++ b/src/lib/Server/Reports/reports/templatetags/bcfg2_tags.py @@ -237,3 +237,38 @@ def sortwell(value): configItems.sort(lambda x,y: cmp(x.entry.kind, y.entry.kind)) return configItems +class MediaTag(template.Node): + def __init__(self, filter_value): + self.filter_value = filter_value + + def render(self, context): + base = context['MEDIA_URL'] + try: + request = context['request'] + try: + base = request.environ['bcfg2.media_url'] + except: + if request.path != request.META['PATH_INFO']: + offset = request.path.find(request.META['PATH_INFO']) + if offset > 0: + base = "%s/%s" % (request.path[:offset], \ + context['MEDIA_URL'].strip('/')) + except: + pass + return "%s/%s" % (base, self.filter_value) + +@register.tag +def to_media_url(parser, token): + """ + Return a url relative to the media_url. + + {% to_media_url /bcfg2.css %} + """ + try: + tag_name, filter_value = token.split_contents() + filter_value = parser.compile_filter(filter_value) + except ValueError: + raise template.TemplateSyntaxError, "%r tag requires exactly one argument" % token.contents.split()[0] + + return MediaTag(filter_value) + -- cgit v1.2.3-1-g7c22