Skip to content
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

Merged
merged 13 commits into from
Sep 23, 2020

Conversation

rajendra-dendukuri
Copy link
Collaborator

No description provided.

@rajendra-dendukuri
Copy link
Collaborator Author

retest buster please

@@ -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"
Copy link

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

Copy link
Collaborator Author

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>
@lguohan
Copy link
Contributor

lguohan commented Jun 25, 2020

retest this please

jleveque and others added 4 commits August 7, 2020 00:02
`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:
Copy link
Contributor

@qiluo-msft qiluo-msft Sep 21, 2020

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in latest commit

Copy link
Contributor

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)

Copy link
Collaborator Author

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")
Copy link
Contributor

@qiluo-msft qiluo-msft Sep 21, 2020

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in latest commit

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)
Copy link
Contributor

@qiluo-msft qiluo-msft Sep 21, 2020

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in latest commit

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)
Copy link
Contributor

@qiluo-msft qiluo-msft Sep 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in latest commit

def __link_scan(self):
## Redis DB connectors
configDB = None
applDB = None
Copy link
Contributor

@qiluo-msft qiluo-msft Sep 21, 2020

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in latest commit

Copy link
Contributor

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As comments

@qiluo-msft
Copy link
Contributor

@dzhangalibaba Could you also help review this PR?

Copy link
Contributor

@qiluo-msft qiluo-msft left a 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.

# Connect to AppDB
try:
if self.applDB is None:
self.applDB = SonicV2Connector(host='127.0.0.1')

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented the recommended change.

@qiluo-msft qiluo-msft merged commit 6f0305b into sonic-net:master Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants