Extract common part of instances.py and instances_heat.py

Fixes bug: #1259170

Change-Id: I9bcc578a77baff88611e5eb488a69a50fa6bd932
Merge "Extract common part of instances.py and instances_heat.py"