Fix pep8 new warnings

A recent change in pep/pycodingchecks introduced new warnings as part of
the pep8 target that causes pep8 to fail now.

This patch fixes code that issued warnings W503,E731,E266,E402

Change-Id: Ie5ca6c6fe70b3f96809f0624abe6738db2a89c6d
stable/rocky
Adit Sarfaty 5 years ago
parent 30a010d0e2
commit fd231767ca
  1. 4
      networking_l2gw/db/l2gateway/ovsdb/lib.py
  2. 6
      networking_l2gw/db/migration/alembic_migrations/versions/42438454c556_l2gateway_models.py
  3. 6
      networking_l2gw/db/migration/alembic_migrations/versions/54c9c8fe22bf_db_models_for_ovsdb_hardware_vtep_schema.py
  4. 9
      networking_l2gw/db/migration/alembic_migrations/versions/newton/contract/2f533f7705dd_rename_tenant_to_project.py
  5. 7
      networking_l2gw/db/migration/alembic_migrations/versions/queens/contract/0fb45e525aa9_add_standard_attribute_id_for_l2gw.py
  6. 7
      networking_l2gw/db/migration/alembic_migrations/versions/queens/expand/8d7d772eafcf_add_standard_attribute_id_for_l2gw.py
  7. 4
      networking_l2gw/services/l2gateway/agent/ovsdb/manager.py
  8. 7
      networking_l2gw/services/l2gateway/agent_scheduler.py
  9. 57
      networking_l2gw/tests/unit/services/l2gateway/agent/ovsdb/test_base_connection.py
  10. 80
      networking_l2gw/tests/unit/services/l2gateway/agent/ovsdb/test_manager.py
  11. 63
      networking_l2gw/tests/unit/services/l2gateway/agent/ovsdb/test_ovsdb_monitor.py
  12. 87
      networking_l2gw/tests/unit/services/l2gateway/agent/ovsdb/test_ovsdb_writer.py
  13. 89
      networking_l2gw/tests/unit/services/l2gateway/ovsdb/test_data.py
  14. 382
      networking_l2gw/tests/unit/services/l2gateway/service_drivers/test_rpc_l2gw.py

@ -461,8 +461,8 @@ def delete_pending_ucast_mac_remote(context, operation,
"""Delete a pending ucast_mac_remote."""
session = context.session
with session.begin(subtransactions=True):
if(mac_remote and logical_switch_id
and ovsdb_identifier and operation):
if(mac_remote and logical_switch_id and
ovsdb_identifier and operation):
query = session.query(models.PendingUcastMacsRemote).filter_by(
mac=mac_remote,
ovsdb_identifier=ovsdb_identifier,

@ -21,13 +21,13 @@ Create Date: 2014-11-27 01:57:56.997665
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '42438454c556'
down_revision = '54c9c8fe22bf'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.create_table('l2gateways',

@ -21,13 +21,13 @@ Create Date: 2015-01-27 02:05:21.599215
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '54c9c8fe22bf'
down_revision = 'start_networking_l2gw'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.create_table('physical_locators',

@ -20,17 +20,16 @@ Create Date: 2016-07-15 01:53:43.922235
"""
# revision identifiers, used by Alembic.
revision = '2f533f7705dd'
down_revision = '79919185aa99'
depends_on = ('49ce408ac349',)
from alembic import op
import sqlalchemy as sa
from sqlalchemy.engine import reflection
from neutron.db import migration
# revision identifiers, used by Alembic.
revision = '2f533f7705dd'
down_revision = '79919185aa99'
depends_on = ('49ce408ac349',)
_INSPECTOR = None

@ -21,15 +21,14 @@ Create Date: 2017-12-19 07:49:35.418145
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '0fb45e525aa9'
down_revision = '2f533f7705dd'
depends_on = ('8d7d772eafcf',)
from alembic import op
import sqlalchemy as sa
TABLES = ("l2gateways", "l2gatewayconnections", "l2gatewaydevices")
TABLE_MODELS = [

@ -21,13 +21,12 @@ Create Date: 2017-12-19 07:49:23.362289
"""
# revision identifiers, used by Alembic.
revision = '8d7d772eafcf'
down_revision = '49ce408ac349'
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '8d7d772eafcf'
down_revision = '49ce408ac349'
TABLES = ("l2gateways", "l2gatewayconnections", "l2gatewaydevices")

@ -82,8 +82,8 @@ class OVSDBManager(base_agent_manager.BaseAgentManager):
cert_path, ca_cert_path)
priv_key_file = priv_key_path + "/" + ovsdb_identifier + ".key"
cert_file = cert_path + "/" + ovsdb_identifier + ".cert"
ca_cert_file = (ca_cert_path + "/" + ovsdb_identifier
+ ".ca_cert")
ca_cert_file = (ca_cert_path + "/" + ovsdb_identifier +
".ca_cert")
is_priv_key = os.path.isfile(priv_key_file)
is_cert_file = os.path.isfile(cert_file)
is_ca_cert_file = os.path.isfile(ca_cert_file)

@ -88,9 +88,10 @@ class L2GatewayAgentScheduler(agents_db.AgentDbMixin):
# agent.
# Check if there already exists Monitor agent and it's the only one.
monitor_agents = [x for x in agents_to_process
if x['configurations'].get(srv_const.L2GW_AGENT_TYPE)
== srv_const.MONITOR]
monitor_agents = [
x for x in agents_to_process
if x['configurations'].get(srv_const.L2GW_AGENT_TYPE) ==
srv_const.MONITOR]
if len(monitor_agents) == 1:
return

@ -112,9 +112,12 @@ class TestBaseConnection(base.BaseTestCase):
"""Test case to test __init__ with socket error exception."""
fakesocket = SocketClass(socket.error)
with mock.patch.object(base_connection.LOG, 'exception') as logger_exc, \
mock.patch.object(base_connection.LOG, 'warning') as logger_warn, \
mock.patch.object(socket, 'socket', return_value=fakesocket) as sock_connect, \
with mock.patch.object(base_connection.LOG,
'exception') as logger_exc, \
mock.patch.object(base_connection.LOG,
'warning') as logger_warn, \
mock.patch.object(socket, 'socket',
return_value=fakesocket) as sock_connect, \
mock.patch.object(time, 'sleep'):
ovsdb_conf = FakeConf()
self.assertRaises(socket.error, base_connection.BaseConnection,
@ -127,9 +130,12 @@ class TestBaseConnection(base.BaseTestCase):
"""Test case to test __init__ with socket timeout exception."""
fakesocket = SocketClass(socket.timeout)
with mock.patch.object(base_connection.LOG, 'exception') as logger_exc, \
mock.patch.object(base_connection.LOG, 'warning') as logger_warn, \
mock.patch.object(socket, 'socket', return_value=fakesocket) as sock_connect, \
with mock.patch.object(base_connection.LOG,
'exception') as logger_exc, \
mock.patch.object(base_connection.LOG,
'warning') as logger_warn, \
mock.patch.object(socket, 'socket',
return_value=fakesocket) as sock_connect, \
mock.patch.object(time, 'sleep'):
ovsdb_conf = FakeConf()
self.assertRaises(socket.timeout, base_connection.BaseConnection,
@ -216,7 +222,8 @@ class TestBaseConnection_with_enable_manager(base.BaseTestCase):
self.l2gw_ovsdb_conn.ovsdb_conn_list = [fake_ip]
with mock.patch.object(eventlet.greenthread, 'spawn_n',
side_effect=Exception) as mock_thread, \
mock.patch.object(base_connection.LOG, 'warning') as mock_warning, \
mock.patch.object(base_connection.LOG,
'warning') as mock_warning, \
mock.patch.object(self.l2gw_ovsdb_conn,
'disconnect') as mock_disconnect:
self.l2gw_ovsdb_conn._send_monitor_msg_to_ovsdb_connection(
@ -231,12 +238,13 @@ class TestBaseConnection_with_enable_manager(base.BaseTestCase):
"id": "fake_id",
}
with mock.patch.object(eventlet.greenthread, 'sleep') as fake_thread, \
mock.patch.object(jsonutils, 'loads', return_value=fake_resp) as mock_loads, \
mock.patch.object(self.fakesocket,
'recv',
return_value=fake_resp) as mock_sock_rcv, \
mock.patch.object(self.fakesocket,
'send') as mock_sock_send:
mock.patch.object(jsonutils, 'loads',
return_value=fake_resp) as mock_loads, \
mock.patch.object(self.fakesocket,
'recv',
return_value=fake_resp) as mock_sock_rcv, \
mock.patch.object(self.fakesocket,
'send') as mock_sock_send:
self.l2gw_ovsdb_conn._echo_response(self.fake_ip)
self.assertTrue(fake_thread.called)
self.assertTrue(mock_sock_rcv.called)
@ -247,11 +255,12 @@ class TestBaseConnection_with_enable_manager(base.BaseTestCase):
def test_common_sock_rcv_thread_none(self):
with mock.patch.object(base_connection.BaseConnection,
'_echo_response') as mock_resp, \
mock.patch.object(eventlet.greenthread, 'sleep') as green_thrd_sleep, \
mock.patch.object(self.fakesocket,
'recv', return_value=None) as mock_rcv, \
mock.patch.object(base_connection.BaseConnection,
'disconnect') as mock_disconnect:
mock.patch.object(eventlet.greenthread, 'sleep'
) as green_thrd_sleep, \
mock.patch.object(self.fakesocket,
'recv', return_value=None) as mock_rcv, \
mock.patch.object(base_connection.BaseConnection,
'disconnect') as mock_disconnect:
self.l2gw_ovsdb_conn.check_c_sock = True
self.l2gw_ovsdb_conn.read_on = True
self.l2gw_ovsdb_conn._common_sock_rcv_thread(self.fake_ip)
@ -292,8 +301,10 @@ class TestBaseConnection_with_enable_manager(base.BaseTestCase):
cfg.CONF.set_override('l2_gw_agent_ca_cert_base_path',
'/home',
'ovsdb')
with mock.patch.object(os.path, 'isfile', return_value=True) as mock_isfile, \
mock.patch.object(base_connection.LOG, 'error') as mock_error, \
with mock.patch.object(os.path, 'isfile',
return_value=True) as mock_isfile, \
mock.patch.object(base_connection.LOG,
'error') as mock_error, \
mock.patch.object(ssl, 'wrap_socket') as mock_wrap_sock:
self.l2gw_ovsdb_conn._is_ssl_configured('10.10.10.10',
self.mock_sock)
@ -319,8 +330,10 @@ class TestBaseConnection_with_enable_manager(base.BaseTestCase):
cfg.CONF.set_override('l2_gw_agent_ca_cert_base_path',
'/home/',
'ovsdb')
with mock.patch.object(os.path, 'isfile', return_value=False) as mock_isfile, \
mock.patch.object(base_connection.LOG, 'error') as mock_error, \
with mock.patch.object(os.path, 'isfile',
return_value=False) as mock_isfile, \
mock.patch.object(base_connection.LOG, 'error'
) as mock_error, \
mock.patch.object(ssl, 'wrap_socket') as mock_wrap_sock:
self.l2gw_ovsdb_conn._is_ssl_configured('10.10.10.10',
self.mock_sock)

@ -253,9 +253,10 @@ class TestManager(base.BaseTestCase):
def test_init_with_enable_manager(self):
cfg.CONF.set_override('enable_manager', True, 'ovsdb')
with mock.patch.object(manager.OVSDBManager,
'_sock_open_connection') as mock_sock_open_conn, \
mock.patch.object(loopingcall,
'FixedIntervalLoopingCall') as mock_loop:
'_sock_open_connection'
) as mock_sock_open_conn, \
mock.patch.object(loopingcall,
'FixedIntervalLoopingCall') as mock_loop:
self.l2gw_agent_manager.__init__()
self.assertTrue(mock_sock_open_conn.called)
self.assertTrue(mock_loop.called)
@ -287,11 +288,11 @@ class TestManager(base.BaseTestCase):
self.l2gw_agent_manager.l2gw_agent_type = n_const.MONITOR
with mock.patch.object(ovsdb_common_class,
'OVSDB_commom_class') as mock_ovsdb_common, \
mock.patch.object(eventlet.greenthread,
'spawn_n') as mock_thread, \
mock.patch.object(
self.l2gw_agent_manager,
'_start_looping_task_ovsdb_states') as mock_looping:
mock.patch.object(eventlet.greenthread,
'spawn_n') as mock_thread, \
mock.patch.object(
self.l2gw_agent_manager,
'_start_looping_task_ovsdb_states') as mock_looping:
self.l2gw_agent_manager.ovsdb_fd = mock_ovsdb_common.return_value
self.l2gw_agent_manager.ovsdb_fd.check_monitor_table_thread = False
self.l2gw_agent_manager.ovsdb_fd.check_sock_rcv = True
@ -331,9 +332,10 @@ class TestManager(base.BaseTestCase):
self.l2gw_agent_manager.__init__()
self.l2gw_agent_manager.l2gw_agent_type = ''
fake_op_method = 'CREATE'
with mock.patch.object(ovsdb_common_class, 'OVSDB_commom_class') as mock_ovsdb_common, \
mock.patch.object(manager.OVSDBManager,
'_sock_open_connection') as mock_open_conn:
with mock.patch.object(ovsdb_common_class, 'OVSDB_commom_class'
) as mock_ovsdb_common, \
mock.patch.object(manager.OVSDBManager,
'_sock_open_connection') as mock_open_conn:
self.l2gw_agent_manager.ovsdb_fd = mock_ovsdb_common.return_value
self.l2gw_agent_manager.ovsdb_fd.ovsdb_conn_list = ['fake_ip']
self.l2gw_agent_manager.update_connection_to_gateway(
@ -353,9 +355,10 @@ class TestManager(base.BaseTestCase):
self.l2gw_agent_manager.__init__()
fake_op_method = 'CREATE'
with mock.patch.object(self.l2gw_agent_manager,
'_is_valid_request', return_value=True) as mock_valid_req, \
mock.patch.object(ovsdb_writer, 'OVSDBWriter'
) as mock_ovsdb_fd:
'_is_valid_request', return_value=True
) as mock_valid_req, \
mock.patch.object(ovsdb_writer, 'OVSDBWriter'
) as mock_ovsdb_fd:
self.l2gw_agent_manager.update_connection_to_gateway(
self.context, 'fake_ovsdb_id', "fake_logical_switch_dict",
"fake_locator_dicts", "fake_mac_dicts", "fake_port_dicts",
@ -387,9 +390,10 @@ class TestManager(base.BaseTestCase):
cfg.CONF.set_override('enable_manager', False, 'ovsdb')
self.l2gw_agent_manager.__init__()
with mock.patch.object(self.l2gw_agent_manager,
'_is_valid_request', return_value=True) as mock_valid_req, \
mock.patch.object(ovsdb_writer, 'OVSDBWriter'
) as mock_ovsdb_fd:
'_is_valid_request', return_value=True
) as mock_valid_req, \
mock.patch.object(ovsdb_writer, 'OVSDBWriter'
) as mock_ovsdb_fd:
self.l2gw_agent_manager.delete_network(
self.context, 'fake_ovsdb_id', "fake_logical_switch_uuid")
ovsdb_sock_fd = mock_ovsdb_fd.return_value
@ -402,9 +406,10 @@ class TestManager(base.BaseTestCase):
cfg.CONF.set_override('enable_manager', True, 'ovsdb')
self.l2gw_agent_manager.__init__()
self.l2gw_agent_manager.l2gw_agent_type = ''
with mock.patch.object(ovsdb_common_class, 'OVSDB_commom_class') as mock_ovsdb_common, \
mock.patch.object(manager.OVSDBManager,
'_sock_open_connection') as mock_open_conn:
with mock.patch.object(ovsdb_common_class, 'OVSDB_commom_class'
) as mock_ovsdb_common, \
mock.patch.object(manager.OVSDBManager,
'_sock_open_connection') as mock_open_conn:
self.l2gw_agent_manager.ovsdb_fd = mock_ovsdb_common.return_value
self.l2gw_agent_manager.ovsdb_fd.ovsdb_conn_list = ['fake_ip']
self.l2gw_agent_manager.delete_network(
@ -434,9 +439,10 @@ class TestManager(base.BaseTestCase):
cfg.CONF.set_override('enable_manager', True, 'ovsdb')
self.l2gw_agent_manager.__init__()
self.l2gw_agent_manager.l2gw_agent_type = ''
with mock.patch.object(ovsdb_common_class, 'OVSDB_commom_class') as mock_ovsdb_common, \
mock.patch.object(manager.OVSDBManager,
'_sock_open_connection') as mock_open_conn:
with mock.patch.object(ovsdb_common_class, 'OVSDB_commom_class'
) as mock_ovsdb_common, \
mock.patch.object(manager.OVSDBManager,
'_sock_open_connection') as mock_open_conn:
self.l2gw_agent_manager.ovsdb_fd = mock_ovsdb_common.return_value
self.l2gw_agent_manager.ovsdb_fd.check_c_sock = True
self.l2gw_agent_manager.ovsdb_fd.ovsdb_conn_list = ['fake_ip']
@ -492,9 +498,10 @@ class TestManager(base.BaseTestCase):
cfg.CONF.set_override('enable_manager', True, 'ovsdb')
self.l2gw_agent_manager.__init__()
self.l2gw_agent_manager.l2gw_agent_type = ''
with mock.patch.object(ovsdb_common_class, 'OVSDB_commom_class') as mock_ovsdb_common, \
mock.patch.object(manager.OVSDBManager,
'_sock_open_connection') as mock_open_conn:
with mock.patch.object(ovsdb_common_class, 'OVSDB_commom_class'
) as mock_ovsdb_common, \
mock.patch.object(manager.OVSDBManager,
'_sock_open_connection') as mock_open_conn:
self.l2gw_agent_manager.ovsdb_fd = mock_ovsdb_common.return_value
self.l2gw_agent_manager.ovsdb_fd.ovsdb_conn_list = ['fake_ip']
self.l2gw_agent_manager.delete_vif_from_gateway(
@ -513,9 +520,10 @@ class TestManager(base.BaseTestCase):
cfg.CONF.set_override('enable_manager', False, 'ovsdb')
self.l2gw_agent_manager.__init__()
with mock.patch.object(self.l2gw_agent_manager,
'_is_valid_request', return_value=True) as mock_valid_req, \
mock.patch.object(ovsdb_writer, 'OVSDBWriter'
) as mock_ovsdb_fd:
'_is_valid_request', return_value=True
) as mock_valid_req, \
mock.patch.object(ovsdb_writer, 'OVSDBWriter'
) as mock_ovsdb_fd:
self.l2gw_agent_manager.delete_vif_from_gateway(
self.context, 'fake_ovsdb_id', "fake_logical_switch_uuid",
"fake_mac")
@ -549,9 +557,10 @@ class TestManager(base.BaseTestCase):
cfg.CONF.set_override('enable_manager', True, 'ovsdb')
self.l2gw_agent_manager.__init__()
self.l2gw_agent_manager.l2gw_agent_type = ''
with mock.patch.object(ovsdb_common_class, 'OVSDB_commom_class') as mock_ovsdb_common, \
mock.patch.object(manager.OVSDBManager,
'_sock_open_connection') as mock_open_conn:
with mock.patch.object(ovsdb_common_class, 'OVSDB_commom_class'
) as mock_ovsdb_common, \
mock.patch.object(manager.OVSDBManager,
'_sock_open_connection') as mock_open_conn:
self.l2gw_agent_manager.ovsdb_fd = mock_ovsdb_common.return_value
self.l2gw_agent_manager.ovsdb_fd.ovsdb_conn_list = ['fake_ip']
self.l2gw_agent_manager.update_vif_to_gateway(
@ -570,9 +579,10 @@ class TestManager(base.BaseTestCase):
cfg.CONF.set_override('enable_manager', False, 'ovsdb')
self.l2gw_agent_manager.__init__()
with mock.patch.object(self.l2gw_agent_manager,
'_is_valid_request', return_value=True) as mock_valid_req, \
mock.patch.object(ovsdb_writer, 'OVSDBWriter'
) as mock_ovsdb_fd:
'_is_valid_request', return_value=True
) as mock_valid_req, \
mock.patch.object(ovsdb_writer, 'OVSDBWriter'
) as mock_ovsdb_fd:
self.l2gw_agent_manager.update_vif_to_gateway(
self.context, 'fake_ovsdb_id', "fake_locator_dict",
"fake_mac_dict")

@ -126,9 +126,11 @@ class TestOVSDBMonitor(base.BaseTestCase):
'send', return_value=True) as send, \
mock.patch.object(ovsdb_monitor.OVSDBMonitor,
'_process_response',
return_value=(mock.ANY, False)) as process_resp, \
return_value=(mock.ANY, False)
) as process_resp, \
mock.patch.object(ovsdb_monitor.OVSDBMonitor,
'_process_monitor_msg') as process_monitor_msg, \
'_process_monitor_msg'
) as process_monitor_msg, \
mock.patch.object(ovsdb_monitor.LOG, 'warning'):
self.l2gw_ovsdb.set_monitor_response_handler()
self.assertTrue(set_handler.called)
@ -141,15 +143,15 @@ class TestOVSDBMonitor(base.BaseTestCase):
self.l2gw_ovsdb.connected = True
with mock.patch.object(ovsdb_monitor.OVSDBMonitor,
'_set_handler') as set_handler, \
mock.patch.object(ovsdb_monitor.OVSDBMonitor,
'send', return_value=False) as send, \
mock.patch.object(ovsdb_monitor.OVSDBMonitor,
'_process_response',
return_value=(mock.ANY, True)) as process_resp, \
mock.patch.object(ovsdb_monitor.OVSDBMonitor,
'_process_monitor_msg') as process_monitor_msg, \
mock.patch.object(ovsdb_monitor.LOG,
'warning'):
mock.patch.object(ovsdb_monitor.OVSDBMonitor,
'send', return_value=False) as send, \
mock.patch.object(ovsdb_monitor.OVSDBMonitor,
'_process_response',
return_value=(mock.ANY, True)) as process_resp, \
mock.patch.object(ovsdb_monitor.OVSDBMonitor,
'_process_monitor_msg') as process_monitor_msg, \
mock.patch.object(ovsdb_monitor.LOG,
'warning'):
self.l2gw_ovsdb.set_monitor_response_handler()
self.assertTrue(set_handler.called)
self.assertTrue(send.called)
@ -167,22 +169,29 @@ class TestOVSDBMonitor(base.BaseTestCase):
def test_process_update_event(self):
"""Test case to test _process_update_event."""
with mock.patch.object(ovsdb_monitor.OVSDBMonitor,
'_process_physical_port') as proc_phy_port, \
mock.patch.object(ovsdb_monitor.OVSDBMonitor,
'_process_physical_switch') as proc_phy_switch, \
mock.patch.object(ovsdb_monitor.OVSDBMonitor,
'_process_logical_switch') as proc_logic_switch, \
mock.patch.object(ovsdb_monitor.OVSDBMonitor,
'_process_ucast_macs_local') as proc_ucast_mac, \
mock.patch.object(ovsdb_monitor.OVSDBMonitor,
'_process_physical_locator') as proc_phy_loc, \
mock.patch.object(ovsdb_monitor.OVSDBMonitor,
'_process_ucast_macs_remote') as proc_ucast_mac_remote, \
mock.patch.object(ovsdb_monitor.OVSDBMonitor,
'_process_mcast_macs_local') as proc_mcast_mac_local, \
mock.patch.object(
ovsdb_monitor.OVSDBMonitor,
'_process_physical_locator_set') as proc_phys_loc_set:
'_process_physical_port'
) as proc_phy_port, \
mock.patch.object(ovsdb_monitor.OVSDBMonitor,
'_process_physical_switch'
) as proc_phy_switch, \
mock.patch.object(ovsdb_monitor.OVSDBMonitor,
'_process_logical_switch'
) as proc_logic_switch, \
mock.patch.object(ovsdb_monitor.OVSDBMonitor,
'_process_ucast_macs_local'
) as proc_ucast_mac, \
mock.patch.object(ovsdb_monitor.OVSDBMonitor,
'_process_physical_locator'
) as proc_phy_loc, \
mock.patch.object(ovsdb_monitor.OVSDBMonitor,
'_process_ucast_macs_remote'
) as proc_ucast_mac_remote, \
mock.patch.object(ovsdb_monitor.OVSDBMonitor,
'_process_mcast_macs_local'
) as proc_mcast_mac_local, \
mock.patch.object(
ovsdb_monitor.OVSDBMonitor,
'_process_physical_locator_set') as proc_phys_loc_set:
self.l2gw_ovsdb._setup_dispatch_table()
self.l2gw_ovsdb._process_update_event(self.msg2, mock.ANY)
self.assertTrue(proc_phy_port.called)

@ -117,7 +117,8 @@ class TestOVSDBWriter(base.BaseTestCase):
'foo_value'})) as recv_data, \
mock.patch.object(ovsdb_writer.OVSDBWriter,
'_process_response',
return_value=(ret_value, None)) as proc_response, \
return_value=(ret_value, None)
) as proc_response, \
mock.patch.object(ovsdb_writer.LOG,
'debug'):
self.l2gw_ovsdb._get_reply(self.op_id, mock.ANY)
@ -178,7 +179,8 @@ class TestOVSDBWriter(base.BaseTestCase):
def test_insert_ucast_macs_remote(self):
"""Test case to test insert ucast_macs_remote."""
with mock.patch.object(ovsdb_writer.OVSDBWriter,
'_get_ucast_macs_remote_dict') as get_ucast_mac_remote, \
'_get_ucast_macs_remote_dict'
) as get_ucast_mac_remote, \
mock.patch.object(random,
'getrandbits',
return_value=self.op_id
@ -207,11 +209,14 @@ class TestOVSDBWriter(base.BaseTestCase):
without locator_id and logical_switch_id.
"""
with mock.patch.object(ovsdb_writer.OVSDBWriter,
'_get_ucast_macs_remote_dict') as get_ucast_mac_remote, \
'_get_ucast_macs_remote_dict'
) as get_ucast_mac_remote, \
mock.patch.object(ovsdb_writer.OVSDBWriter,
'_get_physical_locator_dict') as get_physical_locator_dict, \
'_get_physical_locator_dict'
) as get_physical_locator_dict, \
mock.patch.object(ovsdb_writer.OVSDBWriter,
'_get_logical_switch_dict') as get_logical_switch_dict, \
'_get_logical_switch_dict'
) as get_logical_switch_dict, \
mock.patch.object(random,
'getrandbits',
return_value=self.op_id
@ -221,9 +226,12 @@ class TestOVSDBWriter(base.BaseTestCase):
), \
mock.patch.object(ovsdb_writer.LOG,
'debug'), \
mock.patch.object(ovsdb_schema, 'LogicalSwitch') as mock_ls, \
mock.patch.object(ovsdb_schema, 'PhysicalLocator') as mock_pl, \
mock.patch.object(ovsdb_schema, 'UcastMacsRemote'):
mock.patch.object(ovsdb_schema,
'LogicalSwitch') as mock_ls, \
mock.patch.object(ovsdb_schema,
'PhysicalLocator') as mock_pl, \
mock.patch.object(ovsdb_schema,
'UcastMacsRemote'):
locator = mock_pl.return_value
locator.uuid = None
ls = mock_ls.return_value
@ -240,7 +248,8 @@ class TestOVSDBWriter(base.BaseTestCase):
def test_update_ucast_macs_remote(self):
"""Test case to test update ucast_macs_remote."""
with mock.patch.object(ovsdb_writer.OVSDBWriter,
'_get_dict_for_update_ucast_mac_remote') as get_update_ucast_mac_remote, \
'_get_dict_for_update_ucast_mac_remote'
) as get_update_ucast_mac_remote, \
mock.patch.object(random,
'getrandbits',
return_value=self.op_id
@ -267,9 +276,11 @@ class TestOVSDBWriter(base.BaseTestCase):
without locator_id and logical_switch_id.
"""
with mock.patch.object(ovsdb_writer.OVSDBWriter,
'_get_dict_for_update_ucast_mac_remote') as get_update_ucast_mac_remote, \
'_get_dict_for_update_ucast_mac_remote'
) as get_update_ucast_mac_remote, \
mock.patch.object(ovsdb_writer.OVSDBWriter,
'_get_physical_locator_dict') as get_physical_locator_dict, \
'_get_physical_locator_dict'
) as get_physical_locator_dict, \
mock.patch.object(random,
'getrandbits',
return_value=self.op_id
@ -279,7 +290,8 @@ class TestOVSDBWriter(base.BaseTestCase):
), \
mock.patch.object(ovsdb_writer.LOG,
'debug'), \
mock.patch.object(ovsdb_schema, 'PhysicalLocator') as mock_pl, \
mock.patch.object(ovsdb_schema,
'PhysicalLocator') as mock_pl, \
mock.patch.object(ovsdb_schema, 'UcastMacsRemote'):
locator = mock_pl.return_value
locator.uuid = None
@ -295,11 +307,11 @@ class TestOVSDBWriter(base.BaseTestCase):
'getrandbits',
return_value=self.op_id
) as get_rand, \
mock.patch.object(ovsdb_writer.OVSDBWriter,
'_send_and_receive'
) as send_n_receive, \
mock.patch.object(ovsdb_writer.LOG,
'debug'):
mock.patch.object(ovsdb_writer.OVSDBWriter,
'_send_and_receive'
) as send_n_receive, \
mock.patch.object(ovsdb_writer.LOG,
'debug'):
self.l2gw_ovsdb.delete_ucast_macs_remote(mock.Mock(),
mock.MagicMock(),
mock.ANY)
@ -311,15 +323,15 @@ class TestOVSDBWriter(base.BaseTestCase):
"""Test case to test update_connection_to_gateway."""
with mock.patch.object(ovsdb_writer.OVSDBWriter,
'_get_bindings_to_update') as get_bindings, \
mock.patch.object(random,
'getrandbits',
return_value=self.op_id
) as get_rand, \
mock.patch.object(ovsdb_writer.OVSDBWriter,
'_send_and_receive'
) as send_n_receive, \
mock.patch.object(ovsdb_writer.LOG,
'debug'):
mock.patch.object(random,
'getrandbits',
return_value=self.op_id
) as get_rand, \
mock.patch.object(ovsdb_writer.OVSDBWriter,
'_send_and_receive'
) as send_n_receive, \
mock.patch.object(ovsdb_writer.LOG,
'debug'):
self.l2gw_ovsdb.update_connection_to_gateway(
mock.Mock(), mock.Mock(), mock.Mock(), mock.Mock(),
mock.ANY, mock.ANY)
@ -331,15 +343,20 @@ class TestOVSDBWriter(base.BaseTestCase):
def test_get_bindings_to_update1(self):
"""Test case to test _get_bindings_to_update."""
fake_op_method = 'CREATE'
with mock.patch.object(ovsdb_writer.OVSDBWriter,
'_form_logical_switch') as form_ls, \
mock.patch.object(ovsdb_writer.OVSDBWriter,
'_form_physical_locators') as form_pl, \
mock.patch.object(ovsdb_writer.OVSDBWriter,
'_form_ports') as form_pp, \
mock.patch.object(ovsdb_schema, 'LogicalSwitch') as mock_ls, \
mock.patch.object(ovsdb_schema, 'PhysicalLocator') as mock_pl, \
mock.patch.object(ovsdb_schema, 'UcastMacsRemote') as mock_ucmr, \
with mock.patch.object(
ovsdb_writer.OVSDBWriter,
'_form_logical_switch') as form_ls, \
mock.patch.object(
ovsdb_writer.OVSDBWriter,
'_form_physical_locators') as form_pl, \
mock.patch.object(
ovsdb_writer.OVSDBWriter, '_form_ports') as form_pp, \
mock.patch.object(
ovsdb_schema, 'LogicalSwitch') as mock_ls, \
mock.patch.object(
ovsdb_schema, 'PhysicalLocator') as mock_pl, \
mock.patch.object(
ovsdb_schema, 'UcastMacsRemote') as mock_ucmr, \
mock.patch.object(ovsdb_schema, 'PhysicalPort') as mock_pp:
ls = mock_ls.return_value = ovsdb_schema.LogicalSwitch(
'ls_uuid', 'ls_name', 'ls_key', 'ls_desc')

@ -124,36 +124,65 @@ class TestOVSDBData(base.BaseTestCase):
'deleted_physical_locators': fake_deleted_physical_locators,
'deleted_local_macs': fake_deleted_local_macs,
'deleted_remote_macs': fake_deleted_remote_macs}
with mock.patch.object(self.ovsdb_data,
'_process_new_logical_switches') as process_new_logical_switches, \
mock.patch.object(self.ovsdb_data,
'_process_new_physical_ports') as process_new_physical_ports, \
mock.patch.object(self.ovsdb_data,
'_process_new_physical_switches') as process_new_physical_switches, \
mock.patch.object(self.ovsdb_data,
'_process_new_physical_locators') as process_new_physical_locators, \
mock.patch.object(self.ovsdb_data,
'_process_new_local_macs') as process_new_local_macs, \
mock.patch.object(self.ovsdb_data,
'_process_new_remote_macs') as process_new_remote_macs, \
mock.patch.object(self.ovsdb_data,
'_process_modified_remote_macs') as process_modified_remote_macs, \
mock.patch.object(self.ovsdb_data,
'_process_modified_physical_ports') as process_modified_physical_ports, \
mock.patch.object(self.ovsdb_data,
'_process_deleted_logical_switches') as process_deleted_logical_switches, \
mock.patch.object(self.ovsdb_data,
'_process_deleted_physical_switches') as process_deleted_physical_switches, \
mock.patch.object(self.ovsdb_data,
'_process_deleted_physical_ports') as process_deleted_physical_ports, \
mock.patch.object(self.ovsdb_data,
'_process_deleted_physical_locators') as process_deleted_physical_locators, \
mock.patch.object(self.ovsdb_data,
'_process_deleted_local_macs') as process_deleted_local_macs, \
mock.patch.object(self.ovsdb_data,
'_process_deleted_remote_macs') as process_deleted_remote_macs, \
mock.patch.object(self.ovsdb_data,
'_handle_l2pop') as mock_handle_l2pop:
with mock.patch.object(
self.ovsdb_data,
'_process_new_logical_switches'
) as process_new_logical_switches, \
mock.patch.object(
self.ovsdb_data,
'_process_new_physical_ports'
) as process_new_physical_ports, \
mock.patch.object(
self.ovsdb_data,
'_process_new_physical_switches'
) as process_new_physical_switches, \
mock.patch.object(
self.ovsdb_data,
'_process_new_physical_locators'
) as process_new_physical_locators, \
mock.patch.object(
self.ovsdb_data,
'_process_new_local_macs'
) as process_new_local_macs, \
mock.patch.object(
self.ovsdb_data,
'_process_new_remote_macs'
) as process_new_remote_macs, \
mock.patch.object(
self.ovsdb_data,
'_process_modified_remote_macs'
) as process_modified_remote_macs, \
mock.patch.object(
self.ovsdb_data,
'_process_modified_physical_ports'
) as process_modified_physical_ports, \
mock.patch.object(
self.ovsdb_data,
'_process_deleted_logical_switches'
) as process_deleted_logical_switches, \
mock.patch.object(
self.ovsdb_data,
'_process_deleted_physical_switches'
) as process_deleted_physical_switches, \
mock.patch.object(
self.ovsdb_data,
'_process_deleted_physical_ports'
) as process_deleted_physical_ports, \
mock.patch.object(
self.ovsdb_data,
'_process_deleted_physical_locators'
) as process_deleted_physical_locators, \
mock.patch.object(
self.ovsdb_data,
'_process_deleted_local_macs'
) as process_deleted_local_macs, \
mock.patch.object(
self.ovsdb_data,
'_process_deleted_remote_macs'
) as process_deleted_remote_macs, \
mock.patch.object(
self.ovsdb_data,
'_handle_l2pop') as mock_handle_l2pop:
self.ovsdb_data.entry_table = {
'new_logical_switches': process_new_logical_switches,
'new_physical_ports': process_new_physical_ports,

@ -155,8 +155,8 @@ class TestL2gwRpcDriver(test_plugin.Ml2PluginV2TestCase):
self.service_plugin,
'get_l2gateway_interfaces_by_device_id',
return_value=fake_interface_list) as get_intf, \
mock.patch.object(self.plugin,
'_generate_port_list') as gen_port_list:
mock.patch.object(self.plugin,
'_generate_port_list') as gen_port_list:
self.plugin._process_port_list(self.context, fake_device,
fake_connection,
fake_method)
@ -477,8 +477,8 @@ class TestL2gwRpcDriver(test_plugin.Ml2PluginV2TestCase):
with mock.patch.object(self.plugin,
'_get_port_details',
return_value=fake_port_list) as get_port, \
mock.patch.object(self.plugin,
'delete_port_mac') as delete_mac:
mock.patch.object(self.plugin,
'delete_port_mac') as delete_mac:
self.plugin._remove_vm_macs(self.context,
fake_network_id,
fake_ovsdb_id_set)
@ -635,31 +635,33 @@ class TestL2gwRpcDriver(test_plugin.Ml2PluginV2TestCase):
'_get_ip_details',
return_value=(fake_ip1,
fake_ip2)), \
mock.patch.object(self.plugin,
'_get_network_details',
return_value=fake_network_dict) as get_network, \
mock.patch.object(self.service_plugin,
'get_l2_gateway_connections',
return_value=fake_conn_list), \
mock.patch.object(self.plugin,
'_form_physical_locator_schema',
return_value=fake_locator_dict) as get_pl, \
mock.patch.object(ovsdb_schema,
'UcastMacsRemote') as mock_ucmr, \
mock.patch.object(self.plugin,
'_get_dict',
return_value=fake_dict) as get_dict, \
mock.patch.object(db,
'get_ucast_mac_remote_by_mac_and_ls',
return_value=False) as get_ucast_mac, \
mock.patch.object(self.plugin.agent_rpc,
'add_vif_to_gateway',
side_effect=RuntimeError) as add_rpc, \
mock.patch.object(self.plugin.agent_rpc,
'update_vif_to_gateway') as update_rpc, \
mock.patch.object(db, 'add_pending_ucast_mac_remote') as add_pending_mac, \
mock.patch.object(db, 'get_all_logical_switches_by_name',
return_value=fake_logical_switch_list):
mock.patch.object(self.plugin,
'_get_network_details',
return_value=fake_network_dict) as get_network, \
mock.patch.object(self.service_plugin,
'get_l2_gateway_connections',
return_value=fake_conn_list), \
mock.patch.object(self.plugin,
'_form_physical_locator_schema',
return_value=fake_locator_dict) as get_pl, \
mock.patch.object(ovsdb_schema,
'UcastMacsRemote') as mock_ucmr, \
mock.patch.object(self.plugin,
'_get_dict',
return_value=fake_dict) as get_dict, \
mock.patch.object(db,
'get_ucast_mac_remote_by_mac_and_ls',
return_value=False) as get_ucast_mac, \
mock.patch.object(self.plugin.agent_rpc,
'add_vif_to_gateway',
side_effect=RuntimeError) as add_rpc, \
mock.patch.object(self.plugin.agent_rpc,
'update_vif_to_gateway') as update_rpc, \
mock.patch.object(
db,
'add_pending_ucast_mac_remote') as add_pending_mac, \
mock.patch.object(db, 'get_all_logical_switches_by_name',
return_value=fake_logical_switch_list):
remote_mac = ovsdb_schema.UcastMacsRemote(
None, fake_dict['mac'], fake_logical_switch['uuid'],
fake_locator_dict['uuid'],
@ -715,28 +717,28 @@ class TestL2gwRpcDriver(test_plugin.Ml2PluginV2TestCase):
'_get_ip_details',
return_value=(fake_ip1,
fake_ip2)), \
mock.patch.object(self.plugin,
'_get_network_details',
return_value=fake_network_dict) as get_network, \
mock.patch.object(self.service_plugin,
'get_l2_gateway_connections',
return_value=fake_conn_list) as get_l2gw_conn, \
mock.patch.object(self.plugin,
'_form_physical_locator_schema',
return_value=fake_locator_dict) as get_pl, \
mock.patch.object(self.plugin,
'_get_dict',
return_value=fake_dict), \
mock.patch.object(db,
'get_ucast_mac_remote_by_mac_and_ls',
return_value=fake_mac_dict) as get_ucast_mac, \
mock.patch.object(self.plugin.agent_rpc,
'add_vif_to_gateway') as add_rpc, \
mock.patch.object(self.plugin.agent_rpc,
'update_vif_to_gateway') as update_rpc, \
mock.patch.object(db,
'get_all_logical_switches_by_name',
return_value=fake_logical_switch_list):
mock.patch.object(self.plugin,
'_get_network_details',
return_value=fake_network_dict) as get_network, \
mock.patch.object(self.service_plugin,
'get_l2_gateway_connections',
return_value=fake_conn_list) as get_l2gw_conn, \
mock.patch.object(self.plugin,
'_form_physical_locator_schema',
return_value=fake_locator_dict) as get_pl, \
mock.patch.object(self.plugin,
'_get_dict',
return_value=fake_dict), \
mock.patch.object(db,
'get_ucast_mac_remote_by_mac_and_ls',
return_value=fake_mac_dict) as get_ucast_mac, \
mock.patch.object(self.plugin.agent_rpc,
'add_vif_to_gateway') as add_rpc, \
mock.patch.object(self.plugin.agent_rpc,
'update_vif_to_gateway') as update_rpc, \
mock.patch.object(db,
'get_all_logical_switches_by_name',
return_value=fake_logical_switch_list):
self.plugin.add_port_mac(self.context, fake_dict)
get_network.assert_called_with(self.context, 'fake_network_id')
get_l2gw_conn.assert_called_with(
@ -785,29 +787,31 @@ class TestL2gwRpcDriver(test_plugin.Ml2PluginV2TestCase):
'_get_ip_details',
return_value=(fake_ip1,
fake_ip2)), \
mock.patch.object(self.plugin,
'_get_network_details',
return_value=fake_network_dict) as get_network, \
mock.patch.object(self.service_plugin,
'get_l2_gateway_connections',
return_value=fake_conn_list) as get_l2gw_conn, \
mock.patch.object(self.plugin,
'_form_physical_locator_schema',
return_value=fake_locator_dict) as get_pl, \
mock.patch.object(self.plugin,
'_get_dict',
return_value=fake_dict), \
mock.patch.object(db,
'get_ucast_mac_remote_by_mac_and_ls',
return_value=fake_mac_dict) as get_ucast_mac, \
mock.patch.object(self.plugin.agent_rpc,
'add_vif_to_gateway') as add_rpc, \
mock.patch.object(self.plugin.agent_rpc,
'update_vif_to_gateway',
side_effect=RuntimeError) as update_rpc, \
mock.patch.object(db, 'add_pending_ucast_mac_remote') as add_pending_mac, \
mock.patch.object(db, 'get_all_logical_switches_by_name',
return_value=fake_logical_switch_list):
mock.patch.object(self.plugin,
'_get_network_details',
return_value=fake_network_dict) as get_network, \
mock.patch.object(self.service_plugin,
'get_l2_gateway_connections',
return_value=fake_conn_list) as get_l2gw_conn, \
mock.patch.object(self.plugin,
'_form_physical_locator_schema',
return_value=fake_locator_dict) as get_pl, \
mock.patch.object(self.plugin,
'_get_dict',
return_value=fake_dict), \
mock.patch.object(db,
'get_ucast_mac_remote_by_mac_and_ls',
return_value=fake_mac_dict) as get_ucast_mac, \
mock.patch.object(self.plugin.agent_rpc,
'add_vif_to_gateway') as add_rpc, \
mock.patch.object(self.plugin.agent_rpc,
'update_vif_to_gateway',
side_effect=RuntimeError) as update_rpc, \
mock.patch.object(
db,
'add_pending_ucast_mac_remote') as add_pending_mac, \
mock.patch.object(db, 'get_all_logical_switches_by_name',
return_value=fake_logical_switch_list):
self.plugin.add_port_mac(self.context, fake_dict)
get_network.assert_called_with(self.context, 'fake_network_id')
get_l2gw_conn.assert_called_with(
@ -856,28 +860,28 @@ class TestL2gwRpcDriver(test_plugin.Ml2PluginV2TestCase):
'_get_ip_details',
return_value=(fake_ip1,
fake_ip2)), \
mock.patch.object(self.plugin,
'_get_network_details',
return_value=fake_network_dict) as get_network, \
mock.patch.object(self.service_plugin,
'get_l2_gateway_connections',
return_value=fake_conn_list) as get_l2gw_conn, \
mock.patch.object(self.plugin,
'_form_physical_locator_schema',
return_value=fake_locator_dict) as get_pl, \
mock.patch.object(self.plugin,
'_get_dict',
return_value=fake_dict), \
mock.patch.object(db,
'get_ucast_mac_remote_by_mac_and_ls',
return_value=fake_mac_dict) as get_ucast_mac, \
mock.patch.object(agent_api.L2gatewayAgentApi,
'add_vif_to_gateway') as add_rpc, \
mock.patch.object(data.L2GatewayOVSDBCallbacks,
'get_ovsdbdata_object') as get_ovsdbdata_obj, \
mock.patch.object(db,
'get_all_logical_switches_by_name',
return_value=fake_logical_switch_list):
mock.patch.object(self.plugin,
'_get_network_details',
return_value=fake_network_dict) as get_network, \
mock.patch.object(self.service_plugin,
'get_l2_gateway_connections',
return_value=fake_conn_list) as get_l2gw_conn, \
mock.patch.object(self.plugin,
'_form_physical_locator_schema',
return_value=fake_locator_dict) as get_pl, \
mock.patch.object(self.plugin,
'_get_dict',
return_value=fake_dict), \
mock.patch.object(db,
'get_ucast_mac_remote_by_mac_and_ls',
return_value=fake_mac_dict) as get_ucast_mac, \
mock.patch.object(agent_api.L2gatewayAgentApi,
'add_vif_to_gateway') as add_rpc, \
mock.patch.object(data.L2GatewayOVSDBCallbacks,
'get_ovsdbdata_object') as get_ovsdbdata_obj, \
mock.patch.object(db,
'get_all_logical_switches_by_name',
return_value=fake_logical_switch_list):
self.plugin.add_port_mac(self.context, fake_dict)
get_network.assert_called_with(self.context, 'fake_network_id')
get_l2gw_conn.assert_called_with(
@ -908,9 +912,9 @@ class TestL2gwRpcDriver(test_plugin.Ml2PluginV2TestCase):
get_ls.return_value = fake_logical_switch_list
with mock.patch.object(self.plugin.agent_rpc,
'delete_vif_from_gateway') as delete_rpc, \
mock.patch.object(self.service_plugin,
'get_l2_gateway_connections',
return_value=True):
mock.patch.object(self.service_plugin,
'get_l2_gateway_connections',
return_value=True):
self.plugin.delete_port_mac(self.context, fake_port_dict)
get_ls.assert_called_with(self.context, network_id)
get_mac.assert_called_with(self.context, fake_dict)
@ -942,9 +946,9 @@ class TestL2gwRpcDriver(test_plugin.Ml2PluginV2TestCase):
get_ls_by_name.return_value = fake_rec_dict
with mock.patch.object(self.plugin.agent_rpc,
'delete_vif_from_gateway') as delete_rpc, \
mock.patch.object(self.service_plugin,
'get_l2_gateway_connections',
return_value=[1]):
mock.patch.object(self.service_plugin,
'get_l2_gateway_connections',
return_value=[1]):
self.plugin.delete_port_mac(self.context, fake_port_list)
get_ls_by_name.assert_called_with(self.context, fake_dict)
get_ls.assert_not_called()
@ -971,9 +975,9 @@ class TestL2gwRpcDriver(test_plugin.Ml2PluginV2TestCase):
'ovsdb_identifier': 'fake_ovsdb_id'}
with mock.patch.object(self.plugin.agent_rpc,
'delete_vif_from_gateway') as delete_rpc, \
mock.patch.object(self.service_plugin,
'get_l2_gateway_connections',
return_value=[1, 2]):
mock.patch.object(self.service_plugin,
'get_l2_gateway_connections',
return_value=[1, 2]):
self.plugin.delete_port_mac(self.context, fake_port_list)
get_ls_by_name.assert_called_with(self.context, fake_rec_dict)
get_ls.assert_not_called()
@ -1073,26 +1077,27 @@ class TestL2gwRpcDriver(test_plugin.Ml2PluginV2TestCase):
with mock.patch.object(self.service_plugin,
'_admin_check',
return_value=True) as admin_check, \
mock.patch.object(self.service_plugin,
'get_l2_gateway_connection',
return_value=fake_conn_dict) as get_con, \
mock.patch.object(self.plugin,
'_get_identifer_list',
return_value=fake_identifier_list) as get_id_list, \
mock.patch.object(self.plugin,
'_get_set_of_ovsdb_ids',
return_value=fake_ovsdb_list) as get_ovsdb_id, \
mock.patch.object(self.service_plugin,
'get_l2gateway_devices_by_gateway_id',
return_value=fake_device_list) as get_devices, \
mock.patch.object(self.plugin,
'_process_port_list',
return_value=(ovsdb_id, logical_switch,
fake_port_dict)) as port_list, \
mock.patch.object(self.plugin.agent_rpc,
'update_connection_to_gateway') as update_rpc, \
mock.patch.object(self.plugin,
'_remove_vm_macs') as remove_vm_mac:
mock.patch.object(self.service_plugin,
'get_l2_gateway_connection',
return_value=fake_conn_dict) as get_con, \
mock.patch.object(
self.plugin,
'_get_identifer_list',
return_value=fake_identifier_list) as get_id_list, \
mock.patch.object(self.plugin,
'_get_set_of_ovsdb_ids',
return_value=fake_ovsdb_list) as get_ovsdb_id, \
mock.patch.object(self.service_plugin,
'get_l2gateway_devices_by_gateway_id',
return_value=fake_device_list) as get_devices, \
mock.patch.object(self.plugin,
'_process_port_list',
return_value=(ovsdb_id, logical_switch,
fake_port_dict)) as port_list, \
mock.patch.object(self.plugin.agent_rpc,
'update_connection_to_gateway') as update_rpc, \
mock.patch.object(self.plugin,
'_remove_vm_macs') as remove_vm_mac:
self.plugin.delete_l2_gateway_connection(self.context,
fake_conn_dict)
admin_check.assert_called_with(self.context, 'DELETE')
@ -1128,18 +1133,18 @@ class TestL2gwRpcDriver(test_plugin.Ml2PluginV2TestCase):
with mock.patch.object(self.service_plugin,
'_admin_check',
return_value=True), \
mock.patch.object(self.service_plugin,
'get_l2_gateway', return_value=fake_device), \
mock.patch.object(db, 'get_physical_port_by_name_and_ps',
return_value=fake_physical_port), \
mock.patch.object(db, 'get_physical_switch_by_name',
return_value=fake_physical_switch), \
mock.patch.object(self.service_plugin,
'_get_network',
return_value=True), \
mock.patch.object(self.service_plugin,
'_get_l2_gateway',
return_value=True):
mock.patch.object(self.service_plugin,
'get_l2_gateway', return_value=fake_device), \
mock.patch.object(db, 'get_physical_port_by_name_and_ps',
return_value=fake_physical_port), \
mock.patch.object(db, 'get_physical_switch_by_name',
return_value=fake_physical_switch), \
mock.patch.object(self.service_plugin,
'_get_network',
return_value=True), \
mock.patch.object(self.service_plugin,
'_get_l2_gateway',
return_value=True):
self.assertRaises(l2gw_exc.L2GatewayPhysicalSwitchFaultStatus,
self.plugin.create_l2_gateway_connection,
self.db_context,
@ -1164,18 +1169,18 @@ class TestL2gwRpcDriver(test_plugin.Ml2PluginV2TestCase):
with mock.patch.object(self.service_plugin,
'_admin_check',
return_value=True), \
mock.patch.object(self.service_plugin,
'get_l2_gateway', return_value=fake_device), \
mock.patch.object(db, 'get_physical_port_by_name_and_ps',
return_value=fake_physical_port), \
mock.patch.object(db, 'get_physical_switch_by_name',
return_value=fake_physical_switch), \
mock.patch.object(self.service_plugin,
'_get_network',
return_value=True), \
mock.patch.object(self.service_plugin,
'_get_l2_gateway',
return_value=True):
mock.patch.object(self.service_plugin,
'get_l2_gateway', return_value=fake_device), \
mock.patch.object(db, 'get_physical_port_by_name_and_ps',
return_value=fake_physical_port), \
mock.patch.object(db, 'get_physical_switch_by_name',
return_value=fake_physical_switch), \
mock.patch.object(self.service_plugin,
'_get_network',
return_value=True), \
mock.patch.object(self.service_plugin,
'_get_l2_gateway',