diff --git a/geant/gap_ansible/roles/promote_p_to_pe/templates/routers/nokia/policy_options/policy_options.j2 b/geant/gap_ansible/roles/promote_p_to_pe/templates/routers/nokia/policy_options/policy_options.j2 index 047dc0e8d49df8f4ba3409189c6fde4a1aa27684..bb4790c644b63d38021a989f56870478946505b2 100644 --- a/geant/gap_ansible/roles/promote_p_to_pe/templates/routers/nokia/policy_options/policy_options.j2 +++ b/geant/gap_ansible/roles/promote_p_to_pe/templates/routers/nokia/policy_options/policy_options.j2 @@ -1,26 +1,30 @@ -<policy-options xmlns="urn:nokia.com:sros:ns:yang:sr:conf" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nokia-attr="urn:nokia.com:sros:ns:yang:sr:attributes"> - {% if nokia_po_prefix_lists is defined %} - {% with prefix_lists_obj=nokia_po_prefix_lists %} - {% include 'policy_options/prefix_lists.j2' %} - {% endwith %} - {% endif %} - {# Communities #} - {% if nokia_po_communities is defined %} - {% with communities_obj=nokia_po_communities %} - {% include 'policy_options/communites.j2' %} - {% endwith %} - {% endif %} - {# AS paths #} - {% if nokia_po_as_paths is defined %} - {% with as_paths_obj=nokia_po_as_paths %} - {% include 'policy_options/as_paths.j2' %} - {% endwith %} - {% endif %} -{# Policy statements #} - {% if nokia_po_policy_statements is defined %} - {% with policy_obj=nokia_po_policy_statements %} - {% include 'policy_options/policy_statement.j2' %} - {% endwith %} - {% endif %} -</policy-options> - + <policy-options xmlns="urn:nokia.com:sros:ns:yang:sr:conf" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nokia-attr="urn:nokia.com:sros:ns:yang:sr:attributes"> + {% if nokia_po_prefix_lists is defined %} + {% with prefix_lists_obj=nokia_po_prefix_lists %} + {% include 'policy_options/prefix_lists.j2' %} + {% endwith %} + {% endif %} + + {# Communities #} + {% if nokia_po_communities is defined %} + {% with communities_obj=nokia_po_communities %} + {% include 'policy_options/communities.j2' %} + {% endwith %} + {% endif %} + + {# AS paths #} + {% if nokia_po_as_paths is defined %} + {% with as_paths_obj=nokia_po_as_paths %} + {% include 'policy_options/as_paths.j2' %} + {% endwith %} + {% endif %} + + {# Policy statements #} + {% if nokia_po_policy_statements is defined %} + {% with policy_obj=nokia_po_policy_statements %} + {% include 'policy_options/policy_statements.j2' %} + {% endwith %} + {% endif %} + + </policy-options> + diff --git a/geant/gap_ansible/roles/promote_p_to_pe/templates/routers/nokia/policy_options/policy_statements.j2 b/geant/gap_ansible/roles/promote_p_to_pe/templates/routers/nokia/policy_options/policy_statements.j2 index 3e451852fba859acd7595ca33e8b5d0d2888986c..95126f78838203c9bce99458cee179a0a87f5f75 100644 --- a/geant/gap_ansible/roles/promote_p_to_pe/templates/routers/nokia/policy_options/policy_statements.j2 +++ b/geant/gap_ansible/roles/promote_p_to_pe/templates/routers/nokia/policy_options/policy_statements.j2 @@ -3,60 +3,64 @@ <name>{{ pol.name }}</name> <entry-type>{{ pol.entry_type }}</entry-type> {% for entry in pol.entries %} + {% if pol.entry_type == 'named' %} + <named-entry> + {% endif %} <entry-name>{{ entry.name }}</entry-name> {% if entry.from is defined %} <from> {% if entry.from.as_path is defined %} <as-path> {% if entry.from.as_path.name is defined %} - <name>{{ entry.from.as_path.name }}</name> + <name>{{ entry.from.as_path.name }}</name> {% endif %} {% if entry.from.as_path.length is defined %} - <length> - <value>{{ entry.from.as_path.length }}</value> - </length> + <length> + <value>{{ entry.from.as_path.length }}</value> + </length> {% endif %} </as-path> {% endif %} {% if entry.from.prefix_list is defined %} {% for pl in entry.from.prefix_list %} - <prefix_list>{{ pl }}</prefix_list> + <prefix-list>{{ pl }}</prefix-list> {% endfor %} {% endif %} {% if entry.from.community is defined %} - <community> - <name>{{ entry.from.community }}</name> - </community> + <community> + <name>{{ entry.from.community }}</name> + </community> {% endif %} {% if entry.from.origin_validation_state is defined %} - <origin-validation-state>{{ entry.from.origin_validation_state }}</origin-validation-state> + <origin-validation-state>{{ entry.from.origin_validation_state }}</origin-validation-state> {% endif %} {% if entry.from.protocol is defined %} {% for proto in entry.from.protocol %} - <protocol> - <name>{{ proto }}</name> - </protocol> + <protocol> + <name>{{ proto }}</name> + </protocol> {% endfor %} {% endif %} </from> {% endif %} <action> - <action-type>{{ entry.action_type }}</action-type> + <action-type>{{ entry.action_type }}</action-type> {% if entry.action is defined %} {% for action_item in entry.action %} {% for act_k, act_v in action_item.items() %} {% if act_k == "community_add" %} - <community> - <add>{{ act_v }}</add> - </community> + <community> + <add>{{ act_v }}</add> + </community> {% else %} - <{{ act_k }}>{{ act_v }}</{{act_k }}> + <{{ act_k | replace("_", "-") }}>{{ act_v }}</{{act_k | replace("_", "-") }}> {% endif %} {% endfor %} {% endfor %} {% endif %} </action> + </named-entry> {% endfor %} </policy-statement> + {% endfor %} - {% endif %} diff --git a/geant/gap_ansible/roles/promote_p_to_pe/templates/routers/nokia/policy_options/prefix_lists.j2 b/geant/gap_ansible/roles/promote_p_to_pe/templates/routers/nokia/policy_options/prefix_lists.j2 index 67529ea5b0af0e1b6cf0b5ddb936a502dc3d4643..507986e60983c0445d2110328584695d67b2b70a 100644 --- a/geant/gap_ansible/roles/promote_p_to_pe/templates/routers/nokia/policy_options/prefix_lists.j2 +++ b/geant/gap_ansible/roles/promote_p_to_pe/templates/routers/nokia/policy_options/prefix_lists.j2 @@ -9,6 +9,7 @@ <start-length>{{ prefix.range_start_length }}</start-length> <end-length>{{ prefix.range_end_length }}</end-length> {% endif %} + </prefix> {% endfor %} </prefix-list> {% endfor %}