def test_cfg_agent_registration_triggers_autoscheduling(self):
     with self.router() as router:
         r_id = router['router']['id']
         routers_1 = self.plugin.get_sync_data_ext(self.adminContext,
                                                   [r_id])
         self.assertEqual(1, len(routers_1))
         hosting_device_1 = routers_1[0]['hosting_device']
         self.assertIsNotNone(hosting_device_1)
         self.assertIsNone(hosting_device_1['cfg_agent_id'])
         cfg_dh_rpc = devices_cfgagent_rpc_cb.DeviceCfgRpcCallbackMixin()
         cfg_dh_rpc._l3plugin = self.plugin
         self._register_cfg_agent()
         res = cfg_dh_rpc.register_for_duty(self.adminContext, host=HOST)
         self.assertTrue(res)
         routers_2 = self.plugin.get_sync_data_ext(self.adminContext,
                                                   [r_id])
         self.assertEqual(1, len(routers_2))
         hosting_device_2 = routers_2[0]['hosting_device']
         self.assertIsNotNone(hosting_device_2)
         self.assertIsNotNone(hosting_device_2['cfg_agent_id'])
 def test_dead_device_is_removed(self):
     cfg_dh_rpc = devices_cfgagent_rpc_cb.DeviceCfgRpcCallbackMixin()
     cfg_dh_rpc._l3plugin = self.plugin
     with mock.patch(
             'neutron.plugins.cisco.l3.rpc.l3_router_rpc_joint_agent_api.'
             'L3RouterJointAgentNotifyAPI.hosting_devices_removed') as (
                 mock_notify):
         with self.router() as router:
             r_id = router['router']['id']
             routers_1 = self.plugin.get_sync_data_ext(
                 self.adminContext, [r_id])
             self.assertEqual(1, len(routers_1))
             hosting_device_1 = routers_1[0]['hosting_device']
             self.assertIsNotNone(hosting_device_1)
             cfg_dh_rpc.report_non_responding_hosting_devices(
                 self.adminContext,
                 host=None,
                 hosting_device_ids=[hosting_device_1['id']])
         self.assertEqual(1, mock_notify.call_count)
         mock_notify.assert_called_with(
             mock.ANY, {hosting_device_1['id']: {
                            'routers': [r_id]
                        }}, False, mock.ANY)