-
Notifications
You must be signed in to change notification settings - Fork 661
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
YANG validation for ConfigDB Updates: portchannel add/remove, loopback interface, VLAN YANG validation Using GCU #2190
YANG validation for ConfigDB Updates: portchannel add/remove, loopback interface, VLAN YANG validation Using GCU #2190
Conversation
This pull request introduces 1 alert when merging d4ab077 into 2513da1 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging e4db00c into 2513da1 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging 8259894 into 3197f39 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging ac45e07 into 3197f39 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging 6bb9189 into 3197f39 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging 6b6feda into 3197f39 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging 98888f4 into 9f2607d - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging d9c069e into 248ddd5 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging f0b7fb5 into 248ddd5 - view on LGTM.com new alerts:
|
config/main.py
Outdated
|
||
db = ctx.obj['db'] | ||
db = validate(ctx.obj['db'], error_map, ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pull request introduces 1 alert when merging 74e8431 into 28926b0 - view on LGTM.com new alerts:
|
|
||
from generic_config_updater.generic_updater import GenericUpdater, ConfigFormat | ||
|
||
def ValidatedConfigDBConnector(config_db_connector): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we discussed on design, we need to check global disable/enable option. So suggest add the check in this function. #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I did not mean fallback_adhoc_validation
. I mean yang_config_validation
you added in ConfigDB. You may check @wen587 PR https://github.com/sonic-net/sonic-buildimage/pull/11715/files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fallback_adhoc_validation
should be independent with ValidatedConfigDBConnector
. We have use cases like
- True, True
- True, False
- False, True
- False, False
So just remove this parameter in this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still applicable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed to make fallback_adhoc_validation
independent of ValidatedConfigDBConnector
. In ValidatedConfigDBConnector
, we use yang_config_enabled
This pull request introduces 5 alerts when merging e01c295 into 92b889b - view on LGTM.com new alerts:
|
|
.format(loopback_name, CFG_LOOPBACK_PREFIX, CFG_LOOPBACK_NO)) | ||
|
||
config_db = ValidatedConfigDBConnector(ctx.obj['db'], ADHOC_VALIDATION) | ||
|
||
lo_config_db = config_db.get_table('LOOPBACK_INTERFACE') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lo_config_db
is used with and without ADHOC_VALIDATION, so I moved the definition to before ADHOC_VALIDATION
3ab82c1
to
f338049
Compare
This pull request introduces 1 alert when merging 6565224 into bbcdf2e - view on LGTM.com new alerts:
|
This pull request introduces 2 alerts when merging 7a7768a into bbcdf2e - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging 96788dc into bbcdf2e - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging 3566cdc into 4d377a6 - view on LGTM.com new alerts:
|
generic_config_updater/gu_common.py
Outdated
@@ -16,6 +16,9 @@ | |||
class GenericConfigUpdaterError(Exception): | |||
pass | |||
|
|||
class EmptyTableError(Exception): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to inherit from ValueError
config_db.connect() | ||
try: | ||
GenericUpdater().apply_patch(patch=gcu_patch, config_format=config_format, verbose=False, dry_run=False, ignore_non_yang_tables=False, ignore_paths=None) | ||
except EmptyTableError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand GCU could not delete the last vlan entry in vlan table, because it will lead to an empty vlan table. And GCU is okay to delete the whole vlan table in this case.
Suggest catch the exception, if the original patch is delete one entry, we change the patch to delete the whole table and retry apply_patch
. #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or you can decorate delete_table
, and call it instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or
gcu_json_input.append(gcu_json)
gcu_json_input.append({
"op": "remove",
"path": table
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decorated delete_table
and changed exception handling to call validated_delete_table
This pull request introduces 1 alert when merging 1777e61 into 28f6820 - view on LGTM.com new alerts:
|
This pull request introduces 2 alerts when merging 7084ccb into 28f6820 - view on LGTM.com new alerts:
|
This pull request introduces 2 alerts when merging c20651f into 28f6820 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging 605cd8c into 28f6820 - view on LGTM.com new alerts:
|
|
commit 1efdb89 Author: isl <isl@contoso.com> Date: Fri Sep 23 22:34:09 2022 +0000 mock call to device_info commit d483ad6 Author: isabelmsft <isabel.li@microsoft.com> Date: Fri Sep 23 22:20:39 2022 +0000 Uncomment debug code commit 1a3b257 Author: isabelmsft <isabel.li@microsoft.com> Date: Fri Sep 23 22:05:06 2022 +0000 specify yang validation within unit test function commit e01f5c8 Author: isabelmsft <isabel.li@microsoft.com> Date: Fri Sep 23 21:39:07 2022 +0000 mock yang_enabled commit 605cd8c Author: isabelmsft <isabel.li@microsoft.com> Date: Fri Sep 23 08:47:24 2022 +0000 address LGTM commit c20651f Author: isabelmsft <isabel.li@microsoft.com> Date: Fri Sep 23 08:20:28 2022 +0000 Fix UTs commit 7084ccb Author: isabelmsft <isabel.li@microsoft.com> Date: Fri Sep 23 01:14:35 2022 +0000 fix validated configdb connector commit 1777e61 Author: isabelmsft <isabel.li@microsoft.com> Date: Fri Sep 23 00:48:52 2022 +0000 configure adhoc validation to true commit b4c33e2 Author: isabelmsft <isabel.li@microsoft.com> Date: Fri Sep 23 00:47:38 2022 +0000 Address PR comments commit d797149 Author: isabelmsft <isabel.li@microsoft.com> Date: Tue Sep 20 06:07:25 2022 +0000 remove print statements commit 29263f3 Author: isabelmsft <isabel.li@microsoft.com> Date: Tue Sep 20 06:05:31 2022 +0000 syntax error commit 793e659 Author: isabelmsft <isabel.li@microsoft.com> Date: Tue Sep 20 05:51:13 2022 +0000 fix spacing commit 076458f Author: isabelmsft <isabel.li@microsoft.com> Date: Tue Sep 20 05:15:32 2022 +0000 add missing loopback unit tests, etc. commit 9b37211 Author: isabelmsft <isabel.li@microsoft.com> Date: Sun Sep 18 09:07:13 2022 +0000 add validated_config_db_connector_test commit 201f005 Author: isabelmsft <isabel.li@microsoft.com> Date: Sun Sep 18 00:16:12 2022 +0000 reset adhoc validation variable in unit test commit dd66886 Author: isabelmsft <isabel.li@microsoft.com> Date: Sat Sep 17 23:28:03 2022 +0000 fix adhoc validation variable commit 273436c Author: isabelmsft <isabel.li@microsoft.com> Date: Sat Sep 17 09:07:12 2022 +0000 fix portchannel test commit cac0f96 Author: isabelmsft <isabel.li@microsoft.com> Date: Fri Sep 16 17:09:27 2022 +0000 add missing space commit c52e8cc Author: isabelmsft <isabel.li@microsoft.com> Date: Fri Sep 16 09:33:54 2022 +0000 fix order commit e24f7d8 Author: isabelmsft <isabel.li@microsoft.com> Date: Fri Sep 16 08:29:40 2022 +0000 fix empty table test commit 14addea Author: isabelmsft <isabel.li@microsoft.com> Date: Fri Sep 16 08:13:46 2022 +0000 revert portchannel config unit tests commit 219020c Author: isabelmsft <isabel.li@microsoft.com> Date: Thu Sep 15 20:03:09 2022 +0000 remove unused import commit 5bc3918 Author: isabelmsft <isabel.li@microsoft.com> Date: Thu Sep 15 20:01:29 2022 +0000 fix vlan commit 3566cdc Author: isabelmsft <isabel.li@microsoft.com> Date: Wed Sep 14 01:39:21 2022 +0000 add import jsonpatch commit 96788dc Author: isabelmsft <isabel.li@microsoft.com> Date: Fri Sep 9 21:33:30 2022 +0000 save mod_entry for future PR commit 7a7768a Author: isabelmsft <isabel.li@microsoft.com> Date: Fri Sep 9 21:15:32 2022 +0000 move comment commit 6565224 Merge: ed39006 7546b7c Author: isabelmsft <isabel.li@microsoft.com> Date: Fri Sep 9 00:35:38 2022 +0000 resolve merge conflict commit ed39006 Merge: f338049 bbcdf2e Author: isabelmsft <isabel.li@microsoft.com> Date: Fri Sep 9 00:34:16 2022 +0000 merge commit 7546b7c Merge: f338049 bbcdf2e Author: isabelmsft <67024108+isabelmsft@users.noreply.github.com> Date: Thu Sep 8 17:32:23 2022 -0700 Merge branch 'master' into yang_portchannel_gcu_poc_2 commit f338049 Author: isabelmsft <isabel.li@microsoft.com> Date: Wed Sep 7 19:53:31 2022 +0000 Squashed commit of the following: commit 3ab82c1 Author: isabelmsft <isabel.li@microsoft.com> Date: Wed Sep 7 18:33:46 2022 +0000 add VLAN_MEMBER case commit 74b22e5 Author: isabelmsft <isabel.li@microsoft.com> Date: Fri Sep 2 04:28:35 2022 +0000 fix typo, syntax commit e888493 Author: isabelmsft <isabel.li@microsoft.com> Date: Fri Sep 2 03:52:21 2022 +0000 remove remaining mod_entry reference commit dee4a70 Author: isabelmsft <isabel.li@microsoft.com> Date: Tue Aug 23 08:36:29 2022 +0000 set ADHOC_VALIDATION to True by default commit 09a2ec9 Author: isabelmsft <isabel.li@microsoft.com> Date: Tue Aug 23 08:35:59 2022 +0000 remove validated_mod_entry - save for future PR commit 7370198 Merge: 975717b 9f6d79d Author: isabelmsft <isabel.li@microsoft.com> Date: Tue Aug 23 08:34:54 2022 +0000 resolve merge conflict commit 975717b Author: isabelmsft <isabel.li@microsoft.com> Date: Tue Aug 23 08:33:50 2022 +0000 address PR comments commit 4bcd2d2 Author: isabelmsft <isabel.li@microsoft.com> Date: Wed Aug 10 23:18:43 2022 +0000 re-add removed adhoc validation commit 9f6d79d Author: Ubuntu <isl@isl-dev-9.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Wed Aug 10 23:18:43 2022 +0000 re-add removed adhoc validation commit 405dd9b Author: Ubuntu <isl@isl-dev-9.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Fri Aug 5 00:02:44 2022 +0000 Add note for missing constraints in YANG model commit b5b15bb Author: Ubuntu <isl@isl-dev-9.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Wed Aug 3 18:15:45 2022 +0000 address PR comment commit 443b2c3 Author: Ubuntu <isl@isl-dev-9.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Tue Aug 2 08:35:00 2022 +0000 fix decorator commit e01c295 Author: Ubuntu <isl@isl-dev-9.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Tue Aug 2 07:29:28 2022 +0000 vlan add remove commit 8829d96 Author: Ubuntu <isl@isl-dev-9.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Tue Jul 19 09:27:19 2022 +0000 add loopback interfaces config case commit eacc138 Author: Ubuntu <isl@isl-dev-9.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Sat Jul 9 05:51:58 2022 +0000 remove unused import commit 74e8431 Author: Ubuntu <isl@isl-dev-9.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Sat Jul 9 05:22:03 2022 +0000 small fixes commit a40c351 Author: Ubuntu <isl@isl-dev-9.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Sat Jul 9 05:17:50 2022 +0000 fix portchannel unit tests, update decorator name commit 3c69396 Author: Ubuntu <isl@isl-dev-6.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Tue Jun 28 18:11:47 2022 +0000 adjust error handling commit dd2e2fd Author: Ubuntu <isl@isl-dev-6.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Tue Jun 21 00:28:21 2022 +0000 Address LGTM, formatting fixes commit f0b7fb5 Author: Ubuntu <isl@isl-dev-6.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Mon Jun 20 16:36:05 2022 +0000 Add error specific error handling commit d9c069e Author: Ubuntu <isl@isl-dev-6.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Mon Jun 20 15:10:10 2022 +0000 fix imports commit 98888f4 Author: Ubuntu <isl@isl-dev-6.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Sun Jun 19 23:35:55 2022 +0000 keep one ConfigDBConnector instance commit e9f0baf Author: Ubuntu <isl@isl-dev-6.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Tue Jun 14 17:46:00 2022 +0000 re add comment commit 1df71b3 Author: Ubuntu <isl@isl-dev-6.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Tue Jun 14 16:14:43 2022 +0000 Revert to just db.set_entry() commit 57ab896 Author: Ubuntu <isl@isl-dev-6.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Sat Jun 4 03:53:59 2022 +0000 remove portchannel member changes commit 42051c9 Author: Ubuntu <isl@isl-dev-6.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Fri Jun 3 22:20:15 2022 +0000 Fix unit tests, LGTM commit 6b6feda Author: Ubuntu <isl@isl-dev-6.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Fri Jun 3 06:31:08 2022 +0000 separate db and validated_db commit 6bb9189 Author: Ubuntu <isl@isl-dev-6.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Fri Jun 3 00:22:30 2022 +0000 simplify wrapper commit ac45e07 Author: Ubuntu <isl@isl-dev-6.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Thu Jun 2 05:56:57 2022 +0000 fix quotes commit 8259894 Author: Ubuntu <isl@isl-dev-6.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Thu Jun 2 04:58:48 2022 +0000 change to decorated commit e4db00c Author: Ubuntu <isl@isl-dev-6.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Wed Jun 1 22:21:09 2022 +0000 Keep original method signature commit d4ab077 Author: Ubuntu <isl@isl-dev-6.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Wed Jun 1 06:23:52 2022 +0000 Move GCU to subclass commit 220a605 Author: Ubuntu <isl@isl-dev-6.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Tue May 31 07:32:29 2022 +0000 remove yvs commit cb9cb94 Author: Ubuntu <isl@isl-dev-6.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Tue May 31 07:30:33 2022 +0000 portchannel add and remove commit e5d3687 Merge: 95afe70 2513da1 Author: Ubuntu <isl@isl-dev-6.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Mon May 30 20:49:25 2022 +0000 Merge branch 'master' of https://github.com/Azure/sonic-utilities commit 95afe70 Merge: 8909517 2f53bd4 Author: Ubuntu <isl@isl-dev-6.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Tue May 24 21:53:43 2022 +0000 Merge branch 'master' of https://github.com/Azure/sonic-utilities commit 8909517 Author: Ubuntu <isl@isl-dev-6.gccxvha3jmperpu0bogtupfduf.jx.internal.cloudapp.net> Date: Tue May 10 10:55:19 2022 +0000 Add portchannel YANG validation
1efdb89
to
f3ee6ce
Compare
What I did
Added YANG validation to add/remove portchannel using GCU apply patch
How I did it
How to verify it
Previous command output (if the output of a command-line utility has changed)
New command output (if the output of a command-line utility has changed)