Esempio n. 1
0
def api_factory(context):
    global _connection
    if _connection is None:
        _connection = connection.Connection(
            idl=n_connection.idl_factory(),
            timeout=cfg.CONF.OVS.ovsdb_timeout)
    return NeutronOvsdbIdl(_connection)
Esempio n. 2
0
def api_factory(context):
    global _connection
    if _connection is None:
        try:
            _connection = connection.Connection(
                idl=connection.idl_factory(),
                timeout=cfg.CONF.ovs_vsctl_timeout)
        except TypeError:
            _connection = connection.Connection(
                idl_factory=connection.idl_factory,
                timeout=cfg.CONF.ovs_vsctl_timeout)
    return NeutronOvsdbIdl(_connection)
Esempio n. 3
0
def api_factory(context):
    global _connection
    if _connection is None:
        try:
            _connection = connection.Connection(
                idl=n_connection.idl_factory(),
                timeout=cfg.CONF.ovs_vsctl_timeout)
        except TypeError:
            #pylint: disable=unexpected-keyword-arg,no-value-for-parameter
            _connection = connection.Connection(
                idl_factory=n_connection.idl_factory,  # noqa
                timeout=cfg.CONF.ovs_vsctl_timeout)
    return NeutronOvsdbIdl(_connection)
Esempio n. 4
0
def api_factory(context):
    global _connection
    if _connection is None:
        try:
            _connection = connection.Connection(
                idl=n_connection.idl_factory(),
                timeout=cfg.CONF.OVS.ovsdb_timeout)
        except TypeError:
            #pylint: disable=unexpected-keyword-arg,no-value-for-parameter
            _connection = connection.Connection(
                idl_factory=n_connection.idl_factory,  # noqa
                timeout=cfg.CONF.OVS.ovsdb_timeout)
    return NeutronOvsdbIdl(_connection)
Esempio n. 5
0
    def test_ssl_connection(self, mock_cfg, mock_os, mock_get_schema_helper,
                            mock_idl, mock_threading, mock_stream):
        mock_os.path.isfile.return_value = True
        mock_cfg.CONF.OVS.ovsdb_connection = 'ssl:127.0.0.1:6640'
        mock_cfg.CONF.OVS.ssl_key_file = SSL_KEY_FILE
        mock_cfg.CONF.OVS.ssl_cert_file = SSL_CERT_FILE
        mock_cfg.CONF.OVS.ssl_ca_cert_file = SSL_CA_FILE

        conn = connection.Connection(idl=native_conn.idl_factory(), timeout=1)
        conn.start()
        mock_stream.ssl_set_private_key_file.assert_called_once_with(
            SSL_KEY_FILE)
        mock_stream.ssl_set_certificate_file.assert_called_once_with(
            SSL_CERT_FILE)
        mock_stream.ssl_set_ca_cert_file.assert_called_once_with(SSL_CA_FILE)
Esempio n. 6
0
 def test_do_get_schema_helper_retry(self, mock_get_schema_helper,
                                     mock_enable_conn, mock_idl,
                                     mock_wait_for_change, mock_threading):
     mock_helper = mock.Mock()
     # raise until 3rd retry attempt
     mock_get_schema_helper.side_effect = [
         Exception(), Exception(), mock_helper
     ]
     try:
         conn = connection.Connection(idl_factory=native_conn.idl_factory,
                                      timeout=mock.Mock())
     except TypeError:
         conn = connection.Connection(idl=native_conn.idl_factory(),
                                      timeout=mock.Mock())
     conn.start()
     self.assertEqual(3, len(mock_get_schema_helper.mock_calls))
     mock_helper.register_all.assert_called_once_with()
Esempio n. 7
0
 def test_do_get_schema_helper_retry(self, mock_get_schema_helper,
                                     mock_enable_conn,
                                     mock_idl,
                                     mock_wait_for_change,
                                     mock_threading):
     mock_helper = mock.Mock()
     # raise until 3rd retry attempt
     mock_get_schema_helper.side_effect = [Exception(), Exception(),
                                           mock_helper]
     try:
         conn = connection.Connection(idl_factory=native_conn.idl_factory,
                                      timeout=mock.Mock())
     except TypeError:
         conn = connection.Connection(idl=native_conn.idl_factory(),
                                      timeout=mock.Mock())
     conn.start()
     self.assertEqual(3, len(mock_get_schema_helper.mock_calls))
     mock_helper.register_all.assert_called_once_with()
Esempio n. 8
0
    def test_ssl_connection(self, mock_cfg, mock_os, mock_get_schema_helper,
                            mock_idl, mock_threading, mock_stream):
        mock_os.path.isfile.return_value = True
        mock_cfg.CONF.OVS.ovsdb_connection = 'ssl:127.0.0.1:6640'
        mock_cfg.CONF.OVS.ssl_key_file = SSL_KEY_FILE
        mock_cfg.CONF.OVS.ssl_cert_file = SSL_CERT_FILE
        mock_cfg.CONF.OVS.ssl_ca_cert_file = SSL_CA_FILE

        conn = connection.Connection(idl=native_conn.idl_factory(),
                                     timeout=1)
        conn.start()
        mock_stream.ssl_set_private_key_file.assert_called_once_with(
            SSL_KEY_FILE
        )
        mock_stream.ssl_set_certificate_file.assert_called_once_with(
            SSL_CERT_FILE
        )
        mock_stream.ssl_set_ca_cert_file.assert_called_once_with(
            SSL_CA_FILE
        )
Esempio n. 9
0
def api_factory(context):
    global _connection
    if _connection is None:
        _connection = connection.Connection(idl=n_connection.idl_factory(),
                                            timeout=cfg.CONF.OVS.ovsdb_timeout)
    return NeutronOvsdbIdl(_connection)