[SOLVED] Is it possible to get an information about VM's placement via API?

Hello. I want to get information on which host VM’s were placed via API (Ruby)
I’ve tried to use the VirtualMachinePool and VirtualMachine classes, unfortunately, I haven’t found necessary information (like :host or may be :placed)

Hello @FoxSibirsky

You can do it in the following way:

client = OpenNebula::Client.new
xml    = OpenNebula::VirtualMachine.build_xml(<VM_ID>)
vm     = OpenNebula::VirtualMachine.new(xml, client)

vm.info
vm['//VM/HISTORY_RECORDS/HISTORY[last()]/HID']

Cool! Thank so much!

1 Like