Compare commits

...

2 Commits

2 changed files with 30 additions and 24 deletions

View File

@@ -9,7 +9,9 @@ try:
except ImportError:
from yaml import Loader
def main(template_filepath,input_filepath,output_filepath):
def main(args: list) -> None:
template_filepath = args.template
input_filepath = args.input
with open(input_filepath, 'r') as file:
input_devices = file.read()
@@ -25,6 +27,11 @@ def main(template_filepath,input_filepath,output_filepath):
print('{} is not a valid JSON format!\n'.format(input_filepath))
return 406
if args.output is not None:
output_filepath = args.output
else:
output_filepath = './output/{}.nso.config'.format(device_info["device"])
template_path = os.path.dirname(os.path.abspath(template_filepath))
template_filename = os.path.basename(template_filepath)
@@ -58,8 +65,6 @@ def main(template_filepath,input_filepath,output_filepath):
# print('{}\n'.format(content))
# output.write('{}\n'.format(content))
return 0
if __name__ == "__main__":
@@ -79,14 +84,14 @@ if __name__ == "__main__":
parser.add_argument('-output',
help='Output File',
required=True
required=False
)
custom_args = parser.parse_known_args()[0]
template = custom_args.template
input = custom_args.input
output = custom_args.output
main(template,input,output)
#template = custom_args.template
#input = custom_args.input
#output = custom_args.output
main(custom_args)

View File

@@ -6,7 +6,7 @@ Protocols for the Lo0.0 are automatically handled by the common packages
{%- for loopback, unit in interfaces["loopback-interface"]["lo0"]["units"].items() %}
set services infra-crt {{device}} interface loopback-interface lo0 {{unit["name"]}} skip-loopback-check true
{%- if unit["description"] is not none %}
set services infra-crt {{device}} interface loopback-interface lo0 {{unit["name"]}} description {{unit["description"]}}
set services infra-crt {{device}} interface loopback-interface lo0 {{unit["name"]}} description "{{unit["description"]}}"
{%- else %}
ERROR: Missing Description for Lo0 unit {{unit["name"]}}!!!
set services infra-crt {{device}} interface loopback-interface lo0 {{unit["name"]}} description "FIX_ME"
@@ -45,13 +45,21 @@ ERROR: IP Addressing Missing for {{aggregate_interface["name"]}} unit {{aggregat
set services infra-crt {{device}} interface aggregate-interface {{ae_num}} {{aggregate_unit["name"]}} ipv4 FIX_ME
{%- endif %}
{%- if aggregate_interface["description"] is not none %}
set services infra-crt {{device}} interface aggregate-interface {{ae_num}} {{aggregate_unit["name"]}} description {{aggregate_interface["description"]}}
set services infra-crt {{device}} interface aggregate-interface {{ae_num}} {{aggregate_unit["name"]}} description "{{aggregate_interface["description"]}}"
{%- else %}
ERROR: Missing Description for {{aggregate_interface["name"]}} unit {{aggregate_unit["name"]}}!!!
set services infra-crt {{device}} interface aggregate-interface {{ae_num}} {{aggregate_unit["name"]}} description FIX_ME
{%- endif %}
{#- Find Protocols for AE #}
{#- ISIS#}
{%- for key,member_interface in aggregate_interface["member-interface"].items() %}
{%- if member_interface["description"] is not none %}
set services infra-crt {{device}} interface aggregate-interface {{ae_num}} 0 core-interface {{member_interface["name"]}} description "{{member_interface["description"]}}"
{%- else %}
ERROR: Missing Description for {{aggregate_interface["name"]}} Member-interface {{member_interface["name"]}}!!!
set services infra-crt {{device}} interface aggregate-interface {{ae_num}} 0 core-interface {{member_interface["name"]}} description FIX_ME
{%- endif %}
{%- endfor %}
{# Find Protocols for AE #}
{#- ISIS #}
{%- if aggregate_unit["isis-passive"] == True %}
set services infra-crt {{device}} isis passive-interface name {{aggregate_interface["name"]}} {{aggregate_unit["name"]}}
{%- else %}
@@ -71,7 +79,7 @@ set services infra-crt {{device}} ldp core-interface name {{aggregate_interface[
{#- MPLS-TE #}
{%- if aggregate_unit["mpls"] == True %}
{%- if aggregate_unit["mpls-te-att-names"] is not none %}
set services infra-crt {{device}} mpls-te core-interface name {{aggregate_interface["name"]}} {{aggregate_unit["name"]}} mpls-te-att-names {{aggregate_unit["mpls-te-att-names"]}}
set services infra-crt {{device}} mpls-te core-interface name {{aggregate_interface["name"]}} {{aggregate_unit["name"]}} mpls-te-att-names [ {{aggregate_unit["mpls-te-att-names"] | join(' ')}} ]
{%- else %}
set services infra-crt {{device}} mpls-te core-interface name {{aggregate_interface["name"]}} {{aggregate_unit["name"]}}
{%- endif %}
@@ -100,14 +108,7 @@ set services infra-crt {{device}} service-policy core-interface name {{aggregate
{%- endif %}
{%- endif %}
{%- endfor %}
{%- for key,member_interface in aggregate_interface["member-interface"].items() %}
{%- if member_interface["description"] is not none %}
set services infra-crt {{device}} interface aggregate-interface {{ae_num}} 0 core-interface {{member_interface["name"]}} description {{member_interface["description"]}}
{%- else %}
ERROR: Missing Description for {{aggregate_interface["name"]}} Member-interface {{member_interface["name"]}}!!!
set services infra-crt {{device}} interface aggregate-interface {{ae_num}} 0 core-interface {{member_interface["name"]}} description FIX_ME
{%- endif %}
{%- endfor %}
{%- endif %}
{%- endfor %}
@@ -117,7 +118,7 @@ set services infra-crt {{device}} interface aggregate-interface {{ae_num}} 0 cor
{% for key,core_unit in core_interface["units"].items() %}
{%- if core_unit["disabled"] == False %}
{%- if core_interface["description"] is not none %}
set services infra-crt {{device}} interface core-interface name {{core_interface["name"]}} {{core_unit["name"]}} description {{core_interface["description"]}}
set services infra-crt {{device}} interface core-interface name {{core_interface["name"]}} {{core_unit["name"]}} description "{{core_interface["description"]}}"
{%- endif %}
{%- if core_interface["description"] is none %}
set services infra-crt {{device}} interface core-interface name {{core_interface["name"]}} {{core_unit["name"]}} description FIX_ME
@@ -154,7 +155,7 @@ set services infra-crt {{device}} ldp core-interface name {{core_interface["name
{#- MPLS-TE #}
{%- if core_unit["mpls"] == True %}
{%- if none not in core_unit["mpls-te-att-names"] %}
set services infra-crt {{device}} mpls-te core-interface name {{core_interface["name"]}} {{core_unit["name"]}} mpls-te-att-names {{core_unit["mpls-te-att-names"]}}
set services infra-crt {{device}} mpls-te core-interface name {{core_interface["name"]}} {{core_unit["name"]}} mpls-te-att-names [ {{core_unit["mpls-te-att-names"] | join(' ')}} ]
{%- else %}
set services infra-crt {{device}} mpls-te core-interface name {{core_interface["name"]}} {{core_unit["name"]}}
{%- endif %}