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

Added ndo_l3out_bgp_peer module to manage L3Out Node/Interface Group Policy - BGP Peer objects (DCNE-182) #611

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

sajagana
Copy link
Collaborator

No description provided.

@github-actions github-actions bot changed the title Added ndo_l3out_bgp_peer module to manage L3Out Node/Interface Group Policy - BGP Peer objects Added ndo_l3out_bgp_peer module to manage L3Out Node/Interface Group Policy - BGP Peer objects (DCNE-182) Feb 13, 2025
@gmicol gmicol added the jira-sync Sync this issue to Jira label Feb 13, 2025
anvitha-jain
anvitha-jain previously approved these changes Feb 25, 2025
Copy link
Collaborator

@anvitha-jain anvitha-jain left a comment

Choose a reason for hiding this comment

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

LGTM

mso_values_remove.append("peerAddressV6")
mso_values.pop("peerAddressV6", None)

if remote_asn == 0 and "peerAsn" in proposed_payload:
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we go by documentation this will never be true. We need to figure out a more effective way to remove int values because a few attributes might have "0" as a valid value.

mso_values_remove.append("peerAsn")
mso_values.pop("peerAsn", None)

if weight == 0 and "weight" in proposed_payload:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above.

When the UUID is existing, returns object name -> Str
When the UUID is not existing -> None
"""
response_object = mso.request("templates/objects?type={0}&uuid={1}".format(object_type, uuid), "GET")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I have a few concerns with this method of obtaining object names with a UUID.

  1. The templates/objects API is currently undocumented and potentially not supported yet unless there's been any recent changes.
  2. This is another API call which can produce slow playbook performance.
  3. The module and template may already have the name information we need. This would be the case if the reference object needs to be in the same template.

elif peer_prefix_identifier.get("name") is not None and peer_prefix_identifier.get("name") != "":
peer_prefix_uuid = mso_template.get_object_by_key_value_pairs(
"BGP Peer Prefix Policy",
mso.query_objs(generate_api_endpoint("templates/objects", **{"type": "bgpPeerPrefixPol", "tenant-id": tenant_id})),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this work when there are objects in different templates with the same name?
The get_object_from_list function will return the first matched object which may not be the intended reference.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The template objects are unique within the tenant level, so we cannot have the same name object with two different templates. Let me recheck the logic once again.

- The name of the L3Out template.
type: str
aliases: [ l3out_template ]
template_id:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we have a task to update the previous ndo_ module with template_id?

- The local autonomous system number (ASN) of the L3Out BGP Peer.
- The value must be between 1 and 4294967295.
type: int
import_route_map:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should the route_map and peer_prefix parameters be a dictionary with name and template options? How do we specify which template the objects are from?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The route_map objects are unique within the tenant level, so we can skip the template check for the route_map objects.
The peer_prefix also unique within the tenant level, but it allows to import common tenant peer_prefix value. Let me make changes for both route map and peer prefix.

Copy link
Collaborator

Choose a reason for hiding this comment

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

see choices made in this discussion where it is a map with name, https://github.com/CiscoDevNet/ansible-mso/pull/577/files#r1970341772. perhaps we should follow same here?

- The local autonomous system number (ASN) of the L3Out BGP Peer.
- The value must be between 1 and 4294967295.
type: int
import_route_map:
Copy link
Collaborator

Choose a reason for hiding this comment

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

see choices made in this discussion where it is a map with name, https://github.com/CiscoDevNet/ansible-mso/pull/577/files#r1970341772. perhaps we should follow same here?


mso = MSOModule(module)

template_identifier = get_object_identifier(module.params.get("template_id"), module.params.get("template"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is the use case for template_identifier instead of just storing in two variables?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira-sync Sync this issue to Jira
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: New module for NDO L3Out Node Group Policy BGP Peer (DCNE-182)
6 participants