url(r'^syslogger/', include('nav.web.syslogger.urls')), url(r'^ipam/', include('nav.web.ipam.urls')), url(r'^threshold/', include('nav.web.threshold.urls')), url(r'^graphite/', include('nav.web.graphite.urls')), url(r'^navlets/', include('nav.web.navlets.urls')), url(r'^watchdog/', include('nav.web.watchdog.urls')), url(r'^useradmin/', include('nav.web.useradmin.urls')), url(r'^styleguide/', styleguide_index), url(r'^refresh_session/', refresh_session, name='refresh-session'), url(r'^auditlog/', include('nav.auditlog.urls')), url(r'^interfaces/', include('nav.web.interface_browser.urls')), url(r'^500/', force_500), ] # Load local url-config _local_python_dir = os.path.join(find_config_dir() or '.', 'python') _local_url_filepath = os.path.join(_local_python_dir, 'local_urls.py') if os.path.isfile(_local_url_filepath): if _local_python_dir not in sys.path: sys.path.append(_local_python_dir) try: import local_urls urlpatterns += local_urls.urlpatterns except (ImportError, TypeError): _logger.exception("failed to import urlpatterns from local_urls.py") pass handler500 = 'nav.django.views.custom_500'
from django.urls import reverse from nav.models.manage import Prefix from nav.report.IPtree import get_max_leaf, build_tree from nav.report.generator import Generator, ReportList, ReportTuple from nav.report.matrixIPv4 import MatrixIPv4 from nav.report.matrixIPv6 import MatrixIPv6 from nav.report.metaIP import MetaIP from nav.config import find_config_file, find_config_dir, list_config_files_from_dir from nav.web.navlets import add_navlet _logger = logging.getLogger(__name__) IpGroup = namedtuple('IpGroup', 'private ipv4 ipv6') CONFIG_DIR = join(find_config_dir() or "", "report", "report.conf.d/") FRONT_FILE = find_config_file(join("report", "front.html")) DEFAULT_PAGE_SIZE = 25 PAGE_SIZES = [25, 50, 100, 500, 1000] def index(request): """Report front page""" context = { 'title': 'Report - Index', 'navpath': [('Home', '/'), ('Report', False)], 'heading': 'Report Index', } with open(FRONT_FILE, 'r') as f:
"""Django configuration wrapper around the NAV configuration files""" import os import sys import copy import django from django.utils.log import DEFAULT_LOGGING from nav.config import (NAV_CONFIG, getconfig, find_config_dir) from nav.db import get_connection_parameters import nav.buildconf ALLOWED_HOSTS = ['*'] _config_dir = find_config_dir() try: _webfront_config = getconfig('webfront/webfront.conf') except (IOError, OSError): _webfront_config = {} DEBUG = NAV_CONFIG.get('DJANGO_DEBUG', 'False').upper() in ('TRUE', 'YES', 'ON') # Copy Django's default logging config, but modify it to enable HTML e-mail # part for improved debugging: LOGGING = copy.deepcopy(DEFAULT_LOGGING) _handlers = LOGGING.get('handlers', {}) _mail_admin_handler = _handlers.get('mail_admins', {}) _mail_admin_handler['include_html'] = True
error free. This only ensures that the SQL can be run, no further verification is performed. """ from __future__ import unicode_literals import pytest from django.http import QueryDict from django.urls import reverse from nav import db from nav.report.generator import ReportList, Generator from nav.config import find_config_dir, list_config_files_from_dir from os.path import join config_files_dir = join(find_config_dir() or "", "report", "report.conf.d/") def report_list(): result = ReportList(list_config_files_from_dir(config_files_dir)) return [report.id for report in result.reports] @pytest.mark.parametrize("report_name", report_list()) def test_report(report_name): # uri = 'http://example.com/report/%s/' % report_name uri = QueryDict('').copy() db.closeConnections() # Ensure clean connection for each test generator = Generator() report, contents, neg, operator, adv, config, dbresult = generator.make_report(