Compare commits

..
13 Commits
Author SHA1 Message Date
mattieserver 26139cbb1c Merge pull request #24 from mattieserver/19052020_dev_1
19052020 dev 1
2020-05-20 08:11:04 +02:00
Mattijs Vanhaverbeke 4ea315d4b2 v0.4.8 2020-05-20 08:09:45 +02:00
Mattijs Vanhaverbeke 40ae715eb5 more NoneType checks 2020-05-19 22:35:55 +02:00
Mattijs Vanhaverbeke 204098a143 #23 check for nonetype in cable.termination 2020-05-19 22:17:13 +02:00
mattieserver 9b606643ea Update README.md 2020-05-19 19:50:56 +02:00
mattieserver f184bdf2f3 Merge pull request #20 from mattieserver/19052020_dev
#14, added circuit terminations
2020-05-19 17:20:11 +02:00
Mattijs Vanhaverbeke 370eff6b67 #14, added circuit terminations 2020-05-19 17:18:20 +02:00
Mattijs Vanhaverbeke 6d28ce2da4 v0.4.6 2020-05-18 19:12:32 +02:00
mattieserver 8a97923bb2 Merge pull request #19 from JohannesKreuzer/color-edges
color the edges
2020-05-18 19:10:10 +02:00
Johannes Kreuzer 7f0dcd97f7 color the edges
When a cable has a color set, use this color for the edge which
repesents the cable, so that a cabling type or maybe a purpose of the cable
could be seen in the topology graph.
2020-05-18 19:03:18 +02:00
Mattijs Vanhaverbeke 0d7052d83d small cleanup and v0.4.5 2020-05-18 18:52:56 +02:00
mattieserver e50945f8b5 Merge pull request #18 from JohannesKreuzer/add-dev-details
Shorter Label and more details for device
2020-05-18 18:19:57 +02:00
Johannes Kreuzer 987aab772f move device type name to title and add more device details to title 2020-05-18 18:14:23 +02:00
5 changed files with 87 additions and 15 deletions
+4 -3
View File
@@ -1,7 +1,8 @@
# Netbox Topology Views Plugin
Create topology views/maps from your devices in netbox.
Support to filter on name, site and device role.
The connections are based on the cables you created in netbox.
Support to filter on name, site, tag and device role.
## Preview
@@ -44,7 +45,7 @@ PLUGINS_CONFIG = {
| allow_coordinates_saving | False | (bool) Set to true if you use the custom coordinates fields and want to save the coordinates |
| ignore_cable_type | 'power outlet,power port' | The cable types that you want to ignore in the views |
| preselected_tags | '' | The name of tags you want to preload |
| enable_circuit_terminations | False | (bool) Set to true if you want to see circuit terminations in the topology |
### Custom Images
@@ -62,4 +63,4 @@ Run `pip install netbox-topology-views --upgrade` in your venv.
Run `python3 manage.py collectstatic --no-input`
Clear you browser cache.
Clear your browser cache.
+3 -2
View File
@@ -4,7 +4,7 @@ class TopologyViewsConfig(PluginConfig):
name = 'netbox_topology_views'
verbose_name = 'Topology views'
description = 'An plugin to render toplogoy maps'
version = '0.4.4'
version = '0.4.8'
author = 'Mattijs Vanhaverbeke'
author_email = 'author@example.com'
base_url = 'topology-views'
@@ -14,7 +14,8 @@ class TopologyViewsConfig(PluginConfig):
'ignore_cable_type': 'power outlet,power port',
'device_img': 'access-switch,core-switch,firewall,router,distribution-switch,backup,storage,wan-network,wireless-ap,server,internal-switch,isp-cpe-material,non-racked-devices,power-units',
'allow_coordinates_saving': False,
'preselected_tags' : ''
'preselected_tags' : '',
'enable_circuit_terminations': False
}
config = TopologyViewsConfig
+78 -8
View File
@@ -9,6 +9,7 @@ from django.conf import settings
from utilities.api import IsAuthenticatedOrLoginNotRequired
from dcim.models import DeviceRole, Device, Cable
from circuits.models import Circuit
from extras.models import Tag, CustomField, CustomFieldValue
ignore_cable_type_raw = settings.PLUGINS_CONFIG["netbox_topology_views"]["ignore_cable_type"]
@@ -120,6 +121,7 @@ class SearchViewSet(GenericViewSet):
edges = []
edge_ids = 0
cable_ids = []
circuit_ids = []
for device in devices:
cables = device.get_cables()
for cable in cables:
@@ -146,30 +148,98 @@ class SearchViewSet(GenericViewSet):
edge["id"] = edge_ids
edge["from"] = cable.termination_a.device.id
edge["to"] = cable.termination_b.device.id
edge["title"] = "Connection between <br> " + cable_a_dev_name + " [" + cable_a_name + "]<br>" + cable_b_dev_name + " [" + cable_b_name + "]"
edge["title"] = "Cable between <br> " + cable_a_dev_name + " [" + cable_a_name + "]<br>" + cable_b_dev_name + " [" + cable_b_name + "]"
if cable.color != "":
edge["color"] = "#" + cable.color
edges.append(edge)
else:
pass
#circuittermination not supported for now
if cable.termination_a_type.name == "circuit termination":
if settings.PLUGINS_CONFIG["netbox_topology_views"]["enable_circuit_terminations"]:
if cable.termination_a.circuit.id not in circuit_ids:
circuit_ids.append(cable.termination_a.circuit.id)
edge_ids += 1
cable_b_dev_name = cable.termination_b.device.name
if cable_b_dev_name is None:
cable_b_dev_name = "device B name unknown"
cable_b_name = cable.termination_b.name
if cable_b_name is None:
cable_b_name = "cable B name unknown"
edge = {}
edge["id"] = edge_ids
edge["to"] = cable.termination_b.device.id
edge["dashes"] = True
title = ""
title += "Circuit provider: " + cable.termination_a.circuit.provider.name + "<br>"
title += "Termination between <br>"
title += cable_b_dev_name + " [" + cable_b_name + "]<br>"
# To Many if's
if cable.termination_a.circuit.termination_a is not None:
if cable.termination_a.circuit.termination_a.cable is not None:
if cable.termination_a.circuit.termination_a.cable.id != cable.id:
if cable.termination_a.circuit.termination_a.cable.termination_b is not None:
if cable.termination_a.circuit.termination_a.cable.termination_b.device is not None:
edge["from"] = cable.termination_a.circuit.termination_a.cable.termination_b.device.id
cable_a_dev_name = cable.termination_a.circuit.termination_a.cable.termination_b.device.name
if cable_a_dev_name is None:
cable_a_dev_name = "device B name unknown"
cable_b_name = cable.termination_a.circuit.termination_a.cable.termination_b.name
if cable_a_name is None:
cable_a_name = "cable B name unknown"
title += cable_a_dev_name + " [" + cable_a_name + "]<br>"
edge["title"] = title
edges.append(edge)
# To Many if's
if cable.termination_a.circuit.termination_z is not None:
if cable.termination_a.circuit.termination_z.cable is not None:
if cable.termination_a.circuit.termination_z.cable.id != cable.id:
if cable.termination_a.circuit.termination_z.cable.termination_b is not None:
if cable.termination_a.circuit.termination_z.cable.termination_b.device is not None:
edge["from"] = cable.termination_a.circuit.termination_z.cable.termination_b.device.id
cable_a_dev_name = cable.termination_a.circuit.termination_z.cable.termination_b.device.name
if cable_a_dev_name is None:
cable_a_dev_name = "device B name unknown"
cable_a_name = cable.termination_a.circuit.termination_z.cable.termination_b.name
if cable_a_name is None:
cable_a_name = "cable B name unknown"
title += cable_a_dev_name + " [" + cable_a_name + "]<br>"
edge["title"] = title
edges.append(edge)
dev_name = device.name
if dev_name is None:
dev_name = "device name unknown"
cable_role_name = device.device_type.display_name
if cable_role_name is None:
cable_role_name = "device role name unknown"
node_content = ""
if device.device_type.display_name is not None:
node_content += "<tr><th>Type: </th><td>" + device.device_type.display_name + "</td></tr>"
if device.device_role.name is not None:
node_content += "<tr><th>Role: </th><td>" + device.device_role.name + "</td></tr>"
if device.serial != "":
node_content += "<tr><th>Serial: </th><td>" + device.serial + "</td></tr>"
if device.primary_ip is not None:
node_content += "<tr><th>IP Address: </th><td>" + str(device.primary_ip.address) + "</td></tr>"
dev_title = "<table> %s </table>" % (node_content)
node = {}
node["id"] = device.id
node["name"] = dev_name
node["label"] = dev_name + " {" + cable_role_name + "}"
node["label"] = dev_name
node["title"] = dev_title
node["shape"] = 'image'
if device.device_role.slug in settings.PLUGINS_CONFIG["netbox_topology_views"]["device_img"]:
node["image"] = '../../static/netbox_topology_views/img/' + device.device_role.slug + ".png"
else:
node["image"] = "../../static/netbox_topology_views/img/role-unknown.png"
if device.device_role.color != "":
node["color.border"] = "#" + device.device_role.color
for device_custom_field in device.custom_field_values.all():
if device_custom_field.field.name == "coordinates":
cords = device_custom_field.serialized_value.split(";")
+1 -1
View File
@@ -1,7 +1,7 @@
{
"private": true,
"name": "netbox_topology_views",
"version": "0.4.4",
"version": "0.4.8",
"scripts": {
"resources": "gulp build",
"resources_dev": "gulp build_dev"
+1 -1
View File
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
setup(
name='netbox-topology-views',
version='0.4.4',
version='0.4.8',
description='An NetBox plugin to create Topology maps',
url='https://github.com/mattieserver/netbox-topology-views',
author='Mattijs Vanhaverbeke',