mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-08 16:48:16 -06:00
Merge 7e8bad4a5a
into b10635a9b1
This commit is contained in:
commit
1c484228b7
@ -293,12 +293,24 @@ class DeviceViewSet(CustomFieldModelViewSet):
|
||||
# TODO: Improve error handling
|
||||
response = OrderedDict([(m, None) for m in napalm_methods])
|
||||
ip_address = str(device.primary_ip.address.ip)
|
||||
|
||||
# Merge NAPALM_ARGS settings and form data
|
||||
optional_args = {}
|
||||
if settings.NAPALM_ARGS:
|
||||
optional_args.update(settings.NAPALM_ARGS)
|
||||
|
||||
if device.platform.napalm_port:
|
||||
optional_args.update({'port': device.platform.napalm_port})
|
||||
|
||||
if device.platform.napalm_transport:
|
||||
optional_args.update({'transport': device.platform.napalm_transport})
|
||||
|
||||
d = driver(
|
||||
hostname=ip_address,
|
||||
username=settings.NAPALM_USERNAME,
|
||||
password=settings.NAPALM_PASSWORD,
|
||||
timeout=settings.NAPALM_TIMEOUT,
|
||||
optional_args=settings.NAPALM_ARGS
|
||||
optional_args=optional_args
|
||||
)
|
||||
try:
|
||||
d.open()
|
||||
|
@ -723,7 +723,7 @@ class PlatformForm(BootstrapMixin, forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = Platform
|
||||
fields = ['name', 'slug', 'manufacturer', 'napalm_driver', 'rpc_client']
|
||||
fields = ['name', 'slug', 'manufacturer', 'napalm_driver', 'napalm_port', 'napalm_transport', 'rpc_client']
|
||||
|
||||
|
||||
class PlatformCSVForm(forms.ModelForm):
|
||||
|
25
netbox/dcim/migrations/0056_auto_20180416_1309.py
Normal file
25
netbox/dcim/migrations/0056_auto_20180416_1309.py
Normal file
@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.12 on 2018-04-16 13:09
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('dcim', '0055_virtualchassis_ordering'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='platform',
|
||||
name='napalm_port',
|
||||
field=models.PositiveIntegerField(blank=True, help_text='The port to be used by NAPALM driver when interacting with devices', null=True, verbose_name='NAPALM port'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='platform',
|
||||
name='napalm_transport',
|
||||
field=models.CharField(blank=True, help_text='The transport protocol to be used by NAPALM driver when interacting with devices', max_length=50, verbose_name='NAPALM transport type'),
|
||||
),
|
||||
]
|
@ -815,6 +815,21 @@ class Platform(models.Model):
|
||||
verbose_name='NAPALM driver',
|
||||
help_text="The name of the NAPALM driver to use when interacting with devices"
|
||||
)
|
||||
|
||||
napalm_port = models.PositiveIntegerField(
|
||||
blank=True,
|
||||
null=True,
|
||||
verbose_name='NAPALM port',
|
||||
help_text="The port to be used by NAPALM driver when interacting with devices"
|
||||
)
|
||||
|
||||
napalm_transport = models.CharField(
|
||||
max_length=50,
|
||||
blank=True,
|
||||
verbose_name='NAPALM transport type',
|
||||
help_text="The transport protocol to be used by NAPALM driver when interacting with devices"
|
||||
)
|
||||
|
||||
rpc_client = models.CharField(
|
||||
max_length=30,
|
||||
choices=RPC_CLIENT_CHOICES,
|
||||
|
Loading…
Reference in New Issue
Block a user