def _sort_resources_per_hosting_device(resources):
        hosting_devices = {}
        for key in resources.keys():
            for r in resources.get(key) or []:
                if r.get('hosting_device') is None:
                    continue
                hd_id = r['hosting_device']['id']
                hosting_devices.setdefault(hd_id, {})
                hosting_devices[hd_id].setdefault(key, []).append(r)
        return hosting_devices