-
Notifications
You must be signed in to change notification settings - Fork 31
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
[MultiDB] Add multidb support to sonic-ztp #16
[MultiDB] Add multidb support to sonic-ztp #16
Conversation
retest buster please |
src/usr/lib/ztp/ztp-profile.sh
Outdated
@@ -264,7 +256,7 @@ if [ "$CMD" = "remove" ] ; then | |||
fi | |||
else | |||
# Remove ZTP configuration from config-db | |||
redis-cli -n 4 DEL "ZTP|mode" | |||
sonic-db-cli CONFIG_DB DEL "ZTP|mode" |
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.
May need to direct to /dev/null
to avoid sonic-ztp[xxx]: 1
in syslog
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.
Thanks. I fixed it.
Signed-off-by: Rajendra Dendukuri <rajendra.dendukuri@broadcom.com>
Signed-off-by: Rajendra Dendukuri <rajendra.dendukuri@broadcom.com>
retest this please |
`sonic_installer` has been renamed `sonic-installer`. Update the file name everywhere it is used.
…cal/bin/ (sonic-net#19) Update paths to reflect new sonic-utilities install location. As of PR sonic-net/sonic-utilities#1122, sonic-utilities is built and installed as a Python Wheel package. As such, the installation directory of the scripts/entrypoints has changed from `/usr/bin/` to `/usr/local/bin`. This patch updates all references to the old location to either reference the new location, or remove the absolute path entirely, where applicable.
@@ -47,6 +50,11 @@ class ConfigDBJson: | |||
raise TypeError('Snmp provided with invalid argument type.') | |||
self.__input_file = input_file | |||
|
|||
self.configDB = ConfigDBConnector() | |||
if self.configDB is None: |
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.
self.configDB [](start = 11, length = 13)
Could you clarify when it is None? #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.
Fixed in latest commit
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.
The new code seems worse. Why construct ConfigDBConnector twice?
In reply to: 492363061 [](ancestors = 492363061)
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.
My bad. I did not resolve the merge conflict properly and ended up having two copies of the code. I fixed it now.
updateActivity('configdb-json: Removing ZTP configuation from Config DB') | ||
logger.info('configdb-json: Configuration change detected. Removing ZTP configuation from Config DB.') | ||
runCommand('redis-cli -n 4 DEL "ZTP|mode"', capture_stdout=False) | ||
self.configDB.delete_table("ZTP") |
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.
delete_table [](start = 30, length = 12)
Original code is deleting a entry, and new code is deleting a table. Is it expected? #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.
Fixed in latest commit
tests/test_configdb-json.py
Outdated
cmd = "/bin/sed -i -e 's/\"mac\": \".*\"/\"mac\": \"invalid2\"/' " + str(fh_after) | ||
rc = runCommand(cmd) | ||
cmd = "/bin/sed -i -e 's/\"hwsku\": \".*\"/\"hwsku\": \"invalid3\"/' " + str(fh_after) | ||
rc = runCommand(cmd) |
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.
Could you just parse config-before.json, modify in memory and write to config-after.json? #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.
Fixed in latest commit
tests/test_configdb-json.py
Outdated
cmd = "/bin/sed -i -e 's/\"mac\": \".*\"/\"mac\": \"invalid2\"/' " + str(fh_after) | ||
rc = runCommand(cmd) | ||
cmd = "/bin/sed -i -e 's/\"hwsku\": \".*\"/\"hwsku\": \"" + hwsku + "_dup" +"\"/' " + str(fh_after) | ||
rc = runCommand(cmd) |
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.
The same #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.
Fixed in latest commit
src/usr/lib/ztp/ztp-engine.py
Outdated
def __link_scan(self): | ||
## Redis DB connectors | ||
configDB = None | ||
applDB = None |
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.
You mixed using Class Variables and Instance Variables. Please check some tutorial, such as https://careerkarma.com/blog/python-class-variables/ #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.
Fixed in latest commit
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 comments
Signed-off-by: Rajendra Dendukuri <rajendra.dendukuri@broadcom.com>
…dukuri/sonic-ztp into multidb_ztp_cleanup
@dzhangalibaba Could you also help review this PR? |
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.
LGTM. Please also resolve other reviewers' comments.
src/usr/lib/ztp/ztp-engine.py
Outdated
# Connect to AppDB | ||
try: | ||
if self.applDB is None: | ||
self.applDB = SonicV2Connector(host='127.0.0.1') |
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.
remove "host='127.0.0.1' " , it is not needed , all info should come from database_config.json and the host here didn't take effect.
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.
Implemented the recommended change.
No description provided.