-
Notifications
You must be signed in to change notification settings - Fork 819
[generic-config-updater] Add caclrule validator #2103
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,3 +71,35 @@ def vlan_validator(old_config, upd_config, keys): | |
| # No update to DHCP servers. | ||
| return True | ||
|
|
||
| def caclrule_validator(old_config, upd_config, keys): | ||
| old_acltable = old_config.get("ACL_TABLE", {}) | ||
| upd_acltable = upd_config.get("ACL_TABLE", {}) | ||
|
|
||
| try: | ||
| old_cacltable = [table for table in old_acltable | ||
wen587 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if old_acltable.get(table)["type"] == "CTRLPLANE"] | ||
| upd_cacltable = [table for table in upd_acltable | ||
| if upd_acltable.get(table)["type"] == "CTRLPLANE"] | ||
| except KeyError: | ||
| logger.log(logger.LOG_PRIORITY_ERROR, | ||
| "Field 'type' is required in ACL_TABLE", | ||
| print_to_console) | ||
| return False | ||
|
|
||
| old_aclrule = old_config.get("ACL_RULE", {}) | ||
| upd_aclrule = upd_config.get("ACL_RULE", {}) | ||
|
|
||
| old_caclrule = [rule for rule in old_aclrule | ||
| if rule.split("|")[0] in old_cacltable] | ||
| upd_caclrule = [rule for rule in upd_aclrule | ||
| if rule.split("|")[0] in upd_cacltable] | ||
|
|
||
| for key in set(old_caclrule).union(set(upd_caclrule)): | ||
| if (old_aclrule.get(key, {}) != upd_aclrule.get(key, {})): | ||
wen587 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # caclmgrd will update in 0.5 sec when configuration stops, | ||
| # we sleep 1 sec to make sure it does update. | ||
| rc = os.system("sleep 1s") | ||
|
||
| return rc == 0 | ||
| # No update to ACL_RULE. | ||
| return True | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.