Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mirror cli validation for source port list #3026

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 9 additions & 4 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -962,12 +962,17 @@ def interface_has_mirror_config(ctx, mirror_table, dst_port, src_port, direction
for port in src_port.split(","):
if 'dst_port' in v and v['dst_port'] == port:
ctx.fail("Error: Source Interface {} already has mirror config".format(port))
if 'src_port' in v and re.search(port,v['src_port']):
if check_mirror_direction_config(v, direction):
ctx.fail("Error: Source Interface {} already has mirror config in same direction".format(port))
if 'src_port' in v:
for p in v['src_port'].split(","):
if port == p and check_mirror_direction_config(v, direction):
ctx.fail("Error: Source Interface {} already has mirror config in same direction".format(port))
if dst_port:
if ('dst_port' in v and v['dst_port'] == dst_port) or ('src_port' in v and re.search(dst_port,v['src_port'])):
if ('dst_port' in v and v['dst_port'] == dst_port):
ctx.fail("Error: Destination Interface {} already has mirror config".format(dst_port))
if ('src_port' in v):
for port in v['src_port'].split(","):
if(dst_port == port):
ctx.fail("Error: Destination Interface {} already has mirror config".format(dst_port))

return False

Expand Down