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

Swim bug fixed - An image cannot be tagged as golden with multiple device roles #27

Conversation

syed-khadeerahmed
Copy link
Collaborator

@syed-khadeerahmed syed-khadeerahmed commented Nov 13, 2024

Description

problem: An image cannot be tagged as golden with multiple device roles
Solution: To allow an image to be tagged as golden for multiple device roles, I implemented a loop structure that iterates through each specified device role in the list and applies the golden tag accordingly. The loop ensures that each device role specified will be processed, tagging the image as golden for all applicable roles without requiring multiple separate executions. This approach helps to streamline the tagging process, making it more efficient and adaptable for various configurations.
The loop verifies each device role before tagging to ensure compatibility and avoid errors. If the image is not already tagged for a particular role, the loop adds the tag, ensuring that no redundant tags are applied. This solution not only enhances code efficiency but also improves scalability, allowing future expansion to accommodate more device roles or additional tagging criteria with minimal adjustments.

Type of Change

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

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

description: |
Specifies the device role(s) for tagging or untagging the image as golden.
Permissible values:
- `ALL`: Applies the golden tag to all devices, regardless of role.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use ' instead of `

- 'ALL': Tags all devices as golden, regardless of role.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated the code

Specifies the device role(s) for tagging or untagging the image as golden.
Permissible values:
- `ALL`: Applies the golden tag to all devices, regardless of role.
- `UNKNOWN`: For devices without a specific classification.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Tags devices without a specified classification.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated the code

Permissible values:
- `ALL`: Applies the golden tag to all devices, regardless of role.
- `UNKNOWN`: For devices without a specific classification.
- `ACCESS`: Devices connecting end-user devices (e.g., access switches).
Copy link
Collaborator

Choose a reason for hiding this comment

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

Tags devices that connect end-user devices (e.g., access switches).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated the code

- `ALL`: Applies the golden tag to all devices, regardless of role.
- `UNKNOWN`: For devices without a specific classification.
- `ACCESS`: Devices connecting end-user devices (e.g., access switches).
- `BORDER ROUTER`: Devices linking different network segments or domains.
Copy link
Collaborator

Choose a reason for hiding this comment

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

  - 'BORDER ROUTER': Tags devices linking different network segments or domains.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated the code

- `UNKNOWN`: For devices without a specific classification.
- `ACCESS`: Devices connecting end-user devices (e.g., access switches).
- `BORDER ROUTER`: Devices linking different network segments or domains.
- `DISTRIBUTION`: Devices aggregating traffic towards the core.
Copy link
Collaborator

Choose a reason for hiding this comment

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

  - 'DISTRIBUTION': Tags devices aggregating traffic toward the core.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated the code

plugins/modules/swim_workflow_manager.py Show resolved Hide resolved
self.log(tag_image_golden)

if image_status == tag_image_golden:
self.log("inside if")
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove this log, not useful one

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated the code

self.log(msg, "INFO")
already_tagged_device_role.append(role)

if not image_status and image_status == tag_image_golden:
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should be elif since you have already checked image_status as tag_image_golden in 1584 a

elif not image_status and not tag_image_golden:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated the code

plugins/modules/swim_workflow_manager.py Show resolved Hide resolved
plugins/modules/swim_workflow_manager.py Show resolved Hide resolved
@madhansansel madhansansel merged commit 4c45cc6 into cisco-en-programmability:main Nov 13, 2024
6 of 9 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