Skip to content

Conversation

@Abhishek-121
Copy link
Collaborator

@Abhishek-121 Abhishek-121 commented Oct 17, 2025

…0 ports per device in a single operation.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Description

Please include a summary of the changes and the related issue. Also, include relevant motivation and context.

-- Added the feature of supporting bulk creation of port channels — more than 20 ports per device in a single operation.
-- Also added the new parameter sda_fabric_port_channel_limit, by default it is set to 20.

Bug Fix: [Brief description of the bug fixed]
Root Cause (if applicable): [Explain what caused the bug]
Fix Implemented: [Describe the fix applied]

Enhancement: [Brief description of the improvement/enhancement made]
Enhancement Description: [Explain what was enhanced, why, and how]
Impact Area: [Mention which part of the system/codebase is affected]

Testing Done:

  • [] Manual testing
  • [] Unit tests
  • [] Integration tests

Test cases covered: [Mention test case IDs or brief points]

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • All the sanity checks have been completed and the sanity test cases have been executed

Ansible Best Practices

  • Tasks are idempotent (can be run multiple times without changing state)
  • Variables and secrets are handled securely (e.g., using ansible-vault or environment variables)
  • Playbooks are modular and reusable
  • Handlers are used for actions that need to run on change

Documentation

  • All options and parameters are documented clearly.
  • Examples are provided and tested.
  • Notes and limitations are clearly stated.

Screenshots (if applicable)

Notes to Reviewers

This helps manage large configurations without overwhelming
the system.
type: int
default: 20
Copy link
Collaborator

@madhansansel madhansansel Oct 23, 2025

Choose a reason for hiding this comment

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

If sda_fabric_port_channel_limit is set to 0 or negative, the for-range and logic will break... do we have a min and max value? or the range?

default is 20, cool.. what's the max value I can set? Can we specify the range or is it not needed? or is 20 the max value?

If the max is 20, then you can change

lower values (1-10)
Higher values (11-20) ..

version_added: "6.17.0" ?? Is it correct? Please check and update?

sda_fabric_port_channel_limit:
  description:
    - Maximum number of port channels processed in a single API batch
      for add, update, and delete operations on SD-Access fabric devices.
    - When total port channels exceed this limit, operations are split
      into sequential batches of the specified size for processing.
    - Each batch completes successfully before the next batch starts,
      ensuring data consistency and better error isolation.
    - Sequential processing prevents API timeouts, reduces system load,
      and improves reliability for large port channel configurations.
    - Module provides detailed logging and status reporting for each
      batch, enabling progress tracking and issue identification.
    - Lower values (1-10) provide granular control but slower processing.
    - Higher values (11-20) improve speed but may cause API timeouts.
  type: int
  default: 20
  version_added: "6.17.0". <<< Is it correct?? 

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sample play??

This method initiates the task to add port channels using the provided parameters and returns the task ID.
The method processes port channels in batches of 20 sequentially, waiting for each batch to complete.
"""
payload = add_port_channels_params.get("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 not payload: log and return None or a clear message.

    if not payload:
        self.msg = "No port channels provided in payload for addition operation"
        self.set_operation_result("failed", False, self.msg, "ERROR")
        return None
    

dict: The task ID from the API call.
Description:
This method initiates the task to add port channels using the provided parameters and returns the task ID.
The method processes port channels in batches of 20 sequentially, waiting for each batch to complete.
Copy link
Collaborator

Choose a reason for hiding this comment

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

    The method processes port channels in batches based on sda_fabric_port_channel_limit (default 20) sequentially,
    waiting for each batch to complete before proceeding to the next batch.

Description:
This method initiates the task to add port channels using the provided parameters and returns the task ID.
The method processes port channels in batches of 20 sequentially, waiting for each batch to complete.
"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

self.log(
    "Starting bulk port channel addition with parameters: {0}".format(add_port_channels_params),
    "DEBUG"
)

The method processes port channels in batches of 20 sequentially, waiting for each batch to complete.
"""
payload = add_port_channels_params.get("payload", [])
batch_size = self.params.get("sda_fabric_port_channel_limit", 20)
Copy link
Collaborator

Choose a reason for hiding this comment

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

self.log(
    "Using batch size of {0} for port channel processing (from sda_fabric_port_channel_limit parameter)".format(batch_size),
    "DEBUG"
)

if batch_size <= 0:
    self.msg = "Invalid sda_fabric_port_channel_limit value: {0}. Must be greater than 0".format(batch_size)
    self.set_operation_result("failed", False, self.msg, "ERROR")
    return None

# Retrieve the parameters for updating port channels
update_port_channels_params = self.want.get("update_port_channels_params")
payload = update_port_channels_params.get("payload", [])
batch_size = self.params.get("sda_fabric_port_channel_limit", 20)
Copy link
Collaborator

Choose a reason for hiding this comment

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

self.log(
    "Using batch size of {0} for port channel processing " \
    "(from sda_fabric_port_channel_limit parameter)".format(batch_size),
    "DEBUG"
)

if batch_size <= 0:
    self.log(
        "Invalid sda_fabric_port_channel_limit value: {0}. " \
        "Must be greater than 0".format(batch_size),
        "WARNING"
    )
    batch_size = 20  # Use default if invalid

# For sequential processing, the task status was already checked during processing
# We just need to prepare the final message
self.log(
"Processing sequential update port channels task status for {0} port channels".format(
Copy link
Collaborator

Choose a reason for hiding this comment

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

        "Processing sequential update port channels task status for {0} port " \
        "channels in {1} batches".format(
            len(payload), (len(payload) + batch_size - 1) // batch_size

if self.status == "success":
msg = {}
msg["{0} Succeeded for following port channel(s) (Sequential Processing)".format(task_name)] = {
"success_count": len(port_channels_list),
Copy link
Collaborator

Choose a reason for hiding this comment

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

            "success_count": len(port_channels_list),
            "success_port_channels": port_channels_list,
            "total_batches": (len(payload) + batch_size - 1) // batch_size,
            "batch_size": batch_size,
            "sequential_processing": True,
            "total_channels_requested": len(payload)

return self.get_task_status_from_tasks_by_id(task_id, task_name, msg)
else:
msg = {}
msg["{0} Failed during sequential processing".format(task_name)] = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

        msg["{0} Failed during sequential processing".format(task_name)] = {
            "total_port_channels": len(port_channels_list),
            "port_channels": port_channels_list,
            "total_batches": (len(payload) + batch_size - 1) // batch_size,
            "batch_size": batch_size,
            "sequential_processing": True,
            "status": self.status
        }

}
return self.get_task_status_from_tasks_by_id(task_id, task_name, msg)

msg = {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

msg = {}
msg["{0} Succeeded for following port channel(s)".format(task_name)] = {
    "success_count": len(port_channels_list),
    "success_port_channels": port_channels_list,
    "single_batch": True,
    "total_channels_requested": len(payload)
}

self.log(
    "Completed task status retrieval for update port channels operation",
    "DEBUG"
)

@madhansansel madhansansel merged commit 50eeb1e into cisco-en-programmability:main Oct 30, 2025
12 of 13 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.

2 participants