Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
MuhammadUmarAsad committed May 9, 2023
2 parents 2273103 + ba7b72d commit 57f1c99
Show file tree
Hide file tree
Showing 96 changed files with 4,981 additions and 1,162 deletions.
9 changes: 6 additions & 3 deletions acl_loader/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,17 +670,20 @@ def convert_rule_to_db_schema(self, table_name, rule):
def deny_rule(self, table_name):
"""
Create default deny rule in Config DB format
Only create default deny rule when table is [L3, L3V6]
:param table_name: ACL table name to which rule belong
:return: dict with Config DB schema
"""
rule_props = {}
rule_data = {(table_name, "DEFAULT_RULE"): rule_props}
rule_props["PRIORITY"] = str(self.min_priority)
rule_props["PACKET_ACTION"] = "DROP"
if self.is_table_ipv6(table_name):
if self.is_table_l3v6(table_name):
rule_props["IP_TYPE"] = "IPV6ANY" # ETHERTYPE is not supported for DATAACLV6
else:
elif self.is_table_l3(table_name):
rule_props["ETHER_TYPE"] = str(self.ethertype_map["ETHERTYPE_IPV4"])
else:
return {} # Don't add default deny rule if table is not [L3, L3V6]
return rule_data

def convert_rules(self):
Expand All @@ -707,7 +710,7 @@ def convert_rules(self):
except AclLoaderException as ex:
error("Error processing rule %s: %s. Skipped." % (acl_entry_name, ex))

if not self.is_table_mirror(table_name) and not self.is_table_egress(table_name):
if not self.is_table_egress(table_name):
deep_update(self.rules_info, self.deny_rule(table_name))

def full_update(self):
Expand Down
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ stages:
source: specific
project: build
pipeline: 9
artifact: sonic-swss-common.bullseye.amd64
artifact: sonic-swss-common
runVersion: 'latestFromBranch'
runBranch: 'refs/heads/master'
runBranch: 'refs/heads/$(sourceBranch)'
displayName: "Download sonic swss common deb packages"

- script: |
Expand Down
27 changes: 13 additions & 14 deletions clear/bgp_frr_v6.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def neigh_all(ipaddress):
"""Clear all BGP peers"""

if ipaddress is not None:
command = 'sudo vtysh -c "clear bgp ipv6 {}"'.format(ipaddress)
command = ['sudo', 'vtysh', '-c', "clear bgp ipv6 {}".format(ipaddress)]
else:
command = 'sudo vtysh -c "clear bgp ipv6 *"'
command = ['sudo', 'vtysh', '-c', "clear bgp ipv6 *"]
run_command(command)

# 'in' subcommand
Expand All @@ -38,9 +38,9 @@ def neigh_in(ipaddress):
"""Send route-refresh"""

if ipaddress is not None:
command = 'sudo vtysh -c "clear bgp ipv6 {} in"'.format(ipaddress)
command = ['sudo', 'vtysh', '-c', "clear bgp ipv6 {} in".format(ipaddress)]
else:
command = 'sudo vtysh -c "clear bgp ipv6 * in"'
command = ['sudo', 'vtysh', '-c', "clear bgp ipv6 * in"]
run_command(command)


Expand All @@ -51,9 +51,9 @@ def neigh_out(ipaddress):
"""Resend all outbound updates"""

if ipaddress is not None:
command = 'sudo vtysh -c "clear bgp ipv6 {} out"'.format(ipaddress)
command = ['sudo', 'vtysh', '-c', "clear bgp ipv6 {} out".format(ipaddress)]
else:
command = 'sudo vtysh -c "clear bgp ipv6 * out"'
command = ['sudo', 'vtysh', '-c', "clear bgp ipv6 * out"]
run_command(command)


Expand All @@ -69,22 +69,22 @@ def soft_in(ipaddress):
"""Send route-refresh"""

if ipaddress is not None:
command = 'sudo vtysh -c "clear bgp ipv6 {} soft in"'.format(ipaddress)
command = ['sudo', 'vtysh', '-c', "clear bgp ipv6 {} soft in".format(ipaddress)]
else:
command = 'sudo vtysh -c "clear bgp ipv6 * soft in"'
command = ['sudo', 'vtysh', '-c', "clear bgp ipv6 * soft in"]
run_command(command)


# 'soft all' subcommand
@neighbor.command('all')
@soft.command('all')
@click.argument('ipaddress', required=False)
def soft_all(ipaddress):
"""Clear BGP neighbors soft configuration"""

if ipaddress is not None:
command = 'sudo vtysh -c "clear bgp ipv6 {} soft"'.format(ipaddress)
command = ['sudo', 'vtysh', '-c', "clear bgp ipv6 {} soft".format(ipaddress)]
else:
command = 'sudo vtysh -c "clear bgp ipv6 * soft"'
command = ['sudo', 'vtysh', '-c', "clear bgp ipv6 * soft"]
run_command(command)

# 'soft out' subcommand
Expand All @@ -94,8 +94,7 @@ def soft_out(ipaddress):
"""Resend all outbound updates"""

if ipaddress is not None:
command = 'sudo vtysh -c "clear bgp ipv6 {} soft out"' \
.format(ipaddress)
command = ['sudo', 'vtysh', '-c', "clear bgp ipv6 {} soft out".format(ipaddress)]
else:
command = 'sudo vtysh -c "clear bgp ipv6 * soft out"'
command = ['sudo', 'vtysh', '-c', "clear bgp ipv6 * soft out"]
run_command(command)
24 changes: 12 additions & 12 deletions clear/bgp_quagga_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def neigh_all(ipaddress):
"""Clear all BGP peers"""

if ipaddress is not None:
command = 'sudo vtysh -c "clear ip bgp {}"'.format(ipaddress)
command = ['sudo', 'vtysh', '-c', "clear ip bgp {}".format(ipaddress)]
else:
command = 'sudo vtysh -c "clear ip bgp *"'
command = ['sudo', 'vtysh', '-c', "clear ip bgp *"]
run_command(command)


Expand All @@ -40,9 +40,9 @@ def neigh_in(ipaddress):
"""Send route-refresh"""

if ipaddress is not None:
command = 'sudo vtysh -c "clear ip bgp {} in"'.format(ipaddress)
command = ['sudo', 'vtysh', '-c', "clear ip bgp {} in".format(ipaddress)]
else:
command = 'sudo vtysh -c "clear ip bgp * in"'
command = ['sudo', 'vtysh', '-c', "clear ip bgp * in"]
run_command(command)


Expand All @@ -53,9 +53,9 @@ def neigh_out(ipaddress):
"""Resend all outbound updates"""

if ipaddress is not None:
command = 'sudo vtysh -c "clear ip bgp {} out"'.format(ipaddress)
command = ['sudo', 'vtysh', '-c', "clear ip bgp {} out".format(ipaddress)]
else:
command = 'sudo vtysh -c "clear ip bgp * out"'
command = ['sudo', 'vtysh', '-c', "clear ip bgp * out"]
run_command(command)


Expand All @@ -71,9 +71,9 @@ def soft_all(ipaddress):
"""Clear BGP neighbors soft configuration"""

if ipaddress is not None:
command = 'sudo vtysh -c "clear ip bgp {} soft"'.format(ipaddress)
command = ['sudo', 'vtysh', '-c', "clear ip bgp {} soft".format(ipaddress)]
else:
command = 'sudo vtysh -c "clear ip bgp * soft"'
command = ['sudo', 'vtysh', '-c', "clear ip bgp * soft"]
run_command(command)


Expand All @@ -84,9 +84,9 @@ def soft_in(ipaddress):
"""Send route-refresh"""

if ipaddress is not None:
command = 'sudo vtysh -c "clear ip bgp {} soft in"'.format(ipaddress)
command = ['sudo', 'vtysh', '-c', "clear ip bgp {} soft in".format(ipaddress)]
else:
command = 'sudo vtysh -c "clear ip bgp * soft in"'
command = ['sudo', 'vtysh', '-c', "clear ip bgp * soft in"]
run_command(command)


Expand All @@ -97,7 +97,7 @@ def soft_out(ipaddress):
"""Resend all outbound updates"""

if ipaddress is not None:
command = 'sudo vtysh -c "clear ip bgp {} soft out"'.format(ipaddress)
command = ['sudo', 'vtysh', '-c', "clear ip bgp {} soft out".format(ipaddress)]
else:
command = 'sudo vtysh -c "clear ip bgp * soft out"'
command = ['sudo', 'vtysh', '-c', "clear ip bgp * soft out"]
run_command(command)
25 changes: 12 additions & 13 deletions clear/bgp_quagga_v6.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ def neigh_all(ipaddress):
"""Clear all BGP peers"""

if ipaddress is not None:
command = 'sudo vtysh -c "clear ipv6 bgp {}"'.format(ipaddress)
command = ['sudo', 'vtysh', '-c', "clear ipv6 bgp {}".format(ipaddress)]
else:
command = 'sudo vtysh -c "clear ipv6 bgp *"'
command = ['sudo', 'vtysh', '-c', "clear ipv6 bgp *"]
run_command(command)


Expand All @@ -38,9 +38,9 @@ def neigh_in(ipaddress):
"""Send route-refresh"""

if ipaddress is not None:
command = 'sudo vtysh -c "clear ipv6 bgp {} in"'.format(ipaddress)
command = ['sudo', 'vtysh', '-c', "clear ipv6 bgp {} in".format(ipaddress)]
else:
command = 'sudo vtysh -c "clear ipv6 bgp * in"'
command = ['sudo', 'vtysh', '-c', "clear ipv6 bgp * in"]
run_command(command)


Expand All @@ -51,9 +51,9 @@ def neigh_out(ipaddress):
"""Resend all outbound updates"""

if ipaddress is not None:
command = 'sudo vtysh -c "clear ipv6 bgp {} out"'.format(ipaddress)
command = ['sudo', 'vtysh', '-c', 'clear ipv6 bgp {} out'.format(ipaddress)]
else:
command = 'sudo vtysh -c "clear ipv6 bgp * out"'
command = ['sudo', 'vtysh', '-c', 'clear ipv6 bgp * out']
run_command(command)


Expand All @@ -69,9 +69,9 @@ def soft_all(ipaddress):
"""Clear BGP neighbors soft configuration"""

if ipaddress is not None:
command = 'sudo vtysh -c "clear ipv6 bgp {} soft"'.format(ipaddress)
command = ['sudo', 'vtysh', '-c', "clear ipv6 bgp {} soft".format(ipaddress)]
else:
command = 'sudo vtysh -c "clear ipv6 bgp * soft"'
command = ['sudo', 'vtysh', '-c', "clear ipv6 bgp * soft"]
run_command(command)


Expand All @@ -82,9 +82,9 @@ def soft_in(ipaddress):
"""Send route-refresh"""

if ipaddress is not None:
command = 'sudo vtysh -c "clear ipv6 bgp {} soft in"'.format(ipaddress)
command = ['sudo', 'vtysh', '-c', "clear ipv6 bgp {} soft in".format(ipaddress)]
else:
command = 'sudo vtysh -c "clear ipv6 bgp * soft in"'
command = ['sudo', 'vtysh', '-c', "clear ipv6 bgp * soft in"]
run_command(command)


Expand All @@ -95,8 +95,7 @@ def soft_out(ipaddress):
"""Resend all outbound updates"""

if ipaddress is not None:
command = 'sudo vtysh -c "clear ipv6 bgp {} soft out"' \
.format(ipaddress)
command = ['sudo' ,'vtysh' ,'-c', "clear ipv6 bgp {} soft out".format(ipaddress)]
else:
command = 'sudo vtysh -c "clear ipv6 bgp * soft out"'
command = ['sudo', 'vtysh', '-c', "clear ipv6 bgp * soft out"]
run_command(command)
Loading

0 comments on commit 57f1c99

Please sign in to comment.