def remove_router_from_hosting_device(self, context, hosting_device_id,<EOL>router_id):
e_context = context.elevated()<EOL>r_hd_binding_db = self._get_router_binding_info(e_context, router_id)<EOL>if r_hd_binding_db.hosting_device_id != hosting_device_id:<EOL><INDENT>raise routertypeawarescheduler.RouterNotHostedByHostingDevice(<EOL>router_id=router_id, hosting_device_id=hosting_device_id)<EOL><DEDENT>router = self.get_router(context, router_id)<EOL>self.add_type_and_hosting_device_info(<EOL>e_context, router, r_hd_binding_db, schedule=False)<EOL>self.remove_router_from_backlog(id)<EOL>l3_cfg_notifier = self.agent_notifiers.get(AGENT_TYPE_L3_CFG)<EOL>if l3_cfg_notifier:<EOL><INDENT>l3_cfg_notifier.router_removed_from_hosting_device(context, router)<EOL><DEDENT>LOG.debug("<STR_LIT>", r_hd_binding_db.router_id)<EOL>self.unschedule_router_from_hosting_device(context, r_hd_binding_db)<EOL>with e_context.session.begin(subtransactions=True):<EOL><INDENT>r_hd_binding_db.hosting_device_id = None<EOL>e_context.session.add(r_hd_binding_db)<EOL><DEDENT>
Remove the router from hosting device.

        After removal, the router will be non-hosted until there is update
        which leads to re-schedule or be added to another hosting device
        manually.