diff --git a/geant/gap_ansible/roles/edge_port/tasks/compile.yaml b/geant/gap_ansible/roles/edge_port/tasks/compile.yaml index fe1b1848d5bb7ea16e2dd9022aff9ce5a6819c07..6c7fc2c36ec3ad7da2d1fb2bc4fcceb37fe21693 100644 --- a/geant/gap_ansible/roles/edge_port/tasks/compile.yaml +++ b/geant/gap_ansible/roles/edge_port/tasks/compile.yaml @@ -13,11 +13,11 @@ mode: '0755' delegate_to: localhost -- name: Print the template in "/var/tmp/ansible_run_{{ opid }}/edge_port.conf" +- name: Print the template in "/var/tmp/ansible_run_{{ opid }}/edge_port_{{ verb }}.conf" when: verb == "create" ansible.builtin.template: - src: "{{ router.vendor }}/edge_port.j2" - dest: "/var/tmp/ansible_run_{{ opid }}/edge_port.conf" + src: "{{ router.vendor }}/edge_port_{{ verb }}.j2" + dest: "/var/tmp/ansible_run_{{ opid }}/edge_port_{{ verb }}.conf" lstrip_blocks: true trim_blocks: true mode: '0755' diff --git a/geant/gap_ansible/roles/edge_port/tasks/deploy.yaml b/geant/gap_ansible/roles/edge_port/tasks/deploy.yaml index 1533f1345a1369af906e3380d9cfa7caf811186d..df45f81806e2cbbdd0b641cefcd9e45bf57e7f0c 100644 --- a/geant/gap_ansible/roles/edge_port/tasks/deploy.yaml +++ b/geant/gap_ansible/roles/edge_port/tasks/deploy.yaml @@ -1,115 +1,25 @@ -- name: Deploy PE base_config on "{{ inventory_hostname }}" [CHECK ONLY][NOKIA] +- name: Perform "{{ verb }}" Edge port on "{{ inventory_hostname }}" [CHECK ONLY][NOKIA] when: >- dry_run | ansible.builtin.bool - and verb == "deploy_pe_base_config" geant.gap_ansible.nokia_netconf_config: format: xml default_operation: merge - content: "{{ lookup('ansible.builtin.template', 'routers/{{ subscription.router.vendor }}/pe_promotion_base_config.j2') }}" + content: "{{ lookup('ansible.builtin.template', '{{ router.vendor }}/edge_port_{{ verb }}.j2') }}" commit: true validate: true diff: true register: output check_mode: true -- name: Deploy PE base VPRNs on "{{ inventory_hostname }}" [CHECK ONLY][NOKIA] +- name: Perform "{{ verb }}" Edge port on "{{ inventory_hostname }}" [FOR REAL][NOKIA] when: >- - dry_run | ansible.builtin.bool - and verb == "deploy_routing_instances" - geant.gap_ansible.nokia_netconf_config: - format: xml - default_operation: merge - content: "{{ lookup('ansible.builtin.template', 'routers/{{ subscription.router.vendor }}/pe_promotion_base_vprn.j2') }}" - commit: true - validate: true - diff: true - register: output - check_mode: true - -- name: Deploy SDP mesh on "{{ inventory_hostname }}" [CHECK ONLY][NOKIA] - when: >- - dry_run | ansible.builtin.bool - and verb == "update_sdp_mesh" - geant.gap_ansible.nokia_netconf_config: - format: xml - default_operation: merge - content: "{{ lookup('ansible.builtin.template', 'routers/{{ subscription.router.vendor }}/pe_update_sdp.j2') }}" - commit: true - validate: true - diff: true - register: output - check_mode: true - -- name: Delete default routes on "{{ inventory_hostname }}" [CHECK ONLY][NOKIA] - when: >- - dry_run | ansible.builtin.bool - and verb == "delete_default_routes" + not (dry_run | ansible.builtin.bool) geant.gap_ansible.nokia_netconf_config: format: xml default_operation: merge - content: "{{ lookup('ansible.builtin.template', 'routers/{{ subscription.router.vendor }}/router/delete_default_static_routes.j2') }}" + content: "{{ lookup('ansible.builtin.template', '{{ router.vendor }}/edge_port_{{ verb }}.j2') }}" commit: true validate: true diff: true register: output - check_mode: true - -# - name: Fail if there is any diff -# ansible.builtin.fail: -# msg: Base config drift detected!!! -# when: > -# output.changed | ansible.builtin.bool -# and -# is_verification_workflow | ansible.builtin.bool - -- name: Deploy base_config on "{{ inventory_hostname }}" [AND COMMIT][NOKIA] - when: >- - not (dry_run | ansible.builtin.bool) and - verb == "deploy_pe_base_config" - geant.gap_ansible.nokia_netconf_config: - format: xml - default_operation: merge - content: "{{ lookup('ansible.builtin.template', 'routers/{{ subscription.router.vendor }}/pe_promotion_base_config.j2') }}" - commit: true - commit_comment: "{{ commit_comment }}" - diff: true - check_mode: false - -- name: Deploy PE base VPRNs on "{{ inventory_hostname }}" [AND COMMIT][NOKIA] - when: >- - not (dry_run | ansible.builtin.bool) and - verb == "deploy_routing_instances" - geant.gap_ansible.nokia_netconf_config: - format: xml - default_operation: merge - content: "{{ lookup('ansible.builtin.template', 'routers/{{ subscription.router.vendor }}/pe_promotion_base_vprn.j2') }}" - commit: true - commit_comment: "{{ commit_comment }}" - diff: true - check_mode: false - -- name: Deploy updated SDP mesh on "{{ inventory_hostname }}" [AND COMMIT][NOKIA] - when: >- - not (dry_run | ansible.builtin.bool) and - verb == "update_sdp_mesh" - geant.gap_ansible.nokia_netconf_config: - format: xml - default_operation: merge - content: "{{ lookup('ansible.builtin.template', 'routers/{{ subscription.router.vendor }}/pe_update_sdp.j2') }}" - commit: true - commit_comment: "{{ commit_comment }}" - diff: true - check_mode: false - -- name: Delete default routes on "{{ inventory_hostname }}" [AND COMMIT][NOKIA] - when: >- - not (dry_run | ansible.builtin.bool) - and verb == "delete_default_routes" - geant.gap_ansible.nokia_netconf_config: - format: xml - default_operation: merge - content: "{{ lookup('ansible.builtin.template', 'routers/{{ subscription.router.vendor }}/router/delete_default_static_routes.j2') }}" - commit: true - commit_comment: "{{ commit_comment }}" - diff: true check_mode: false diff --git a/geant/gap_ansible/roles/edge_port/tasks/main.yml b/geant/gap_ansible/roles/edge_port/tasks/main.yml index 9b2e64f3a9460e0f3fc165940705c6f547923117..172cbfa9e9cc2d0cd119ee957903653cacfb3961 100644 --- a/geant/gap_ansible/roles/edge_port/tasks/main.yml +++ b/geant/gap_ansible/roles/edge_port/tasks/main.yml @@ -7,6 +7,6 @@ when: verb in verbs ansible.builtin.include_tasks: compile.yaml -# - name: Include deploy if selected -# when: verb in verbs -# ansible.builtin.include_tasks: deploy.yaml +- name: Include create if selected + when: verb in verbs + ansible.builtin.include_tasks: deploy.yaml diff --git a/geant/gap_ansible/roles/edge_port/templates/nokia/edge_port.j2 b/geant/gap_ansible/roles/edge_port/templates/nokia/edge_port.j2 index 609be9ba284d82fcbf2ef456472026384cdee791..1799ca4efe04f6f5f463aef8af5adfe5eb773261 100644 --- a/geant/gap_ansible/roles/edge_port/templates/nokia/edge_port.j2 +++ b/geant/gap_ansible/roles/edge_port/templates/nokia/edge_port.j2 @@ -1,15 +1,15 @@ <config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:alu="urn:ietf:params:xml:ns:netconf:base:1.0"> <configure xmlns="urn:nokia.com:sros:ns:yang:sr:conf"> -{% for member in edge_port_ae_members %} +{% for member in ep.edge_port_ae_members %} <port 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" alu:operation="replace"> <port-id>{{ member.interface_name }}</port-id> <admin-state>enable</admin-state> - <description>PHY {{ edge_port_type }} {{ partner_name }} P_{{ edge_port_name }} | {{ member.interface_description }}</description> + <description>PHY {{ ep.edge_port_type }} {{ partner_name }} P_{{ ep.edge_port_name }} | {{ member.interface_description }}</description> <ethernet> <mode>access</mode> <mtu>{{ mtu_phy | default(9192) }}</mtu> - {% if edge_port_lldp_enable_map[edge_port_type] is true %} + {% if edge_port_lldp_enable_map[ep.edge_port_type] is true %} <lldp> <dest-mac> <mac-type>nearest-bridge</mac-type> @@ -27,33 +27,37 @@ </port> {% endfor %} {% if edge_port_removed_ae_members is defined %} -{% for member in edge_port_removed_ae_members %} + {% for member in edge_port_removed_ae_members %} <port 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" alu:operation="replace"> <port-id>{{ member.interface_name }}</port-id> <admin-state>disable</admin-state> <description>''</description> </port> -{% endfor %} + {% endfor %} {% endif %} <lag 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" alu:operation="replace"> - <lag-name>{{ edge_port_name | lower }}</lag-name> + <lag-name>{{ ep.edge_port_name | lower }}</lag-name> <admin-state>enable</admin-state> - <description>LAG {{ edge_port_type }} {{ partner_name }} </description> - <mode>network</mode> - {% if edge_port_enable_lacp is true %} + {% if ep.edge_port_geant_ga_id is string %} + <description>LAG {{ ep.edge_port_type }} {{ partner_name }} ${{ ep.edge_port_geant_ga_id }} | </description> + {% else %} + <description>LAG {{ ep.edge_port_type }} {{ partner_name }} | </description> + {% endif %} + <mode>access</mode> + {% if ep.edge_port_enable_lacp is true %} <lacp> <mode>active</mode> - <administrative-key>{{ (edge_port_name|split("-"))[1] }}</administrative-key> + <administrative-key>{{ (ep.edge_port_name|split("-"))[1] }}</administrative-key> </lacp> {% endif %} -{% for member in edge_port_ae_members %} +{% for member in ep.edge_port_ae_members %} <port> <port-id>{{ member.interface_name }}</port-id> </port> {% endfor %} - {% if ( edge_port_minimum_links | int) > 1 %} + {% if ( ep.edge_port_minimum_links | int) > 1 %} <port-threshold> - <value>{{ ( edge_port_minimum_links | int) - 1 }}</value> + <value>{{ ( ep.edge_port_minimum_links | int) - 1 }}</value> <action>down</action> </port-threshold> {% endif %} diff --git a/geant/gap_ansible/roles/edge_port/templates/nokia/edge_port_create.j2 b/geant/gap_ansible/roles/edge_port/templates/nokia/edge_port_create.j2 new file mode 100644 index 0000000000000000000000000000000000000000..3ec4ef543e880d1d8132d56c91175d6a51b4077b --- /dev/null +++ b/geant/gap_ansible/roles/edge_port/templates/nokia/edge_port_create.j2 @@ -0,0 +1,65 @@ +<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:alu="urn:ietf:params:xml:ns:netconf:base:1.0"> + <configure xmlns="urn:nokia.com:sros:ns:yang:sr:conf"> + +{% for member in ep.edge_port_ae_members %} + <port 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" alu:operation="replace"> + <port-id>{{ member.interface_name }}</port-id> + <admin-state>enable</admin-state> + <description>PHY {{ ep.edge_port_type }} {{ partner_name }} P_{{ ep.edge_port_name }} | {{ member.interface_description }}</description> + <ethernet> + <mode>access</mode> + <mtu>{{ mtu_phy | default(9192) }}</mtu> + {% if edge_port_lldp_enable_map[ep.edge_port_type] is true %} + <lldp> + <dest-mac> + <mac-type>nearest-bridge</mac-type> + <receive>true</receive> + <transmit>true</transmit> + <tx-tlvs> + <port-desc>true</port-desc> + <sys-name>true</sys-name> + <sys-cap>true</sys-cap> + </tx-tlvs> + </dest-mac> + </lldp> + {% endif %} + </ethernet> + </port> +{% endfor %} +{% if removed_ae_members is defined and removed_ae_members|length > 0 %} + {% for member in removed_ae_members %} + <port 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" alu:operation="replace"> + <port-id>{{ member.interface_name }}</port-id> + <admin-state>disable</admin-state> + </port> + {% endfor %} +{% endif %} + <lag 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" alu:operation="replace"> + <lag-name>{{ ep.edge_port_name | lower }}</lag-name> + <admin-state>enable</admin-state> + {% if ep.edge_port_geant_ga_id is string %} + <description>LAG {{ ep.edge_port_type }} {{ partner_name }} ${{ ep.edge_port_geant_ga_id }} | </description> + {% else %} + <description>LAG {{ ep.edge_port_type }} {{ partner_name }} | </description> + {% endif %} + <mode>access</mode> + {% if ep.edge_port_enable_lacp is true %} + <lacp> + <mode>active</mode> + <administrative-key>{{ (ep.edge_port_name|split("-"))[1] }}</administrative-key> + </lacp> + {% endif %} +{% for member in ep.edge_port_ae_members %} + <port> + <port-id>{{ member.interface_name }}</port-id> + </port> +{% endfor %} + {% if ( ep.edge_port_minimum_links | int) > 1 %} + <port-threshold> + <value>{{ ( ep.edge_port_minimum_links | int) - 1 }}</value> + <action>down</action> + </port-threshold> + {% endif %} + </lag> + </configure> +</config> diff --git a/geant/gap_ansible/roles/edge_port/templates/nokia/edge_port_terminate.j2 b/geant/gap_ansible/roles/edge_port/templates/nokia/edge_port_terminate.j2 new file mode 100644 index 0000000000000000000000000000000000000000..36eed596088a1a5b564b607ef0820da0a3f14bf8 --- /dev/null +++ b/geant/gap_ansible/roles/edge_port/templates/nokia/edge_port_terminate.j2 @@ -0,0 +1,14 @@ +<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:alu="urn:ietf:params:xml:ns:netconf:base:1.0"> + <configure xmlns="urn:nokia.com:sros:ns:yang:sr:conf"> + +{% for member in ep.edge_port_ae_members %} + <port 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" alu:operation="replace"> + <port-id>{{ member.interface_name }}</port-id> + <admin-state>disable</admin-state> + </port> +{% endfor %} + <lag 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" alu:operation="delete"> + <lag-name>{{ ep.edge_port_name | lower }}</lag-name> + </lag> + </configure> +</config> diff --git a/geant/gap_ansible/roles/edge_port/templates/nokia/edge_port_update.j2 b/geant/gap_ansible/roles/edge_port/templates/nokia/edge_port_update.j2 new file mode 120000 index 0000000000000000000000000000000000000000..4f9110ef2350e0a36583633440d625068d7fc5f4 --- /dev/null +++ b/geant/gap_ansible/roles/edge_port/templates/nokia/edge_port_update.j2 @@ -0,0 +1 @@ +edge_port_create.j2 \ No newline at end of file diff --git a/geant/gap_ansible/roles/edge_port/vars/main.yml b/geant/gap_ansible/roles/edge_port/vars/main.yml index fef36d0dab3ae1e1de2ab7b1e7fc0b8940b636c6..40213f93bbc690e91d6d92145f7edc2fd49371cc 100644 --- a/geant/gap_ansible/roles/edge_port/vars/main.yml +++ b/geant/gap_ansible/roles/edge_port/vars/main.yml @@ -4,8 +4,8 @@ dry_run: true verbs: - create - - deploy # deploys an EdgePort - - delete # deletes an EdgePort + - update + - terminate - migrate # migrates an EdgePort ep: "{{ subscription.edge_port }}"