-
Notifications
You must be signed in to change notification settings - Fork 5
Fix the issue of support bulk creation of port channels — more than 2… #315
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 the issue of support bulk creation of port channels — more than 2… #315
Conversation
…0 ports per device in a single operation.
| This helps manage large configurations without overwhelming | ||
| the system. | ||
| type: int | ||
| default: 20 |
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.
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??
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.
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", []) |
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.
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. |
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.
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. | ||
| """ |
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.
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) |
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.
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) |
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.
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( |
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.
"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), |
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.
"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)] = { |
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.
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 = {} |
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.
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"
)
50eeb1e
into
cisco-en-programmability:main
…0 ports per device in a single operation.
Type of Change
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:
Test cases covered: [Mention test case IDs or brief points]
Checklist
Ansible Best Practices
ansible-vaultor environment variables)Documentation
Screenshots (if applicable)
Notes to Reviewers