Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1d155fdbc | ||
|
|
ab944fdcef | ||
|
|
f72ca57ac7 | ||
|
|
8a6f1660f0 | ||
|
|
d608d63207 | ||
|
|
4d161fe6ac | ||
|
|
c6a6893c10 | ||
|
|
b2430d1723 |
@@ -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.
|
||||
Then run python3 manage.py collectstatic --no-input
|
||||
Run `pip install netbox-topology-views` in your virtual env.
|
||||
|
||||
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.
|
||||
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'
|
||||
verbose_name = 'Topology views'
|
||||
description = 'An plugin to render toplogoy maps'
|
||||
version = '0.2'
|
||||
version = '0.3'
|
||||
author = 'Mattijs Vanhaverbeke'
|
||||
author_email = 'author@example.com'
|
||||
base_url = 'topology-views'
|
||||
|
||||
@@ -66,12 +66,12 @@ class SearchViewSet(ViewSet):
|
||||
node = {}
|
||||
node["id"] = device.id
|
||||
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'
|
||||
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:
|
||||
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():
|
||||
if device_custom_field.field.name == "coordinates":
|
||||
@@ -86,4 +86,4 @@ class SearchViewSet(ViewSet):
|
||||
results["nodes"] = nodes
|
||||
results["edges"] = edges
|
||||
|
||||
return Response(results)
|
||||
return Response(results)
|
||||
|
||||
@@ -11,7 +11,7 @@ var options = {
|
||||
},
|
||||
nodes: {
|
||||
shape: 'image',
|
||||
brokenImage: '/static/netbox_topology_views/img/role-unknown.png',
|
||||
brokenImage: '../../static/netbox_topology_views/img/role-unknown.png',
|
||||
size: 35,
|
||||
font: {
|
||||
multi: 'md',
|
||||
@@ -46,7 +46,7 @@ function startLoadSearchBar() {
|
||||
theme: "bootstrap",
|
||||
multiple: true,
|
||||
ajax: {
|
||||
url: "/api/dcim/device-roles/?brief=true",
|
||||
url: "../../api/dcim/device-roles/?brief=true",
|
||||
dataType: "json",
|
||||
type: "GET",
|
||||
data: function (params) {
|
||||
@@ -73,7 +73,7 @@ function startLoadSearchBar() {
|
||||
theme: "bootstrap",
|
||||
multiple: true,
|
||||
ajax: {
|
||||
url: "/api/dcim/sites/?brief=true",
|
||||
url: "../../api/dcim/sites/?brief=true",
|
||||
dataType: "json",
|
||||
type: "GET",
|
||||
data: function (params) {
|
||||
@@ -99,7 +99,7 @@ function startLoadSearchBar() {
|
||||
var deviceRolesSelect = $('#device-roles');
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/api/plugins/topology-views/preselectdeviceroles/'
|
||||
url: '../../api/plugins/topology-views/preselectdeviceroles/'
|
||||
}).then(function (data) {
|
||||
$.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);
|
||||
@@ -123,7 +123,7 @@ function handleButtonPress() {
|
||||
var value3 = $("#sites").val();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/api/plugins/topology-views/search/search/",
|
||||
url: "../../api/plugins/topology-views/search/search/",
|
||||
data: JSON.stringify({
|
||||
'name': value,
|
||||
'devicerole': value2,
|
||||
@@ -157,7 +157,7 @@ function handleButtonPress() {
|
||||
if ($('#checkSaveCoordinates').is(":checked")) {
|
||||
nodes.update({ id: node_id, physics: false });
|
||||
$.ajax({
|
||||
url: "/api/save_coords",
|
||||
url: "../../api/save_coords",
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
headers: { "X-CSRFToken": csrftoken },
|
||||
@@ -191,4 +191,4 @@ function handleButtonPress() {
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user