-
Notifications
You must be signed in to change notification settings - Fork 25
Confirmation check for mgmtvrf should only be for mgmt IP and not check for loopback #24
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: 202311.X
Are you sure you want to change the base?
Conversation
…ck for loopback Signed-off-by: irene_pan irene_pan@edge-core.com
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.
Pull Request Overview
This PR updates the mgmtVRF confirmation check in the SNMP agent address addition workflow so that it only validates against management interface IPs and excludes loopback IPs.
- Added retrieval of all management interface keys via _get_all_mgmtinterface_keys().
- Introduced an IP-based check that compares the provided agent IP (stripped of its mask) against the management IPs.
| if entry and entry['mgmtVrfEnabled'] == 'true' : | ||
| click.echo("ManagementVRF is Enabled. Provide vrf.") | ||
| return False | ||
| mgmtintf_key_list = _get_all_mgmtinterface_keys() |
Copilot
AI
Apr 17, 2025
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.
Verify that _get_all_mgmtinterface_keys() returns only management interface IPs and excludes any loopback interfaces. Consider adding a comment or validation to clarify its expected output.
| mgmtintf_key_list = _get_all_mgmtinterface_keys() | |
| mgmtintf_key_list = _get_all_mgmtinterface_keys() | |
| # Filter out loopback interfaces to ensure only management interface IPs are included | |
| mgmtintf_key_list = [key for key in mgmtintf_key_list if not key[0].startswith('lo')] |
| click.echo("ManagementVRF is Enabled. Provide vrf.") | ||
| return False | ||
| mgmtintf_key_list = _get_all_mgmtinterface_keys() | ||
| if any(ip.split('/')[0].lower() == agentip.lower() for _, ip in mgmtintf_key_list): |
Copilot
AI
Apr 17, 2025
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.
Using string splitting for IP comparison may lead to issues if the IP format changes; consider using the ipaddress module for robust IP address comparisons (e.g., comparing ipaddress.ip_address values).
| if any(ip.split('/')[0].lower() == agentip.lower() for _, ip in mgmtintf_key_list): | |
| if any(str(ipaddress.ip_interface(ip).ip).lower() == agentip.lower() for _, ip in mgmtintf_key_list): |
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.
Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
config/main.py:3186
- The condition assumes that all IP strings include a '/' for subnet separation, which might lead to an error if an IP is provided in a different format. Consider adding validation or error handling to ensure the split operation is safe.
if any(ip.split('/')[0].lower() == agentip.lower() for _, ip in mgmtintf_key_list):
config/main.py:3185
- Ensure that there are corresponding unit tests for _get_all_mgmtinterface_keys() and this new check to verify the behavior when the agent IP belongs or does not belong to the management interface list.
mgmtintf_key_list = _get_all_mgmtinterface_keys()
What I did
Confirmation check for mgmtvrf should only be for mgmt IP and not check for loopback
How I did it
How to verify it
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)