Open bogdan-ds opened 4 years ago
Hi,
Believe you would be passing the catalog ID instead of media ID when inserting the CD for a VM. To get the media ID, you would need to access the Entity for the catalog Item.
Sharing a code snippet to help you out:
# Get VM object
>>> vm = VM(client, resource=vapp.get_all_vms()[0])
# Get catalog item
>>> it = org.get_catalog_item(CATALOG_LIBRARY, ITEM_NAME)
# Media ID can be accessed via **Entity** attribute for the catalog object
>>> it.Entity.items()
[('href', 'https://fqdn/api/media/e91052bd-46bb-4a2f-bf11-4285511c52ef'), ('id', 'urn:vcloud:media:e91052bd-46bb-4a2f-bf11-4285511c52ef'), ('name', ITEM_NAME), ('type', 'application/vnd.vmware.vcloud.media+xml')]
# insert CD
>>> t = vm.insert_cd_from_catalog(dict(it.Entity.items())["id"].split(":")[-1])
# eject CD
>>> t = vm.eject_cd(dict(it.Entity.items())["id"].split(":")[-1])```
Thanks a lot @sumitkapoor, that worked!
Hello,
I'm trying to insert a media from a public catalog into a VM, when using the method
insert_cd
I'm getting a 403 error. However when I try to insert the same CD from the same catalog via vCloud director it works without any issues. Also the eject method, which is more or less the same works fine. The full error is:P.S When using the pyvcloud client I'm using the administrative user and the system org, the same as in vCD. I also checked if the organisation has the required rights and it does.
Thanks in advance.