Skip to content

Commit

Permalink
Test for strict tags function
Browse files Browse the repository at this point in the history
  • Loading branch information
sugetha24 committed Feb 8, 2024
1 parent d43f20d commit 4ce2899
Show file tree
Hide file tree
Showing 7 changed files with 484 additions and 84 deletions.
129 changes: 65 additions & 64 deletions ansible_collections/arista/avd/molecule/deploy_to_cv/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,31 @@
tag_url: https://{{ cv_server }}/api/v3/services/arista.tag.v2.TagAssignmentService/GetOne
configuration_dir: "{{ playbook_dir }}/intended/configs"
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"
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 }}"

ws_name: avd-static-studio-42
ws_description: sample description
ws_req_state: submitted
ws_force: true

# TODO: cc_id is not getting set to anything other than Workspace-<ws_nane>
cc_id: Workspace-avd-static-studio-42
cc_requested_state: running
cc_name: cc_avd_studio-42
cc_desctiption: sample description

# TODO: get end state device and assert state
tasks:
- name: Generate random string
set_fact:
r: "{{ lookup('password', '/dev/null chars=ascii_lowercase,digits length=4') }}"
run_once: true

- name: set facts
set_fact:
ws_name: avd-static-studio-{{ r }}
ws_description: sample description
ws_req_state: submitted
ws_force: true
cc_name: cc_avd_studio-{{ r }}
cc_requested_state: running
cc_desctiption: sample description
run_once: true

- name: Test = Provision CVP with AVD configuration
run_once: true
delegate_to: localhost
Expand All @@ -37,8 +46,8 @@
# structured_config_suffix: "yml"
# device_list: "{{ ansible_play_hosts }}"
device_list: ["s1-leaf1", "s1-leaf2", "s1-leaf3", "s1-leaf4", "s1-spine1", "s1-spine2"]
# strict_tags: true
# skip_missing_devices: false
strict_tags: true
# skip_strict_devices: false
# configlet_name_template: "AVD-${hostname}"
cv_servers: [ '{{ cv_server }}' ]
cv_token: '{{ token }}'
Expand All @@ -65,6 +74,8 @@
msg: '{{CVP_RESULTS}}'

- name: check CVP returns
vars:
cc_id: Workspace-{{ ws_name }}
ansible.builtin.assert:
that:
# workspace
Expand Down Expand Up @@ -113,7 +124,7 @@
register: result

# CC information
- name: get CC information
- name: Validate CC state to completed
delegate_to: localhost
run_once: true
ansible.builtin.uri:
Expand All @@ -126,7 +137,7 @@
body_format: json
body:
key:
id: '{{ cc_id }}'
id: Workspace-{{ ws_name }}
register: CC_INFO
until: CC_INFO.json[0].value.status == "CHANGE_CONTROL_STATUS_COMPLETED"
retries: 5
Expand All @@ -150,12 +161,6 @@
- item.key == lookup('file', item.value)
loop: "{{ response_configlet | dict2items }}"

# - name: 'Display intended tags'
# run_once: true
# debug:
# msg: '{{ item }}'
# loop: '{{ intended_tags.metadata.cv_tags.interface_tags }}'

- name: Get Device Tag information
delegate_to: localhost
run_once: true
Expand All @@ -177,14 +182,6 @@
loop:
"{{ intended_tags.metadata.cv_tags.device_tags }}"

# - name: 'Assert designed tags'
# run_once: true
# ansible.builtin.assert:
# that:
# - item.failed == false
# loop:
# '{{ designed_tags.results }}'

# # XXX: Assuming that there is only one interfaceTag per port
- name: Get and verify Interface Tag information
delegate_to: localhost
Expand All @@ -208,50 +205,54 @@
loop:
"{{ intended_tags.metadata.cv_tags.interface_tags }}"

# - name: 'Assert designed interface tags'
# run_once: true
# ansible.builtin.assert:
# that:
# - item.failed == false
# loop:
# '{{ designed_tags.results }}'

- name: Test = Provision with missing device
- name: Test Strict tags = Set tags
run_once: true
delegate_to: localhost
vars:
ws_name: missing-device-studio-4
ws_name_strict: avd-static-studio-strict-{{ r }}
ws_description_strict: sample description
ws_req_state_strict: submitted
ws_force_strict: true
cc_name_strict: cc_avd_studio-strict-{{ r }}
cc_requested_state_strict: running
cc_desctiption_strict: sample description
arista.avd.deploy_to_cv:
configuration_dir: "{{ configuration_dir }}"
structured_config_dir: "{{ structured_config_dir }}"
# structured_config_suffix: "yml"
# device_list: "{{ ansible_play_hosts }}"
device_list: ["s1-missing"]
configuration_dir: "{{ strict_configuration_dir }}"
structured_config_dir: "{{ strict_structured_config_dir }}"
device_list: ["s1-leaf1"]
strict_tags: true
# skip_missing_devices: false
# configlet_name_template: "AVD-${hostname}"
cv_servers: [ '{{ cv_server }}' ]
cv_token: '{{ token }}'
# cv_verify_certs: True
workspace:
name: '{{ ws_name }}'
description: '{{ ws_description }}'
id: '{{ ws_name }}'
requested_state: '{{ ws_req_state }}'
force: '{{ ws_force }}'
name: '{{ ws_name_strict }}'
description: '{{ ws_description_strict }}'
id: '{{ ws_name_strict }}'
requested_state: '{{ ws_req_state_strict }}'
force: '{{ ws_force_strict }}'
change_control:
name: '{{ cc_name }}'
description: '{{ cc_desctiption }}'
requested_state: '{{ cc_requested_state }}'
# timeouts:
# workspace_build_timeout: 300.0
# change_control_creation_timeout: 300.0
name: '{{ cc_name_strict }}'
description: '{{ cc_desctiption_strict }}'
requested_state: '{{ cc_requested_state_strict }}'
return_details: true
ignore_errors: true
register: CVP_RESULTS_MISSING
register: CVP_STRICT_TAGS_RESULTS

- name: Assert missing device errors
- name: Get Device Tag information
delegate_to: localhost
run_once: true
ansible.builtin.assert:
that:
- CVP_RESULTS_MISSING.errors == ["('Missing devices on CloudVision', CVDevice(hostname='s1-missing', serial_number=None, system_mac_address=None, _exists_on_cv=None))"]
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 }}'
elementType: 1
label: "{{ item.name }}"
value: "{{ item.value }}"
deviceId: "{{ intended_tag_device }}"
loop:
"{{ intended_strict_tags.metadata.cv_tags.device_tags }}"
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ management api http-commands
no shutdown
!
interface Ethernet1
description test
!
interface Ethernet2
!
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -122,34 +122,22 @@ metadata:
device_tags:
- name: Role
value: edge
# - name: Region
# value: AVD_Land_East
# - name: Zone
# value: DEFAULT-ZONE
# - name: Site
# value: Site511
- name: Region
value: AVD_Land_East
- name: Zone
value: DEFAULT-ZONE
- name: Site
value: Site511
interface_tags:
- interface: Ethernet1
tags:
- name: Type
value: wan
# - name: Carrier
# value: ATT
# - name: Circuit
# value: '666'
- interface: Ethernet2
tags:
- name: Type
value: wan
# - name: Carrier
# value: Colt
# - name: Circuit
# value: '10555'
- interface: Ethernet3
tags:
- name: Type
value: wan
# - name: Carrier
# value: Comcast-5G
# - name: Circuit
# value: AF830
value: wan
Loading

0 comments on commit 4ce2899

Please sign in to comment.