def add_router_to_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:<EOL><INDENT>if r_hd_binding_db.hosting_device_id == hosting_device_id:<EOL><INDENT>return<EOL><DEDENT>raise routertypeawarescheduler.RouterHostedByHostingDevice(<EOL>router_id=router_id, hosting_device_id=hosting_device_id)<EOL><DEDENT>rt_info = self.validate_hosting_device_router_combination(<EOL>context, r_hd_binding_db, hosting_device_id)<EOL>result = self.schedule_router_on_hosting_device(<EOL>e_context, r_hd_binding_db, hosting_device_id,<EOL>rt_info['<STR_LIT>'])<EOL>if result:<EOL><INDENT>e_context.session.expire(r_hd_binding_db)<EOL>router = self.get_router(e_context, router_id)<EOL>self.add_type_and_hosting_device_info(<EOL>e_context, router, r_hd_binding_db, schedule=False)<EOL>l3_cfg_notifier = self.agent_notifiers.get(AGENT_TYPE_L3_CFG)<EOL>if l3_cfg_notifier:<EOL><INDENT>l3_cfg_notifier.router_added_to_hosting_device(context, router)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise routertypeawarescheduler.RouterSchedulingFailed(<EOL>router_id=router_id, hosting_device_id=hosting_device_id)<EOL><DEDENT>
Add a (non-hosted) router to a hosting device.