Skip to content

Commit ef7fbe9

Browse files
pavel-shirshovlguohan
authored andcommitted
Sync with our private repo (#139)
new testbed topology: t0-64 script for cleaning testbed after power outage fixes for the testbed server configuration which permits bridging in kernel some fixes for Ansible 2.2 ptf_runner
1 parent 0b68648 commit ef7fbe9

File tree

13 files changed

+471
-7
lines changed

13 files changed

+471
-7
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
mgmt_bridge: br1
2-
mgmt_prefixlen: 24
2+
mgmt_prefixlen: 23
33
mgmt_gw: 10.255.0.1
44
external_iface: p4p1
55

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
mgmt_bridge: br1
2-
mgmt_prefixlen: 24
2+
mgmt_prefixlen: 23
33
mgmt_gw: 10.255.0.1
44
external_iface: p4p1
55

ansible/library/minigraph_facts.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,26 @@ def parse_cpg(cpg, hname):
260260

261261
return bgp_sessions, myasn
262262

263+
def parse_meta(meta, hname):
264+
syslog_servers = []
265+
dhcp_servers = []
266+
ntp_servers = []
267+
device_metas = meta.find(str(QName(ns, "Devices")))
268+
for device in device_metas.findall(str(QName(ns1, "DeviceMetadata"))):
269+
if device.find(str(QName(ns1, "Name"))).text == hname:
270+
properties = device.find(str(QName(ns1, "Properties")))
271+
for device_property in properties.findall(str(QName(ns1, "DeviceProperty"))):
272+
name = device_property.find(str(QName(ns1, "Name"))).text
273+
value = device_property.find(str(QName(ns1, "Value"))).text
274+
value_group = value.split(';') if value and value != "" else []
275+
if name == "DhcpResources":
276+
dhcp_servers = value_group
277+
elif name == "NtpResources":
278+
ntp_servers = value_group
279+
elif name == "SyslogResources":
280+
syslog_servers = value_group
281+
return syslog_servers, dhcp_servers, ntp_servers
282+
263283

264284
def get_console_info(devices, dev, port):
265285
for k, v in devices.items():
@@ -343,6 +363,9 @@ def parse_xml(filename, hostname):
343363
lo_intf = None
344364
neighbors = None
345365
devices = None
366+
syslog_servers = []
367+
dhcp_servers = []
368+
ntp_servers = []
346369

347370
hwsku_qn = QName(ns, "HwSku")
348371
for child in root:
@@ -375,6 +398,8 @@ def parse_xml(filename, hostname):
375398
(neighbors, devices, console_dev, console_port, mgmt_dev, mgmt_port) = parse_png(child, hostname)
376399
elif child.tag == str(QName(ns, "UngDec")):
377400
(u_neighbors, u_devices, _, _, _, _) = parse_png(child, hostname)
401+
elif child.tag == str(QName(ns, "MetadataDeclaration")):
402+
(syslog_servers, dhcp_servers, ntp_servers) = parse_meta(child, hostname)
378403

379404
# Replace port with alias in Vlan interfaces members
380405
if vlan_intfs is not None:
@@ -443,6 +468,9 @@ def parse_xml(filename, hostname):
443468
results['minigraph_console'] = get_console_info(devices, console_dev, console_port)
444469
results['minigraph_mgmt'] = get_mgmt_info(devices, mgmt_dev, mgmt_port)
445470
results['minigraph_port_indices'] = port_index_map
471+
results['syslog_servers'] = syslog_servers
472+
results['dhcp_servers'] = dhcp_servers
473+
results['ntp_servers'] = ntp_servers
446474

447475
return results
448476

@@ -497,4 +525,5 @@ def print_parse_xml(hostname):
497525

498526
if __name__ == "__main__":
499527
main()
528+
#debug_main()
500529

ansible/roles/eos/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
- name: Expand {{ hostname }} properties into props
66
set_fact: props="{{ configuration_properties[item] | combine(props | default({})) }}"
7-
with_items: configuration[hostname]['properties']
7+
with_items: "{{ configuration[hostname]['properties'] }}"
88
when: hostname in configuration
99

1010
- name: build a startup config
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
{% set host = configuration[hostname] %}
2+
{% set mgmt_ip = ansible_host %}
3+
hostname {{ hostname }}
4+
!
5+
spanning-tree mode mstp
6+
!
7+
aaa root secret 0 123456
8+
!
9+
username admin privilege 15 role network-admin secret 0 123456
10+
!
11+
clock timezone UTC
12+
!
13+
lldp run
14+
lldp management-address Management1
15+
!
16+
snmp-server community {{ snmp_rocommunity }} ro
17+
!
18+
ip routing
19+
ipv6 unicast-routing
20+
!
21+
ip route 0.0.0.0/0 {{ mgmt_gw }}
22+
!
23+
route-map DEFAULT_ROUTES permit
24+
!
25+
{# #}
26+
{# NOTE: Using large enough values (e.g., podset_number = 200, #}
27+
{# max_tor_subnet_number = 16, tor_subnet_size = 64), will cause #}
28+
{# us to overflow the 192.168.0.0/16 private address space here. #}
29+
{# This should be fine for internal use, but may pose an issue if used otherwise #}
30+
{# #}
31+
{% for podset in range(0, props.podset_number) %}
32+
{% for tor in range(0, props.tor_number) %}
33+
{% for subnet in range(0, props.tor_subnet_number) %}
34+
{% set suffix = ( (podset * props.tor_number * props.max_tor_subnet_number * props.tor_subnet_size) +
35+
(tor * props.max_tor_subnet_number * props.tor_subnet_size) +
36+
(subnet * props.tor_subnet_size) ) %}
37+
{% set octet2 = (168 + ((suffix // (256 ** 2))) % 256) %}
38+
{% set octet3 = ((suffix // 256) % 256) %}
39+
{% set octet4 = (suffix % 256) %}
40+
{% set prefixlen_v4 = (32 - ((props.tor_subnet_size | log(2))) | int) %}
41+
ip route 192.{{ octet2 }}.{{ octet3 }}.{{ octet4 }}/{{ prefixlen_v4 }} {{ props.nhipv4 }}
42+
ipv6 route 20C0:{{ '%02X%02X' % (octet2, octet3) }}:0:{{ '%02X' % octet4 }}::/64 {{ props.nhipv6 }}
43+
{% endfor %}
44+
{% endfor %}
45+
{% endfor %}
46+
!
47+
{% for podset in range(0, props.podset_number) %}
48+
{% for tor in range(0, props.tor_number) %}
49+
{% set suffix = ( (podset * props.tor_number * props.max_tor_subnet_number * props.tor_subnet_size) +
50+
(tor * props.max_tor_subnet_number * props.tor_subnet_size) ) %}
51+
{% set octet2 = (168 + ((suffix // (256 ** 2))) % 256) %}
52+
{% set octet3 = ((suffix // 256) % 256) %}
53+
{% set octet4 = (suffix % 256) %}
54+
{% set prefixlen_v4 = (32 - (((props.max_tor_subnet_number * props.tor_subnet_size) | log(2)) | int) ) %}
55+
{% set prefixlen_v6 = (64 - (((props.max_tor_subnet_number * props.tor_subnet_size) | log(2)) | int) ) %}
56+
ip prefix-list test_ipv4_{{ podset}}_{{ tor }} seq 10 permit 192.{{ octet2 }}.{{ octet3 }}.{{ octet4 }}/{{ prefixlen_v4 }} ge {{ prefixlen_v4 }}
57+
ipv6 prefix-list test_ipv6_{{ podset}}_{{ tor }}
58+
seq 10 permit 20C0:{{ '%02X%02X' % (octet2, octet3) }}:0:{{ '%02X' % octet4 }}::/{{ prefixlen_v6 }} ge {{ prefixlen_v6 }}
59+
exit
60+
{% endfor %}
61+
{% endfor %}
62+
!
63+
interface Management 1
64+
description TO LAB MGMT SWITCH
65+
ip address {{ mgmt_ip }}/{{ mgmt_prefixlen }}
66+
no shutdown
67+
!
68+
{% for name, iface in host['interfaces'].items() %}
69+
interface {{ name }}
70+
{% if name.startswith('Loopback') %}
71+
description LOOPBACK
72+
{% else %}
73+
no switchport
74+
{% endif %}
75+
{% if name.startswith('Port-Channel') %}
76+
port-channel min-links 2
77+
{% endif %}
78+
{% if iface['lacp'] is defined %}
79+
channel-group {{ iface['lacp'] }} mode active
80+
lacp rate fast
81+
{% endif %}
82+
{% if iface['ipv4'] is defined %}
83+
ip address {{ iface['ipv4'] }}
84+
{% endif %}
85+
{% if iface['ipv6'] is defined %}
86+
ipv6 enable
87+
ipv6 address {{ iface['ipv6'] }}
88+
ipv6 nd ra suppress
89+
{% endif %}
90+
no shutdown
91+
!
92+
{% endfor %}
93+
!
94+
{% for podset in range(0, props.podset_number) %}
95+
{% if range(0, 1000)|random() >= props.failure_rate %}
96+
{% for tor in range(0, props.tor_number) %}
97+
{% set leafasn = props.leaf_asn_start + podset %}
98+
{% set torasn = props.tor_asn_start + tor %}
99+
route-map PREPENDAS permit {{ 2 * (podset * props.tor_number + tor + 1) }}
100+
match ip address prefix-list test_ipv4_{{ podset }}_{{ tor }}
101+
{% if podset == 0 %}
102+
set as-path prepend {{ torasn }}
103+
{% else %}
104+
set as-path prepend {{ props.spine_asn }} {{ leafasn }} {{ torasn }}
105+
{% endif %}
106+
!
107+
route-map PREPENDAS permit {{ 2 * (podset * props.tor_number + tor + 1) + 1 }}
108+
match ipv6 address prefix-list test_ipv6_{{ podset }}_{{ tor }}
109+
{% if podset == 0 %}
110+
set as-path prepend {{ torasn }}
111+
{% else %}
112+
set as-path prepend {{ props.spine_asn }} {{ leafasn }} {{ torasn }}
113+
{% endif %}
114+
!
115+
{% endfor %}
116+
{% endif %}
117+
{% endfor %}
118+
!
119+
router bgp {{ host['bgp']['asn'] }}
120+
router-id {{ host['interfaces']['Loopback0']['ipv4'] | ipaddr('address') }}
121+
!
122+
{% for asn, remote_ips in host['bgp']['peers'].items() %}
123+
{% for remote_ip in remote_ips %}
124+
neighbor {{ remote_ip }} remote-as {{ asn }}
125+
neighbor {{ remote_ip }} description {{ asn }}
126+
neighbor {{ remote_ip }} default-originate route-map DEFAULT_ROUTES
127+
{% if remote_ip | ipv6 %}
128+
address-family ipv6
129+
neighbor {{ remote_ip }} activate
130+
exit
131+
{% endif %}
132+
{% endfor %}
133+
{% endfor %}
134+
!
135+
{% for name, iface in host['interfaces'].items() if name.startswith('Loopback') %}
136+
{% if iface['ipv4'] is defined %}
137+
network {{ iface['ipv4'] }}
138+
{% endif %}
139+
{% if iface['ipv6'] is defined %}
140+
network {{ iface['ipv6'] }}
141+
{% endif %}
142+
{% endfor %}
143+
redistribute static route-map PREPENDAS
144+
!
145+
management api http-commands
146+
no protocol https
147+
protocol http
148+
no shutdown
149+
!
150+
end
151+

ansible/roles/fanout/tasks/rootfanout_connect.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
- set_fact:
2121
ansible_host: "{{ lab_devices[item]['mgmtip'] }}"
2222
root_dev: "{{ item }}"
23-
with_items: lab_devices
23+
with_items: "{{ lab_devices }}"
2424
when: lab_devices[item]['Type'] == 'FanoutRoot'
2525

2626
- set_fact:

ansible/roles/test/tasks/lldp.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@
2525

2626
- name: Compare the lldp neighbors name with minigraph neigbhors name (exclude the management port)
2727
assert: { that: "'{{ lldp[item]['chassis']['name'] }}' == '{{ minigraph_neighbors[alias_map[item]]['name'] }}'" }
28-
with_items: lldp.keys()
28+
with_items: "{{ lldp.keys() }}"
2929
when: item != "eth0"
3030

3131
- name: Compare the lldp neighbors interface with minigraph neigbhor interface (exclude the management port)
3232
assert: { that: "'{{ lldp[item]['port']['ifname'] }}' == '{{ minigraph_neighbors[alias_map[item]]['port'] }}'" }
33-
with_items: lldp.keys()
33+
with_items: "{{ lldp.keys() }}"
3434
when: item != "eth0"
3535

3636
- name: Iterate throguh each lldp neighbor and verify the information received by neighbor are also correct
3737
add_host: name={{ lldp[item]['chassis']['mgmt-ip'] }} groups=lldp_neighbors,eos neighbor_interface={{lldp[item]['port']['ifname']}} dut_interface={{item}} hname={{lldp[item]['chassis']['mgmt-ip'] }}
38-
with_items: lldp.keys()
38+
with_items: "{{ lldp.keys() }}"
3939
when: item != "eth0"
4040

41+

ansible/roles/test/tasks/lldp_neighbor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@
2020
- name: verify the dut port description field is published correctly
2121
assert: {that: "'{{ ansible_lldp_facts[neighbor_interface]['neighbor_port_desc'] }}' == dut_interface"}
2222

23+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Common runner for ptf tests
2+
#
3+
# Parameters:
4+
# ptf_host - ip address of ptf host. This ip address should be presented in str inventory file with credentials
5+
# ptf_test_name - name of the test
6+
# ptf_test_dir - directory where test was copied to
7+
# ptf_test_path - ptf path to the test
8+
# ptf_platform - ptf platform
9+
# ptf_test_params - a list with the test parameters
10+
# ptf_qlen - qlen parameter for ptf
11+
# ptf_extra_options - extra options for ptf
12+
#
13+
# Example:
14+
# - include: ptf_runner.yml
15+
# vars:
16+
# ptf_test_name: COPP test - {{ item }}
17+
# ptf_test_dir: ptftests
18+
# ptf_test_path: copp_tests.{{ item }}
19+
# ptf_platform: nn
20+
# ptf_qlen: 100000
21+
# ptf_extra_options: --device-socket 0-3@tcp://127.0.0.1:10900 --device-socket 1-3@tcp://{{ ansible_eth0['ipv4']['address'] }}:10900
22+
# with_items:
23+
# - ARPTest
24+
# - DHCPTest
25+
# - LLDPTest
26+
# - BGPTest
27+
# - LACPTest
28+
# - SNMPTest
29+
# - SSHTest
30+
# - IP2METest
31+
#
32+
33+
- fail: msg="Please set ptf_host variable"
34+
when: ptf_host is not defined
35+
36+
- name: "PTF Test - {{ ptf_test_name }}"
37+
shell: ptf --test-dir {{ ptf_test_dir }} {{ ptf_test_path }} {% if ptf_qlen is defined %} --qlen={{ ptf_qlen }} {% endif %} --platform {{ ptf_platform }} -t "verbose=True;{{ ptf_test_params | default([]) | join(';') }}" {{ ptf_extra_options | default("")}} --disable-ipv6 --disable-vxlan --disable-geneve --disable-erspan --disable-mpls --disable-nvgre 2>&1
38+
args:
39+
chdir: /root
40+
delegate_to: "{{ ptf_host }}"
41+
failed_when: False
42+
register: out
43+
44+
- debug: var=out.stdout_lines
45+
46+
- fail: msg="Failed test '{{ ptf_test_name }}'"
47+
when: out.rc != 0
48+

ansible/roles/vm_set/tasks/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
pip: name=docker-py state=present version=1.7.2
3232
environment: "{{ proxy_env | default({}) }}"
3333

34+
- name: Install cleanup script
35+
template: src=cleanup.sh.j2
36+
dest={{ root_path }}/cleanup.sh
37+
3438
- name: Retrieve a list of the defined VMs
3539
virt: command=list_vms
3640
uri=qemu:///system

0 commit comments

Comments
 (0)