Changes for Netbox
parent
38a07f013e
commit
21b228b71b
|
|
@ -1,14 +1,14 @@
|
||||||
{% macro systemsection(device) %}
|
{% macro systemsection(device,root_pw,users,syslog_servers,ntp_servers) %}
|
||||||
system {
|
system {
|
||||||
host-name {{ device['hostname'] }};
|
host-name {{ device['hostname'] }};
|
||||||
root-authentication {
|
root-authentication {
|
||||||
encrypted-password "{{ device['config_context']['root_pw'] }}"; ## Client Higher
|
encrypted-password "{{ root_pw }}"; ## Client Higher
|
||||||
}
|
}
|
||||||
login {
|
login {
|
||||||
class sysadmin {
|
class sysadmin {
|
||||||
permissions [ admin clear configure control firewall-control interface interface-control network reset rollback routing routing-control snmp snmp-control trace-control view view-configuration ];
|
permissions [ admin clear configure control firewall-control interface interface-control network reset rollback routing routing-control snmp snmp-control trace-control view view-configuration ];
|
||||||
}
|
}
|
||||||
{% for user, details in device['config_context']['users']|dictsort %}
|
{% for user, details in users|dictsort %}
|
||||||
user {{ user }} {
|
user {{ user }} {
|
||||||
uid 200{{ loop.index }};
|
uid 200{{ loop.index }};
|
||||||
class {{ details['role'] }};
|
class {{ details['role'] }};
|
||||||
|
|
@ -22,7 +22,7 @@ system {
|
||||||
ssh;
|
ssh;
|
||||||
}
|
}
|
||||||
syslog {
|
syslog {
|
||||||
{% for server in device['config_context']['syslog_servers'] %}
|
{% for server in syslog_servers %}
|
||||||
host {{ server }} {
|
host {{ server }} {
|
||||||
any notice;
|
any notice;
|
||||||
authorization info;
|
authorization info;
|
||||||
|
|
@ -40,9 +40,9 @@ system {
|
||||||
authorization info;
|
authorization info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{% if device['config_context']['ntp_servers']|length > 0 %}
|
{% if ntp_servers|length > 0 %}
|
||||||
ntp {
|
ntp {
|
||||||
{% for server in device['config_context']['ntp_servers'] %}
|
{% for server in ntp_servers %}
|
||||||
server {{ server }};
|
server {{ server }};
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
}
|
}
|
||||||
|
|
@ -51,15 +51,15 @@ system {
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
|
|
||||||
{% macro chassissection(device) %}
|
{% macro chassissection(device,breakout_ports) %}
|
||||||
chassis {
|
chassis {
|
||||||
aggregated-devices {
|
aggregated-devices {
|
||||||
ethernet {
|
ethernet {
|
||||||
device-count {{ device['interfaces']|selectattr('type','eq','LAG')|list|count }};
|
device-count {{ device['interfaces']|selectattr('type','eq','LAG')|list|count }};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{% if device['config_context']['breakout_ports'] %}
|
{% if breakout_ports %}
|
||||||
{% for fpc, fpcdata in device['config_context']['breakout_ports'].items() %}
|
{% for fpc, fpcdata in breakout_ports.items() %}
|
||||||
fpc {{ fpc }} {
|
fpc {{ fpc }} {
|
||||||
{% for pic, picdata in fpcdata.items() %}
|
{% for pic, picdata in fpcdata.items() %}
|
||||||
pic {{ pic }} {
|
pic {{ pic }} {
|
||||||
|
|
@ -102,9 +102,9 @@ chassis {
|
||||||
aggregated-ether-options {
|
aggregated-ether-options {
|
||||||
lacp {
|
lacp {
|
||||||
periodic fast;
|
periodic fast;
|
||||||
{% if interface['_custom_field_data']['system_id'] %}
|
{% if interface['custom_field_data']['system_id'] %}
|
||||||
system-id {{ interface['_custom_field_data']['system_id'] }};
|
system-id {{ interface['custom_field_data']['system_id'] }};
|
||||||
{% elif interface['_custom_field_data']['esi_lag'] %}
|
{% elif interface['custom_field_data']['esi_lag'] %}
|
||||||
system-id 00:00:{{ '%02d' % rack|int }}:{% if interface['name'][2:]|int < 99 %}{{ '%02d' % interface['name'][2:]|int }}{% else %}{{ '%02x' % interface['name'][2:]|int }}{% endif %}:00:01;
|
system-id 00:00:{{ '%02d' % rack|int }}:{% if interface['name'][2:]|int < 99 %}{{ '%02d' % interface['name'][2:]|int }}{% else %}{{ '%02x' % interface['name'][2:]|int }}{% endif %}:00:01;
|
||||||
{% endif %}
|
{% endif %}
|
||||||
}
|
}
|
||||||
|
|
@ -178,13 +178,13 @@ interfaces {
|
||||||
}
|
}
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
{% macro snmpsection(rack, config_context) %}
|
{% macro snmpsection(rack, snmp) %}
|
||||||
snmp {
|
snmp {
|
||||||
location "Domicilium Datacentre {{ rack['name'] }}";
|
location "Domicilium Datacentre {{ rack['name'] }}";
|
||||||
contact "{{ config_context['snmp']['contact'] }}";
|
contact "{{ snmp['contact'] }}";
|
||||||
community {{ config_context['snmp']['community'] }} {
|
community {{ snmp['community'] }} {
|
||||||
authorization read-only;
|
authorization read-only;
|
||||||
{% for client in config_context['snmp']['clients'] %}
|
{% for client in snmp['clients'] %}
|
||||||
{% if loop.first %}
|
{% if loop.first %}
|
||||||
clients {
|
clients {
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
@ -197,13 +197,13 @@ snmp {
|
||||||
}
|
}
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
{% macro routingoptionssection(primary_ip4, config_context) %}
|
{% macro routingoptionssection(primary_ip4, overlay_as, gateway) %}
|
||||||
routing-options {
|
routing-options {
|
||||||
router-id {{ primary_ip4['address'][:-3] }};
|
router-id {{ primary_ip4['address'][:-3] }};
|
||||||
autonomous-system {{ config_context['overlay_as'] }};
|
autonomous-system {{ overlay_as }};
|
||||||
{% if config_context['gateway'] %}
|
{% if gateway %}
|
||||||
static {
|
static {
|
||||||
route 0.0.0.0/0 next-hop {{ config_context['gateway'] }};
|
route 0.0.0.0/0 next-hop {{ gateway }};
|
||||||
}
|
}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
forwarding-table {
|
forwarding-table {
|
||||||
|
|
@ -267,7 +267,7 @@ routing-options {
|
||||||
unicast;
|
unicast;
|
||||||
}
|
}
|
||||||
export BGP_LOOPBACK0;
|
export BGP_LOOPBACK0;
|
||||||
local-as {{ device['config_context']['underlay_as'] }};
|
local-as {{ device['local_context_data']['underlay_as'] }};
|
||||||
multipath {
|
multipath {
|
||||||
multiple-as;
|
multiple-as;
|
||||||
}
|
}
|
||||||
|
|
@ -305,17 +305,15 @@ routing-options {
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
|
|
||||||
{% macro sflowsection(device) %}
|
{% macro sflowsection(sflow) %}
|
||||||
{% if device['config_context']['sflow'] %}
|
|
||||||
sflow {
|
sflow {
|
||||||
{% for collector in device['config_context']['sflow']['collectors'] %}
|
{% for collector in sflow['collectors'] %}
|
||||||
collector {{ collector }};
|
collector {{ collector }};
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% for interface in device['config_context']['sflow']['interfaces'] %}
|
{% for interface in sflow['interfaces'] %}
|
||||||
interfaces {{ interface }}.0;
|
interfaces {{ interface }}.0;
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
}
|
}
|
||||||
{% endif %}
|
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
{% set device=({'hostname':hostname,'device_role':device_role,'primary_ip4':primary_ip4,'rack':rack,'interfaces':interfaces,'peering_interfaces':peering_interfaces,'config_context':config_context}) %}
|
|
||||||
{% import "juniper-macros.j2" as junos %}
|
{% import "juniper-macros.j2" as junos %}
|
||||||
{{ junos.systemsection(device) }}
|
{{ junos.systemsection(device,root_pw,users,syslog_servers,ntp_servers) }}
|
||||||
{% if device_role['name'] == 'Leaf' %}
|
{% if device.role['name'] == 'Leaf' %}
|
||||||
{{ junos.chassissection(device) }}
|
{{ junos.chassissection(device,breakout_ports) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ junos.interfacesection(device,tenant['vlans']) }}
|
{{ junos.interfacesection(device,tenant['vlans']) }}
|
||||||
{{ junos.snmpsection(rack, config_context) }}
|
{{ junos.snmpsection(rack, snmp) }}
|
||||||
{% if device_role['name'] == 'Leaf' %}
|
{% if device_role['name'] == 'Leaf' %}
|
||||||
forwarding-options {
|
forwarding-options {
|
||||||
storm-control-profiles default {
|
storm-control-profiles default {
|
||||||
|
|
@ -29,7 +28,7 @@ policy-options {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{{ junos.routingoptionssection(primary_ip4, config_context) }}
|
{{ junos.routingoptionssection(primary_ip4, overlay_as, gateway) }}
|
||||||
protocols {
|
protocols {
|
||||||
{{ junos.bgpsection(device,tenant['spines']) }}
|
{{ junos.bgpsection(device,tenant['spines']) }}
|
||||||
{% if device_role['name'] == 'Leaf' %}
|
{% if device_role['name'] == 'Leaf' %}
|
||||||
|
|
@ -41,7 +40,9 @@ protocols {
|
||||||
lldp {
|
lldp {
|
||||||
interface all;
|
interface all;
|
||||||
}
|
}
|
||||||
{{ junos.sflowsection(device) }}
|
{% if sflow %}
|
||||||
|
{{ junos.sflowsection(sflow) }}
|
||||||
|
{% endif %}
|
||||||
}
|
}
|
||||||
{% if device_role['name'] == 'Leaf' %}
|
{% if device_role['name'] == 'Leaf' %}
|
||||||
switch-options {
|
switch-options {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue