Support golden config in db migrator#3076
Conversation
scripts/db_migrator.py
Outdated
| with open(GOLDEN_CFG_FILE) as f: | ||
| golden_data = json.load(f) | ||
| if namespace is None: | ||
| self.minigraph_data = golden_data |
There was a problem hiding this comment.
It's confusing to change the meaning of "minigraph_data". Suggest make it immutable, and create new var for new purpose.
If both GOLDEN_CFG_FILE and MINIGRAPH_FILE exists, the table inside GOLDEN_CFG_FILE will override table from MINIGRAPH_FILE. Please check with @wen587 and try reuse this override logic. #Closed
|
|
||
| def update_config(current_config, config_input): | ||
| """ | ||
| Override current config with golden config |
scripts/db_migrator.py
Outdated
| # this is to avoid duplicating the hardcoded these values in db_migrator | ||
| self.config_src_data = None | ||
| if self.__minigraph_data: | ||
| self.config_src_data = self.__minigraph_data |
There was a problem hiding this comment.
This is shallow copy. So any future change on right side will also appear on left side.
I understand it is not efficient to make minigraph_data immutable. So instead, you can call it config_src_data, and override it.
__xxx convention does not help your case, it is just make the member super private. #Closed
There was a problem hiding this comment.
For reused function, add an argument to update_config, and update_config will use deepcopy by default, but db migrator will use shallow copy.
For db migrator, add a method to generate config_src_data. golden_config_data and minigraph_data are local variables, so it's impossible to alter them and then we can prevent unintended change.
What I did Need to support golden config in db migrator. How I did it If there's golden config json, read from golden config instead of minigraph. And db migrator will use golden config data to generate new configuration. How to verify it Run unit test.
|
Cherry-pick PR to 202311: #3136 |
What I did Need to support golden config in db migrator. How I did it If there's golden config json, read from golden config instead of minigraph. And db migrator will use golden config data to generate new configuration. How to verify it Run unit test.
What I did Need to support golden config in db migrator. How I did it If there's golden config json, read from golden config instead of minigraph. And db migrator will use golden config data to generate new configuration. How to verify it Run unit test.
What I did
Need to support golden config in db migrator.
How I did it
If there's golden config json, read from golden config instead of minigraph.
And db migrator will use golden config data to generate new configuration.
How to verify it
Run unit test.
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)