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

content_library_item_info fails when you only specify library_id #540

Closed
1 task done
mikemorency opened this issue Oct 10, 2024 · 5 comments
Closed
1 task done
Assignees
Labels
bug This issue/PR relates to a bug

Comments

@mikemorency
Copy link
Collaborator

mikemorency commented Oct 10, 2024

Summary

The content_library_item_info module fails when a user specifies just the library_id. This triggers the 'list' method, which has an incorrect API url. Heres the relevant lines: https://github.com/ansible-collections/vmware.vmware_rest/blob/main/plugins/modules/content_library_item_info.py#L292-L298

As far as I can tell, the module generation is working as expected. Heres the VMware source docs:
https://developer.broadcom.com/xapis/vsphere-automation-api/latest/content/api/content/library/item__library_id/get/

It currently is:

    return yarl.URL(
        ("https://{vcenter_hostname}" "/api/content/library/item?library_id").format(
            **params
        )
        + gen_args(params, _in_query_parameters),
        encoded=True,
    )

It should be:

    return yarl.URL(
        ("https://{vcenter_hostname}" "/api/content/library/item").format(
            **params
        )
        + gen_args(params, _in_query_parameters),
        encoded=True,
    )

Obviously the quick fix is a simple change. However, since the module will just be re-generated with the incorrect URL I'd like to discuss how best to fix this long term.

We could migrate the module functionality to vmware.vmware, but whats the best way to communicate this to users in this collection? Would we be able to deprecate this module with a minor release, and then remove it with a major release down the line? Is that the best course of action?

Issue Type

Feature Idea

Component Name

content_library_item_info

Additional Information

---
- name: Test Playbook
  hosts: localhost
  gather_facts: false
  tasks:
    - name: Foo
      vmware.vmware_rest.content_library_item_info:
        vcenter_validate_certs: false
        library_id: "{{ my_library_id }}"
      register: ds_lib_items_info
    - debug:
        var: ds_lib_items_info

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@mikemorency
Copy link
Collaborator Author

@mariolenz @bardielle Id like your opinions on this please

@asulliv1
Copy link

I just spend a good hour trying to figure this problem out. after I figure out the code change I then found this issue..

I have been getting to following error "Unsupported property with name: library_id?library_id."

I was able to verify that modifying the code to

    return yarl.URL(
        ("https://{vcenter_hostname}" "/api/content/library/item").format(
            **params
        )
        + gen_args(params, _in_query_parameters),
        encoded=True,
    )

Allowed me to pull all content library items.

I have not validated if this had any impact else where.

@asulliv1
Copy link

Here is an output of the logging before and after the change.

GET: https://vcenter.fqdn/api/content/library/item?library_id?library_id=53c70953-2ec5-4a3a-9ec2-bd7c490c7a6f
headers: <CIMultiDict('vmware-api-session-id': 'ca7d61acc4c189a93cfb78a14f5afd0d', 'content-type': 'application/json')>
status: 400
answer: {"error_type":"INVALID_ARGUMENT","messages":[{"args":["library_id?library_id"],"default_message":"Unsupported property with name: library_id?library_id.","id":"com.vmware.vapi.rest.unsupportedProperty"}]}

GET: https://vcenter.fqdn/api/content/library/item?library_id=53c70953-2ec5-4a3a-9ec2-bd7c490c7a6f
headers: <CIMultiDict('vmware-api-session-id': '987cd6e6a7b3f35bc62dc6ea9b948a9e', 'content-type': 'application/json')>
status: 200
answer: ["9a81171a-ede3-4500-833c-64d0e3236a08",...removed to save space in this message]

@mikemorency
Copy link
Collaborator Author

Hey @asulliv1 , just an FYI, due to the nature of this repo we are deprecating this module and recommending that people use the vmware.vmware.content_library_item_info module instead (https://github.com/ansible-collections/vmware.vmware/blob/main/plugins/modules/content_library_item_info.py)

Related PR #551

@mariolenz
Copy link
Collaborator

Since the module has been moved to vmware.vmware and deprecated in this collection, I don't think we'll work on this issue anymore.

Please try if content_library_item_info works for you. If not, I suggest to open an issue in vmware.vmware.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug
Projects
None yet
Development

No branches or pull requests

3 participants