Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1d155fdbc | ||
|
|
ab944fdcef | ||
|
|
f72ca57ac7 | ||
|
|
8a6f1660f0 | ||
|
|
d608d63207 | ||
|
|
4d161fe6ac | ||
|
|
c6a6893c10 | ||
|
|
b2430d1723 | ||
|
|
19ec0b8f2e | ||
|
|
94e26c5af1 | ||
|
|
acd60c7175 |
@@ -0,0 +1,4 @@
|
|||||||
|
recursive-include netbox_topology_views/static *
|
||||||
|
recursive-include netbox_topology_views/templates *
|
||||||
|
recursive-include netbox_topology_views/api *
|
||||||
|
prune netbox_topology_views/api/__pycache__
|
||||||
@@ -1,17 +1,50 @@
|
|||||||
# netbox-topology-views
|
# Netbox Topology Views Plugin
|
||||||
|
|
||||||
## preview
|
Create topology views/maps from your devices in netbox.
|
||||||
|
Support to filter on name, site and device role.
|
||||||
|
|
||||||
|
## Preview
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## install
|
## Install
|
||||||
|
|
||||||
Add 'netbox_topology_views' to the PLUGINS array in your django configuration file.
|
Run `pip install netbox-topology-views` in your virtual env.
|
||||||
Then run python3 manage.py collectstatic --no-input
|
|
||||||
|
Add 'netbox_topology_views' to the PLUGINS array in your django configuration file.
|
||||||
|
|
||||||
|
Then run `python3 manage.py collectstatic --no-input`
|
||||||
|
|
||||||
|
### Custom field: coordinates
|
||||||
|
|
||||||
There is also support for custom fiels.
|
There is also support for custom fiels.
|
||||||
If you create a custom field "coordinates" for "dcim > device" with type "text" and name "coordinates" you will see the same layout every time.
|
If you create a custom field "coordinates" for "dcim > device" with type "text" and name "coordinates" you will see the same layout every time.
|
||||||
|
|
||||||
## use
|
## Configure
|
||||||
|
|
||||||
go to /plugins/topology-views/ view your topologies
|
If you want to override the default values configure the `PLUGINS_CONFIG` in your `netbox configuration.py`.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```
|
||||||
|
PLUGINS_CONFIG = {
|
||||||
|
'netbox_topology_views': {
|
||||||
|
'device_img': 'router,switch,firewall',
|
||||||
|
'preselected_device_roles': 'Router, Firewall'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
| Setting | Default value | Description |
|
||||||
|
| ------------- |-------------| -----|
|
||||||
|
| 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' | The slug of the device roles that you have a image for. |
|
||||||
|
| preselected_device_roles | 'Firewall,Router,Distribution Switch,Core Switch,Internal Switch,Access Switch,Server,Storage,Backup,Wireless AP' | The full name of the device roles you want to pre select in the global view. |
|
||||||
|
|
||||||
|
### Custom Images
|
||||||
|
|
||||||
|
You upload you own custom images to the netbox static dir (`static/netbox_topology_views/img/`).
|
||||||
|
These images need to be named after de device role slug and have the .png format/extension.
|
||||||
|
If you add your own image you also need to add the slug to the `device_img` setting.
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
Go to the plugins tab in the navbar and click topology or go to NETBOX_URL/plugins/topology-views/ view your topologies
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class TopologyViewsConfig(PluginConfig):
|
|||||||
name = 'netbox_topology_views'
|
name = 'netbox_topology_views'
|
||||||
verbose_name = 'Topology views'
|
verbose_name = 'Topology views'
|
||||||
description = 'An plugin to render toplogoy maps'
|
description = 'An plugin to render toplogoy maps'
|
||||||
version = '0.1'
|
version = '0.3'
|
||||||
author = 'Mattijs Vanhaverbeke'
|
author = 'Mattijs Vanhaverbeke'
|
||||||
author_email = 'author@example.com'
|
author_email = 'author@example.com'
|
||||||
base_url = 'topology-views'
|
base_url = 'topology-views'
|
||||||
|
|||||||
@@ -66,12 +66,12 @@ class SearchViewSet(ViewSet):
|
|||||||
node = {}
|
node = {}
|
||||||
node["id"] = device.id
|
node["id"] = device.id
|
||||||
node["name"] = device.name
|
node["name"] = device.name
|
||||||
node["label"] = device.name + device.device_type.display_name
|
node["label"] = device.name + " " + device.device_type.display_name
|
||||||
node["shape"] = 'image'
|
node["shape"] = 'image'
|
||||||
if device.device_role.slug in settings.PLUGINS_CONFIG["netbox_topology_views"]["device_img"]:
|
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"
|
node["image"] = '../../static/netbox_topology_views/img/' + device.device_role.slug + ".png"
|
||||||
else:
|
else:
|
||||||
node["image"] = "/static/netbox_topology_views/img/role-unknown.png"
|
node["image"] = "../../static/netbox_topology_views/img/role-unknown.png"
|
||||||
|
|
||||||
for device_custom_field in device.custom_field_values.all():
|
for device_custom_field in device.custom_field_values.all():
|
||||||
if device_custom_field.field.name == "coordinates":
|
if device_custom_field.field.name == "coordinates":
|
||||||
@@ -86,4 +86,4 @@ class SearchViewSet(ViewSet):
|
|||||||
results["nodes"] = nodes
|
results["nodes"] = nodes
|
||||||
results["edges"] = edges
|
results["edges"] = edges
|
||||||
|
|
||||||
return Response(results)
|
return Response(results)
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
from extras.plugins import PluginMenuButton, PluginMenuItem
|
||||||
|
from utilities.choices import ButtonColorChoices
|
||||||
|
|
||||||
|
menu_items = (
|
||||||
|
PluginMenuItem(
|
||||||
|
link='plugins:netbox_topology_views:home',
|
||||||
|
link_text='Topology',
|
||||||
|
buttons=()
|
||||||
|
),
|
||||||
|
)
|
||||||
@@ -11,7 +11,7 @@ var options = {
|
|||||||
},
|
},
|
||||||
nodes: {
|
nodes: {
|
||||||
shape: 'image',
|
shape: 'image',
|
||||||
brokenImage: '/static/netbox_topology_views/img/role-unknown.png',
|
brokenImage: '../../static/netbox_topology_views/img/role-unknown.png',
|
||||||
size: 35,
|
size: 35,
|
||||||
font: {
|
font: {
|
||||||
multi: 'md',
|
multi: 'md',
|
||||||
@@ -46,7 +46,7 @@ function startLoadSearchBar() {
|
|||||||
theme: "bootstrap",
|
theme: "bootstrap",
|
||||||
multiple: true,
|
multiple: true,
|
||||||
ajax: {
|
ajax: {
|
||||||
url: "/api/dcim/device-roles/?brief=true",
|
url: "../../api/dcim/device-roles/?brief=true",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
type: "GET",
|
type: "GET",
|
||||||
data: function (params) {
|
data: function (params) {
|
||||||
@@ -73,7 +73,7 @@ function startLoadSearchBar() {
|
|||||||
theme: "bootstrap",
|
theme: "bootstrap",
|
||||||
multiple: true,
|
multiple: true,
|
||||||
ajax: {
|
ajax: {
|
||||||
url: "/api/dcim/sites/?brief=true",
|
url: "../../api/dcim/sites/?brief=true",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
type: "GET",
|
type: "GET",
|
||||||
data: function (params) {
|
data: function (params) {
|
||||||
@@ -99,7 +99,7 @@ function startLoadSearchBar() {
|
|||||||
var deviceRolesSelect = $('#device-roles');
|
var deviceRolesSelect = $('#device-roles');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
url: '/api/plugins/topology-views/preselectdeviceroles/'
|
url: '../../api/plugins/topology-views/preselectdeviceroles/'
|
||||||
}).then(function (data) {
|
}).then(function (data) {
|
||||||
$.each(data.results, function (index, device_role_to_preload) {
|
$.each(data.results, function (index, device_role_to_preload) {
|
||||||
var option = new Option(device_role_to_preload.name, device_role_to_preload.id, true, true);
|
var option = new Option(device_role_to_preload.name, device_role_to_preload.id, true, true);
|
||||||
@@ -123,7 +123,7 @@ function handleButtonPress() {
|
|||||||
var value3 = $("#sites").val();
|
var value3 = $("#sites").val();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/api/plugins/topology-views/search/search/",
|
url: "../../api/plugins/topology-views/search/search/",
|
||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
'name': value,
|
'name': value,
|
||||||
'devicerole': value2,
|
'devicerole': value2,
|
||||||
@@ -157,7 +157,7 @@ function handleButtonPress() {
|
|||||||
if ($('#checkSaveCoordinates').is(":checked")) {
|
if ($('#checkSaveCoordinates').is(":checked")) {
|
||||||
nodes.update({ id: node_id, physics: false });
|
nodes.update({ id: node_id, physics: false });
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/api/save_coords",
|
url: "../../api/save_coords",
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
headers: { "X-CSRFToken": csrftoken },
|
headers: { "X-CSRFToken": csrftoken },
|
||||||
@@ -191,4 +191,4 @@ function handleButtonPress() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+666
-1175
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"name": "netbox_topology_views",
|
"name": "netbox_topology_views",
|
||||||
"version": "0.0.1",
|
"version": "0.2",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"resources": "gulp build",
|
"resources": "gulp build",
|
||||||
"resources_dev": "gulp build_dev"
|
"resources_dev": "gulp build_dev"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='netbox-topology-views',
|
name='netbox-topology-views',
|
||||||
version='0.1',
|
version='0.3',
|
||||||
description='An NetBox plugin to create Topology maps',
|
description='An NetBox plugin to create Topology maps',
|
||||||
url='https://github.com/mattieserver/netbox-topology-views',
|
url='https://github.com/mattieserver/netbox-topology-views',
|
||||||
author='Mattijs Vanhaverbeke',
|
author='Mattijs Vanhaverbeke',
|
||||||
@@ -11,4 +11,12 @@ setup(
|
|||||||
install_requires=[],
|
install_requires=[],
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
|
classifiers=[
|
||||||
|
'Programming Language :: Python',
|
||||||
|
'Programming Language :: Python :: 3',
|
||||||
|
'Programming Language :: Python :: 3 :: Only',
|
||||||
|
],
|
||||||
|
project_urls={
|
||||||
|
'Source': 'https://github.com/mattieserver/netbox-topology-views',
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user