I have a CREATE VM hook that gets the template data and based on User templates and VM template it creates an DATABLOCK image, and uploads it to Opennebula. I have the VM ID and IMAGE ID (In ready state), and I want to add it to the VM before it boots.
I have tried:
onevm disk-attach "$VMID" --image "$IMAGEID"
[VirtualMachineAttach] VM is not running in any host
hooks are asynchronous, you cannot guarantee that the datastore will be created before that. However I think you can accomplish what you want by using a VOLATILE disk.
Thanks Jaime, I got this working, my next question is, is there a way to get the total number of nic cards attached to a VM using Hooks? Someting like:
NIC=$XPATH -b $T64 TEMPLATE/NIC`
Any thoughts, thanks
I think this is what you are looking for:
[oneadmin]$ onevm show 34 -x | /var/lib/one/remotes/datastore/xpath.rb -s %m%TEMPLATE/NIC/MAC
Then count the returned elements…