Quarantining VMs

Is it possible to override the default behaviour of Delete and Shutdown so that we can quarantine VMs?

Ideally we would be able to snapshot the VMs (or their disks) before the shutdown or delete command runs with a hook, however I am not opposed to changing something elsewhere in order to get what I need.

One solution that springs to mind would be to reassign the VMs to a Quarantine user and then having a cron to clean those up.


The problem with using hooks is that you need your operations to be synchronous, but opennebula will not wait for the hook to finish before the next driver action is executed.

The way I see it there are two options:

  • Modify the ruby oca

The CLI and sunstone server use the ruby oca to talk to the core. So you can modify the shutdown and delete methods to perform any action you want

I would suggest to perform your workflow async. I mean that the call to shutdown should not have an active wait loop; instead you could move the VM to that ‘quarantine user’ you mention or add a special flag (QUARANTINE = YES). Then the cron job will do the rest.

  • Modify the drivers

The VM drivers are designed to be easy to modify. In your case, you may want to modify the shutdown and cancel scripts.