Skip to content

Commit

Permalink
[acl-loader] Not to crash upon invalid rule (sonic-net#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
taoyl-ms authored and lguohan committed Apr 6, 2018
1 parent eafa643 commit c863e94
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions acl_loader/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import click
import json
import syslog
import tabulate
from natsort import natsorted

Expand All @@ -13,14 +14,17 @@

def info(msg):
click.echo(click.style("Info: ", fg='cyan') + click.style(str(msg), fg='green'))
syslog.syslog(syslog.LOG_INFO, msg)


def warning(msg):
click.echo(click.style("Warning: ", fg='cyan') + click.style(str(msg), fg='yellow'))
syslog.syslog(syslog.LOG_WARNING, msg)


def error(msg):
click.echo(click.style("Error: ", fg='cyan') + click.style(str(msg), fg='red'))
syslog.syslog(syslog.LOG_ERR, msg)


def deep_update(dst, src):
Expand Down Expand Up @@ -354,8 +358,11 @@ def convert_rules(self):

for acl_entry_name in acl_set.acl_entries.acl_entry:
acl_entry = acl_set.acl_entries.acl_entry[acl_entry_name]
rule = self.convert_rule_to_db_schema(table_name, acl_entry)
deep_update(self.rules_info, rule)
try:
rule = self.convert_rule_to_db_schema(table_name, acl_entry)
deep_update(self.rules_info, rule)
except AclLoaderException as ex:
error("Error processing rule %s: %s. Skipped." % (acl_entry_name, ex))

if not self.is_table_mirror(table_name):
deep_update(self.rules_info, self.deny_rule(table_name))
Expand Down

0 comments on commit c863e94

Please sign in to comment.