Ejemplo n.º 1
0
    def test___init__(self,):
        test_obj = backend.ServerSideRpcBackend()

        calls = [mock.call(
                    *tools.get_subscribe_args(
                        test_obj.process_event,
                        resources.TRUNK,
                        events.AFTER_CREATE)),
                 mock.call(
                    *tools.get_subscribe_args(
                        test_obj.process_event,
                        resources.TRUNK,
                        events.AFTER_DELETE)),
                 mock.call(
                    *tools.get_subscribe_args(
                        test_obj.process_event,
                        resources.SUBPORTS,
                        events.AFTER_CREATE)),
                 mock.call(
                    *tools.get_subscribe_args(
                        test_obj.process_event,
                        resources.SUBPORTS,
                        events.AFTER_DELETE))
                 ]
        self._mgr.subscribe.assert_has_calls(calls, any_order=True)
Ejemplo n.º 2
0
    def test___init__(self, ):
        test_obj = backend.ServerSideRpcBackend()

        calls = [
            mock.call(test_obj.process_event, trunk_consts.TRUNK,
                      events.AFTER_CREATE),
            mock.call(test_obj.process_event, trunk_consts.TRUNK,
                      events.AFTER_DELETE),
            mock.call(test_obj.process_event, trunk_consts.SUBPORTS,
                      events.AFTER_CREATE),
            mock.call(test_obj.process_event, trunk_consts.SUBPORTS,
                      events.AFTER_DELETE)
        ]
        self._mgr.subscribe.assert_has_calls(calls, any_order=True)
Ejemplo n.º 3
0
    def test_process_event(self):
        test_obj = backend.ServerSideRpcBackend()
        test_obj._stub = mock_stub = mock.Mock()
        trunk_plugin = mock.Mock()

        test_obj.process_event(
            trunk_consts.TRUNK, events.AFTER_CREATE, trunk_plugin,
            callbacks.TrunkPayload("context",
                                   "id",
                                   current_trunk="current_trunk"))
        test_obj.process_event(
            trunk_consts.TRUNK, events.AFTER_DELETE, trunk_plugin,
            callbacks.TrunkPayload("context",
                                   "id",
                                   original_trunk="original_trunk"))

        calls = [
            mock.call.trunk_created("context", "current_trunk"),
            mock.call.trunk_deleted("context", "original_trunk")
        ]
        mock_stub.assert_has_calls(calls, any_order=False)
Ejemplo n.º 4
0
    def test_process_event(self):
        test_obj = backend.ServerSideRpcBackend()
        test_obj._stub = mock_stub = mock.Mock()
        trunk_plugin = mock.Mock()

        test_obj.process_trunk_payload_event(
            resources.TRUNK, events.AFTER_CREATE, trunk_plugin,
            events.DBEventPayload("context",
                                  resource_id="id",
                                  states=("current_trunk", )))

        test_obj.process_trunk_payload_event(
            resources.TRUNK, events.AFTER_DELETE, trunk_plugin,
            events.DBEventPayload("context",
                                  resource_id="id",
                                  states=("original_trunk", )))

        calls = [
            mock.call.trunk_created("context", "current_trunk"),
            mock.call.trunk_deleted("context", "original_trunk")
        ]
        mock_stub.assert_has_calls(calls, any_order=False)
Ejemplo n.º 5
0
    def register(self, resource, event, trigger, **kwargs):
        """Register the trunk driver.

        This method should be overridden so that the driver can subscribe
        to the required trunk events. The driver should also advertise
        itself as supported driver by calling register_driver() on the
        TrunkPlugin otherwise the trunk plugin may fail to start if no
        compatible configuration is found.

        External drivers must subscribe to the AFTER_INIT event for the
        trunk plugin so that they can integrate without an explicit
        register() method invocation.

        :param resource: neutron.services.trunk.constants.TRUNK_PLUGIN
        :param event: neutron.callbacks.events.AFTER_INIT
        :param trigger: neutron.service.trunks.plugin.TrunkPlugin
        """

        trigger.register_driver(self)
        # Set up the server-side RPC backend if the driver is loaded,
        # it is agent based, and the RPC backend is not already initialized.
        if self.is_loaded and self.agent_type and not trigger.is_rpc_enabled():
            trigger.set_rpc_backend(backend.ServerSideRpcBackend())