vmware / vsphere-automation-sdk-python

Python samples, language bindings, and API reference documentation for vSphere, VMC, and NSX-T using the VMware REST API
MIT License
745 stars 313 forks source link

How to get VM Hardware of a OVF Template in Content Library #401

Closed Zer0x00 closed 10 months ago

Zer0x00 commented 11 months ago

Is your feature request related to a problem? Please describe.

We need to access the configured hard disk size of a OVF Template inside a content library.

The HTML5 application seems to have a private API to show this data in the frontend: GET /ui/data/urn:vapi:com.vmware.content.library.Item:<Library Item ID>:<Library ID>?model=com.vmware.vsphere.client.library.h5model.OvfTemplateHardwareData

which returns:

{
    "provider": "urn:vapi:com.vmware.content.library.Item:<Library Item ID>:<Library ID>",
...
    "diskData": [
        {
            "name": "Hard disk 1",
            "diskCapacity": 64,
            "storagePolicy": null
        }
    ],
...
}

We can't access the private API since it requires SAML authentication. Is there a way to access this data via the Python SDK?

Describe the solution you'd like

from vmware.vapi.vsphere.client import create_vsphere_client

server = "<server>"
username = "<username>"
password = "<password>"
template_name = "template_name"

client = create_vsphere_client(server=server, username=username, password=password)

local_library = client.content.LocalLibrary
local_library_ids = local_library.list()

library_item = client.content.library.Item

searched_library_item = next(
    (
        library_item.get(id)
        for library_id in local_library_ids
        for id in library_item.list(library_id=library_id)
        if library_item.get(id).name == template_name
    ),
    None,
)

print(searched_library_item)

The above code example returns some template related details but everything regarding the VM Hardware is missing. The information could be added at this point.

Describe alternatives you've considered

No response

Additional context

No response

kunal-pmj commented 10 months ago

There are no Content Library API(s) to get OVF item properties and this is as per design. There can be N number of properties in the descriptor and it will be difficult to provide APIs to capture all of them. I will get back to you to see if there is an alternative to retrieve this data.

Thanks Kunal

kunal-pmj commented 10 months ago

There is no option to review the OVF Library Item using API.

Zer0x00 commented 10 months ago

Can this be implemented in a future release?

kunal-pmj commented 10 months ago

We are following up with the Feature owners, Will update the ticket once we hear back from them.

thanks Kunal

kunal-pmj commented 10 months ago

There are no public APIs to do this operation and there is no plan to add any API for the same.