Cope better with no rack information

netbox
Daniel Ankers 2024-07-04 14:56:24 +01:00
parent ee0620612b
commit 2617f6bdfe
1 changed files with 8 additions and 0 deletions

View File

@ -250,7 +250,15 @@ interfaces {
{% macro snmpsection(device, snmp) %} {% macro snmpsection(device, snmp) %}
snmp { snmp {
{% if device.rack and device.rack.site %}
location "{{ device.rack.site.name }} Rack {{ device.rack.name }}"; location "{{ device.rack.site.name }} Rack {{ device.rack.name }}";
{% elif device.rack and device.site %}
location "{{ device.site.name }} Rack {{ device.rack.name }}";
{% elif device.site %}
location "{{ device.site.name }}"
{% elif device.rack %}
location "{{ device.rack.name }}"
{% endif %}
contact "{{ snmp['contact'] }}"; contact "{{ snmp['contact'] }}";
community {{ snmp['community'] }} { community {{ snmp['community'] }} {
authorization read-only; authorization read-only;