Compare commits

...
8 Commits
Author SHA1 Message Date
mattieserver a1d155fdbc Merge pull request #7 from mattieserver/dev
bump version to 0.3
2020-05-14 18:26:48 +02:00
mattijs vanhaverbeke ab944fdcef bump version to 0.3 2020-05-14 18:19:16 +02:00
mattieserver f72ca57ac7 Merge pull request #5 from JohannesKreuzer/netbox-subdir-support
support of netbox deployments in subdirectories
2020-05-14 18:17:23 +02:00
Johannes Kreuzer 8a6f1660f0 Update for support of netbox deployments, which are not in the webserver root (e.g. /netbox/) 2020-05-14 15:52:47 +02:00
mattieserver d608d63207 Update README.md 2020-04-24 12:57:47 +02:00
mattieserver 4d161fe6ac Update README.md 2020-04-24 12:56:47 +02:00
mattieserver c6a6893c10 Update README.md 2020-04-24 12:45:49 +02:00
mattieserver b2430d1723 Update README.md 2020-04-17 11:13:10 +02:00
5 changed files with 53 additions and 20 deletions
+40 -7
View File
@@ -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
![preview image](doc/img/preview.png?raw=true "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
+1 -1
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.2'
version = '0.3'
author = 'Mattijs Vanhaverbeke'
author_email = 'author@example.com'
base_url = 'topology-views'
+4 -4
View File
@@ -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)
+7 -7
View File
@@ -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() {
},
});
});
}
}
+1 -1
View File
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
setup(
name='netbox-topology-views',
version='0.2',
version='0.3',
description='An NetBox plugin to create Topology maps',
url='https://github.com/mattieserver/netbox-topology-views',
author='Mattijs Vanhaverbeke',