Beispiel #1
0
def pdu_detail(request, handle_id):
    nh = get_object_or_404(NodeHandle, pk=handle_id)
    # Get node from neo4j-database
    pdu = nh.get_node()
    last_seen, expired = helpers.neo4j_data_age(pdu.data)
    location_path = pdu.get_location_path()
    # Get ports in pdu
    connections = pdu.get_connections()
    host_services = pdu.get_host_services()
    dependent = pdu.get_dependent_as_types()
    dependencies = pdu.get_dependencies_as_types()
    relations = pdu.get_relations()

    urls = helpers.get_node_urls(pdu, host_services, connections, dependent,
                                 dependencies, relations, location_path)
    scan_enabled = helpers.app_enabled("apps.scan")
    return render(
        request, 'noclook/detail/pdu_detail.html', {
            'node_handle': nh,
            'node': pdu,
            'last_seen': last_seen,
            'expired': expired,
            'host_services': host_services,
            'connections': connections,
            'dependent': dependent,
            'dependencies': dependencies,
            'relations': relations,
            'location_path': location_path,
            'history': True,
            'urls': urls,
            'scan_enabled': scan_enabled
        })
Beispiel #2
0
def host_detail(request, handle_id):
    nh = get_object_or_404(NodeHandle, pk=handle_id)
    # Get node from neo4j-database
    host = nc.get_node_model(nc.graphdb.manager, nh.handle_id)
    last_seen, expired = helpers.neo4j_data_age(host.data)
    location_path = host.get_location_path()
    # Handle relationships
    host_services = host.get_host_services()
    relations = host.get_relations()
    dependent = host.get_dependent_as_types()
    # Get ports in Host
    connections = host.get_connections()
    if not any(dependent.values()):
        dependent = None
    dependencies = host.get_dependencies_as_types()

    urls = helpers.get_node_urls(relations, host_services, dependent,
                                 dependencies)
    scan_enabled = helpers.app_enabled("apps.scan")
    return render(
        request, 'noclook/detail/host_detail.html', {
            'node_handle': nh,
            'node': host,
            'last_seen': last_seen,
            'expired': expired,
            'relations': relations,
            'host_services': host_services,
            'dependent': dependent,
            'dependencies': dependencies,
            'location_path': location_path,
            'history': True,
            'urls': urls,
            'connections': connections,
            'scan_enabled': scan_enabled,
        })
Beispiel #3
0
def firewall_detail(request, handle_id):
    nh = get_object_or_404(NodeHandle, pk=handle_id)
    # Get node from neo4j-database
    firewall = nh.get_node()
    last_seen, expired = helpers.neo4j_data_age(firewall.data)
    location_path = firewall.get_location_path()
    # Get ports in firewall
    connections = firewall.get_connections()
    host_services = firewall.get_host_services()
    dependent = firewall.get_dependent_as_types()
    dependencies = firewall.get_dependencies_as_types()
    relations = firewall.get_relations()
    scan_enabled = helpers.app_enabled("apps.scan")
    return render(
        request, 'noclook/detail/firewall_detail.html', {
            'node_handle': nh,
            'node': firewall,
            'last_seen': last_seen,
            'expired': expired,
            'host_services': host_services,
            'connections': connections,
            'dependent': dependent,
            'dependencies': dependencies,
            'relations': relations,
            'location_path': location_path,
            'history': True,
            'scan_enabled': scan_enabled
        })
Beispiel #4
0
def switch_detail(request, handle_id):
    nh = get_object_or_404(NodeHandle, pk=handle_id)
    # Get node from neo4j-database
    switch = nh.get_node()
    last_seen, expired = helpers.neo4j_data_age(switch.data)
    location_path = switch.get_location_path()
    # Get ports in switch
    connections = switch.get_connections()
    host_services = switch.get_host_services()
    dependent = switch.get_dependent_as_types()
    dependencies = switch.get_dependencies_as_types()
    relations = switch.get_relations()

    urls = helpers.get_node_urls(switch, host_services, connections, dependent,
                                 dependencies, relations, location_path)
    scan_enabled = helpers.app_enabled("apps.scan")
    hw_name = "{}-hardware.json".format(switch.data.get('name', 'switch'))
    hw_attachment = helpers.find_attachments(handle_id, hw_name).first()
    if hw_attachment:
        try:
            hardware_modules = [
                json.loads(helpers.attachment_content(hw_attachment))
            ]
        except IOError as e:
            logger.warning(
                'Missing hardware modules json for router %s(%s). Error was: %s',
                nh.node_name, nh.handle_id, e)
            hardware_modules = []
    else:
        hardware_modules = []
    return render(
        request, 'noclook/detail/switch_detail.html', {
            'node_handle': nh,
            'node': switch,
            'last_seen': last_seen,
            'expired': expired,
            'host_services': host_services,
            'connections': connections,
            'dependent': dependent,
            'dependencies': dependencies,
            'relations': relations,
            'location_path': location_path,
            'history': True,
            'urls': urls,
            'scan_enabled': scan_enabled,
            'hardware_modules': hardware_modules
        })
Beispiel #5
0
    ("service", "Service"),
    ("odf", "ODF"),
    ("optical-filter", "Optical Filter"),
    ("optical-multiplex-section", "Optical Multiplex Section"),
    ("optical-node", "Optical Node"),
    ("outlet", "Outlet"),
    ("patch-panel", "Patch Panel"),
    ("port", "Port"),
    ("provider", "Provider"),
    ("rack", "Rack"),
    ("room", "Room"),
    ("site", "Site"),
    ("site-owner", "Site Owner"),
    ("switch", "Switch"),
]
if helpers.app_enabled("apps.scan"):
    TYPES.append(("/scan/queue", "Host scan"))


# Create functions
@login_required
def new_node(request, slug=None, **kwargs):
    """
    Generic edit function that redirects calls to node type sensitive edit
    functions.
    """
    if not slug:
        types = sorted(TYPES, key=lambda x: x[1])
        return render(request, 'noclook/create/new_node.html',
                      {"types": types})
    try: