summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYushiro FURUKAWA <y.furukawa_2@jp.fujitsu.com>2018-03-23 16:10:55 +0900
committerYushiro FURUKAWA <y.furukawa_2@jp.fujitsu.com>2018-07-27 22:39:06 +0900
commit0c61ebef0399392459cbe8b2d1eaf5316b9c8c8f (patch)
tree56a24c865329abe12d238ba00aa549968ec1fbe5
parentc8932b4f818910b3bfb7e42e3b723b089dbd1cc7 (diff)
Fix tunnel IP configuration
This commit fixes tunnel IP configuration for each OVS. Change-Id: Ia1a6ba0ff5a4e5088fb8817cc305c7e03b4c1cf2
Notes
Notes (review): Code-Review+2: Yushiro FURUKAWA <y.furukawa_2@jp.fujitsu.com> Workflow+1: Yushiro FURUKAWA <y.furukawa_2@jp.fujitsu.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Sat, 28 Jul 2018 09:36:19 +0000 Reviewed-on: https://review.openstack.org/555680 Project: openstack/networking-fujitsu Branch: refs/heads/master
-rw-r--r--networking_fujitsu/ml2/fossw/fossw_vxlandriver.py14
-rw-r--r--networking_fujitsu/tests/unit/ml2/fossw/test_fossw_vxlandriver.py237
2 files changed, 142 insertions, 109 deletions
diff --git a/networking_fujitsu/ml2/fossw/fossw_vxlandriver.py b/networking_fujitsu/ml2/fossw/fossw_vxlandriver.py
index 25300c0..a2e6f9a 100644
--- a/networking_fujitsu/ml2/fossw/fossw_vxlandriver.py
+++ b/networking_fujitsu/ml2/fossw/fossw_vxlandriver.py
@@ -197,7 +197,7 @@ class FOSSWVxlanDriver(object):
197 mac = port["mac_address"] 197 mac = port["mac_address"]
198 port_ips = [fixed_ip['ip_address'] for fixed_ip in port["fixed_ips"]] 198 port_ips = [fixed_ip['ip_address'] for fixed_ip in port["fixed_ips"]]
199 host_id = port['binding:host_id'] 199 host_id = port['binding:host_id']
200 target_ip = ip_mac_pairs[lli[0]['switch_id']] if lli else None 200 sw_ip = ip_mac_pairs[lli[0]['switch_id']] if lli else None
201 target = lli[0]['switch_info'] if lli else host_id 201 target = lli[0]['switch_info'] if lli else host_id
202 tunnel_ip = self.type_vxlan.db_get_endpoint_ip_by_host(target) 202 tunnel_ip = self.type_vxlan.db_get_endpoint_ip_by_host(target)
203 203
@@ -208,7 +208,7 @@ class FOSSWVxlanDriver(object):
208 else: 208 else:
209 lag_port = None 209 lag_port = None
210 # Update Physical_Port table first. 210 # Update Physical_Port table first.
211 ovsdb_cli = ovsdb_writer.OVSDBWriter(target_ip, self.ovsdb_port) 211 ovsdb_cli = ovsdb_writer.OVSDBWriter(sw_ip, self.ovsdb_port)
212 lsw_id = ovsdb_cli.get_logical_switch_uuid(ls_name) 212 lsw_id = ovsdb_cli.get_logical_switch_uuid(ls_name)
213 binding_vid = ovsdb_cli.get_binding_vid(lsw_id) 213 binding_vid = ovsdb_cli.get_binding_vid(lsw_id)
214 bind_vlanid = binding_vid if binding_vid else ( 214 bind_vlanid = binding_vid if binding_vid else (
@@ -237,18 +237,18 @@ class FOSSWVxlanDriver(object):
237 # req_id. 237 # req_id.
238 if req_id: 238 if req_id:
239 ctxt = context.Context(request_id=req_id, is_admin=True) 239 ctxt = context.Context(request_id=req_id, is_admin=True)
240 self.tunnel_caller.trigger_tunnel_sync(ctxt, target_ip) 240 self.tunnel_caller.trigger_tunnel_sync(ctxt, tunnel_ip)
241 # At last Ucast_Macs_Remote table of other switches. 241 # At last Ucast_Macs_Remote table of other switches.
242 self._update_ucast_macs_remote( 242 self._update_ucast_macs_remote(
243 target_ip, ls_name, mac, tunnel_ip, port_ips) 243 ls_name, mac, tunnel_ip, port_ips, ignore=sw_ip)
244 if save: 244 if save:
245 self.save_all_fossw() 245 self.save_all_fossw()
246 246
247 def _update_ucast_macs_remote(self, target_ip, logical_switch_name, mac, 247 def _update_ucast_macs_remote(self, logical_switch_name, mac, tunnel_ip,
248 tunnel_ip, port_ips): 248 port_ips, ignore=None):
249 """Update Ucast_Macs_Remote table in all FOS switches OVSDB.""" 249 """Update Ucast_Macs_Remote table in all FOS switches OVSDB."""
250 for fossw_ip in self.fossw_ips: 250 for fossw_ip in self.fossw_ips:
251 if target_ip == fossw_ip: 251 if ignore == fossw_ip:
252 continue 252 continue
253 ovsdb_cli = ovsdb_writer.OVSDBWriter(fossw_ip, self.ovsdb_port) 253 ovsdb_cli = ovsdb_writer.OVSDBWriter(fossw_ip, self.ovsdb_port)
254 ls_uuid = ovsdb_cli.get_logical_switch_uuid(logical_switch_name) 254 ls_uuid = ovsdb_cli.get_logical_switch_uuid(logical_switch_name)
diff --git a/networking_fujitsu/tests/unit/ml2/fossw/test_fossw_vxlandriver.py b/networking_fujitsu/tests/unit/ml2/fossw/test_fossw_vxlandriver.py
index 6cea635..3a12434 100644
--- a/networking_fujitsu/tests/unit/ml2/fossw/test_fossw_vxlandriver.py
+++ b/networking_fujitsu/tests/unit/ml2/fossw/test_fossw_vxlandriver.py
@@ -26,7 +26,7 @@ from networking_fujitsu.ml2.fossw import mech_fossw
26from networking_fujitsu.tests.unit.ml2.common.ovsdb import ( 26from networking_fujitsu.tests.unit.ml2.common.ovsdb import (
27 test_base_connection as base_test) 27 test_base_connection as base_test)
28 28
29FOSSW_IPS = ["fake_switch_ip1", "fake_switch_ip2"] 29FOSSW_IPS = ["fake_sw_ip1", "fake_sw_ip2"]
30FAKE_SOCKET = base_test.SocketClass(None, None, None, '{"f_key":"f_value"}') 30FAKE_SOCKET = base_test.SocketClass(None, None, None, '{"f_key":"f_value"}')
31 31
32 32
@@ -43,35 +43,53 @@ class TestFOSSWVxlanDriver(base.BaseTestCase):
43 cfg.CONF.set_override('fossw_ips', FOSSW_IPS, group='fujitsu_fossw') 43 cfg.CONF.set_override('fossw_ips', FOSSW_IPS, group='fujitsu_fossw')
44 cfg.CONF.set_override('tenant_network_types', ['vlan', 'vxlan'], 'ml2') 44 cfg.CONF.set_override('tenant_network_types', ['vlan', 'vxlan'], 'ml2')
45 45
46 self.fake_ovsdb_port = 6640 46 self.fake_ip_mac_pairs = {
47 self.fake_udp_dest_port = 4789 47 'fake_switch_mac1': FOSSW_IPS[0],
48 self.fake_ip_mac_pairs = {'fake_switch_mac1': 'fake_switch_ip1', 48 'fake_switch_mac2': FOSSW_IPS[1]
49 'fake_switch_mac2': 'fake_switch_ip2'} 49 }
50 self.fake_lli = [{'switch_id': 'fake_switch_mac1', 50 self.fake_lli = [{
51 'port_id': '0/2', 51 'switch_id': 'fake_switch_mac1',
52 'switch_info': 'fake_switch_name1'}] 52 'port_id': '0/2',
53 'switch_info': 'fake_switch_name1'
54 }]
53 self.fake_llis = [{'switch_id': 'fake_switch_mac1', 55 self.fake_llis = [{'switch_id': 'fake_switch_mac1',
54 'port_id': '0/2', 56 'port_id': '0/2',
55 'switch_info': 'fake_switch_name1'}, 57 'switch_info': 'fake_switch_name1'},
56 {'switch_id': 'fake_switch_mac1', 58 {'switch_id': 'fake_switch_mac1',
57 'port_id': '0/3', 59 'port_id': '0/3',
58 'switch_info': 'fake_switch_name1'}] 60 'switch_info': 'fake_switch_name1'}]
59 self.fake_port_context = {'network_id': 'aa-bb-cc', 61 self.fake_vni = 11111
60 'mac_address': 'fake_port_mac', 62 self.fake_network_id = '708cc7a2-4e9e-44f7-8bda-f36468b36d6d'
61 'binding:host_id': 'fake_host_id', 63 self.fake_ls_name = '708cc7a24e9e44f78bdaf36468b36d6d'
62 'fixed_ips': [{'ip_address': 64 self.port_mac_address = 'fa:16:3e:50:b6:45'
63 'fake_port_ip1'}, 65 self.tunnel_ip = '10.0.0.1'
64 {'ip_address': 66 self.fixed_ips = [
65 'fake_port_ip2'}]} 67 '172.16.1.1',
66 self.fake_switch_ips = ['fake_switch_ip1', 'fake_switch_ip2'] 68 '172.16.1.2',
67 self.type_vxlan_endpoints = [{'ip_address': 'fake_ip_address1', 69 ]
68 'udp_port': 4789, 70 self.fake_port_context = {
69 'host': 'fake_host_name1'}, 71 'network_id': self.fake_network_id,
70 {'ip_address': 'fake_ip_address2', 72 'mac_address': self.port_mac_address,
71 'udp_port': 4789, 73 'binding:host_id': 'fake_host_id',
72 'host': 'fake_host_name2'}] 74 'fixed_ips': [
73 self.fake_context = mock.MagicMock() 75 {'ip_address': self.fixed_ips[0]},
74 self.fake_request_id = "req-00000000-0000-0000-0000-000000000000" 76 {'ip_address': self.fixed_ips[1]}
77 ]
78 }
79 self.type_vxlan_endpoints = [
80 {
81 'ip_address': 'fake_ep_ip1',
82 'udp_port': 4789,
83 'host': 'fake_hostname1'
84 },
85 {
86 'ip_address': 'fake_ep_ip2',
87 'udp_port': 4789,
88 'host': 'fake_hostname2'
89 }
90 ]
91 self.fake_ctx = mock.Mock()
92 self.fake_req_id = "req-00000000-0000-0000-0000-000000000000"
75 93
76 with mock.patch.object(socket, 'socket', return_value=FAKE_SOCKET), \ 94 with mock.patch.object(socket, 'socket', return_value=FAKE_SOCKET), \
77 mock.patch.object(ovsdb_writer.OVSDBWriter, 95 mock.patch.object(ovsdb_writer.OVSDBWriter,
@@ -83,14 +101,14 @@ class TestFOSSWVxlanDriver(base.BaseTestCase):
83 mock.patch.object(fossw_vxlandriver.FOSSWVxlanDriver, 101 mock.patch.object(fossw_vxlandriver.FOSSWVxlanDriver,
84 '_update_neutron_db', 102 '_update_neutron_db',
85 return_value=None): 103 return_value=None):
86 self.driver = fossw_vxlandriver.FOSSWVxlanDriver() 104 self.vxlan = fossw_vxlandriver.FOSSWVxlanDriver()
87 105
88 def test_save_all_fossw(self): 106 def test_save_all_fossw(self):
89 """Test case to test save_all_fossw.""" 107 """Test case to test save_all_fossw."""
90 self.driver.client = mock.Mock(return_value=None) 108 self.vxlan.client = mock.Mock(return_value=None)
91 self.assertIsNone(self.driver.save_all_fossw()) 109 self.assertIsNone(self.vxlan.save_all_fossw())
92 self.assertEqual(len(FOSSW_IPS), 110 self.assertEqual(len(FOSSW_IPS),
93 self.driver.client.save_running_config.call_count) 111 self.vxlan.client.save_running_config.call_count)
94 112
95 def test_update_neutron_db_insert(self): 113 def test_update_neutron_db_insert(self):
96 """Test case to test _update_neutron_db. 114 """Test case to test _update_neutron_db.
@@ -108,7 +126,7 @@ class TestFOSSWVxlanDriver(base.BaseTestCase):
108 return_value={}) as get_epbi, \ 126 return_value={}) as get_epbi, \
109 mock.patch.object(type_vxlan.TypeVxlan, 127 mock.patch.object(type_vxlan.TypeVxlan,
110 'add_endpoint') as add_ep: 128 'add_endpoint') as add_ep:
111 self.driver._update_neutron_db() 129 self.vxlan._update_neutron_db()
112 get_epbi.assert_called_with('fake_endpoint_ip') 130 get_epbi.assert_called_with('fake_endpoint_ip')
113 add_ep.assert_called_with('fake_endpoint_ip', 131 add_ep.assert_called_with('fake_endpoint_ip',
114 'fake_endpoint_hostname', 4789) 132 'fake_endpoint_hostname', 4789)
@@ -134,7 +152,7 @@ class TestFOSSWVxlanDriver(base.BaseTestCase):
134 'delete_endpoint') as del_ep, \ 152 'delete_endpoint') as del_ep, \
135 mock.patch.object(type_vxlan.TypeVxlan, 153 mock.patch.object(type_vxlan.TypeVxlan,
136 'add_endpoint') as add_ep: 154 'add_endpoint') as add_ep:
137 self.driver._update_neutron_db() 155 self.vxlan._update_neutron_db()
138 get_epbi.assert_called_with('fake_endpoint_ip') 156 get_epbi.assert_called_with('fake_endpoint_ip')
139 del_ep.assert_called_with('fake_endpoint_ip') 157 del_ep.assert_called_with('fake_endpoint_ip')
140 add_ep.assert_called_with('fake_endpoint_ip', 158 add_ep.assert_called_with('fake_endpoint_ip',
@@ -157,7 +175,7 @@ class TestFOSSWVxlanDriver(base.BaseTestCase):
157 'udp_port': 4789, 175 'udp_port': 4789,
158 'host': 'fake_endpoint_hostname'} 176 'host': 'fake_endpoint_hostname'}
159 ) as get_epbi: 177 ) as get_epbi:
160 self.driver._update_neutron_db() 178 self.vxlan._update_neutron_db()
161 get_epbi.assert_called_with('fake_endpoint_ip') 179 get_epbi.assert_called_with('fake_endpoint_ip')
162 180
163 def test_create_logical_switch(self): 181 def test_create_logical_switch(self):
@@ -167,8 +185,9 @@ class TestFOSSWVxlanDriver(base.BaseTestCase):
167 'insert_logical_switch') as ins_ls, \ 185 'insert_logical_switch') as ins_ls, \
168 mock.patch.object(fossw_vxlandriver.FOSSWVxlanDriver, 186 mock.patch.object(fossw_vxlandriver.FOSSWVxlanDriver,
169 'save_all_fossw') as save_all: 187 'save_all_fossw') as save_all:
170 self.driver.create_logical_switch("aa-bb-cc", "fake_vnid") 188 self.vxlan.create_logical_switch(
171 ins_ls.assert_called_with("fake_vnid", "aabbcc") 189 self.fake_network_id, self.fake_vni)
190 ins_ls.assert_called_with(self.fake_vni, self.fake_ls_name)
172 self.assertEqual(1, save_all.call_count) 191 self.assertEqual(1, save_all.call_count)
173 192
174 def test_delete_logical_switch(self): 193 def test_delete_logical_switch(self):
@@ -181,8 +200,8 @@ class TestFOSSWVxlanDriver(base.BaseTestCase):
181 'delete_logical_switch') as del_ls, \ 200 'delete_logical_switch') as del_ls, \
182 mock.patch.object(fossw_vxlandriver.FOSSWVxlanDriver, 201 mock.patch.object(fossw_vxlandriver.FOSSWVxlanDriver,
183 'save_all_fossw') as save_all: 202 'save_all_fossw') as save_all:
184 self.driver.delete_logical_switch("aa-bb-cc") 203 self.vxlan.delete_logical_switch(self.fake_network_id)
185 get_lsuuid.assert_called_with("aabbcc") 204 get_lsuuid.assert_called_with(self.fake_ls_name)
186 del_ls.assert_called_with("fake_uuid") 205 del_ls.assert_called_with("fake_uuid")
187 self.assertEqual(1, save_all.call_count) 206 self.assertEqual(1, save_all.call_count)
188 207
@@ -191,7 +210,7 @@ class TestFOSSWVxlanDriver(base.BaseTestCase):
191 with mock.patch.object(socket, 'socket', return_value=FAKE_SOCKET), \ 210 with mock.patch.object(socket, 'socket', return_value=FAKE_SOCKET), \
192 mock.patch.object(type_vxlan.TypeVxlan, 211 mock.patch.object(type_vxlan.TypeVxlan,
193 'db_get_endpoint_ip_by_host', 212 'db_get_endpoint_ip_by_host',
194 return_value='fake_target_tunnel_ip' 213 return_value=self.tunnel_ip
195 ) as get_epbh, \ 214 ) as get_epbh, \
196 mock.patch.object(ovsdb_writer.OVSDBWriter, 215 mock.patch.object(ovsdb_writer.OVSDBWriter,
197 'get_logical_switch_uuid', 216 'get_logical_switch_uuid',
@@ -230,35 +249,39 @@ class TestFOSSWVxlanDriver(base.BaseTestCase):
230 'trigger_tunnel_sync') as tun_sync, \ 249 'trigger_tunnel_sync') as tun_sync, \
231 mock.patch( 250 mock.patch(
232 'networking_fujitsu.ml2.fossw.fossw_vxlandriver.context.' 251 'networking_fujitsu.ml2.fossw.fossw_vxlandriver.context.'
233 'Context', return_value=self.fake_context): 252 'Context', return_value=self.fake_ctx):
234 self.driver.update_physical_port("fake_vnid", self.fake_lli, 253 self.vxlan.update_physical_port(self.fake_vni, self.fake_lli,
235 self.fake_port_context, 254 self.fake_port_context,
236 self.fake_ip_mac_pairs, 255 self.fake_ip_mac_pairs,
237 req_id=self.fake_request_id) 256 req_id=self.fake_req_id)
238 get_epbh.assert_called_with('fake_switch_name1') 257 get_epbh.assert_called_with('fake_switch_name1')
239 get_ls_uuid.assert_called_with("aabbcc") 258 get_ls_uuid.assert_called_with(self.fake_ls_name)
240 get_bvid.assert_called_with("fake_uuid") 259 get_bvid.assert_called_with("fake_uuid")
241 up_pp.assert_called_with("0/2", 3, "fake_uuid") 260 up_pp.assert_called_with("0/2", 3, "fake_uuid")
242 get_uml.assert_called_with('fake_port_mac') 261 get_uml.assert_called_with(self.port_mac_address)
243 del_uml.assert_called_with('fake_port_mac') 262 del_uml.assert_called_with(self.port_mac_address)
244 self.assertEqual(1, get_sepi.call_count) 263 get_sepi.assert_called_once()
245 get_pluuid.assert_called_with("fake_locator_ip_local") 264 get_pluuid.assert_called_with("fake_locator_ip_local")
246 ins_uml.assert_called_with("fake_uuid", 265 ins_uml.assert_called_with("fake_uuid",
247 "fake_locator_uuid_local", 266 "fake_locator_uuid_local",
248 "fake_port_mac") 267 self.port_mac_address)
249 self.assertFalse(ins_umlal.called) 268 ins_umlal.assert_not_called()
250 _up_umr.assert_called_with( 269 _up_umr.assert_called_with(
251 'fake_switch_ip1', 'aabbcc', 'fake_port_mac', 270 self.fake_ls_name,
252 'fake_target_tunnel_ip', ['fake_port_ip1', 'fake_port_ip2']) 271 self.port_mac_address,
253 self.assertEqual(1, _save.call_count) 272 self.tunnel_ip,
254 tun_sync.assert_called_with(self.fake_context, 'fake_switch_ip1') 273 self.fixed_ips,
274 ignore=FOSSW_IPS[0]
275 )
276 _save.assert_called_once()
277 tun_sync.assert_called_once_with(self.fake_ctx, self.tunnel_ip)
255 278
256 def test_update_physical_port_without_request_id(self): 279 def test_update_physical_port_without_request_id(self):
257 """Test case to test update_physical_port.""" 280 """Test case to test update_physical_port."""
258 with mock.patch.object(socket, 'socket', return_value=FAKE_SOCKET), \ 281 with mock.patch.object(socket, 'socket', return_value=FAKE_SOCKET), \
259 mock.patch.object(type_vxlan.TypeVxlan, 282 mock.patch.object(type_vxlan.TypeVxlan,
260 'db_get_endpoint_ip_by_host', 283 'db_get_endpoint_ip_by_host',
261 return_value='fake_target_tunnel_ip' 284 return_value=self.tunnel_ip
262 ) as get_epbh, \ 285 ) as get_epbh, \
263 mock.patch.object(ovsdb_writer.OVSDBWriter, 286 mock.patch.object(ovsdb_writer.OVSDBWriter,
264 'get_logical_switch_uuid', 287 'get_logical_switch_uuid',
@@ -297,26 +320,30 @@ class TestFOSSWVxlanDriver(base.BaseTestCase):
297 'trigger_tunnel_sync') as tun_sync, \ 320 'trigger_tunnel_sync') as tun_sync, \
298 mock.patch( 321 mock.patch(
299 'networking_fujitsu.ml2.fossw.fossw_vxlandriver.context.' 322 'networking_fujitsu.ml2.fossw.fossw_vxlandriver.context.'
300 'Context', return_value=self.fake_context): 323 'Context', return_value=self.fake_ctx):
301 self.driver.update_physical_port("fake_vnid", self.fake_lli, 324 self.vxlan.update_physical_port(self.fake_vni, self.fake_lli,
302 self.fake_port_context, 325 self.fake_port_context,
303 self.fake_ip_mac_pairs) 326 self.fake_ip_mac_pairs)
304 get_epbh.assert_called_with('fake_switch_name1') 327 get_epbh.assert_called_with('fake_switch_name1')
305 get_ls_uuid.assert_called_with("aabbcc") 328 get_ls_uuid.assert_called_with(self.fake_ls_name)
306 get_bvid.assert_called_with("fake_uuid") 329 get_bvid.assert_called_with("fake_uuid")
307 up_pp.assert_called_with("0/2", 3, "fake_uuid") 330 up_pp.assert_called_with("0/2", 3, "fake_uuid")
308 get_uml.assert_called_with('fake_port_mac') 331 get_uml.assert_called_with(self.port_mac_address)
309 del_uml.assert_called_with('fake_port_mac') 332 del_uml.assert_called_with(self.port_mac_address)
310 self.assertEqual(1, get_sepi.call_count) 333 get_sepi.assert_called_once()
311 get_pluuid.assert_called_with("fake_locator_ip_local") 334 get_pluuid.assert_called_with("fake_locator_ip_local")
312 ins_uml.assert_called_with("fake_uuid", 335 ins_uml.assert_called_with("fake_uuid",
313 "fake_locator_uuid_local", 336 "fake_locator_uuid_local",
314 "fake_port_mac") 337 self.port_mac_address)
315 self.assertFalse(ins_umlal.called) 338 ins_umlal.assert_not_called()
316 _up_umr.assert_called_with( 339 _up_umr.assert_called_with(
317 'fake_switch_ip1', 'aabbcc', 'fake_port_mac', 340 self.fake_ls_name,
318 'fake_target_tunnel_ip', ['fake_port_ip1', 'fake_port_ip2']) 341 self.port_mac_address,
319 self.assertEqual(1, _save.call_count) 342 self.tunnel_ip,
343 self.fixed_ips,
344 ignore=FOSSW_IPS[0]
345 )
346 _save.assert_called_once()
320 tun_sync.assert_not_called() 347 tun_sync.assert_not_called()
321 348
322 def test_update_ucast_macs_remote(self): 349 def test_update_ucast_macs_remote(self):
@@ -340,16 +367,19 @@ class TestFOSSWVxlanDriver(base.BaseTestCase):
340 'insert_ucast_macs_remote_and_locator' 367 'insert_ucast_macs_remote_and_locator'
341 ) as ins_umral: 368 ) as ins_umral:
342 369
343 self.driver._update_ucast_macs_remote( 370 self.vxlan._update_ucast_macs_remote(
344 'fake_switch_ip1', 'logical_switch_name', 'fake_port_mac', 371 self.fake_ls_name,
345 'fake_target_tunnel_ip', ['fake_port_ips']) 372 self.port_mac_address,
346 get_lsuuid.assert_called_with('logical_switch_name') 373 self.tunnel_ip,
347 get_umr.assert_called_with('fake_port_mac') 374 self.fixed_ips
348 del_umr.assert_called_with('fake_port_mac') 375 )
349 get_pluuid.assert_called_with('fake_target_tunnel_ip') 376 get_lsuuid.assert_called_with(self.fake_ls_name)
350 ins_umr.assert_called_with('fake_ls_uuid', 'fake_port_mac', 377 get_umr.assert_called_with(self.port_mac_address)
351 ['fake_port_ips'], 'fake_locator_uuid') 378 del_umr.assert_called_with(self.port_mac_address)
352 self.assertFalse(ins_umral.called) 379 get_pluuid.assert_called_with(self.tunnel_ip)
380 ins_umr.assert_called_with('fake_ls_uuid', self.port_mac_address,
381 self.fixed_ips, 'fake_locator_uuid')
382 ins_umral.assert_not_called()
353 383
354 def test_update_ucast_macs_remote_with_locator(self): 384 def test_update_ucast_macs_remote_with_locator(self):
355 """Test case to test _update_ucast_macs_remote. 385 """Test case to test _update_ucast_macs_remote.
@@ -376,17 +406,20 @@ class TestFOSSWVxlanDriver(base.BaseTestCase):
376 'insert_ucast_macs_remote_and_locator' 406 'insert_ucast_macs_remote_and_locator'
377 ) as ins_umral: 407 ) as ins_umral:
378 408
379 self.driver._update_ucast_macs_remote( 409 self.vxlan._update_ucast_macs_remote(
380 'fake_switch_ip1', 'aabbcc', 'fake_port_mac', 410 'fake_sw_ip1',
381 'fake_target_tunnel_ip', ['fake_port_ips']) 411 self.port_mac_address,
382 get_lsuuid.assert_called_with('aabbcc') 412 self.tunnel_ip,
383 get_umr.assert_called_with('fake_port_mac') 413 ['fake_port_ips']
384 del_umr.assert_called_with('fake_port_mac') 414 )
385 get_pluuid.assert_called_with('fake_target_tunnel_ip') 415 get_lsuuid.assert_called_with('fake_sw_ip1')
386 self.assertFalse(ins_umr.called) 416 get_umr.assert_called_with(self.port_mac_address)
387 ins_umral.assert_called_with('fake_ls_uuid', 'fake_port_mac', 417 del_umr.assert_called_with(self.port_mac_address)
418 get_pluuid.assert_called_with(self.tunnel_ip)
419 ins_umr.assert_not_called()
420 ins_umral.assert_called_with('fake_ls_uuid', self.port_mac_address,
388 ['fake_port_ips'], 421 ['fake_port_ips'],
389 'fake_target_tunnel_ip') 422 self.tunnel_ip)
390 423
391 def test_reset_physical_port(self): 424 def test_reset_physical_port(self):
392 """Test case to test reset_physical_port.""" 425 """Test case to test reset_physical_port."""
@@ -399,41 +432,41 @@ class TestFOSSWVxlanDriver(base.BaseTestCase):
399 'delete_ucast_macs_remote') as del_umr, \ 432 'delete_ucast_macs_remote') as del_umr, \
400 mock.patch.object(fossw_vxlandriver.FOSSWVxlanDriver, 433 mock.patch.object(fossw_vxlandriver.FOSSWVxlanDriver,
401 'save_all_fossw') as _save: 434 'save_all_fossw') as _save:
402 self.driver.reset_physical_port(self.fake_lli, 435 self.vxlan.reset_physical_port(self.fake_lli,
403 self.fake_port_context, 436 self.fake_port_context,
404 self.fake_ip_mac_pairs) 437 self.fake_ip_mac_pairs)
405 res_pp.assert_called_with("0/2") 438 res_pp.assert_called_with("0/2")
406 del_uml.assert_called_with("fake_port_mac") 439 del_uml.assert_called_with(self.port_mac_address)
407 del_umr.assert_called_with("fake_port_mac") 440 del_umr.assert_called_with(self.port_mac_address)
408 self.assertTrue(_save.called) 441 _save.assert_called_once()
409 442
410 def test_update_physical_port_with_lag(self): 443 def test_update_physical_port_with_lag(self):
411 """Test case to test update_physical_port_with_lag.""" 444 """Test case to test update_physical_port_with_lag."""
412 with mock.patch.object(fossw_vxlandriver.FOSSWVxlanDriver, 445 with mock.patch.object(fossw_vxlandriver.FOSSWVxlanDriver,
413 'update_physical_port') as up_pp: 446 'update_physical_port') as up_pp:
414 self.driver.update_physical_port_with_lag('fake_vnid', 447 self.vxlan.update_physical_port_with_lag('fake_vnid',
415 self.fake_llis, 448 self.fake_llis,
416 self.fake_port_context, 449 self.fake_port_context,
417 self.fake_ip_mac_pairs, 450 self.fake_ip_mac_pairs,
418 self.fake_request_id, 451 self.fake_req_id,
419 mac_lag_map={}) 452 mac_lag_map={})
420 self.assertEqual(2, up_pp.call_count) 453 self.assertEqual(2, up_pp.call_count)
421 for idx, arg in enumerate(up_pp.call_args_list): 454 for idx, arg in enumerate(up_pp.call_args_list):
422 self.assertEqual('fake_vnid', arg[0][0]) 455 self.assertEqual('fake_vnid', arg[0][0])
423 self.assertEqual([self.fake_llis[idx]], arg[0][1]) 456 self.assertEqual([self.fake_llis[idx]], arg[0][1])
424 self.assertEqual(self.fake_port_context, arg[0][2]) 457 self.assertEqual(self.fake_port_context, arg[0][2])
425 self.assertEqual(self.fake_ip_mac_pairs, arg[0][3]) 458 self.assertEqual(self.fake_ip_mac_pairs, arg[0][3])
426 self.assertEqual(self.fake_request_id, arg[0][4]) 459 self.assertEqual(self.fake_req_id, arg[0][4])
427 self.assertEqual({'mac_lag_map': {}}, arg[1]) 460 self.assertEqual({'mac_lag_map': {}}, arg[1])
428 461
429 def test_reset_physical_port_with_lag(self): 462 def test_reset_physical_port_with_lag(self):
430 """Test case to test reset_physical_port_with_lag.""" 463 """Test case to test reset_physical_port_with_lag."""
431 with mock.patch.object(fossw_vxlandriver.FOSSWVxlanDriver, 464 with mock.patch.object(fossw_vxlandriver.FOSSWVxlanDriver,
432 'reset_physical_port') as res_pp: 465 'reset_physical_port') as res_pp:
433 self.driver.reset_physical_port_with_lag(self.fake_llis, 466 self.vxlan.reset_physical_port_with_lag(self.fake_llis,
434 self.fake_port_context, 467 self.fake_port_context,
435 self.fake_ip_mac_pairs, 468 self.fake_ip_mac_pairs,
436 mac_lag_map={}) 469 mac_lag_map={})
437 self.assertEqual(2, res_pp.call_count) 470 self.assertEqual(2, res_pp.call_count)
438 for idx, arg in enumerate(res_pp.call_args_list): 471 for idx, arg in enumerate(res_pp.call_args_list):
439 self.assertEqual([self.fake_llis[idx]], arg[0][0]) 472 self.assertEqual([self.fake_llis[idx]], arg[0][0])