CP- 6679

This is an updated version of #1568 from @djs55 with some small issues fixed.

Cloudstack folks have tested the feature in their prototype and seem liking it.