Skip to content

vmware_custom_attribute_manager: Enhance custom attribute management#2344

Open
sbaerlocher wants to merge 4 commits into
ansible-collections:mainfrom
sbaerlocher:feature/refactor-vmware-custom-manager-attribute
Open

vmware_custom_attribute_manager: Enhance custom attribute management#2344
sbaerlocher wants to merge 4 commits into
ansible-collections:mainfrom
sbaerlocher:feature/refactor-vmware-custom-manager-attribute

Conversation

@sbaerlocher

@sbaerlocher sbaerlocher commented Mar 5, 2025

Copy link
Copy Markdown
SUMMARY

Extended support for additional object types and refactored the code to improve maintainability and readability. This update includes consistent parameter naming, the introduction of type hints and enhanced validations, and a more structured error handling approach. These changes enable a more robust integration with vCenter/vSphere.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

vmware_custom_attribute_manager

ADDITIONAL INFORMATION

The changes include:

  • Extended Object Types:
    • Expanding the supported vSphere object types by adding "Network" and "VirtualApp".
  • Code Refactoring:
    • Refactoring the module to consolidate setting and clearing custom attributes into a single method (process_custom_attributes) and providing an alias (update) for backward compatibility.
    • Adding enhanced validations for required parameters (ensuring that object_name and object_type are non-empty strings and that attributes is a non-empty list).
    • Implementing structured exception handling to catch and report specific errors more clearly.
  • Changelog:
    • Added changelog fragment categorized as minor_changes.
  • Review Feedback Addressed:
    • Replaced deprecated ansible.module_utils._text import with ansible.module_utils.common.text.converters.
    • Updated to use base_argument_spec and documentation fragments from vmware.vmware collection.

@sbaerlocher sbaerlocher force-pushed the feature/refactor-vmware-custom-manager-attribute branch from d54279d to 5f9d7c0 Compare March 5, 2025 21:11
@softwarefactory-project-zuul

Copy link
Copy Markdown

It supports creating/updating custom attributes (state=present) and clearing them (state=absent).
"""

from ansible.module_utils._text import to_native

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It looks like ansible.module_utils._text will be deprecated in ansible-core 2.20 and we've just got rid of it (#2504). I don't think it's a good idea to introduce it again.

from ansible_collections.community.vmware.plugins.module_utils.vmware import (
PyVmomi,
find_obj,
vmware_argument_spec,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since #2459 we're re-using code from vmware.vmware, including the argument specs. I suggest to have a look at this.

@mariolenz

mariolenz commented Oct 29, 2025

Copy link
Copy Markdown
Collaborator

Sorry for the late reply, somehow it's a lot of work to keep this collection at least basically healthy so I don't find much time to work on feature requests... sometimes not even on bugfixes :-/

BTW please add a changelog fragment. I think this would probably be a case of minor_changes.

Additionally, there seem to be some conflicts that need to be resolved.

…ement – extended object types, refactored code
Add changelog entry for PR ansible-collections#2344 documenting the addition of Network
and VirtualApp object type support and code refactoring improvements.
@sbaerlocher sbaerlocher force-pushed the feature/refactor-vmware-custom-manager-attribute branch from 5f9d7c0 to e08673f Compare November 15, 2025 21:33
@softwarefactory-project-zuul

Copy link
Copy Markdown

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/3f2f36d0cd6e4785b6e09ad603546999

⚠️ ansible-tox-linters CANCELED
⚠️ ansible-galaxy-importer SKIPPED Skipped due to failed job build-ansible-collection (non-voting)
build-ansible-collection FAILURE in 5m 04s

- Replace deprecated ansible.module_utils._text import with
  ansible.module_utils.common.text.converters
- Use base_argument_spec from vmware.vmware collection
- Update documentation fragment to vmware.vmware.base_options
- Remove unused vmware_argument_spec import

Addresses review feedback from PR ansible-collections#2344
@softwarefactory-project-zuul

Copy link
Copy Markdown

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/6f1df00eb4af49c0a8f7ff30f577470f

✔️ ansible-tox-linters SUCCESS in 5m 22s
✔️ ansible-galaxy-importer SUCCESS in 5m 07s (non-voting)
✔️ build-ansible-collection SUCCESS in 6m 35s

…anager

- Split long description strings into multiple lines to comply with
  160 character limit
- Fixed lines 39 and 47 that exceeded the maximum line length
@softwarefactory-project-zuul

Copy link
Copy Markdown

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/5967231f2f8a47ee8999f718f2a25cb9

✔️ ansible-tox-linters SUCCESS in 5m 11s
✔️ ansible-galaxy-importer SUCCESS in 5m 21s (non-voting)
✔️ build-ansible-collection SUCCESS in 6m 54s

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