Fujitsu Neutron Plugin
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

580 lines
23KB

  1. # Copyright 2017 FUJITSU LIMITED
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  12. # implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. import mock
  16. from neutron.conf.plugins.ml2 import config
  17. from neutron.plugins.ml2.common import exceptions as ml2_exc
  18. from oslo_config import cfg
  19. from oslo_utils import importutils
  20. from networking_fujitsu.ml2.fossw import fossw_vlandriver
  21. from networking_fujitsu.ml2.fossw import mech_fossw
  22. from networking_fujitsu.tests.unit.ml2.common import helper
  23. ADDRESS = '192.168.100.1'
  24. ADDRESS2 = '192.168.100.2'
  25. USERNAME = 'fossw_user'
  26. PASSWORD = 'fossw_password'
  27. class TestFujitsuMechDriverV2(helper.FujitsuMechanismHelper):
  28. """Test Fujitsu mechanism driver.
  29. """
  30. _mechanism_drivers = ['fujitsu_fossw']
  31. _skip = ["test_create_router_port_and_fail_create_postcommit"]
  32. def setUp(self):
  33. config.cfg.CONF.set_override(
  34. 'tenant_network_types', ['vlan', 'vxlan'], 'ml2')
  35. if self._testMethodName in self._skip:
  36. self.skipTest("This test has already verified at neutron's test.")
  37. def mocked_initialize(self):
  38. self.ips = [ADDRESS, ADDRESS2]
  39. self.username = USERNAME
  40. self.password = PASSWORD
  41. self._vlan_driver = mock.Mock()
  42. self._vxlan_driver = mock.Mock()
  43. self.switches_mac_ip_pair = {
  44. "00:00:4c:ee:e5:39": ADDRESS,
  45. "00:00:4c:ee:e5:40": ADDRESS2,
  46. }
  47. with mock.patch.object(mech_fossw.FOSSWMechanismDriver,
  48. 'initialize', new=mocked_initialize):
  49. self.mech = mech_fossw.FOSSWMechanismDriver()
  50. super(TestFujitsuMechDriverV2, self).setUp()
  51. class TestFOSSWInitialize(helper.FujitsuMechanismHelper):
  52. def setUp(self):
  53. super(TestFOSSWInitialize, self).setUp()
  54. config.cfg.CONF.set_override(
  55. 'tenant_network_types', ['vlan', 'vxlan'], 'ml2')
  56. config.cfg.CONF.set_override(
  57. 'username', 'admin', 'fujitsu_fossw')
  58. config.cfg.CONF.set_override(
  59. 'password', 'password', 'fujitsu_fossw')
  60. config.cfg.CONF.set_override(
  61. 'fossw_ips', [ADDRESS, ADDRESS2], 'fujitsu_fossw')
  62. importutils.import_object = mock.Mock()
  63. fossw_vlandriver.FOSSWVlanDriver().get_switch_mac_ip_pair = mock.Mock()
  64. def test_initialize_success(self):
  65. self.mech = mech_fossw.FOSSWMechanismDriver()
  66. self.assertEqual('admin', self.mech.username)
  67. self.assertEqual('password', self.mech.password)
  68. self.assertEqual('password', self.mech.password)
  69. self.assertEqual(
  70. mech_fossw.FOSSW_VLAN_DRIVER,
  71. importutils.import_object.call_args_list[0][0][0])
  72. self.assertEqual(
  73. config.cfg.CONF,
  74. importutils.import_object.call_args_list[0][0][1])
  75. self.assertEqual(
  76. mech_fossw.FOSSW_VXLAN_DRIVER,
  77. importutils.import_object.call_args_list[1][0][0])
  78. self.assertEqual(
  79. config.cfg.CONF,
  80. importutils.import_object.call_args_list[1][0][1])
  81. self.mech._vlan_driver.get_switch_mac_ip_pair.assert_called_once_with(
  82. [ADDRESS, ADDRESS2])
  83. def test_initialize_with_no_ips(self):
  84. config.cfg.CONF.set_override(
  85. 'fossw_ips', [], 'fujitsu_fossw')
  86. self.assertRaises(
  87. cfg.RequiredOptError,
  88. mech_fossw.FOSSWMechanismDriver)
  89. class TestFOSSWNetwork(TestFujitsuMechDriverV2):
  90. def setUp(self):
  91. super(TestFOSSWNetwork, self).setUp()
  92. def test_create_network(self):
  93. ctx = self.prepare_dummy_context('network')
  94. self.mech.create_network_postcommit(ctx)
  95. self.mech._vlan_driver.create_vlan.assert_called()
  96. self.mech._vxlan_driver.create_logical_switch.assert_not_called()
  97. self.assertEqual(2, self.mech._vlan_driver.create_vlan.call_count)
  98. def test_delete_network(self):
  99. ctx = self.prepare_dummy_context('network')
  100. self.mech.delete_network_postcommit(ctx)
  101. self.mech._vlan_driver.delete_vlan.assert_called()
  102. self.mech._vxlan_driver.delete_logical_switch.assert_not_called()
  103. self.assertEqual(2, self.mech._vlan_driver.delete_vlan.call_count)
  104. def test_create_network_raises_create_vlan(self):
  105. ctx = self.prepare_dummy_context('network')
  106. self.mech._vlan_driver.create_vlan.side_effect = Exception
  107. self.assertRaises(
  108. ml2_exc.MechanismDriverError,
  109. self.mech.create_network_postcommit, ctx
  110. )
  111. def test_delete_network_raises_delete_vlan(self):
  112. ctx = self.prepare_dummy_context('network')
  113. self.mech._vlan_driver.delete_vlan.side_effect = Exception
  114. self.assertRaises(
  115. ml2_exc.MechanismDriverError,
  116. self.mech.delete_network_postcommit, ctx
  117. )
  118. class TestFOSSWBaremetalPortsVlan(TestFujitsuMechDriverV2):
  119. def setUp(self):
  120. super(TestFOSSWBaremetalPortsVlan, self).setUp()
  121. def test_create_port(self):
  122. ctx = self.prepare_dummy_context()
  123. self.mech.create_port_postcommit(ctx)
  124. self.mech._vxlan_driver.update_physical_port.assert_not_called()
  125. self.mech._vlan_driver.setup_vlan.assert_not_called()
  126. def test_bind_port_with_single(self):
  127. ctx = self.prepare_dummy_context()
  128. self.mech.bind_port(ctx)
  129. params = params_for_driver(ctx.current)
  130. self.mech._vlan_driver.setup_vlan.assert_called_once_with(
  131. params['segmentation_id'],
  132. params['local_link_info'],
  133. self.mech.switches_mac_ip_pair
  134. )
  135. def test_bind_port_with_single_raises_setup_vlan(self):
  136. ctx = self.prepare_dummy_context()
  137. self.mech._vlan_driver.setup_vlan.side_effect = Exception
  138. self.assertRaises(
  139. ml2_exc.MechanismDriverError,
  140. self.mech.bind_port, ctx)
  141. def test_bind_port_with_lag(self):
  142. ctx = self.prepare_dummy_context(nic='lag')
  143. self.mech.bind_port(ctx)
  144. params = params_for_driver(ctx.current, lag=True)
  145. self.mech._vlan_driver.setup_lag.assert_called_once_with(
  146. params['local_link_info'],
  147. self.mech.switches_mac_ip_pair,
  148. vlanid=params['segmentation_id'],
  149. )
  150. def test_bind_port_with_lag_raises_setup_lag(self):
  151. ctx = self.prepare_dummy_context(nic='lag')
  152. self.mech._vlan_driver.setup_lag.side_effect = Exception
  153. self.assertRaises(
  154. ml2_exc.MechanismDriverError,
  155. self.mech.bind_port, ctx)
  156. def test_bind_port_with_mlag(self):
  157. ctx = self.prepare_dummy_context(nic='mlag')
  158. self.mech.bind_port(ctx)
  159. params = params_for_driver(ctx.current, lag=True)
  160. self.mech._vlan_driver.setup_lag.assert_called_once_with(
  161. params['local_link_info'],
  162. self.mech.switches_mac_ip_pair,
  163. vlanid=params['segmentation_id'],
  164. )
  165. def test_bind_port_with_flat(self):
  166. ctx = self.prepare_dummy_context(net_type='flat')
  167. self.mech.bind_port(ctx)
  168. self.mech._vlan_driver.setup_vlan.assert_not_called()
  169. self.mech._vxlan_driver.update_physical_port.assert_not_called()
  170. def test_update_port(self):
  171. ctx = self.prepare_dummy_context(vif_type='other')
  172. self.mech.update_port_postcommit(ctx)
  173. self.mech._vlan_driver.clear_vlan.assert_not_called()
  174. def test_update_port_for_baremetal_with_unbound(self):
  175. ctx = self.prepare_dummy_context(vif_type='unbound', set_original=True)
  176. self.mech.update_port_postcommit(ctx)
  177. params = params_for_driver(ctx.original)
  178. self.mech._vlan_driver.clear_vlan.assert_called_with(
  179. params['local_link_info'],
  180. self.mech.switches_mac_ip_pair
  181. )
  182. def test_update_port_for_baremetal_with_unbound_and_lag(self):
  183. ctx = self.prepare_dummy_context(
  184. vif_type='unbound', set_original=True, nic='lag')
  185. self.mech.update_port_postcommit(ctx)
  186. params = params_for_driver(ctx.original)
  187. self.mech._vlan_driver.clear_lag.assert_called_once_with(
  188. params['local_link_info'],
  189. self.mech.switches_mac_ip_pair)
  190. def test_update_port_for_baremetal_with_unbound_flat(self):
  191. ctx = self.prepare_dummy_context(net_type='flat', vif_type='other',
  192. set_original=True)
  193. self.mech.update_port_postcommit(ctx)
  194. self.mech._vlan_driver.clear_vlan.assert_not_called()
  195. def test_update_port_with_bound_not_baremetal(self):
  196. ctx = self.prepare_dummy_context(vif_type='normal', vnic_type='ovs')
  197. self.mech.update_port_postcommit(ctx)
  198. self.mech._vlan_driver.associate_mac_to_network.assert_not_called()
  199. def test_delete_port_with_no_local_link_information(self):
  200. ctx = self.prepare_dummy_context(nic='single')
  201. ctx.current['binding:profile'] = {}
  202. self.mech.delete_port_postcommit(ctx)
  203. self.mech._vlan_driver.clear_vlan.assert_not_called()
  204. def test_delete_port_with_single(self):
  205. ctx = self.prepare_dummy_context(nic='single')
  206. self.mech.delete_port_postcommit(ctx)
  207. params = params_for_driver(ctx.current)
  208. self.mech._vlan_driver.clear_vlan.assert_called_with(
  209. params['local_link_info'],
  210. self.mech.switches_mac_ip_pair
  211. )
  212. def test_delete_with_lag(self):
  213. ctx = self.prepare_dummy_context(nic='lag')
  214. self.mech.delete_port_postcommit(ctx)
  215. params = params_for_driver(ctx.current, lag=True)
  216. self.mech._vlan_driver.clear_lag.assert_called_with(
  217. params['local_link_info'],
  218. self.mech.switches_mac_ip_pair
  219. )
  220. def test_delete_with_mlag(self):
  221. ctx = self.prepare_dummy_context(nic='mlag')
  222. self.mech.delete_port_postcommit(ctx)
  223. params = params_for_driver(ctx.current, lag=True)
  224. self.mech._vlan_driver.clear_lag.assert_called_with(
  225. params['local_link_info'],
  226. self.mech.switches_mac_ip_pair
  227. )
  228. def test_delete_port_with_normal(self):
  229. ctx = self.prepare_dummy_context(vnic_type='normal')
  230. self.mech.delete_port_postcommit(ctx)
  231. self.mech._vlan_driver.clear_vlan.assert_not_called()
  232. def test_delete_port_raises_driver_clear_vlan(self):
  233. self.mech._vlan_driver.clear_vlan.side_effect = Exception
  234. ctx = self.prepare_dummy_context(nic='single')
  235. self.assertRaises(
  236. ml2_exc.MechanismDriverError,
  237. self.mech.delete_port_postcommit, ctx)
  238. self.mech._vxlan_driver.reset_physical_port.assert_not_called()
  239. def test_delete_with_lag_raises_clear_lag(self):
  240. self.mech._vlan_driver.clear_lag.side_effect = Exception
  241. ctx = self.prepare_dummy_context(nic='lag')
  242. self.assertRaises(
  243. ml2_exc.MechanismDriverError,
  244. self.mech.delete_port_postcommit, ctx)
  245. self.mech._vxlan_driver.reset_physical_port.assert_not_called()
  246. def params_for_driver(port, lag=False):
  247. return {
  248. 'local_link_info': port['binding:profile']['local_link_information'],
  249. 'segmentation_id': 1111,
  250. 'mac': port['mac_address'],
  251. 'lag': lag
  252. }
  253. class TestFOSSWIsSupported(TestFujitsuMechDriverV2):
  254. def setUp(self):
  255. super(TestFOSSWIsSupported, self).setUp()
  256. def test_is_supported_not_support_type(self):
  257. ctx = self.prepare_dummy_context('network', net_type='flat')
  258. network = ctx.current
  259. self.assertFalse(mech_fossw.is_supported(network))
  260. def test_is_supported_illegal_seg_id_is_none(self):
  261. ctx = self.prepare_dummy_context('network', net_type='vlan')
  262. network = ctx.current
  263. ctx.current['provider:segmentation_id'] = None
  264. self.assertFalse(mech_fossw.is_supported(network))
  265. def test_is_supported_illegal_seg_id_is_not_defined(self):
  266. ctx = self.prepare_dummy_context('network', net_type='vlan')
  267. network = ctx.current
  268. del network['provider:segmentation_id']
  269. self.assertFalse(mech_fossw.is_supported(network))
  270. class TestFOSSWBaremetalPortsVxlan(TestFujitsuMechDriverV2):
  271. def setUp(self):
  272. super(TestFOSSWBaremetalPortsVxlan, self).setUp()
  273. def test_is_supported_not_support_type(self):
  274. ctx = self.prepare_dummy_context('network', net_type='flat')
  275. network = ctx.current
  276. self.assertFalse(mech_fossw.is_supported(network))
  277. def test_is_supported_illegal_seg_id_is_none(self):
  278. ctx = self.prepare_dummy_context('network', net_type='flat')
  279. network = ctx.current
  280. ctx.current['provider:segmentation_id'] = None
  281. self.assertFalse(mech_fossw.is_supported(network))
  282. def test_is_supported_illegal_seg_id_is_not_defined(self):
  283. ctx = self.prepare_dummy_context('network', net_type='flat')
  284. network = ctx.current
  285. self.assertFalse(mech_fossw.is_supported(network))
  286. def test_create_network(self):
  287. ctx = self.prepare_dummy_context('network', net_type='vxlan')
  288. self.mech.create_network_postcommit(ctx)
  289. self.mech._vlan_driver.create_vlan.assert_not_called()
  290. net_id = ctx.current['id']
  291. vni = ctx.current['provider:segmentation_id']
  292. self.mech._vxlan_driver.create_logical_switch.assert_called_with(
  293. net_id, vni)
  294. def test_delete_network(self):
  295. ctx = self.prepare_dummy_context('network', net_type='vxlan')
  296. self.mech.delete_network_postcommit(ctx)
  297. net_id = ctx.current['id']
  298. self.mech._vlan_driver.delete_vlan.assert_not_called()
  299. self.mech._vxlan_driver.delete_logical_switch.assert_called_with(
  300. net_id)
  301. def test_create_network_raises_create_logical_switch(self):
  302. ctx = self.prepare_dummy_context('network', net_type='vxlan')
  303. self.mech._vxlan_driver.create_logical_switch.side_effect = Exception
  304. self.assertRaises(
  305. ml2_exc.MechanismDriverError,
  306. self.mech.create_network_postcommit, ctx
  307. )
  308. def test_delete_network_raises_delete_logical_switch(self):
  309. ctx = self.prepare_dummy_context('network', net_type='vxlan')
  310. self.mech._vxlan_driver.delete_logical_switch.side_effect = Exception
  311. self.assertRaises(
  312. ml2_exc.MechanismDriverError,
  313. self.mech.delete_network_postcommit, ctx
  314. )
  315. def test_create_port(self):
  316. ctx = self.prepare_dummy_context(net_type='vxlan')
  317. self.mech.create_port_postcommit(ctx)
  318. self.mech._vlan_driver.setup_vlan.assert_not_called()
  319. self.mech._vxlan_driver.update_physical_port.assert_not_called()
  320. def test_bind_port_with_single(self):
  321. ctx = self.prepare_dummy_context(net_type='vxlan')
  322. self.mech.bind_port(ctx)
  323. params = params_for_driver(ctx.current)
  324. self.mech._vxlan_driver.update_physical_port.assert_called_once_with(
  325. params['segmentation_id'],
  326. params['local_link_info'],
  327. ctx.current,
  328. self.mech.switches_mac_ip_pair,
  329. ctx.network._plugin_context.request_id
  330. )
  331. def test_bind_port_with_lag(self):
  332. ctx = self.prepare_dummy_context(net_type='vxlan', nic='lag')
  333. self.mech._vlan_driver.setup_lag.return_value = {}
  334. params = params_for_driver(ctx.current, lag=True)
  335. self.mech.bind_port(ctx)
  336. self.mech._vlan_driver.setup_lag.assert_called_once_with(
  337. params['local_link_info'],
  338. self.mech.switches_mac_ip_pair)
  339. target = self.mech._vxlan_driver.update_physical_port_with_lag
  340. target.assert_called_once_with(
  341. params['segmentation_id'],
  342. params['local_link_info'],
  343. ctx.current,
  344. self.mech.switches_mac_ip_pair,
  345. ctx.network._plugin_context.request_id,
  346. mac_lag_map={})
  347. def test_bind_port_with_mlag(self):
  348. ctx = self.prepare_dummy_context(net_type='vxlan', nic='mlag')
  349. self.mech._vlan_driver.setup_lag.return_value = {}
  350. params = params_for_driver(ctx.current, lag=True)
  351. self.mech.bind_port(ctx)
  352. self.mech._vlan_driver.setup_lag.assert_called_once_with(
  353. params['local_link_info'],
  354. self.mech.switches_mac_ip_pair)
  355. target = self.mech._vxlan_driver.update_physical_port_with_lag
  356. target.assert_called_once_with(
  357. params['segmentation_id'],
  358. params['local_link_info'],
  359. ctx.current,
  360. self.mech.switches_mac_ip_pair,
  361. ctx.network._plugin_context.request_id,
  362. mac_lag_map={})
  363. def test_bind_port_with_lag_raises_driver_method(self):
  364. ctx = self.prepare_dummy_context(net_type='vxlan', nic='lag')
  365. self.mech._vxlan_driver.update_physical_port_with_lag.side_effect = \
  366. Exception
  367. self.assertRaises(
  368. ml2_exc.MechanismDriverError,
  369. self.mech.bind_port, ctx)
  370. def test_update_port(self):
  371. ctx = self.prepare_dummy_context(net_type='vxlan', vif_type='other')
  372. self.mech.update_port_postcommit(ctx)
  373. self.mech._vxlan_driver.reset_physical_port.assert_not_called()
  374. def test_update_port_with_flat(self):
  375. ctx = self.prepare_dummy_context(net_type='flat', vif_type='other')
  376. self.mech.update_port_postcommit(ctx)
  377. self.mech._vxlan_driver.update_physical_port.assert_not_called()
  378. def test_update_port_with_bound(self):
  379. ctx = self.prepare_dummy_context(net_type='vxlan', vif_type='normal')
  380. self.mech.update_port_postcommit(ctx)
  381. self.mech._vxlan_driver.update_physical_port.assert_not_called()
  382. def test_update_port_for_baremetal_with_unbound(self):
  383. ctx = self.prepare_dummy_context(net_type='vxlan', vif_type='unbound',
  384. set_original=True)
  385. self.mech.update_port_postcommit(ctx)
  386. params = params_for_driver(ctx.original)
  387. self.mech._vxlan_driver.reset_physical_port.assert_called_with(
  388. params['local_link_info'],
  389. ctx.original,
  390. self.mech.switches_mac_ip_pair
  391. )
  392. def test_update_port_for_baremetal_with_unbound_and_lag(self):
  393. ctx = self.prepare_dummy_context(
  394. net_type='vxlan', vif_type='unbound', set_original=True, nic='lag')
  395. self.mech._vlan_driver.clear_lag.return_value = {}
  396. params = params_for_driver(ctx.original)
  397. self.mech.update_port_postcommit(ctx)
  398. self.mech._vlan_driver.clear_lag.assert_called_once_with(
  399. params['local_link_info'],
  400. self.mech.switches_mac_ip_pair)
  401. target = self.mech._vxlan_driver.reset_physical_port_with_lag
  402. target.assert_called_with(
  403. params['local_link_info'],
  404. ctx.original,
  405. self.mech.switches_mac_ip_pair, mac_lag_map={})
  406. def test_update_port_for_baremetal_with_unbound_flat(self):
  407. ctx = self.prepare_dummy_context(net_type='flat', vif_type='other',
  408. set_original=True)
  409. self.mech.clear_vxlan = mock.Mock()
  410. self.mech.update_port_postcommit(ctx)
  411. self.mech.clear_vxlan.assert_not_called()
  412. def test_update_port_with_bound_not_baremetal(self):
  413. ctx = self.prepare_dummy_context(
  414. net_type='vxlan', vif_type='normal', vnic_type='ovs')
  415. self.mech.update_port_postcommit(ctx)
  416. params = params_for_driver(ctx.current)
  417. self.mech._vxlan_driver.update_physical_port.assert_called_with(
  418. params['segmentation_id'],
  419. [],
  420. ctx.current,
  421. self.mech.switches_mac_ip_pair
  422. )
  423. def test_update_port_raises_update_physical_port(self):
  424. ctx = self.prepare_dummy_context(
  425. net_type='vxlan', vif_type='normal', vnic_type='ovs')
  426. self.mech._vxlan_driver.update_physical_port.side_effect = Exception
  427. self.assertRaises(
  428. ml2_exc.MechanismDriverError,
  429. self.mech.update_port_postcommit, ctx)
  430. def test_delete_port(self):
  431. ctx = self.prepare_dummy_context(net_type='vxlan')
  432. self.mech.delete_port_postcommit(ctx)
  433. self.mech._vxlan_driver.reset_physical_port.assert_not_called()
  434. def test_delete_port_with_no_local_link_information(self):
  435. ctx = self.prepare_dummy_context(net_type='vxlan')
  436. ctx.current['binding:profile'] = {}
  437. self.mech.delete_port_postcommit(ctx)
  438. self.mech._vxlan_driver.reset_physical_port.assert_not_called()
  439. def test_delete_port_with_bound(self):
  440. ctx = self.prepare_dummy_context(net_type='vxlan', vif_type='normal')
  441. self.mech.delete_port_postcommit(ctx)
  442. params = params_for_driver(ctx.current)
  443. self.mech._vxlan_driver.reset_physical_port.assert_called_with(
  444. params['local_link_info'],
  445. ctx.current,
  446. self.mech.switches_mac_ip_pair
  447. )
  448. def test_delete_port_raises_reset_physical_port(self):
  449. ctx = self.prepare_dummy_context(net_type='vxlan', vif_type='normal')
  450. self.mech._vxlan_driver.reset_physical_port.side_effect = Exception
  451. self.assertRaises(
  452. ml2_exc.MechanismDriverError,
  453. self.mech.delete_port_postcommit, ctx)
  454. def test_delete_port_with_lag_raises_reset_physical_port_with_lag(self):
  455. ctx = self.prepare_dummy_context(
  456. net_type='vxlan', vif_type='normal', nic='lag')
  457. self.mech._vlan_driver.clear_lag.side_effect = [
  458. Exception, None]
  459. self.mech._vxlan_driver.reset_physical_port_with_lag.side_effect = [
  460. Exception, Exception]
  461. self.assertRaises(
  462. ml2_exc.MechanismDriverError,
  463. self.mech.delete_port_postcommit, ctx)
  464. self.assertRaises(
  465. ml2_exc.MechanismDriverError,
  466. self.mech.delete_port_postcommit, ctx)
  467. def test_delete_port_with_flat(self):
  468. ctx = self.prepare_dummy_context(net_type='flat')
  469. self.mech.delete_port_postcommit(ctx)
  470. self.mech._vxlan_driver.reset_physical_port.assert_not_called()
  471. def test_delete_with_lag(self):
  472. ctx = self.prepare_dummy_context(
  473. net_type='vxlan', vif_type='normal', nic='lag')
  474. self.mech._vlan_driver.clear_lag.return_value = {}
  475. self.mech.delete_port_postcommit(ctx)
  476. params = params_for_driver(ctx.current)
  477. target = self.mech._vxlan_driver.reset_physical_port_with_lag
  478. target.assert_called_with(
  479. params['local_link_info'],
  480. ctx.current,
  481. self.mech.switches_mac_ip_pair,
  482. mac_lag_map={})
  483. def test_delete_with_mlag(self):
  484. ctx = self.prepare_dummy_context(
  485. net_type='vxlan', vif_type='normal', nic='mlag')
  486. self.mech._vlan_driver.clear_lag.return_value = {}
  487. self.mech.delete_port_postcommit(ctx)
  488. params = params_for_driver(ctx.current)
  489. target = self.mech._vxlan_driver.reset_physical_port_with_lag
  490. target.assert_called_with(
  491. params['local_link_info'],
  492. ctx.current, self.mech.switches_mac_ip_pair, mac_lag_map={})