diff --git a/config.yaml b/config.yaml index 84af99e..657b193 100644 --- a/config.yaml +++ b/config.yaml @@ -15,8 +15,6 @@ coresnippets: - features - vlans - - vsans - - fcalias - qos - ports - misc diff --git a/main.py b/main.py index ec03704..a4cc747 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#/usr/bin/env python """ jinja2-nxos-config Accepts arguments from YAML config file diff --git a/methods.py b/methods.py index b32997d..d979c43 100644 --- a/methods.py +++ b/methods.py @@ -22,5 +22,5 @@ def gen_snippet(snippet, config): "config" represents the portion of the YAML file applicable to this snippet""" - template = ENV.get_template(snippet) + template = ENV.get_template(snippet + ".j2") return template.render(config=config) diff --git a/snippets/features.j2 b/snippets/features.j2 new file mode 100644 index 0000000..b0e8c9f --- /dev/null +++ b/snippets/features.j2 @@ -0,0 +1,4 @@ +{# handle different feature syntaxes - currently statically defining commands in list #} +{% for feature in config|sort %} + {{- feature }} +{% endfor %} diff --git a/snippets/misc.j2 b/snippets/misc.j2 new file mode 100644 index 0000000..05341e7 --- /dev/null +++ b/snippets/misc.j2 @@ -0,0 +1,18 @@ +hostname {{ config['hostname'] }} + +{# snmp-server user admin network-admin auth md5 -- priv -- localizedkey #} +snmp-server host {{ config['snmp']['traphost'] }} traps version 2c public udp-port 2162 +{# snmp-server community -- group network-operator #} +{# snmp-server community -- use-acl acl_for_ro_comm #} + +{% for ntpserver in config['ntp'] -%} + ntp server {{ ntpserver }} use-vrf management +{% endfor %} +{# TODO: Need to find a way to insert "prefer" keyword #} +ntp source-interface mgmt0 + +vrf context management + ip route 0.0.0.0/0 {{ config['mgmtgw']}} + +spanning-tree domain 101 +spanning-tree vlan 1-4093 priority 4096 diff --git a/snippets/ports.j2 b/snippets/ports.j2 new file mode 100644 index 0000000..e86ab28 --- /dev/null +++ b/snippets/ports.j2 @@ -0,0 +1,3 @@ +interface Ethernet {{ config['trunks'] }} + switchport mode trunk +{# need to have a loop here #} diff --git a/snippets/qos.j2 b/snippets/qos.j2 new file mode 100644 index 0000000..3847d23 --- /dev/null +++ b/snippets/qos.j2 @@ -0,0 +1 @@ +class-map type qos match-all class-gold description NFS Traffic match cos 4 class-map type qos match-all class-bronze description Reserved for Future Use match cos 1 class-map type qos match-all class-silver description vMotion Traffic match cos 2 class-map type qos match-all class-platinum description Reserved for Future Use match cos 5 class-map type queuing class-gold description NFS Traffic match qos-group 4 class-map type queuing class-bronze description Reserved for Future Use match qos-group 2 class-map type queuing class-silver description vMotion Traffic match qos-group 3 class-map type queuing class-platinum description Reserved for Future Use match qos-group 5 policy-map type qos system-level-qos class class-platinum set qos-group 5 class class-gold set qos-group 4 class class-silver set qos-group 3 class class-bronze set qos-group 2 class class-fcoe set qos-group 1 policy-map type queuing Uplink-out_policy class type queuing class-platinum class type queuing class-gold bandwidth percent 40 class type queuing class-silver bandwidth percent 5 class type queuing class-bronze class type queuing class-default bandwidth percent 35 class type queuing class-fcoe bandwidth percent 20 class-map type network-qos class-gold description NFS Traffic match qos-group 4 class-map type network-qos class-bronze description Reserved for Future Use match qos-group 2 class-map type network-qos class-silver description vMotion Traffic match qos-group 3 class-map type network-qos class-platinum description Reserved for Future Use match qos-group 5 policy-map type network-qos system-level-net-qos class type network-qos class-platinum set cos 5 mtu 9216 class type network-qos class-gold set cos 4 mtu 9216 class type network-qos class-silver set cos 2 mtu 9216 class type network-qos class-bronze set cos 1 mtu 9216 class type network-qos class-fcoe pause no-drop mtu 2158 class type network-qos class-default mtu {{ config['defaultmtu'] }} multicast-optimize system qos service-policy type queuing input fcoe-default-in-policy service-policy type qos input system-level-qos service-policy type queuing output Uplink-out_policy service-policy type network-qos system-level-net-qos \ No newline at end of file diff --git a/snippets/vlans.j2 b/snippets/vlans.j2 new file mode 100644 index 0000000..476d6f1 --- /dev/null +++ b/snippets/vlans.j2 @@ -0,0 +1,6 @@ +!VLAN Database +{% for id, name in config|dictsort -%} +vlan {{ id }} + name {{ name }} + {# fabricpath #} +{% endfor %}