REST API: Attaching an existing .vhd to a stopped VM
-
I am automating VM deployments using XOA's REST API. I am successfully deploying a VM from a template and uploading a VHD to one of my SRs. The final step in my automated deployment is attaching this existing VHD that i uploaded to the newly created, halted VM.
I also need to select which .iso is inserted into the CD drive. Is that something configured at the template level? I thought I had done that prior to converting my template.
I saw some discussions about attaching an existing VDI a year ago in the forums, so I am not sure if anyone has asked recently. I am not sure if attaching a disk to a stopped VM after it was newly created is an endpoint I might have missed.
Is this handled under an action sub-URL?
-
You attach a VDI to a VM by creating a VBD. Take a look at the
POST /vbdsendpoint. -
@Danp Thanks! Also, I converted my VM to a template and it had the .iso in it prior to doing that but then when i spin it up from the REST API the .iso is gone?
-
@Danp They're all GET methods no way to mount anything.

-
@Bytevenidos Are you up-to-date?


-
Updated now!

-
@Danp How about the CD-ROM with the .iso? Can i mount that on the VM using these also ?
-
@Bytevenidos I don't see an endpoint in the REST API for mounting an ISO. However, you should be able to mount the ISO during the VM creation. I will ask around about using the REST API to mount and eject ISOs.
-
@danp The POST /vbds endpoint allows configuring both "RW" or "RO" and a bootable Boolean.
If I need to mount an OS installation ISO and a separate provisioning VDI to the same VM, I assume I must execute two distinct POST /vbds requests:
For the CD-ROM (ISO): Set "mode": "RO" and "bootable": true.
For the provisioning VDI: Set "mode": "RW" and "bootable": false.Would this work in mounting my OS .iso to my VM in the CD-ROM and also mount the VDI to the vm so it will read it on first boot?
{ "VM": "VM-UUID", "VDI": "VDI-UUID", "bootable": false, "mode": "RW" } -
@Bytevenidos You can try that, but it most likely won't work.
I've confirmed with the dev team that the end point to mount an ISO doesn't currently exist for the REST API. However, it does exist in the older JSON-RPC API, which you can access using xo-cli --
vm.insertCd id=<string> cd_id=<string> [force=<boolean>] -
@Danp alright, thanks. I'll give that a try.
