-
Notifications
You must be signed in to change notification settings - Fork 44
Fix httpapi plugin for ND4.1 #452
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
base: develop
Are you sure you want to change the base?
Conversation
@@ -1,4 +1,4 @@ | |||
# Copyright (c) 2020-2023 Cisco and/or its affiliates. | |||
# Copyright (c) 2020-2025 Cisco and/or its affiliates. |
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.
NOTE: I would not suggest reviewing the diffs but rather compare the code here to what we have in the develop
branch. Much simpler code structure while maintaining the same functionality.
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.
Approving with just one question about the order in which we attempt login (v11 first, v12 second).
One other observation in the main plugins/httpapi/dcnm.py
file, related to the following (lines 295-299).
try:
return json.loads(response_text) if response_text else {}
# # JSONDecodeError only available on Python 3.5+
except ValueError:
return "Invalid JSON response: {0}".format(response_text)
Since our minimum Python version now supports JSONDecodeError
should we use it? Also, maybe remove the extra #
in the comment.
Really like the new unit tests and the cleaner code in general!
) | ||
login_domain = self.get_option("login_domain") or "local" | ||
|
||
# Define login configurations in order of preference |
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.
Just wondering if the order should be to try v12 first since (hopefully) v11 sees less use than v12?
Please ignore though if the delay due to the v11 login attempt is minimal since this would require changes to multiple of the unit tests as well.
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.
Good suggestion. I will update
Yeah, that is a good call. I will update |
Short Summary
We discovered a problem in ND4.1 where the httpapi plugin gets stuck in a login loop. What I discovered is that the login method gets called and then immediately the logout method is called and we get stuck in a login/logout loop.
Updates in this PR:
black
formatterNOTE: In addition to the new pytests this code has been testing using our VXLAN as Code collection nightly sanities
DCNM HttpAPI Plugin Refactoring Detailed Summary
Overview
This document summarizes the major changes made to
plugins/httpapi/dcnm.py
compared to the develop branch. The refactoring focused on code consolidation, improved maintainability, and enhanced error handling.🔧 Code Refactoring
1. Login Method Consolidation
Before:
_login_old()
,_login_latestv1()
,_login_latestv2()
After:
_attempt_login()
methodlogin_configs
arrayBenefits:
2. Logout Method Simplification
Before:
_logout_old()
for DCNM v11_logout_latest()
for NDFC v12+After:
_attempt_logout()
methodBenefits:
3. Request Handling Consolidation
Before:
send_request()
andsend_txt_request()
had duplicate validation and error handlingAfter:
_send_request_internal()
method handles common logicBenefits:
📝 Code Quality Improvements
4. Constants Definition
Added module-level constants: