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
40 changes: 26 additions & 14 deletions ansible/roles/test/files/acstests/acltb_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def setUp(self):

self.dataplane = ptf.dataplane_instance
self.router_mac = self.test_params['router_mac']
self.testbed_type = self.test_params['testbed_type']

#---------------------------------------------------------------------

Expand Down Expand Up @@ -250,17 +251,28 @@ def runTest(self):
test_result = False

self.switch_info = open(self.test_params["switch_info"], 'r').readlines()
self.tor_ports = map(int, self.switch_info[0].rstrip(",\n").split(","))
self.spine_ports = map(int, self.switch_info[1].rstrip(",\n").split(","))
self.dest_ip_addr_spine = self.switch_info[2].strip()
self.dest_ip_addr_spine_blocked = self.switch_info[3].strip()
self.dest_ip_addr_tor = self.switch_info[4].strip()
self.dest_ip_addr_tor_blocked = self.switch_info[5].strip()

# Verify ACLs on tor port
(tests_passed, tests_total) = self.runAclTests(self.dest_ip_addr_spine, self.dest_ip_addr_spine_blocked, self.tor_ports[0], self.spine_ports)
assert(tests_passed == tests_total)

# Verify ACLs on spine port
(tests_passed, tests_total) = self.runAclTests(self.dest_ip_addr_tor, self.dest_ip_addr_tor_blocked, self.spine_ports[0], self.tor_ports)
assert(tests_passed == tests_total)
if self.testbed_type in [ 't1', 't1-lag' ]:
self.tor_ports = map(int, self.switch_info[0].rstrip(",\n").split(","))
self.spine_ports = map(int, self.switch_info[1].rstrip(",\n").split(","))
self.dest_ip_addr_spine = self.switch_info[2].strip()
self.dest_ip_addr_spine_blocked = self.switch_info[3].strip()
self.dest_ip_addr_tor = self.switch_info[4].strip()
self.dest_ip_addr_tor_blocked = self.switch_info[5].strip()

# Verify ACLs on tor port
(tests_passed, tests_total) = self.runAclTests(self.dest_ip_addr_spine, self.dest_ip_addr_spine_blocked, self.tor_ports[0], self.spine_ports)
assert(tests_passed == tests_total)

# Verify ACLs on spine port
(tests_passed, tests_total) = self.runAclTests(self.dest_ip_addr_tor, self.dest_ip_addr_tor_blocked, self.spine_ports[0], self.tor_ports)
assert(tests_passed == tests_total)
elif self.testbed_type == 't0':
src_port = map(int, self.switch_info[0].rstrip(",\n").split(","))
dst_ports = map(int, self.switch_info[1].rstrip(",\n").split(","))
dst_ip = self.switch_info[2].strip()
dst_ip_blocked = self.switch_info[3].strip()

(tests_passed, tests_total) = self.runAclTests(dst_ip, dst_ip_blocked, src_port[0], dst_ports)
assert(tests_passed == tests_total)


2 changes: 2 additions & 0 deletions ansible/roles/test/tasks/acltb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
- verbose=True
- router_mac=\"{{ ansible_Ethernet0['macaddress'] }}\"
- switch_info=\"/tmp/acltb_switch_info.txt\"
- testbed_type=\"{{ testbed_type }}\"

- name: Clean up ACL rules.
vars:
Expand Down Expand Up @@ -91,6 +92,7 @@
- verbose=True
- router_mac=\"{{ ansible_Ethernet0['macaddress'] }}\"
- switch_info=\"/tmp/acltb_switch_info.txt\"
- testbed_type=\"{{ testbed_type }}\"

always:
- name: Clean up ACL rules.
Expand Down
11 changes: 11 additions & 0 deletions ansible/roles/test/templates/acltb.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% if testbed_type == "t1" or testbed_type == "t1-lag" %}
{# tor ports #}
{% for ifname, v in minigraph_neighbors.iteritems() %}{% if "T0" in v.name %}{{ '%d' % minigraph_port_indices[ifname] }},{% endif %}{% endfor %}

Expand All @@ -8,3 +9,13 @@
192.168.0.16
172.16.1.0
172.16.2.0
{% elif testbed_type == "t0" %}
{# todo #}
{% for ifname, info in minigraph_vlans.iteritems() %}{% for m in info['members'] %}{{ '%d' % minigraph_port_indices[m] }},{% endfor %}{% endfor %}

{% for ifname, v in minigraph_neighbors.iteritems() %}{% if "T1" in v.name %}{{ '%d' % minigraph_port_indices[ifname] }},{% endif %}{% endfor %}

192.168.4.0
192.168.8.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remind me what these IPs stand for?


{% endif %}
18 changes: 17 additions & 1 deletion ansible/templates/topo/t0.j2
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,23 @@
</IPInterface>
</IPInterfaces>
<DataAcls/>
<AclInterfaces/>
<AclInterfaces>
<AclInterface>
<AttachTo>
{% for index in range(4) -%}
PortChannel{{ ((index + 1)|string).zfill(4) }};
{%- endfor -%}
Vlan1000
</AttachTo>
<InAcl>DataAcl</InAcl>
</AclInterface>
<AclInterface>
<AttachTo>
ERSPAN
</AttachTo>
<InAcl>Everflow</InAcl>
</AclInterface>
</AclInterfaces>
<DownstreamSummaries/>
<DownstreamSummarySet xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
</DeviceDataPlaneInfo>
Expand Down
5 changes: 4 additions & 1 deletion ansible/templates/topo/t1-lag.j2
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@
<AclInterfaces>
<AclInterface>
<AttachTo>
{{ port_alias|join(";") }}
{% for index in range(8) -%}
PortChannel{{ index*8 }};
{%- endfor -%}
{{ port_alias[16:]|join(";") }}
</AttachTo>
<InAcl>DataAcl</InAcl>
</AclInterface>
Expand Down