Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions ansible/library/conn_graph_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def get_host_connections(self, hostname):
return the given hostname device each individual connection
"""
if hostname in self.links:
return self.links[hostname]
return { hostname: self.links[hostname] }
else:
return self.links

Expand Down Expand Up @@ -322,7 +322,7 @@ def main():
lab_graph = find_graph(target)

device_info = []
device_conn = []
device_conn = {}
device_port_vlans = []
device_vlan_range = []
device_vlan_list = []
Expand All @@ -332,7 +332,7 @@ def main():
if dev is None:
module.fail_json(msg="cannot find info for %s" % hostname)
device_info.append(dev)
device_conn.append(lab_graph.get_host_connections(hostname))
device_conn.update(lab_graph.get_host_connections(hostname))
host_vlan = lab_graph.get_host_vlan(hostname)
# for multi-DUTs, must ensure all have vlan configured.
if host_vlan:
Expand All @@ -343,10 +343,6 @@ def main():
results = {k: v for k, v in locals().items()
if (k.startswith("device_") and v)}

# flatten the lists for single host
if m_args['hosts'] is None:
results = {k: v[0] if isinstance(v, list) else v for k, v in results.items()}

module.exit_json(ansible_facts=results)
except (IOError, OSError):
module.fail_json(msg="Can not find lab graph file under {}".format(LAB_GRAPHFILE_PATH))
Expand Down
16 changes: 8 additions & 8 deletions ansible/roles/fanout/templates/arista_7060_deploy.j2
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ vrf definition management
{% set intf = 'Ethernet' + i|string + '/1' %}
interface {{ intf }}
{% if intf in device_port_vlans and device_port_vlans[intf]['mode'] != "Trunk" %}
{% if device_conn[intf]['speed'] == "100000" %}
description {{ device_conn[intf]['peerdevice'] }}-{{ device_conn[intf]['peerport'] }}
{% if device_conn[inventory_hostname][intf]['speed'] == "100000" %}
description {{ device_conn[inventory_hostname][intf]['peerdevice'] }}-{{ device_conn[inventory_hostname][intf]['peerport'] }}
switchport access vlan {{ device_port_vlans[intf]['vlanids'] }}
switchport mode dot1q-tunnel
spanning-tree portfast
speed forced 100gfull
error-correction encoding reed-solomon
no shutdown
{% elif device_conn[intf]['speed'] == "40000" %}
description {{ device_conn[intf]['peerdevice'] }}-{{ device_conn[intf]['peerport'] }}
{% elif device_conn[inventory_hostname][intf]['speed'] == "40000" %}
description {{ device_conn[inventory_hostname][intf]['peerdevice'] }}-{{ device_conn[inventory_hostname][intf]['peerport'] }}
switchport access vlan {{ device_port_vlans[intf]['vlanids'] }}
switchport mode dot1q-tunnel
spanning-tree portfast
speed forced 40gfull
no shutdown
{% elif device_conn[intf]['speed'] == "50000" %}
description {{ device_conn[intf]['peerdevice'] }}-{{ device_conn[intf]['peerport'] }}
{% elif device_conn[inventory_hostname][intf]['speed'] == "50000" %}
description {{ device_conn[inventory_hostname][intf]['peerdevice'] }}-{{ device_conn[inventory_hostname][intf]['peerport'] }}
switchport access vlan {{ device_port_vlans[intf]['vlanids'] }}
switchport mode dot1q-tunnel
spanning-tree portfast
Expand All @@ -58,7 +58,7 @@ interface {{ intf }}
{% set intf = 'Ethernet' + i|string + '/3' %}
interface {{ intf }}
{% if intf in device_port_vlans and device_port_vlans[intf]['mode'] != "Trunk" %}
description {{ device_conn[intf]['peerdevice'] }}-{{ device_conn[intf]['peerport'] }}
description {{ device_conn[inventory_hostname][intf]['peerdevice'] }}-{{ device_conn[inventory_hostname][intf]['peerport'] }}
switchport access vlan {{ device_port_vlans[intf]['vlanids'] }}
switchport mode dot1q-tunnel
spanning-tree portfast
Expand All @@ -73,7 +73,7 @@ interface {{ intf }}
shutdown
{% endif %}
{% elif intf in device_port_vlans and device_port_vlans[intf]['mode'] == 'Trunk' %}
description {{ device_conn[intf]['peerdevice'] }}-{{ device_conn[intf]['peerport'] }}
description {{ device_conn[inventory_hostname][intf]['peerdevice'] }}-{{ device_conn[inventory_hostname][intf]['peerport'] }}
switchport mode trunk
switchport trunk allowed vlan {{ device_port_vlans[intf]['vlanids'] }}
spanning-tree portfast
Expand Down
24 changes: 12 additions & 12 deletions ansible/roles/fanout/templates/arista_7260cx3_deploy.j2
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,38 @@ vrf definition management
{% for i in range(1,65) %}
{% set intf = 'Ethernet' + i|string + '/1' %}
{% if intf in device_port_vlans and device_port_vlans[intf]['mode'] != "Trunk" %}
{% if device_conn[intf]['speed'] == "100000" %}
{% if device_conn[inventory_hostname][intf]['speed'] == "100000" %}
interface {{ intf }}
description {{ device_conn[intf]['peerdevice'] }}-{{ device_conn[intf]['peerport'] }}
description {{ device_conn[inventory_hostname][intf]['peerdevice'] }}-{{ device_conn[inventory_hostname][intf]['peerport'] }}
switchport access vlan {{ device_port_vlans[intf]['vlanids'] }}
switchport mode dot1q-tunnel
spanning-tree portfast
speed forced 100gfull
error-correction encoding reed-solomon
no shutdown
{% elif device_conn[intf]['speed'] == "40000" %}
{% elif device_conn[inventory_hostname][intf]['speed'] == "40000" %}
interface {{ intf }}
description {{ device_conn[intf]['peerdevice'] }}-{{ device_conn[intf]['peerport'] }}
description {{ device_conn[inventory_hostname][intf]['peerdevice'] }}-{{ device_conn[inventory_hostname][intf]['peerport'] }}
switchport access vlan {{ device_port_vlans[intf]['vlanids'] }}
switchport mode dot1q-tunnel
spanning-tree portfast
speed forced 40gfull
no shutdown
{% elif device_conn[intf]['speed'] == "10000" %}
{% elif device_conn[inventory_hostname][intf]['speed'] == "10000" %}
{% for sub in range (1,5) %}
{% set subintf = 'Ethernet' + i|string + '/' + sub|string %}
interface {{ subintf }}
description {{ device_conn[intf]['peerdevice'] }}-{{ device_conn[intf]['peerport'] }}
description {{ device_conn[inventory_hostname][intf]['peerdevice'] }}-{{ device_conn[inventory_hostname][intf]['peerport'] }}
switchport access vlan {{ device_port_vlans[intf]['vlanids'] }}
switchport mode dot1q-tunnel
spanning-tree portfast
speed forced 10gfull
no shutdown
!
{% endfor %}
{% elif device_conn[intf]['speed'] == "50000" %}
{% elif device_conn[inventory_hostname][intf]['speed'] == "50000" %}
interface {{ intf }}
description {{ device_conn[intf]['peerdevice'] }}-{{ device_conn[intf]['peerport'] }}
description {{ device_conn[inventory_hostname][intf]['peerdevice'] }}-{{ device_conn[inventory_hostname][intf]['peerport'] }}
switchport access vlan {{ device_port_vlans[intf]['vlanids'] }}
switchport mode dot1q-tunnel
spanning-tree portfast
Expand All @@ -74,7 +74,7 @@ interface {{ intf }}
{% set intf = 'Ethernet' + i|string + '/3' %}
interface {{ intf }}
{% if intf in device_port_vlans and device_port_vlans[intf]['mode'] != "Trunk" %}
description {{ device_conn[intf]['peerdevice'] }}-{{ device_conn[intf]['peerport'] }}
description {{ device_conn[inventory_hostname][intf]['peerdevice'] }}-{{ device_conn[inventory_hostname][intf]['peerport'] }}
switchport access vlan {{ device_port_vlans[intf]['vlanids'] }}
switchport mode dot1q-tunnel
spanning-tree portfast
Expand All @@ -90,14 +90,14 @@ interface {{ intf }}
{% endif %}
{% elif intf in device_port_vlans and device_port_vlans[intf]['mode'] == 'Trunk' %}
interface {{ intf }}
description {{ device_conn[intf]['peerdevice'] }}-{{ device_conn[intf]['peerport'] }}
description {{ device_conn[inventory_hostname][intf]['peerdevice'] }}-{{ device_conn[inventory_hostname][intf]['peerport'] }}
switchport mode trunk
switchport trunk allowed vlan {{ device_port_vlans[intf]['vlanids'] }}
spanning-tree portfast
{% if device_conn[intf]['speed'] == "100000" %}
{% if device_conn[inventory_hostname][intf]['speed'] == "100000" %}
speed forced 100gfull
error-correction encoding reed-solomon
{% elif device_conn[intf]['speed'] == "40000" %}
{% elif device_conn[inventory_hostname][intf]['speed'] == "40000" %}
speed forced 40gfull
{% endif %}
no shutdown
Expand Down
4 changes: 2 additions & 2 deletions ansible/roles/fanout/templates/force10_s6100_deploy.j2
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ interface {{ intf }}
no ip address
switchport
{% if intf in device_port_vlans and device_port_vlans[intf]['mode'] != 'Trunk' %}
description {{ device_conn[intf]['peerdevice'] }}-{{ device_conn[intf]['peerport'] }}
description {{ device_conn[inventory_hostname][intf]['peerdevice'] }}-{{ device_conn[inventory_hostname][intf]['peerport'] }}
vlan-stack access
no shutdown
interface Vlan {{ device_port_vlans[intf]['vlanids'] }}
vlan-stack compatible
member {{ intf }}
{% elif intf in device_port_vlans and device_port_vlans[intf]['mode'] == 'Trunk' %}
description {{ device_conn[intf]['peerdevice'] }}-{{ device_conn[intf]['peerport'] }}
description {{ device_conn[inventory_hostname][intf]['peerdevice'] }}-{{ device_conn[inventory_hostname][intf]['peerport'] }}
vlan-stack trunk
no shutdown
{% for vlanid in device_port_vlans[intf]['vlanlist'] %}
Expand Down
6 changes: 3 additions & 3 deletions ansible/roles/fanout/templates/sonic_deploy.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
},

"PORT": {
{% for alias in device_conn %}
{% for alias in device_conn[inventory_hostname] %}
"{{ alias }}": {
{% if device_conn[alias]['speed'] == "100000" %}
{% if device_conn[inventory_hostname][alias]['speed'] == "100000" %}
"fec" : "rs",
{% endif %}
"speed" : "{{ device_conn[alias]['speed'] }}"
"speed" : "{{ device_conn[inventory_hostname][alias]['speed'] }}"
}{% if not loop.last %},{% endif %}
{% endfor %}
},
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/test/tasks/check_fanout_interfaces.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
delegate_to: localhost

- name: Fanout hostname
set_fact: fanout_switch={{ device_conn['Ethernet0']['peerdevice'] }}
set_fact: fanout_switch={{ device_conn[inventory_hostname]['Ethernet0']['peerdevice'] }}

- name: Check Fanout interfaces
local_action: shell ansible-playbook -i lab fanout.yml -l {{ fanout_switch }} --tags check_interfaces_status
Expand Down
22 changes: 11 additions & 11 deletions ansible/roles/test/tasks/continuous_link_flap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@
delegate_to: localhost
tags: always

- debug: msg="{{ device_conn }}"
- debug: msg="{{ device_conn[inventory_hostname] }}"

- name: include continuous_link_flap_helper.yml
include_tasks: continuous_link_flap/continuous_link_flap_helper.yml
vars:
interface: "{{item}}"
with_items: "{{ device_conn.keys() }}"
with_items: "{{ device_conn[inventory_hostname].keys() }}"

- debug: msg="Second Iteration flap all interfaces one by one on DUT"

Expand All @@ -73,7 +73,7 @@
include_tasks: continuous_link_flap/continuous_link_flap_helper.yml
vars:
interface: "{{item}}"
with_items: "{{ device_conn.keys() }}"
with_items: "{{ device_conn[inventory_hostname].keys() }}"

- debug: msg="Third Iteration flap all interfaces one by one on DUT"

Expand All @@ -86,7 +86,7 @@
include_tasks: continuous_link_flap/continuous_link_flap_helper.yml
vars:
interface: "{{item}}"
with_items: "{{ device_conn.keys() }}"
with_items: "{{ device_conn[inventory_hostname].keys() }}"

- debug: msg="First Iteration flap all interfaces one by one on Peer Device"

Expand All @@ -95,16 +95,16 @@
delegate_to: localhost
tags: always

- debug: msg="{{ device_conn }}"
- debug: msg="{{ device_conn[inventory_hostname] }}"

- set_fact:
neighbors: "{{device_conn}}"
neighbors: "{{device_conn[inventory_hostname]}}"

- name: include continuous_peer_link_flap_helper.yml
include_tasks: continuous_link_flap/continuous_peer_link_flap_helper.yml
vars:
interface: "{{item}}"
with_items: "{{ device_conn.keys() }}"
with_items: "{{ device_conn[inventory_hostname].keys() }}"

- debug: msg="Second Iteration flap all interfaces one by one on Peer Device"

Expand All @@ -114,13 +114,13 @@
tags: always

- set_fact:
neighbors: "{{device_conn}}"
neighbors: "{{device_conn[inventory_hostname]}}"

- name: include continuous_peer_link_flap_helper.yml
include_tasks: continuous_link_flap/continuous_peer_link_flap_helper.yml
vars:
interface: "{{item}}"
with_items: "{{ device_conn.keys() }}"
with_items: "{{ device_conn[inventory_hostname].keys() }}"

- debug: msg="Third Iteration flap all interfaces one by one on Peer Device"

Expand All @@ -130,13 +130,13 @@
tags: always

- set_fact:
neighbors: "{{device_conn}}"
neighbors: "{{device_conn[inventory_hostname]}}"

- name: include continuous_peer_link_flap_helper.yml
include_tasks: continuous_link_flap/continuous_peer_link_flap_helper.yml
vars:
interface: "{{item}}"
with_items: "{{ device_conn.keys() }}"
with_items: "{{ device_conn[inventory_hostname].keys() }}"

- name: wait 60 secs so that BGP routes are relearned
pause: seconds=60
Expand Down
6 changes: 3 additions & 3 deletions ansible/roles/test/tasks/ecmp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
tags: always

- set_fact:
neighbors: "{{device_conn}}"
neighbors: "{{device_conn[inventory_hostname]}}"

- name: Initialize an empty list to store interface names
set_fact:
Expand Down Expand Up @@ -94,7 +94,7 @@
tags: always

- set_fact:
neighbors: "{{device_conn}}"
neighbors: "{{device_conn[inventory_hostname]}}"

- debug: msg="iface_list {{ iface_list }}"

Expand All @@ -113,7 +113,7 @@
tags: always

- set_fact:
neighbors: "{{device_conn}}"
neighbors: "{{device_conn[inventory_hostname]}}"

- include: ecmp/paths_up.yml
with_items: iface_list
2 changes: 1 addition & 1 deletion ansible/roles/test/tasks/interface.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
conn_graph_facts: host={{ inventory_hostname }}
delegate_to: localhost

- set_fact: neighbors="{{device_conn}}"
- set_fact: neighbors="{{device_conn[inventory_hostname]}}"

- include_tasks: resume_fanout_ports.yml
with_items: "{{ ansible_interface_link_down_ports }}"
Expand Down
4 changes: 2 additions & 2 deletions ansible/roles/test/tasks/link_flap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

- name: Set neighbor facts
set_fact:
neighbors: "{{ device_conn }}"
neighbors: "{{ device_conn[inventory_hostname] }}"

- include_tasks: link_flap/link_flap_helper.yml
with_items: "{{ device_conn.keys() }}"
with_items: "{{ device_conn[inventory_hostname].keys() }}"
2 changes: 1 addition & 1 deletion ansible/roles/test/tasks/pfc_wd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
ports: "{{minigraph_ports.keys() | join(' ')}}"

- set_fact:
neighbors: "{{device_conn}}"
neighbors: "{{device_conn[inventory_hostname]}}"

- set_fact:
ansible_eth0_ipv4_addr: "{{ansible_eth0['ipv4']['address']}}"
Expand Down
7 changes: 5 additions & 2 deletions tests/common/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def get_critical_group_and_process_lists(self, container_name):
else:
if process_status == "RUNNING" and process_name in critical_process_list:
expected_critical_process_list.append(process_name)

critical_group_list = expected_critical_group_list
critical_process_list = expected_critical_process_list

Expand Down Expand Up @@ -1038,7 +1038,7 @@ def show_and_parse(self, show_cmd, **kwargs):
"""
output = self.shell(show_cmd, **kwargs)["stdout_lines"]
return self._parse_show(output)

def get_namespace_from_asic_id(self, asic_id):
if asic_id is DEFAULT_ASIC_ID:
return DEFAULT_NAMESPACE
Expand Down Expand Up @@ -1359,6 +1359,9 @@ def add_port_map(self, host_port, fanout_port):
DUT instance in the test. As result the port mapping is
unique from the DUT perspective. However, this function
need update when supporting multiple DUT

host_port is a encoded string of <host name>|<port name>,
e.g. sample_host|Ethernet0.
"""
self.host_to_fanout_port_map[host_port] = fanout_port
self.fanout_to_host_port_map[fanout_port] = host_port
Expand Down
16 changes: 6 additions & 10 deletions tests/common/fixtures/conn_graph_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,17 @@


@pytest.fixture(scope="module")
def conn_graph_facts(duthost, localhost):
return get_graph_facts(duthost, localhost, duthost.hostname)


@pytest.fixture(scope="module")
def conn_graph_facts_multi_duts(duthost, duthosts, localhost):
return get_graph_facts(duthost, localhost,
def conn_graph_facts(duthosts, localhost):
return get_graph_facts(duthosts[0], localhost,
[dh.hostname for dh in duthosts])


@pytest.fixture(scope="module")
def fanout_graph_facts(localhost, duthost, conn_graph_facts):
facts = dict()
for intf in conn_graph_facts["device_conn"]:
fanout = conn_graph_facts["device_conn"][intf]["peerdevice"]
dev_conn = conn_graph_facts.get('device_conn', {})
for intf, val in dev_conn[duthost.hostname].items():
fanout = val["peerdevice"]
if fanout not in facts:
facts[fanout] = get_graph_facts(duthost, localhost, fanout)
return facts
Expand Down
Loading