'Get usage info about each active instance.'

def get_per_instance_usage(self):

    usage = {}
    def _is_active(vm_rec):
        power_state = vm_rec['power_state'].lower()
        return (power_state in ['running', 'paused'])
    def _get_uuid(vm_rec):
        other_config = vm_rec['other_config']
        return other_config.get('nova_uuid', None)
    for (vm_ref, vm_rec) in vm_utils.list_vms(self._session):
        uuid = _get_uuid(vm_rec)
        if (_is_active(vm_rec) and (uuid is not None)):
            memory_mb = (int(vm_rec['memory_static_max']) / units.Mi)
            usage[uuid] = {'memory_mb': memory_mb, 'uuid': uuid}
    return usage
