def test_l2agent_rpc_to_bgpvpn_rpc(self): # # Test that really simulate the ML2 codepath that # generate the registry events. ml2_rpc_callbacks = ml2_rpc.RpcCallbacks(mock.Mock(), mock.Mock()) n_dict = { "name": "netfoo", "tenant_id": self._tenant_id, "admin_state_up": True, "shared": False } net = self.plugin.create_network(self.ctxt, {'network': n_dict}) subnet_dict = { 'name': 'test_subnet', 'tenant_id': self._tenant_id, 'ip_version': 4, 'cidr': '10.0.0.0/24', 'allocation_pools': [{ 'start': '10.0.0.2', 'end': '10.0.0.254' }], 'enable_dhcp': False, 'dns_nameservers': [], 'host_routes': [], 'network_id': net['id'] } self.plugin.create_subnet(self.ctxt, {'subnet': subnet_dict}) p_dict = { 'network_id': net['id'], 'tenant_id': self._tenant_id, 'name': 'fooport', "admin_state_up": True, "device_id": "tapfoo", "device_owner": "not_me", "mac_address": "de:ad:00:00:be:ef", "fixed_ips": [], "binding:host_id": helpers.HOST, } port = self.plugin.create_port(self.ctxt, {'port': p_dict}) ml2_rpc_callbacks.update_device_up(self.ctxt, host=helpers.HOST, agent_id='fooagent', device="de:ad:00:00:be:ef") self.mock_attach_rpc.assert_called_once_with( mock.ANY, self._build_expected_return_active(port), helpers.HOST) ml2_rpc_callbacks.update_device_down(self.ctxt, host=helpers.HOST, agent_id='fooagent', device="de:ad:00:00:be:ef") self.mock_detach_rpc.assert_called_once_with( mock.ANY, self._build_expected_return_down(port), helpers.HOST) self.mock_detach_rpc.reset_mock() self.plugin.delete_port(self.ctxt, port['id']) self.mock_detach_rpc.assert_called_once_with( mock.ANY, self._build_expected_return_down(port), helpers.HOST)
def setUp(self): super(TestL2PopulationRpcTestCase, self).setUp() self.adminContext = context.get_admin_context() self.type_manager = managers.TypeManager() self.notifier = rpc.AgentNotifierApi(topics.AGENT) self.callbacks = rpc.RpcCallbacks(self.notifier, self.type_manager) net_arg = {pnet.NETWORK_TYPE: 'vxlan', pnet.SEGMENTATION_ID: '1'} self._network = self._make_network(self.fmt, 'net1', True, arg_list=( pnet.NETWORK_TYPE, pnet.SEGMENTATION_ID, ), **net_arg) net_arg = { pnet.NETWORK_TYPE: 'vlan', pnet.PHYSICAL_NETWORK: 'physnet1', pnet.SEGMENTATION_ID: '2' } self._network2 = self._make_network(self.fmt, 'net2', True, arg_list=( pnet.NETWORK_TYPE, pnet.PHYSICAL_NETWORK, pnet.SEGMENTATION_ID, ), **net_arg) net_arg = {pnet.NETWORK_TYPE: 'flat', pnet.PHYSICAL_NETWORK: 'noagent'} self._network3 = self._make_network(self.fmt, 'net3', True, arg_list=( pnet.NETWORK_TYPE, pnet.PHYSICAL_NETWORK, ), **net_arg) notifier_patch = mock.patch(NOTIFIER) notifier_patch.start() self.fanout_topic = topics.get_topic_name(topics.AGENT, topics.L2POPULATION, topics.UPDATE) fanout = ('neutron.plugins.ml2.drivers.l2pop.rpc.' 'L2populationAgentNotifyAPI._notification_fanout') fanout_patch = mock.patch(fanout) self.mock_fanout = fanout_patch.start() cast = ('neutron.plugins.ml2.drivers.l2pop.rpc.' 'L2populationAgentNotifyAPI._notification_host') cast_patch = mock.patch(cast) self.mock_cast = cast_patch.start() uptime = ('neutron.plugins.ml2.drivers.l2pop.db.get_agent_uptime') uptime_patch = mock.patch(uptime, return_value=190) uptime_patch.start()
def setUp(self): super(OVSvAppServerRpcCallbackTest, self).setUp() self.ovsvapp_callbacks = ovsvapp_rpc.OVSvAppServerRpcCallback( mock.Mock()) self.callbacks = plugin_rpc.RpcCallbacks(mock.Mock()) self.plugin = self.manager.get_plugin()
def _construct_rpc_stuff(self): self.notifier = rpc.AgentNotifierApi(neutron_topics.AGENT) self.type_manager = managers.TypeManager() self.tunnel_rpc_obj = rpc.RpcCallbacks(self.notifier, self.type_manager)