Skip to content

Added ndo_fabric_span_session_source_filter module to manage the SPAN session source filter (DCNE-376) #677

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

Merged

Conversation

sajagana
Copy link
Collaborator

@sajagana sajagana commented May 29, 2025

Added parent ndo_fabric_span_session_source module changes for the testing purpose.

@sajagana sajagana force-pushed the 376_fabric_span_session_source_filters branch from 16a41fc to 37bc01c Compare May 29, 2025 16:26
@sajagana sajagana force-pushed the 376_fabric_span_session_source_filters branch from 37bc01c to d04bc8e Compare June 18, 2025 11:17
"""
existing_objects = self.template.get("monitoringTemplate", {}).get("template", {}).get("spanSessions", [])
if uuid or name: # Query a specific object
return self.get_object_by_key_value_pairs("SPAN Sessions", existing_objects, [KVPair("uuid", uuid) if uuid else KVPair("name", name)], fail_module)
Copy link
Collaborator

Choose a reason for hiding this comment

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

is plural form correct here?

Suggested change
return self.get_object_by_key_value_pairs("SPAN Sessions", existing_objects, [KVPair("uuid", uuid) if uuid else KVPair("name", name)], fail_module)
return self.get_object_by_key_value_pairs("SPAN Session", existing_objects, [KVPair("uuid", uuid) if uuid else KVPair("name", name)], fail_module)

Copy link
Collaborator

Choose a reason for hiding this comment

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

applies to all 3

KVPair("destPortTo", int(PORT_MAPPING.get(filter_config.get("destination_port_to")))),
KVPair("ipProtocol", IP_PROTOCOL_MAPPING.get(filter_config.get("ip_protocol"))),
]
return self.get_object_by_key_value_pairs("SPAN Sessions Source", search_list, KVPairs, fail_module)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return self.get_object_by_key_value_pairs("SPAN Sessions Source", search_list, KVPairs, fail_module)
return self.get_object_by_key_value_pairs("SPAN Sessions Source Filter", search_list, KVPairs, fail_module)

@sajagana sajagana requested a review from akinross June 20, 2025 13:51
return self.get_object_by_key_value_pairs("SPAN Session Source", search_list, [KVPair("name", name)], fail_module)
return search_list # Query all objects

def get_fabric_span_session_source_filter(self, filter_config, search_list, fail_module=False):
Copy link
Collaborator

Choose a reason for hiding this comment

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

If this function is used only in one module, this should be moved inside the module.

state: present
register: update_filter_l3out_ansible_test_source_2

- name: Assertion check for update SPAN Session source with different options
Copy link
Collaborator

Choose a reason for hiding this comment

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

This assesrtion is task is too big, it has to split based on add, remove, update according to the tasks

- This parameter or O(filter_epg.epg) is required.
type: str
aliases: [ epg_uuid ]
epg:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want to name this epg or something like reference? I personally find the filter_epg.epg a bit redundant. In my PR I have a port_channel dict, which would then be port_channel.port_channel.some_key.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

type: list
elements: dict
suboptions:
access_path_type:
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 use an alias of type? or is this a reserved key in ansible?

choices: [ incoming, outgoing, both ]
span_drop_packets:
description:
- The SPAN Drop Packets of the SPAN Session source.
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 add a explanation of behaviour here?

description:
- The Filter L3Out of the SPAN Session source.
- When the Filter L3Out is specified in the configuration, the Filter EPG will be removed.
- Filter L3Out and Filter EPG cannot be configured simultaneously.
Copy link
Collaborator

@akinross akinross Jun 21, 2025

Choose a reason for hiding this comment

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

so we are adding this line now as standard? Should this also be added then to the OR description for all other mutual exclusives? uuid/name because or would not indicate that they cannot be provided together?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We do not have a standard sentence for mutual exclusives condition. But changed the current description to match the current format.

template_id:
description:
- The ID of the Fabric Resource Policy template.
- This parameter or O(access_paths.template) is required to configure the 'Port Channel' or 'Virtual Port Channel' Access Path.
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 use O(access_path_type= port_channel) for these references?

@sajagana sajagana force-pushed the 376_fabric_span_session_source_filters branch 3 times, most recently from a45edda to 7ce2355 Compare June 27, 2025 07:34
- The SPAN Drop Packets of the SPAN Session source.
- SPAN Drop Packets are packets that get dropped when the SPAN destination port cannot handle the volume of mirrored traffic from the source ports.
- Defaults to O(span_drop_packets=false) when unset during creation.
- The O(filter_epg) and O(filter_l3out) is not configurable when this parameter O(span_drop_packets=true) set to true.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- The O(filter_epg) and O(filter_l3out) is not configurable when this parameter O(span_drop_packets=true) set to true.
- The O(filter_epg) and O(filter_l3out) are not configurable when O(span_drop_packets=true).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

uuid:
description:
- The UUID of the EPG used to configure the Filter EPG.
- This parameter or O(filter_epg.epg_reference) is required.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I personally do not like this form. The original comment was to avoid double usage of a object naming in nesting of dictionaries. Originally you proposed for name filter_epg.epg.name and now this becomes filter_epg.epg_reference.name where we already now that the reference is for a epg. I proposed filter_epg.reference.name, to avoid this double usage of epg. In my case it would become virtual_port_channel.virtual_port_channel_reference.name. I think if we prefer epg_reference we might as well use epg.

I understand that the team is not a fan of the reference wording (which is/was used in MSO/NDO to point to objects within a schema). Thus far I proposed reference, object, instance which were all not fitting, but I do not see any alternatives. @anvitha-jain, @samiib, @shrsr, @gmicol, @lhercot, can you provide other proposals or your preference for this to @sajagana?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am happy with using reference. I see how it can become quite verbose when the object name is long eg. virtual_port_channel.

Copy link
Collaborator

@akinross akinross Jun 27, 2025

Choose a reason for hiding this comment

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

Yes i also think alias can help to shorten this even further, alias ref for reference for instance and vpc for virtual_port_channel.

This way virtual_port_channel.reference.name could become vpc.ref.name

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm good with reference as well!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Based on the discussion, "reference" was chosen as the primary attribute name, with "ref" used as its alias.

@sajagana sajagana force-pushed the 376_fabric_span_session_source_filters branch from 7ce2355 to f7b6f74 Compare July 1, 2025 05:48
@sajagana sajagana requested a review from akinross July 1, 2025 05:58
akinross
akinross previously approved these changes Jul 2, 2025
Copy link
Collaborator

@akinross akinross left a comment

Choose a reason for hiding this comment

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

LGTM

source_port_from:
description:
- The starting source port number for the SPAN Session source filter.
- This parameter is required to query/delete a specific SPAN session source filter when it is configured with a non-default value.
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 mean when it is not configured with "unspecified"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, some attributes default to "unspecified" if not provided during creation, update, query, or deletion. If a filter is created without a default value, I need the non-default value to query or delete that specific object.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Shall we be more specific then saying when not configured with "unspecified"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

source_port_to:
description:
- The ending source port number for the SPAN Session source filter.
- This parameter is required to query/delete a specific SPAN session source filter when it is configured with a non-default value.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same question as above?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, some attributes default to "unspecified" if not provided during creation, update, query, or deletion. If a filter is created without a default value, I need the non-default value to query or delete that specific object.

Copy link
Collaborator

@shrsr shrsr left a comment

Choose a reason for hiding this comment

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

LGTM

shrsr
shrsr previously approved these changes Jul 3, 2025
Copy link
Collaborator

@shrsr shrsr left a comment

Choose a reason for hiding this comment

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

LGTM

akinross
akinross previously approved these changes Jul 4, 2025
Copy link
Collaborator

@akinross akinross left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -1891,8 +1891,8 @@ def listener_rules_spec():
)


def epg_object_reference_spec():
return dict(
def epg_object_reference_spec(aliases=None):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should aliases here be alias as its currently only defined as a single string? Or should this be list of strings and the below code would be: epg_reference_spec["aliases"] = aliases

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed!

@sajagana sajagana dismissed stale reviews from akinross and shrsr via 131c14f July 7, 2025 08:22
@sajagana sajagana force-pushed the 376_fabric_span_session_source_filters branch from 3b654ac to 131c14f Compare July 7, 2025 08:22
@sajagana sajagana requested review from samiib, shrsr and akinross July 7, 2025 08:22
Copy link
Collaborator

@akinross akinross left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@samiib samiib left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@shrsr shrsr left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@gmicol gmicol left a comment

Choose a reason for hiding this comment

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

LGTM

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

Copy link
Member

@lhercot lhercot left a comment

Choose a reason for hiding this comment

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

LGTM

@lhercot lhercot merged commit 6b9504c into CiscoDevNet:master Jul 11, 2025
22 of 23 checks passed
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.

7 participants