Example #1
0
def parse_args(argv, default_config_files=None):
    rpc.set_defaults(control_exchange='ironic')
    cfg.CONF(argv[1:],
             project='ironic',
             version=version.version_info.release_string(),
             default_config_files=default_config_files)
    rpc.init(cfg.CONF)
Example #2
0
def parse_args(argv, default_config_files=None):
    rpc.set_defaults(control_exchange='ironic')
    cfg.CONF(argv[1:],
             project='ironic',
             version=version.version_info.release_string(),
             default_config_files=default_config_files)
    rpc.init(cfg.CONF)
Example #3
0
 def test_init_globals(self, mock_get_transport, mock_get_notification,
                       mock_serializer, mock_notifier):
     rpc.TRANSPORT = None
     rpc.NOTIFICATION_TRANSPORT = None
     rpc.NOTIFIER = None
     rpc.init(CONF)
     self.assertEqual(mock_get_transport.return_value, rpc.TRANSPORT)
     self.assertEqual(mock_get_notification.return_value,
                      rpc.NOTIFICATION_TRANSPORT)
     self.assertTrue(mock_serializer.called)
     self.assertEqual(mock_notifier.return_value, rpc.NOTIFIER)
Example #4
0
 def test_init_globals(self, mock_get_transport, mock_get_notification,
                       mock_serializer, mock_notifier):
     rpc.TRANSPORT = None
     rpc.NOTIFICATION_TRANSPORT = None
     rpc.NOTIFIER = None
     rpc.init(CONF)
     self.assertEqual(mock_get_transport.return_value, rpc.TRANSPORT)
     self.assertEqual(mock_get_notification.return_value,
                      rpc.NOTIFICATION_TRANSPORT)
     self.assertTrue(mock_serializer.called)
     self.assertEqual(mock_notifier.return_value, rpc.NOTIFIER)
Example #5
0
    def _test_init_globals(
            self,
            notifications_enabled,
            mock_get_rpc_transport,
            mock_get_notification,
            mock_json_serializer,
            mock_notifier,
            versioned_notifications_topics=['ironic_versioned_notifications']):

        rpc.TRANSPORT = None
        rpc.NOTIFICATION_TRANSPORT = None
        rpc.SENSORS_NOTIFIER = None
        rpc.VERSIONED_NOTIFIER = None
        mock_request_serializer = mock.Mock()
        mock_request_serializer.return_value = mock.Mock()
        rpc.RequestContextSerializer = mock_request_serializer

        # Make sure that two separate Notifiers are instantiated: one for the
        # regular RPC transport, one for the notification transport
        mock_notifiers = [mock.Mock()] * 2
        mock_notifier.side_effect = mock_notifiers

        rpc.init(CONF)

        self.assertEqual(mock_get_rpc_transport.return_value, rpc.TRANSPORT)
        self.assertEqual(mock_get_notification.return_value,
                         rpc.NOTIFICATION_TRANSPORT)
        self.assertTrue(mock_json_serializer.called)

        if not notifications_enabled:
            notifier_calls = [
                mock.call(rpc.NOTIFICATION_TRANSPORT,
                          serializer=mock_request_serializer.return_value),
                mock.call(rpc.NOTIFICATION_TRANSPORT,
                          serializer=mock_request_serializer.return_value,
                          driver='noop')
            ]
        else:
            notifier_calls = [
                mock.call(rpc.NOTIFICATION_TRANSPORT,
                          serializer=mock_request_serializer.return_value),
                mock.call(rpc.NOTIFICATION_TRANSPORT,
                          serializer=mock_request_serializer.return_value,
                          topics=versioned_notifications_topics)
            ]

        mock_notifier.assert_has_calls(notifier_calls)

        self.assertEqual(mock_notifiers[0], rpc.SENSORS_NOTIFIER)
        self.assertEqual(mock_notifiers[1], rpc.VERSIONED_NOTIFIER)
Example #6
0
    def _test_init_globals(
            self, notifications_enabled, mock_get_rpc_transport,
            mock_get_notification, mock_json_serializer, mock_notifier,
            versioned_notifications_topics=['ironic_versioned_notifications']):

        rpc.TRANSPORT = None
        rpc.NOTIFICATION_TRANSPORT = None
        rpc.SENSORS_NOTIFIER = None
        rpc.VERSIONED_NOTIFIER = None
        mock_request_serializer = mock.Mock()
        mock_request_serializer.return_value = mock.Mock()
        rpc.RequestContextSerializer = mock_request_serializer

        # Make sure that two separate Notifiers are instantiated: one for the
        # regular RPC transport, one for the notification transport
        mock_notifiers = [mock.Mock()] * 2
        mock_notifier.side_effect = mock_notifiers

        rpc.init(CONF)

        self.assertEqual(mock_get_rpc_transport.return_value, rpc.TRANSPORT)
        self.assertEqual(mock_get_notification.return_value,
                         rpc.NOTIFICATION_TRANSPORT)
        self.assertTrue(mock_json_serializer.called)

        if not notifications_enabled:
            notifier_calls = [
                mock.call(
                    rpc.NOTIFICATION_TRANSPORT,
                    serializer=mock_request_serializer.return_value),
                mock.call(
                    rpc.NOTIFICATION_TRANSPORT,
                    serializer=mock_request_serializer.return_value,
                    driver='noop')
            ]
        else:
            notifier_calls = [
                mock.call(
                    rpc.NOTIFICATION_TRANSPORT,
                    serializer=mock_request_serializer.return_value),
                mock.call(
                    rpc.NOTIFICATION_TRANSPORT,
                    serializer=mock_request_serializer.return_value,
                    topics=versioned_notifications_topics)
            ]

        mock_notifier.assert_has_calls(notifier_calls)

        self.assertEqual(mock_notifiers[0], rpc.SENSORS_NOTIFIER)
        self.assertEqual(mock_notifiers[1], rpc.VERSIONED_NOTIFIER)