コード例 #1
0
    def test___init__(self, mocked_register):
        mock_conn = mock.MagicMock()
        with mock.patch.object(rpc.Connection, 'create_consumer',
                               new_callable=mock_conn):
            test_obj = agent.TrunkSkeleton()
            self.assertEqual(2, mocked_register.call_count)
            calls = [mock.call(test_obj.handle_trunks, resources.TRUNK),
                     mock.call(test_obj.handle_subports, resources.SUBPORT)]
            mocked_register.assert_has_calls(calls, any_order=True)

            # Test to see if the call to rpc.get_server has the correct
            # target and the correct endpoints
            topic = resources_rpc.resource_type_versioned_topic(
                resources.SUBPORT)
            subport_target = oslo_messaging.Target(
                topic=topic, server=cfg.CONF.host, fanout=True)
            topic = resources_rpc.resource_type_versioned_topic(
                resources.TRUNK)
            trunk_target = oslo_messaging.Target(
                topic=topic, server=cfg.CONF.host, fanout=True)
            calls = [mock.call(subport_target.topic, mock.ANY, fanout=True),
                     mock.call(trunk_target.topic, mock.ANY, fanout=True)]
            self.assertIn(calls[0], mock_conn().mock_calls)
            self.assertIn(calls[1], mock_conn().mock_calls)
            self.assertIn("ResourcesPushRpcCallback",
                          str(mock_conn().call_args_list))
コード例 #2
0
ファイル: test_agent.py プロジェクト: cubeek/neutron
    def test___init__(self, mocked_register):
        mock_conn = mock.MagicMock()
        with mock.patch.object(rpc.Connection, 'create_consumer',
                               new_callable=mock_conn):
            test_obj = agent.TrunkSkeleton()
            self.assertEqual(2, mocked_register.call_count)
            calls = [mock.call(test_obj.handle_trunks, resources.TRUNK),
                     mock.call(test_obj.handle_subports, resources.SUBPORT)]
            mocked_register.assert_has_calls(calls, any_order=True)

            # Test to see if the call to rpc.get_server has the correct
            # target and the correct endpoints
            topic = resources_rpc.resource_type_versioned_topic(
                resources.SUBPORT)
            subport_target = oslo_messaging.Target(
                topic=topic, server=cfg.CONF.host, fanout=True)
            topic = resources_rpc.resource_type_versioned_topic(
                resources.TRUNK)
            trunk_target = oslo_messaging.Target(
                topic=topic, server=cfg.CONF.host, fanout=True)
            calls = [mock.call(subport_target.topic, mock.ANY, fanout=True),
                     mock.call(trunk_target.topic, mock.ANY, fanout=True)]
            self.assertIn(calls[0], mock_conn().mock_calls)
            self.assertIn(calls[1], mock_conn().mock_calls)
            self.assertIn("ResourcesPushRpcCallback",
                          str(mock_conn().call_args_list))
コード例 #3
0
ファイル: test_agent.py プロジェクト: p0i0/openstack-neutron
    def test___init__(self, mocked_get_server, mocked_register):
        test_obj = agent.TrunkSkeleton()
        self.assertEqual(2, mocked_register.call_count)
        calls = [
            mock.call(test_obj.handle_trunks, resources.TRUNK),
            mock.call(test_obj.handle_subports, resources.SUBPORT)
        ]
        mocked_register.assert_has_calls(calls, any_order=True)

        # Test to see if the call to rpc.get_server has the correct
        # target and the correct endpoints
        topic = resources_rpc.resource_type_versioned_topic(resources.SUBPORT)
        subport_target = oslo_messaging.Target(topic=topic,
                                               server=cfg.CONF.host,
                                               fanout=True)
        topic = resources_rpc.resource_type_versioned_topic(resources.TRUNK)
        trunk_target = oslo_messaging.Target(topic=topic,
                                             server=cfg.CONF.host,
                                             fanout=True)
        calls = [
            mock.call(subport_target, mock.ANY),
            mock.call(trunk_target, mock.ANY)
        ]
        mocked_get_server.assert_has_calls(calls, any_order=True)
        self.assertIn("ResourcesPushRpcCallback",
                      str(mocked_get_server.call_args_list))
コード例 #4
0
ファイル: agent.py プロジェクト: zhunzhong/neutron
    def __init__(self):
        registry.register(self.handle_trunks, resources.TRUNK)
        registry.register(self.handle_subports, resources.SUBPORT)

        self._connection = n_rpc.Connection()
        endpoints = [resources_rpc.ResourcesPushRpcCallback()]
        topic = resources_rpc.resource_type_versioned_topic(resources.SUBPORT)
        self._connection.create_consumer(topic, endpoints, fanout=True)
        topic = resources_rpc.resource_type_versioned_topic(resources.TRUNK)
        self._connection.create_consumer(topic, endpoints, fanout=True)
        self._connection.consume_in_threads()
コード例 #5
0
ファイル: agent.py プロジェクト: igordcard/neutron
    def __init__(self):
        registry.register(self.handle_trunks, resources.TRUNK)
        registry.register(self.handle_subports, resources.SUBPORT)

        self._connection = n_rpc.Connection()
        endpoints = [resources_rpc.ResourcesPushRpcCallback()]
        topic = resources_rpc.resource_type_versioned_topic(resources.SUBPORT)
        self._connection.create_consumer(topic, endpoints, fanout=True)
        topic = resources_rpc.resource_type_versioned_topic(resources.TRUNK)
        self._connection.create_consumer(topic, endpoints, fanout=True)
        self._connection.consume_in_threads()
コード例 #6
0
 def _register_rpc_consumers(self, connection):
     endpoints = [resources_rpc.ResourcesPushRpcCallback()]
     for resource_type in self.SUPPORTED_RESOURCES:
         # we assume that neutron-server always broadcasts the latest
         # version known to the agent
         topic = resources_rpc.resource_type_versioned_topic(resource_type)
         connection.create_consumer(topic, endpoints, fanout=True)
コード例 #7
0
    def _register_rpc_consumers(self, connection):
        endpoints = [resources_rpc.ResourcesPushRpcCallback()]

        # Consume BaGPipeChainHop OVO RPC
        cons_registry.register(self.handle_sfc_chain_hops,
                               sfc_obj.BaGPipeChainHop.obj_name())
        topic_chain_hop = resources_rpc.resource_type_versioned_topic(
            sfc_obj.BaGPipeChainHop.obj_name())
        connection.create_consumer(topic_chain_hop, endpoints, fanout=True)

        # Consume BaGPipePortHops OVO RPC
        cons_registry.register(self.handle_sfc_port_hops,
                               sfc_obj.BaGPipePortHops.obj_name())
        topic_port_hops = resources_rpc.resource_type_versioned_topic(
            sfc_obj.BaGPipePortHops.obj_name())
        connection.create_consumer(topic_port_hops, endpoints, fanout=True)
コード例 #8
0
ファイル: qos.py プロジェクト: sckevmit/neutron
 def _register_rpc_consumers(self, connection):
     endpoints = [resources_rpc.ResourcesPushRpcCallback()]
     for resource_type in self.SUPPORTED_RESOURCES:
         # we assume that neutron-server always broadcasts the latest
         # version known to the agent
         topic = resources_rpc.resource_type_versioned_topic(resource_type)
         connection.create_consumer(topic, endpoints, fanout=True)
コード例 #9
0
ファイル: ndp_proxy.py プロジェクト: stackhpc/neutron
 def _register_rpc_consumers(self):
     registry.register(self._handle_notification, resources.NDPPROXY)
     self._connection = n_rpc.Connection()
     endpoints = [resources_rpc.ResourcesPushRpcCallback()]
     topic = resources_rpc.resource_type_versioned_topic(
         resources.NDPPROXY)
     self._connection.create_consumer(topic, endpoints, fanout=True)
     self._connection.consume_in_threads()
コード例 #10
0
 def test_resource_type_versioned_topic(self, validate_mock):
     obj_name = FakeResource.obj_name()
     expected = topics.RESOURCE_TOPIC_PATTERN % {
         'resource_type': 'FakeResource', 'version': '1.0'}
     with mock.patch.object(resources_rpc.resources, 'get_resource_cls',
             return_value=FakeResource):
         observed = resources_rpc.resource_type_versioned_topic(obj_name)
     self.assertEqual(expected, observed)
コード例 #11
0
 def test_resource_type_versioned_topic(self, validate_mock):
     obj_name = FakeResource.obj_name()
     expected = topics.RESOURCE_TOPIC_PATTERN % {
         'resource_type': 'FakeResource', 'version': '1.0'}
     with mock.patch.object(resources_rpc.resources, 'get_resource_cls',
             return_value=FakeResource):
         observed = resources_rpc.resource_type_versioned_topic(obj_name)
     self.assertEqual(expected, observed)
コード例 #12
0
 def _init_rpc_listeners(self):
     endpoints = [resources_rpc.ResourcesPushRpcCallback()]
     self._connection = n_rpc.create_connection()
     for rtype in self.rcache.resource_types:
         registry_rpc.register(self.resource_change_handler, rtype)
         topic = resources_rpc.resource_type_versioned_topic(rtype)
         self._connection.create_consumer(topic, endpoints, fanout=True)
     self._connection.consume_in_threads()
コード例 #13
0
ファイル: resource_cache.py プロジェクト: cubeek/neutron
 def _init_rpc_listeners(self):
     endpoints = [resources_rpc.ResourcesPushRpcCallback()]
     self._connection = n_rpc.Connection()
     for rtype in self.rcache.resource_types:
         registry_rpc.register(self.resource_change_handler, rtype)
         topic = resources_rpc.resource_type_versioned_topic(rtype)
         self._connection.create_consumer(topic, endpoints, fanout=True)
     self._connection.consume_in_threads()
コード例 #14
0
ファイル: test_qos.py プロジェクト: neoareslinux/neutron
 def test_initialize_subscribed_to_rpc(self, rpc_mock, subscribe_mock):
     self.qos_ext.initialize(self.connection, constants.EXTENSION_DRIVER_TYPE)
     self.connection.create_consumer.assert_has_calls(
         [
             mock.call(resources_rpc.resource_type_versioned_topic(resource_type), [rpc_mock()], fanout=True)
             for resource_type in self.qos_ext.SUPPORTED_RESOURCES
         ]
     )
     subscribe_mock.assert_called_with(mock.ANY, resources.QOS_POLICY)
コード例 #15
0
ファイル: base.py プロジェクト: cubeek/neutron
    def _register_rpc_consumers(self):
        registry.register(self._handle_notification, resources.QOS_POLICY)

        self._connection = n_rpc.Connection()
        endpoints = [resources_rpc.ResourcesPushRpcCallback()]
        topic = resources_rpc.resource_type_versioned_topic(
            resources.QOS_POLICY)
        self._connection.create_consumer(topic, endpoints, fanout=True)
        self._connection.consume_in_threads()
コード例 #16
0
    def _setup_rpc(self, connection):
        self.rpc_pull_api = resources_rpc.ResourcesPullRpcApi()

        rpc_registry.register(self.handle_notification_net_assocs,
                              objects.BGPVPNNetAssociation.obj_name())
        rpc_registry.register(self.handle_notification_router_assocs,
                              objects.BGPVPNRouterAssociation.obj_name())
        rpc_registry.register(self.handle_notification_port_assocs,
                              objects.BGPVPNPortAssociation.obj_name())
        endpoints = [resources_rpc.ResourcesPushRpcCallback()]
        topic_net_assoc = resources_rpc.resource_type_versioned_topic(
            objects.BGPVPNNetAssociation.obj_name())
        topic_router_assoc = resources_rpc.resource_type_versioned_topic(
            objects.BGPVPNRouterAssociation.obj_name())
        topic_port_assoc = resources_rpc.resource_type_versioned_topic(
            objects.BGPVPNPortAssociation.obj_name())
        connection.create_consumer(topic_net_assoc, endpoints, fanout=True)
        connection.create_consumer(topic_router_assoc, endpoints, fanout=True)
        connection.create_consumer(topic_port_assoc, endpoints, fanout=True)
コード例 #17
0
ファイル: base.py プロジェクト: rolaya/neutron
    def _register_rpc_consumers(self):
        LOG.info('%s(): caller(): %s', log_utils.get_fname(1), log_utils.get_fname(2))
        registry.register(self._handle_notification, resources.QOS_POLICY)

        self._connection = n_rpc.Connection()
        endpoints = [resources_rpc.ResourcesPushRpcCallback()]
        topic = resources_rpc.resource_type_versioned_topic(
            resources.QOS_POLICY)
        self._connection.create_consumer(topic, endpoints, fanout=True)
        self._connection.consume_in_threads()
コード例 #18
0
ファイル: resource_cache.py プロジェクト: rolaya/neutron
 def _init_rpc_listeners(self):
     LOG.info('%s(): caller(): %s', log_utils.get_fname(1),
              log_utils.get_fname(2))
     endpoints = [resources_rpc.ResourcesPushRpcCallback()]
     self._connection = n_rpc.Connection()
     for rtype in self.rcache.resource_types:
         registry_rpc.register(self.resource_change_handler, rtype)
         topic = resources_rpc.resource_type_versioned_topic(rtype)
         self._connection.create_consumer(topic, endpoints, fanout=True)
     self._connection.consume_in_threads()
コード例 #19
0
 def _register_rpc_consumers(self, connection):
     """Allows an extension to receive notifications of updates made to
        items of interest.
     """
     endpoints = [resources_rpc.ResourcesPushRpcCallback()]
     for resource_type in self.SUPPORTED_RESOURCE_TYPES:
         # We assume that the neutron server always broadcasts the latest
         # version known to the agent
         registry.register(self._handle_notification, resource_type)
         topic = resources_rpc.resource_type_versioned_topic(resource_type)
         connection.create_consumer(topic, endpoints, fanout=True)
コード例 #20
0
ファイル: test_agent.py プロジェクト: AradhanaSingh/neutron
    def test___init__(self, mocked_get_server, mocked_register):
        test_obj = agent.TrunkSkeleton()
        self.assertEqual(2, mocked_register.call_count)
        calls = [mock.call(test_obj.handle_trunks, resources.TRUNK),
                 mock.call(test_obj.handle_subports, resources.SUBPORT)]
        mocked_register.assert_has_calls(calls, any_order=True)

        # Test to see if the call to rpc.get_server has the correct
        # target and the correct endpoints
        topic = resources_rpc.resource_type_versioned_topic(resources.SUBPORT)
        subport_target = oslo_messaging.Target(
            topic=topic, server=cfg.CONF.host, fanout=True)
        topic = resources_rpc.resource_type_versioned_topic(resources.TRUNK)
        trunk_target = oslo_messaging.Target(
            topic=topic, server=cfg.CONF.host, fanout=True)
        calls = [mock.call(subport_target, mock.ANY),
                 mock.call(trunk_target, mock.ANY)]
        mocked_get_server.assert_has_calls(calls, any_order=True)
        self.assertIn("ResourcesPushRpcCallback",
                      str(mocked_get_server.call_args_list))
コード例 #21
0
 def test_initialize_subscribed_to_rpc(self, rpc_mock, subscribe_mock):
     self.agent_ext.initialize(self.connection,
                               constants.EXTENSION_DRIVER_TYPE)
     self.connection.create_consumer.assert_has_calls([
         mock.call(
             resources_rpc.resource_type_versioned_topic(resource_type),
             [rpc_mock()],
             fanout=True)
         for resource_type in self.agent_ext.SUPPORTED_RESOURCE_TYPES
     ])
     subscribe_mock.assert_called_with(mock.ANY, resources.LOGGING_RESOURCE)
コード例 #22
0
ファイル: qos.py プロジェクト: noironetworks/neutron
 def _register_rpc_consumers(self, connection):
     """Allows an extension to receive notifications of updates made to
        items of interest.
     """
     endpoints = [resources_rpc.ResourcesPushRpcCallback()]
     for resource_type in self.SUPPORTED_RESOURCE_TYPES:
         # We assume that the neutron server always broadcasts the latest
         # version known to the agent
         registry.register(self._handle_notification, resource_type)
         topic = resources_rpc.resource_type_versioned_topic(resource_type)
         connection.create_consumer(topic, endpoints, fanout=True)
コード例 #23
0
ファイル: test_ndp_proxy.py プロジェクト: stackhpc/neutron
 def test_initialize_subscribed_to_rpc(self, rpc_mock, subscribe_mock):
     call_to_patch = 'neutron_lib.rpc.Connection'
     with mock.patch(call_to_patch,
                     return_value=self.connection) as create_connection:
         self.np_ext.initialize(self.connection, lib_const.L3_AGENT_MODE)
         create_connection.assert_has_calls([mock.call()])
         self.connection.create_consumer.assert_has_calls([
             mock.call(resources_rpc.resource_type_versioned_topic(
                 resources.NDPPROXY), [rpc_mock()],
                       fanout=True)
         ])
         subscribe_mock.assert_called_with(mock.ANY, resources.NDPPROXY)
コード例 #24
0
    def _register_port_notification(self, connection):
        """Allows an extension to receive notifications of updates made to
           items of interest.
        """
        #endpoints = [resources_rpc.ResourcesPushRpcCallback()]
        endpoints = [taas_plugin_callbacks.TaasCallbacks()]

        # We assume that the neutron server always broadcasts the latest
        # version known to the agent
        registry.register(self._handle_port_notification, resources.PORT)
        topic = resources_rpc.resource_type_versioned_topic(resources.PORT)
        connection.create_consumer(topic, endpoints, fanout=True)
コード例 #25
0
 def test_initialize_subscribed_to_rpc(self, rpc_mock, subscribe_mock):
     with mock.patch.object(
             n_rpc, 'Connection',
             return_value=self.connection) as create_connection:
         self.fip_qos_ext.initialize(self.connection,
                                     lib_const.L3_AGENT_MODE)
         create_connection.assert_has_calls([mock.call()])
         self.connection.create_consumer.assert_has_calls([
             mock.call(resources_rpc.resource_type_versioned_topic(
                 resources.QOS_POLICY), [rpc_mock()],
                       fanout=True)
         ])
         subscribe_mock.assert_called_with(mock.ANY, resources.QOS_POLICY)
コード例 #26
0
ファイル: test_fip.py プロジェクト: openstack/neutron
 def test_initialize_subscribed_to_rpc(self, rpc_mock, subscribe_mock):
     with mock.patch.object(n_rpc, 'Connection',
                     return_value=self.connection) as create_connection:
         self.fip_qos_ext.initialize(
             self.connection, lib_const.L3_AGENT_MODE)
         create_connection.assert_has_calls([mock.call()])
         self.connection.create_consumer.assert_has_calls(
             [mock.call(
                  resources_rpc.resource_type_versioned_topic(
                      resources.QOS_POLICY),
                  [rpc_mock()],
                  fanout=True)]
         )
         subscribe_mock.assert_called_with(mock.ANY, resources.QOS_POLICY)
コード例 #27
0
 def test_initialize_subscribed_to_rpc(self, rpc_mock, subscribe_mock):
     call_to_patch = 'neutron.common.rpc.Connection'
     with mock.patch(call_to_patch,
                     return_value=self.connection) as create_connection:
         self.fip_pf_ext.initialize(
             self.connection, lib_const.L3_AGENT_MODE)
         create_connection.assert_has_calls([mock.call()])
         self.connection.create_consumer.assert_has_calls(
             [mock.call(
                  resources_rpc.resource_type_versioned_topic(
                      resources.PORTFORWARDING),
                  [rpc_mock()],
                  fanout=True)]
         )
         subscribe_mock.assert_called_with(
             mock.ANY, resources.PORTFORWARDING)
コード例 #28
0
ファイル: log_extension.py プロジェクト: cubeek/neutron
 def _register_rpc_consumers(self, connection):
     endpoints = [resources_rpc.ResourcesPushRpcCallback()]
     for resource_type in self.SUPPORTED_RESOURCE_TYPES:
         registry.register(self._handle_notification, resource_type)
         topic = resources_rpc.resource_type_versioned_topic(resource_type)
         connection.create_consumer(topic, endpoints, fanout=True)
コード例 #29
0
ファイル: log_extension.py プロジェクト: zxt2012bs/neutron
 def _register_rpc_consumers(self, connection):
     endpoints = [resources_rpc.ResourcesPushRpcCallback()]
     for resource_type in self.SUPPORTED_RESOURCE_TYPES:
         registry.register(self._handle_notification, resource_type)
         topic = resources_rpc.resource_type_versioned_topic(resource_type)
         connection.create_consumer(topic, endpoints, fanout=True)