Verified Commit 77987d23 authored by Adrian Schollmeyer's avatar Adrian Schollmeyer
Browse files
parents
__pycache__/
*.swp
# Changelog
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
### Added
* `aruba.py` report
* ArubaApNetworkIntegration (ensure valid network configuration and uplink connection)
Copyright (c) 2021 Forschungsgemeinschaft elektronische Medien e.V.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# FeM NetBox report scripts
This repository is a collection of FeM's report scripts for NetBox.
These are meant to be run from within NetBox and outside of it, so don't wonder if it doesn't work if you execute them.
from dcim.models import *
from ipam.models import *
from extras.reports import Report
class ArubaApNetworkIntegration(Report):
description = "Validate that every Aruba AP is properly integrated"
description += " into the network"
def test_uplink_has_ip_address(self):
for ap in Device.objects.filter(
device_role=DeviceRole.objects.get(name="WLAN-AP"),
device_type__in=DeviceType.objects.filter(manufacturer=
Manufacturer.objects.get(name="Aruba"))):
uplink_interface = Interface.objects.filter(name="E0", device=ap)
if len(uplink_interface) == 0:
self.log_failure(ap, "Missing uplink interface")
continue
uplink_interface = uplink_interface[0]
addresses = IPAddress.objects.filter(interface=uplink_interface)
if len(addresses) == 0:
self.log_failure(ap, "Missing IP-address")
continue
self.log_success(ap)
def test_uplink_has_cable(self):
for interface in Interface.objects.prefetch_related("device").filter(
name="E0",
device__in=Device.objects.filter(
device_role=DeviceRole.objects.get(name="WLAN-AP"),
device_type__in=DeviceType.objects.filter(manufacturer=
Manufacturer.objects.get(name="Aruba"))
)
):
if interface.connected_endpoint is None:
self.log_failure(interface.device, "Missing uplink cable")
continue
if not interface.connected_endpoint.device.device_role.name \
== "Access Switch":
self.log_warning(interface.device,
"Uplink is not an access switch")
else:
self.log_success(interface.device)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment