@staticmethod<EOL><INDENT>def _sort_resources_per_hosting_device(resources):<DEDENT>
hosting_devices = {}<EOL>for key in resources.keys():<EOL><INDENT>for r in resources.get(key) or []:<EOL><INDENT>if r.get('<STR_LIT>') is None:<EOL><INDENT>continue<EOL><DEDENT>hd_id = r['<STR_LIT>']['<STR_LIT:id>']<EOL>hosting_devices.setdefault(hd_id, {})<EOL>hosting_devices[hd_id].setdefault(key, []).append(r)<EOL><DEDENT><DEDENT>return hosting_devices<EOL>
This function will sort the resources on hosting device.

        The sorting on hosting device is done by looking up the
        `hosting_device` attribute of the resource, and its `id`.

        :param resources: a dict with key of resource name
        :return dict sorted on the hosting device of input resource. Format:
        hosting_devices = {
                            'hd_id1' : {'routers':[routers],
                                        'removed_routers':[routers], .... }
                            'hd_id2' : {'routers':[routers], .. }
                            .......
                            }