Closed romarioZ1000 closed 2 years ago
I guess this topic should be posted in https://github.com/netbox-community/netbox/discussions/categories/ideas next time. Anyway, inside these scripts you have complete access to the netbox database via the netboxshell (see documentation: https://docs.netbox.dev/en/stable/administration/netbox-shell/)
NetBox version
v3.2.2
Feature type
New functionality
Proposed functionality
Hello, netbox community!
I have an idea to create scripts to manage network devices from web interface.
for example, here is a ready-made simple script for adding VLAN to Mikrotik.
###########################################
add netmiko to the local_requirements.txt
from django.utils.text import slugify import paramiko import netbox.settings from extras.scripts import * from netmiko import ConnectHandler from routeros_ssh_connector import MikrotikDevice
class RunCommand(Script): class Meta: name = "Set VLAN on Mikrotik" description = "Mikrotik via SSH" field_order = [ 'input_ip', 'input_bridge', 'input_vlan_name', 'input_vlan_id' ]
input_ip = StringVar( description="Enter the IP Address:" ) input_bridge = StringVar( description="Name Bdrige:" )
input_vlan_name = StringVar( description="Vlan Name:" )
input_vlan_id = StringVar( description="Vlan id:" )
def run(self, data, commit):
###################################################
In this script, I enter variables myself, but I would like to enter variables from the netbox database - for example through ObjectVar or MultiObjectVar.
############################################
#################################
I can't pass these variables to commands that need to be written on the remote device ! '/interface bridge add name='+[bridge from Interfacebridge ] + '\n'
Can you tell me, at least with one example, how can I do this? All scripts will be laid out in open form, so that everyone can use them!
Thanks a lot!
Use case
Use netbox as a platform for template configuration of network devices using the netbox database. (Mikrotik, Cisco etc)
Database changes
No response
External dependencies
No response