-
Notifications
You must be signed in to change notification settings - Fork 2
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
New swim workflow feature #57
New swim workflow feature #57
Conversation
|
||
messages = [] | ||
|
||
if skipped_images_str: |
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.
Can we opimize the logic?
messages = []
if skipped_images_str:
messages.append("Image(s) {0} were skipped as they already exist in Cisco Catalyst Center.".format(skipped_images_str))
if imported_images_str:
messages.append("Image(s) {0} have been imported successfully into Cisco Catalyst Center.".format(imported_images_str))
elif not skipped_images_str:
messages.append("No images were imported.")
- "{{ item }}" | ||
loop: "{{ vars_map.delete_devices }}" | ||
register: result_device_deleted | ||
# - name: Delete device |
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.
Remove commented lines...
@@ -1679,6 +1681,15 @@ def get_diff_tagging(self): | |||
self.result['response'] = self.msg | |||
self.log(self.msg, "INFO") | |||
break | |||
elif task_details.get("isError"): |
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.
getting isError, progress, failure_reason from task_details used in multiple places.
Can't we get the vaules, store and use it?
<<< Sample Code, modify the code based on your logic.... >>>>>>>>>>
device_family = tagging_details.get("device_image_family_name")
device_role = tagging_details.get("device_role", "ALL")
site_name = tagging_details.get("site_name", "Global")
while True:
task_details = self.get_task_details(task_id)
is_error = task_details.get("isError")
progress = task_details.get("progress", "")
failure_reason = task_details.get("failureReason", "")
if is_error:
if not tag_image_golden and "An inheritted tag cannot be un-tagged" in failure_reason:
self.msg = failure_reason
else:
action = "Tagging" if tag_image_golden else "Un-Tagging"
self.msg = (
"{0} image {1} golden for site {2} for family {3} for device role {4} failed."
.format(action, image_name, site_name, device_family, device_role)
)
self.status = "failed"
self.result['changed'] = False
self.result['msg'] = self.msg
self.log(self.msg, "ERROR")
break
if "successful" in progress:
action = "Tagging" if tag_image_golden else "Un-Tagging"
self.msg = (
"{0} image {1} golden for site {2} for family {3} for device role {4} successful."
.format(action, image_name, site_name, device_family, device_role)
)
self.status = "success"
self.result['changed'] = True
self.result['msg'] = self.msg
self.log(self.msg, "INFO")
break
return self
What happens if not is_error, and not successful in progress? Do we sleep for some time? Is it needed to be in while loop to do tag and untag an image? If we still need to check "while" loop, then add sleep and do checks for default times and break from the loop..
2de3c0d
into
cisco-en-programmability:main
Description
Please include a summary of the changes and the related issue. Also, include relevant motivation and context.
Type of Change
Checklist
Ansible Best Practices
ansible-vault
or environment variables)Documentation
Screenshots (if applicable)
Notes to Reviewers