-
Notifications
You must be signed in to change notification settings - Fork 113
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
Fix: correctly handle that lldp_loc_man_addr contains only IPv6 address without IPv4 address #164
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bf170bb
Fix mgmt_ip_sub_oid default value to prevent later exception
qiluo-msft 5d3b8f9
Refix
qiluo-msft 83cdb0d
Reimplement LLDPLocManAddrUpdater
qiluo-msft db0b843
Fix test case
qiluo-msft dc327db
Revert some back and fix lookup()
qiluo-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -317,6 +317,9 @@ def reinit_data(self): | |
if '.' in mgmt_ip: | ||
mgmt_ip_sub_oid = (addr_subtype_sub_oid, *[int(i) for i in mgmt_ip.split('.')]) | ||
break | ||
else: | ||
logger.error("Could not find IPv4 address in lldp_loc_man_addr") | ||
return | ||
except ValueError: | ||
logger.error("Invalid local mgmt IP {}".format(self.mgmt_ip_str)) | ||
return | ||
|
@@ -334,12 +337,12 @@ def update_data(self): | |
|
||
def get_next(self, sub_id): | ||
right = bisect_right(self.man_addr_list, sub_id) | ||
if right == len(self.man_addr_list): | ||
if right >= len(self.man_addr_list): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this change required? #Resolved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not required. It just make code more robust. In reply to: 503552127 [](ancestors = 503552127) |
||
return None | ||
return self.man_addr_list[right] | ||
|
||
def lookup(self, sub_id, callable): | ||
if len(sub_id) == 0: | ||
if sub_id not in self.man_addr_list: | ||
return None | ||
return callable(sub_id) | ||
|
||
|
This file contains 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
This file contains 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
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.
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.
else block is not intended to match the right if block. #Resolved
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.
This is for-else structure, which is a critical change in this PR. If there is no IPv4 address matched in the for loop, we need to return soon. Otherwise future statement will fail since mgmt_ip_sub_oid==None
In reply to: 503552324 [](ancestors = 503552324)
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.
got it, thank you.