fixing required value validator, and adding replacelane generator#2273
Open
ghooo wants to merge 1 commit intosonic-net:masterfrom
Open
fixing required value validator, and adding replacelane generator#2273ghooo wants to merge 1 commit intosonic-net:masterfrom
ghooo wants to merge 1 commit intosonic-net:masterfrom
Conversation
ghooo
commented
Jul 21, 2022
| matching_keys = config.keys() | ||
| elif token.startswith("*|"): | ||
| suffix = token[2:] | ||
| suffix = token[1:] # the suffix will be `|...` |
Contributor
Author
There was a problem hiding this comment.
Without this change the pattern Ethernet12|* would match Ethernet124|0 and Ethernet12|0
ghooo
commented
Jul 21, 2022
| matching_keys = [key for key in config.keys() if key.endswith(suffix)] | ||
| elif token.endswith("|*"): | ||
| prefix = token[:-2] | ||
| prefix = token[:-1] # the prefix will be `...|` |
Contributor
Author
There was a problem hiding this comment.
Without this change the pattern *|10 would match Ethernet1|10 and Ethernet1|11110
ghooo
commented
Jul 21, 2022
| for required_path, required_value in data[path]: | ||
| current_value = self.identifier.get_value_or_default(current_config, required_path) | ||
| simulated_value = self.identifier.get_value_or_default(simulated_config, required_path) | ||
| if simulated_value == None: # Simulated config does not have this value at all. |
Contributor
Author
There was a problem hiding this comment.
If simulated config does not have the value, it means the move is deleting its parent. in such case skip and assume the mvoe is valid. Let other validators decide.
|
This pull request introduces 3 alerts when merging 63278a8 into 27667cf - view on LGTM.com new alerts:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What I did
Fixes #2263
What is the problem?
/PORT/Ethernet124for example needs to be deleted then added./PORT/Ethernet124requires deletion of all of its dependencies.Check the following to better understand:
initial state:
Deletion dep1
Adding dep1 back will rejected, because it will move us back to the initial state
Try and delete dep2
Try and add dep1
Now the above is a valid state, but it is useless. If you can expand that to 18 dependencies we end up with a lot of tries that are useless.
Solution is to add a custom validator that understand that once a dependency is deleted, do not add it back until we delete the
/PORT/Ethernet124Also add a generator for the deletion to make it faster to pick the dependencies to remove.
How I did it
Added new validator/generator for handling the lane replacement case. The validator/generator understand that for lane replacement the port and its dependencies need to be removed.
How to verify it
UTs TBA
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)