From 52999a38532f456a27608589c727813193578f88 Mon Sep 17 00:00:00 2001 From: Sugetha Chandhrasekar Date: Tue, 13 Feb 2024 11:25:07 -0800 Subject: [PATCH] added test for changing tag value --- .../avd/molecule/deploy_to_cv/converge.yml | 67 ++++++++- .../intended/configs/change_tags/s1-leaf1.cfg | 60 ++++++++ .../change_tags/s1-leaf1.yml | 137 ++++++++++++++++++ .../intended/structured_configs/s1-leaf1.yml | 2 +- .../structured_configs/s1-missing.yml | 2 +- .../strict_tags/s1-leaf1.yml | 2 +- 6 files changed, 262 insertions(+), 8 deletions(-) create mode 100644 ansible_collections/arista/avd/molecule/deploy_to_cv/intended/configs/change_tags/s1-leaf1.cfg create mode 100644 ansible_collections/arista/avd/molecule/deploy_to_cv/intended/structured_configs/change_tags/s1-leaf1.yml diff --git a/ansible_collections/arista/avd/molecule/deploy_to_cv/converge.yml b/ansible_collections/arista/avd/molecule/deploy_to_cv/converge.yml index ac3aeea9d56..f392237eb62 100644 --- a/ansible_collections/arista/avd/molecule/deploy_to_cv/converge.yml +++ b/ansible_collections/arista/avd/molecule/deploy_to_cv/converge.yml @@ -14,10 +14,13 @@ structured_config_dir: "{{ playbook_dir }}/intended/structured_configs" strict_configuration_dir: "{{ playbook_dir }}/intended/configs/strict_tags" strict_structured_config_dir: "{{ playbook_dir }}/intended/structured_configs/strict_tags" + value_configuration_dir: "{{ playbook_dir }}/intended/configs/change_tags" + value_structured_config_dir: "{{ playbook_dir }}/intended/structured_configs/change_tags" intended_tag_device: s1-leaf1 intended_tags: "{{ lookup('file', structured_config_dir ~ '/' ~ intended_tag_device ~ '.yml')|from_yaml }}" # intended_strict_tag_device: s1-leaf1-strict_tags intended_strict_tags: "{{ lookup('file', strict_structured_config_dir ~ '/' ~ intended_tag_device ~ '.yml')|from_yaml }}" + intended_value_tags: "{{ lookup('file', value_structured_config_dir ~ '/' ~ intended_tag_device ~ '.yml')|from_yaml }}" tasks: @@ -147,9 +150,9 @@ run_once: true vars: configs: ['{{ configuration_dir }}/s1-leaf1.cfg', - '{{ configuration_dir }}/s1-leaf2.cfg', - '{{ configuration_dir }}/s1-leaf3.cfg', - '{{ configuration_dir }}/s1-leaf4.cfg' + '{{ configuration_dir }}/s1-leaf2.cfg', + '{{ configuration_dir }}/s1-leaf3.cfg', + '{{ configuration_dir }}/s1-leaf4.cfg' ] set_fact: response_configlet: "{{ response_configlet | default({}) | combine({item.0.json[0].value.body | trim: item.1}) }}" @@ -201,7 +204,7 @@ label: "{{ item.tags[0].name }}" value: "{{ item.tags[0].value }}" deviceId: "{{ intended_tag_device }}" - interfaceId: "{{ item.interface }}" + interfaceId: "{{ item.interface }}" loop: "{{ intended_tags.metadata.cv_tags.interface_tags }}" @@ -255,4 +258,58 @@ value: "{{ item.value }}" deviceId: "{{ intended_tag_device }}" loop: - "{{ intended_strict_tags.metadata.cv_tags.device_tags }}" \ No newline at end of file + "{{ intended_strict_tags.metadata.cv_tags.device_tags }}" + + - name: Test tags = Value change + run_once: true + delegate_to: localhost + vars: + ws_name_value: avd-static-studio-tag-value-change-{{ r }} + ws_description_value: sample description + ws_req_state_value: submitted + ws_force_value: true + cc_name_value: cc_avd-static-studio-tag-value-change-{{ r }} + cc_requested_state_value: running + cc_desctiption_value: sample description + arista.avd.deploy_to_cv: + configuration_dir: "{{ value_configuration_dir }}" + structured_config_dir: "{{ value_structured_config_dir }}" + device_list: ["s1-leaf1"] + strict_tags: true + cv_servers: [ '{{ cv_server }}' ] + cv_token: '{{ token }}' + workspace: + name: '{{ ws_name_value }}' + description: '{{ ws_description_value }}' + id: '{{ ws_name_value }}' + requested_state: '{{ ws_req_state_value }}' + force: '{{ ws_force_value }}' + change_control: + name: '{{ cc_name_value }}' + description: '{{ cc_desctiption_value }}' + requested_state: '{{ cc_requested_state_value }}' + return_details: true + register: CVP_VALUE_TAGS_RESULTS + + - name: Get Value Device Tag information + delegate_to: localhost + run_once: true + vars: + ws_name_value: avd-static-studio-tag-value-change-{{ r }} + ansible.builtin.uri: + url: '{{ tag_url }}' + return_content: true + validate_certs: false + headers: + Cookie: "access_token={{ token }}" + method: POST + body_format: json + body: + key: + workspaceId: '{{ ws_name_value }}' + elementType: 1 + label: "{{ item.name }}" + value: "{{ item.value }}" + deviceId: "{{ intended_tag_device }}" + loop: + "{{ intended_value_tags.metadata.cv_tags.device_tags }}" diff --git a/ansible_collections/arista/avd/molecule/deploy_to_cv/intended/configs/change_tags/s1-leaf1.cfg b/ansible_collections/arista/avd/molecule/deploy_to_cv/intended/configs/change_tags/s1-leaf1.cfg new file mode 100644 index 00000000000..6ffe4d40405 --- /dev/null +++ b/ansible_collections/arista/avd/molecule/deploy_to_cv/intended/configs/change_tags/s1-leaf1.cfg @@ -0,0 +1,60 @@ +!RANCID-CONTENT-TYPE: arista +! +no aaa root +! +username cvpadmin privilege 15 role network-admin secret sha512 $6$zWeb8jvKJY8ZtQkD$QzZDALGL1yDmjOxiGUNVJNyBU2la8AXPW04OmxaBt7JEfAgNU9QULOkG2HmwD3x8hFoo2LnwtjbX.Muj/dXlH0 +username netadmin privilege 15 role network-admin secret sha512 $6$wdCCRfpWoyE3pTFJ$sMePFNrFSFKUVFxlxMTkB7E90tgwiz7BDtcUpBH5ga4Co/N59tsselElTZyYA.LDuSnVl2t/FH.qc1FX9fzNM/ +username arista privilege 15 role network-admin secret arista123! +! +daemon TerminAttr + exec /usr/bin/TerminAttr -cvaddr=apiserver.cv-staging.corp.arista.io:443 -cvauth=token-secure,/mnt/flash/cv-onboarding-token -smashexcludes=ale,flexCounter,hardware,kni,pulse,strata -ingestexclude=/Sysdb/cell/1/agent,/Sysdb/cell/2/agent -cvvrf=MGMT -taillogs + no shutdown +! +vlan internal order ascending range 3900 4000 +! +transceiver qsfp default-mode 4x10G +! +service routing protocols model multi-agent +! +hostname s1-leaf1 +ip name-server vrf MGMT 172.22.22.40 +! +platform tfa + personality arfa +! +spanning-tree mode mstp +! +system l1 + unsupported speed action error + unsupported error-correction action error +! +vrf instance MGMT +! +management api http-commands + no shutdown + ! + vrf MGMT + no shutdown +! +interface Ethernet1 + description test +! +interface Ethernet2 +! +interface Ethernet3 +! +interface Ethernet4 +! +interface Ethernet6 +! +interface Management0 + vrf MGMT + ip address 172.20.20.2/24 + ipv6 address 2001:172:20:20::2/64 +! +no ip routing +no ip routing vrf MGMT +! +ip route vrf MGMT 0.0.0.0/0 172.20.20.1 +! +end diff --git a/ansible_collections/arista/avd/molecule/deploy_to_cv/intended/structured_configs/change_tags/s1-leaf1.yml b/ansible_collections/arista/avd/molecule/deploy_to_cv/intended/structured_configs/change_tags/s1-leaf1.yml new file mode 100644 index 00000000000..1c942dc15d1 --- /dev/null +++ b/ansible_collections/arista/avd/molecule/deploy_to_cv/intended/structured_configs/change_tags/s1-leaf1.yml @@ -0,0 +1,137 @@ +hostname: s1-leaf1 +is_deployed: true +static_routes: +- vrf: default + destination_address_prefix: 0.0.0.0/0 + gateway: 192.168.0.1 +service_routing_protocols_model: multi-agent +vlan_internal_order: + allocation: ascending + range: + beginning: 1006 + ending: 1199 +spanning_tree: + mode: mstp + mst_instances: + - id: '0' + priority: 16384 + no_spanning_tree_vlan: '4094' +local_users: +- name: arista + privilege: 15 + role: network-admin + sha512_password: $6$rounds=656000$workshop$2J0sPzNX5gJs0tOf/ynK.X3f3fTTInXVX1wO0cmY/5ZTTg4GCFu3lvX9SggLk7W2.xD73cm5EA/R69iMBlfJt. +vrfs: +- name: default + ip_routing: false +management_interfaces: +- name: Management0 + description: oob_management + shutdown: false + vrf: default + ip_address: 192.168.0.12/24 + gateway: 192.168.0.1 + type: oob +management_api_http: + enable_vrfs: + - name: default + enable_https: true +vlans: +- id: 4094 + tenant: system + name: MLAG_PEER + trunk_groups: + - MLAG +- id: 10 + name: Ten + tenant: MY_FABRIC +vlan_interfaces: +- name: Vlan4094 + description: MLAG_PEER + shutdown: false + ip_address: 10.1.253.4/31 + no_autostate: true + mtu: 1500 +port_channel_interfaces: +- name: Port-Channel1 + description: MLAG_PEER_s1-leaf2_Po1 + type: switched + shutdown: false + mode: trunk + trunk_groups: + - MLAG +- name: Port-Channel2 + description: SPINES_Po2 + type: switched + shutdown: false + mode: trunk + vlans: '10' + mlag: 2 +ethernet_interfaces: +- name: Ethernet1 + peer: s1-leaf2 + peer_interface: Ethernet1 + peer_type: mlag_peer + description: MLAG_PEER_s1-leaf2_Ethernet1 + type: port-channel-member + shutdown: false + channel_group: + id: 1 + mode: active +- name: Ethernet6 + peer: s1-leaf2 + peer_interface: Ethernet6 + peer_type: mlag_peer + description: MLAG_PEER_s1-leaf2_Ethernet6 + type: port-channel-member + shutdown: false + channel_group: + id: 1 + mode: active +- name: Ethernet2 + peer: s1-spine1 + peer_interface: Ethernet2 + peer_type: l3spine + description: S1-SPINE1_Ethernet2 + shutdown: false + type: port-channel-member + channel_group: + id: 2 + mode: active +- name: Ethernet3 + peer: s1-spine2 + peer_interface: Ethernet2 + peer_type: l3spine + description: S1-SPINE2_Ethernet2 + shutdown: false + type: port-channel-member + channel_group: + id: 2 + mode: active +mlag_configuration: + domain_id: RACK1 + local_interface: Vlan4094 + peer_address: 10.1.253.5 + peer_link: Port-Channel1 + reload_delay_mlag: '300' + reload_delay_non_mlag: '330' +ip_igmp_snooping: + globally_enabled: true +metadata: + cv_tags: + device_tags: + - name: Role + value: border + interface_tags: + - interface: Ethernet1 + tags: + - name: Type + value: wan + - interface: Ethernet2 + tags: + - name: Type + value: wan + - interface: Ethernet3 + tags: + - name: Type + value: wan diff --git a/ansible_collections/arista/avd/molecule/deploy_to_cv/intended/structured_configs/s1-leaf1.yml b/ansible_collections/arista/avd/molecule/deploy_to_cv/intended/structured_configs/s1-leaf1.yml index eb803a04e03..ea2f6937b4c 100644 --- a/ansible_collections/arista/avd/molecule/deploy_to_cv/intended/structured_configs/s1-leaf1.yml +++ b/ansible_collections/arista/avd/molecule/deploy_to_cv/intended/structured_configs/s1-leaf1.yml @@ -140,4 +140,4 @@ metadata: - interface: Ethernet3 tags: - name: Type - value: wan \ No newline at end of file + value: wan diff --git a/ansible_collections/arista/avd/molecule/deploy_to_cv/intended/structured_configs/s1-missing.yml b/ansible_collections/arista/avd/molecule/deploy_to_cv/intended/structured_configs/s1-missing.yml index 1fa921eb808..545c4af0a5d 100644 --- a/ansible_collections/arista/avd/molecule/deploy_to_cv/intended/structured_configs/s1-missing.yml +++ b/ansible_collections/arista/avd/molecule/deploy_to_cv/intended/structured_configs/s1-missing.yml @@ -152,4 +152,4 @@ metadata: # - name: Carrier # value: Comcast-5G # - name: Circuit - # value: AF830 \ No newline at end of file + # value: AF830 diff --git a/ansible_collections/arista/avd/molecule/deploy_to_cv/intended/structured_configs/strict_tags/s1-leaf1.yml b/ansible_collections/arista/avd/molecule/deploy_to_cv/intended/structured_configs/strict_tags/s1-leaf1.yml index 8f987dcb00a..c1d791e07a5 100644 --- a/ansible_collections/arista/avd/molecule/deploy_to_cv/intended/structured_configs/strict_tags/s1-leaf1.yml +++ b/ansible_collections/arista/avd/molecule/deploy_to_cv/intended/structured_configs/strict_tags/s1-leaf1.yml @@ -134,4 +134,4 @@ metadata: - interface: Ethernet3 tags: - name: Type - value: wan \ No newline at end of file + value: wan