A Tempest plugin to test Neutron VMware NSX 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.
 
 

727 lines
36 KiB

  1. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  2. # not use this file except in compliance with the License. You may obtain
  3. # a copy of the License at
  4. #
  5. # http://www.apache.org/licenses/LICENSE-2.0
  6. #
  7. # Unless required by applicable law or agreed to in writing, software
  8. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  9. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  10. # License for the specific language governing permissions and limitations
  11. # under the License.
  12. from tempest import config
  13. from tempest.lib.common.utils import data_utils
  14. from tempest.lib import decorators
  15. from tempest.lib import exceptions
  16. from vmware_nsx_tempest_plugin.lib import feature_manager
  17. CONF = config.CONF
  18. class IPv6RoutersTest(feature_manager.FeatureManager):
  19. """Test the following operations for ports:
  20. port create
  21. port delete
  22. port list
  23. port show
  24. port update
  25. """
  26. @classmethod
  27. def skip_checks(cls):
  28. super(IPv6RoutersTest, cls).skip_checks()
  29. if not (CONF.network_feature_enabled.ipv6 and
  30. CONF.network_feature_enabled.ipv6_subnet_attributes):
  31. raise cls.skipException('IPv6 or its attributes not supported')
  32. if not (CONF.network.project_networks_reachable or
  33. CONF.network.public_network_id):
  34. msg = ('Either project_networks_reachable must be "true", or '
  35. 'public_network_id must be defined.')
  36. raise cls.skipException(msg)
  37. @classmethod
  38. def setup_clients(cls):
  39. super(IPv6RoutersTest, cls).setup_clients()
  40. cls.cmgr_adm = cls.get_client_manager('admin')
  41. @classmethod
  42. def resource_setup(cls):
  43. super(IPv6RoutersTest, cls).resource_setup()
  44. def _create_ipv6_subnet(self, network, cidr, ipv6_ra_mode=None,
  45. ipv6_address_mode=None,
  46. router_id=None, slaac=False, enable_dhcp=False):
  47. subnet_client = self.cmgr_adm.subnets_client
  48. subnet_name = network['name'] + 'sub'
  49. if slaac:
  50. subnet = self.create_topology_subnet(
  51. subnet_name, network,
  52. subnets_client=subnet_client,
  53. ip_version=6, ipv6_ra_mode='slaac',
  54. ipv6_address_mode='slaac',
  55. cidr=cidr, router_id=router_id)
  56. else:
  57. subnet = self.create_topology_subnet(
  58. subnet_name, network,
  59. subnets_client=subnet_client,
  60. ipv6_address_mode=ipv6_address_mode,
  61. ipv6_ra_mode=ipv6_ra_mode,
  62. ip_version=6, enable_dhcp=True,
  63. cidr=cidr, router_id=router_id)
  64. return subnet
  65. def create_topo_single_network(self, namestart, create_instance=True,
  66. set_gateway=True, slaac=True, **kwargs):
  67. """
  68. Create Topo where 1 logical switches which is
  69. connected via tier-1 router.
  70. """
  71. rtr_name = data_utils.rand_name(name='tempest-router')
  72. network_name = data_utils.rand_name(name='tempest-net')
  73. subnet_name = data_utils.rand_name(name='tempest-subnet')
  74. router_state = self.create_topology_router(rtr_name,
  75. set_gateway=set_gateway,
  76. **kwargs)
  77. network_state = self.create_topology_network(network_name)
  78. subnet_state = self.create_topology_subnet(subnet_name, network_state,
  79. router_id=router_state["id"]
  80. )
  81. subnet_v6 = self._create_ipv6_subnet(network_state, cidr="5200::/64",
  82. slaac=slaac,
  83. router_id=router_state["id"])
  84. if create_instance:
  85. image_id = self.get_glance_image_id(["cirros", "esx"])
  86. self.create_topology_instance(
  87. "state_vm_1", [network_state],
  88. create_floating_ip=True, image_id=image_id)
  89. self.create_topology_instance(
  90. "state_vm_2", [network_state],
  91. create_floating_ip=True, image_id=image_id)
  92. topology_dict = dict(router_state=router_state,
  93. network_state=network_state,
  94. subnet_state=subnet_state,
  95. subnet_v6=subnet_v6)
  96. return topology_dict
  97. def create_topo_single_dhcpv6_network(
  98. self, namestart, ipv6_address_mode,
  99. ipv6_ra_mode, create_instance=True,
  100. set_gateway=True, slaac=False,
  101. **kwargs):
  102. """
  103. Create Topo where 1 logical switches which is
  104. connected via tier-1 router.
  105. """
  106. rtr_name = data_utils.rand_name(name='tempest-router')
  107. network_name = data_utils.rand_name(name='tempest-net')
  108. subnet_name = data_utils.rand_name(name='tempest-subnet')
  109. router_state = self.create_topology_router(rtr_name,
  110. set_gateway=set_gateway,
  111. **kwargs)
  112. network_state = self.create_topology_network(network_name)
  113. subnet_state = self.create_topology_subnet(subnet_name, network_state,
  114. router_id=router_state["id"]
  115. )
  116. subnet_v6 = self._create_ipv6_subnet(
  117. network_state, cidr="5200::/64", slaac=slaac,
  118. ipv6_address_mode=ipv6_address_mode,
  119. ipv6_ra_mode=ipv6_ra_mode,
  120. router_id=router_state["id"])
  121. if create_instance:
  122. image_id = self.get_glance_image_id(["cirros", "esx"])
  123. self.create_topology_instance(
  124. "state_vm_1", [network_state],
  125. create_floating_ip=True, image_id=image_id)
  126. self.create_topology_instance(
  127. "state_vm_2", [network_state],
  128. create_floating_ip=True, image_id=image_id)
  129. topology_dict = dict(router_state=router_state,
  130. network_state=network_state,
  131. subnet_state=subnet_state,
  132. subnet_v6=subnet_v6)
  133. return topology_dict
  134. @decorators.attr(type=['nsxv3', 'positive'])
  135. @decorators.idempotent_id('6526db57-c523-4879-b8ae-f50f0190f960')
  136. def test_single_ipv6_downlink_interface_rtr(self):
  137. """Test creating single ipv6 static subnet attached
  138. to router downlink interface
  139. """
  140. name = data_utils.rand_name("ipv6-net")
  141. networks_client = self.cmgr_adm.networks_client
  142. network = self.create_topology_network(
  143. name, networks_client=networks_client)
  144. subnet = self._create_ipv6_subnet(network, cidr="5200::/64",
  145. slaac=True)
  146. rtr_name = data_utils.rand_name("ipv6-rtr")
  147. router = self.create_topology_router(
  148. rtr_name, routers_client=self.cmgr_adm.routers_client)
  149. interface = self.add_router_interface(
  150. router_client=self.cmgr_adm.routers_client,
  151. router_id=router['id'], subnet_id=subnet['id'])
  152. self.assertEqual(subnet['id'], interface['subnet_id'])
  153. @decorators.attr(type=['nsxv3', 'positive'])
  154. @decorators.idempotent_id('6cbd1f61-8d63-4d81-a8ba-f0f0624d4585')
  155. def test_ipv4_ipv6_downlink_interface_rtr(self):
  156. """Test creating ipv4 and ipv6 static subnets attached
  157. to router downlink interface
  158. """
  159. name = data_utils.rand_name("ipv6-net")
  160. networks_client = self.cmgr_adm.networks_client
  161. network = self.create_topology_network(
  162. name, networks_client=networks_client)
  163. subnet_client = self.cmgr_adm.subnets_client
  164. subnet_name = network['name'] + 'ipv4-sub'
  165. subnet_ipv4 = self.create_topology_subnet(
  166. subnet_name, network,
  167. subnets_client=subnet_client,
  168. cidr='20.20.0.0/16')
  169. subnet = self._create_ipv6_subnet(network, cidr="5201::/64",
  170. slaac=True)
  171. rtr_name = data_utils.rand_name("ipv6-rtr")
  172. router = self.create_topology_router(
  173. rtr_name, routers_client=self.cmgr_adm.routers_client)
  174. interface = self.add_router_interface(
  175. router_client=self.cmgr_adm.routers_client,
  176. router_id=router['id'], subnet_id=subnet_ipv4['id'])
  177. self.assertEqual(subnet_ipv4['id'], interface['subnet_id'])
  178. interface = self.add_router_interface(
  179. router_client=self.cmgr_adm.routers_client,
  180. router_id=router['id'], subnet_id=subnet['id'])
  181. self.assertEqual(subnet['id'], interface['subnet_id'])
  182. @decorators.attr(type=['nsxv3', 'positive'])
  183. @decorators.idempotent_id('6a228287-25d2-41b3-aa7d-f6e566b9c8a3')
  184. def test_slaac_single_ipv6_downlink_interface_rtr(self):
  185. """Test creating single ipv6 static subnet attached
  186. to router downlink interface
  187. """
  188. name = data_utils.rand_name("ipv6-net")
  189. networks_client = self.cmgr_adm.networks_client
  190. network = self.create_topology_network(
  191. name, networks_client=networks_client)
  192. subnet = self._create_ipv6_subnet(network, cidr="4010::/64",
  193. slaac=True)
  194. rtr_name = data_utils.rand_name("ipv6-rtr")
  195. router = self.create_topology_router(
  196. rtr_name, routers_client=self.cmgr_adm.routers_client)
  197. interface = self.add_router_interface(
  198. router_client=self.cmgr_adm.routers_client,
  199. router_id=router['id'], subnet_id=subnet['id'])
  200. self.assertEqual(subnet['id'], interface['subnet_id'])
  201. @decorators.attr(type=['nsxv3', 'positive'])
  202. @decorators.idempotent_id('8e7b1e28-e50e-458e-beb4-49ce5663c561')
  203. def test_slaac_ipv4_ipv6_downlink_interface_rtr(self):
  204. """Test creating ipv4 and ipv6 slaac subnets attached
  205. to router downlink interface
  206. """
  207. name = data_utils.rand_name("ipv6-net")
  208. networks_client = self.cmgr_adm.networks_client
  209. network = self.create_topology_network(
  210. name, networks_client=networks_client)
  211. subnet_client = self.cmgr_adm.subnets_client
  212. subnet_name = network['name'] + 'ipv4-sub'
  213. subnet_ipv4 = self.create_topology_subnet(
  214. subnet_name, network, subnets_client=subnet_client,
  215. cidr='20.20.0.0/16')
  216. subnet = self._create_ipv6_subnet(network, cidr="4011::/64",
  217. slaac=True)
  218. rtr_name = data_utils.rand_name("ipv6-rtr")
  219. router = self.create_topology_router(
  220. rtr_name, routers_client=self.cmgr_adm.routers_client)
  221. interface = self.add_router_interface(
  222. router_client=self.cmgr_adm.routers_client,
  223. router_id=router['id'], subnet_id=subnet_ipv4['id'])
  224. self.assertEqual(subnet_ipv4['id'], interface['subnet_id'])
  225. interface = self.add_router_interface(
  226. router_client=self.cmgr_adm.routers_client,
  227. router_id=router['id'], subnet_id=subnet['id'])
  228. self.assertEqual(subnet['id'], interface['subnet_id'])
  229. @decorators.attr(type=['nsxv3', 'positive'])
  230. @decorators.idempotent_id('85235d0f-89b5-48a0-a3ee-d1bd21be6b94')
  231. def test_slaac_multiple_ipv6_downlink_interface_rtr(self):
  232. """Test creating multiple ipv6 slaac subnets attached
  233. to router downlink interface
  234. """
  235. name = data_utils.rand_name("ipv6-net")
  236. networks_client = self.cmgr_adm.networks_client
  237. network = self.create_topology_network(
  238. name, networks_client=networks_client)
  239. subnet = self._create_ipv6_subnet(network, cidr="4012::/64",
  240. slaac=True)
  241. network_1 = self.create_topology_network(
  242. name, networks_client=networks_client)
  243. subnet_1 = self._create_ipv6_subnet(network_1, cidr="4013::/64",
  244. slaac=True)
  245. rtr_name = data_utils.rand_name("ipv6-rtr")
  246. router = self.create_topology_router(
  247. rtr_name, routers_client=self.cmgr_adm.routers_client)
  248. interface = self.add_router_interface(
  249. router_client=self.cmgr_adm.routers_client,
  250. router_id=router['id'], subnet_id=subnet['id'])
  251. self.assertEqual(subnet['id'], interface['subnet_id'])
  252. interface = self.add_router_interface(
  253. router_client=self.cmgr_adm.routers_client,
  254. router_id=router['id'], subnet_id=subnet_1['id'])
  255. self.assertEqual(subnet_1['id'], interface['subnet_id'])
  256. @decorators.attr(type=['nsxv3', 'positive'])
  257. @decorators.idempotent_id('3564b971-6033-43cc-a13a-93b467bca50d')
  258. def test_multiple_ipv6_downlink_interface_rtr(self):
  259. """Test creating multiple ipv6 static subnets attached
  260. to router downlink interface
  261. """
  262. name = data_utils.rand_name("ipv6-net")
  263. networks_client = self.cmgr_adm.networks_client
  264. network = self.create_topology_network(
  265. name, networks_client=networks_client)
  266. subnet_client = self.cmgr_adm.subnets_client
  267. subnet_name = network['name'] + 'ipv4-sub'
  268. subnet_ipv4 = self.create_topology_subnet(
  269. subnet_name, network, subnets_client=subnet_client,
  270. cidr='20.21.0.0/16')
  271. subnet = self._create_ipv6_subnet(network, cidr="4200::/64")
  272. network_1 = self.create_topology_network(
  273. name, networks_client=networks_client)
  274. subnet_ipv4_1 = self.create_topology_subnet(
  275. subnet_name, network_1, subnets_client=subnet_client,
  276. cidr='20.22.0.0/16')
  277. subnet_1 = self._create_ipv6_subnet(network_1, cidr="4201::/64")
  278. rtr_name = data_utils.rand_name("ipv6-rtr")
  279. router = self.create_topology_router(
  280. rtr_name, routers_client=self.cmgr_adm.routers_client)
  281. interface = self.add_router_interface(
  282. router_client=self.cmgr_adm.routers_client,
  283. router_id=router['id'], subnet_id=subnet['id'])
  284. self.assertEqual(subnet['id'], interface['subnet_id'])
  285. interface = self.add_router_interface(
  286. router_client=self.cmgr_adm.routers_client,
  287. router_id=router['id'], subnet_id=subnet_ipv4['id'])
  288. self.assertEqual(subnet_ipv4['id'], interface['subnet_id'])
  289. interface = self.add_router_interface(
  290. router_client=self.cmgr_adm.routers_client,
  291. router_id=router['id'], subnet_id=subnet_1['id'])
  292. self.assertEqual(subnet_1['id'], interface['subnet_id'])
  293. interface = self.add_router_interface(
  294. router_client=self.cmgr_adm.routers_client,
  295. router_id=router['id'], subnet_id=subnet_ipv4_1['id'])
  296. self.assertEqual(subnet_ipv4_1['id'], interface['subnet_id'])
  297. @decorators.attr(type=['nsxv3', 'positive'])
  298. @decorators.idempotent_id('151dd309-44a2-46ac-978a-f058492843c8')
  299. def test_slaac_multiple_ipv4_v6_downlink_interface_rtr(self):
  300. """Test creating multiple ipv6 slaac subnets attached
  301. to router downlink interface
  302. """
  303. name = data_utils.rand_name("dual-net")
  304. networks_client = self.cmgr_adm.networks_client
  305. network = self.create_topology_network(
  306. name, networks_client=networks_client)
  307. subnet_client = self.cmgr_adm.subnets_client
  308. subnet_name = network['name'] + 'ipv4-sub'
  309. subnet_ipv4 = self.create_topology_subnet(
  310. subnet_name, network, subnets_client=subnet_client,
  311. cidr='20.21.0.0/16')
  312. subnet = self._create_ipv6_subnet(network, cidr="4012::/64",
  313. slaac=True)
  314. network_1 = self.create_topology_network(
  315. name, networks_client=networks_client)
  316. subnet_ipv4_1 = self.create_topology_subnet(
  317. subnet_name, network_1, subnets_client=subnet_client,
  318. cidr='20.22.0.0/16')
  319. subnet_1 = self._create_ipv6_subnet(network_1, cidr="4013::/64",
  320. slaac=True)
  321. rtr_name = data_utils.rand_name("ipv6-rtr")
  322. router = self.create_topology_router(
  323. rtr_name, routers_client=self.cmgr_adm.routers_client)
  324. interface = self.add_router_interface(
  325. router_client=self.cmgr_adm.routers_client,
  326. router_id=router['id'], subnet_id=subnet['id'])
  327. self.assertEqual(subnet['id'], interface['subnet_id'])
  328. interface = self.add_router_interface(
  329. router_client=self.cmgr_adm.routers_client,
  330. router_id=router['id'], subnet_id=subnet_ipv4['id'])
  331. self.assertEqual(subnet_ipv4['id'], interface['subnet_id'])
  332. interface = self.add_router_interface(
  333. router_client=self.cmgr_adm.routers_client,
  334. router_id=router['id'], subnet_id=subnet_1['id'])
  335. self.assertEqual(subnet_1['id'], interface['subnet_id'])
  336. interface = self.add_router_interface(
  337. router_client=self.cmgr_adm.routers_client,
  338. router_id=router['id'], subnet_id=subnet_ipv4_1['id'])
  339. self.assertEqual(subnet_ipv4_1['id'], interface['subnet_id'])
  340. @decorators.attr(type=['nsxv3', 'negative'])
  341. @decorators.idempotent_id('8cc317db-4bcd-4f56-821a-9040b4a9c740')
  342. def test_update_router_nsxv3_with_ipv6_static_route_via_0_0(self):
  343. """
  344. Check it should not allow to add static route on router with
  345. ::/0 next hop.
  346. """
  347. kwargs = {"admin_state_up": "True"}
  348. topology_dict = self.create_topo_single_network("rtr_update",
  349. create_instance=False,
  350. set_gateway=False,
  351. **kwargs)
  352. router_state = topology_dict['router_state']
  353. routes = [{
  354. "destination": "3700::/64",
  355. "nexthop": "::/0"
  356. }]
  357. router_id = router_state['id']
  358. self.assertRaises(exceptions.BadRequest,
  359. self.cmgr_adm.routers_client.update_router,
  360. router_id, routes=routes)
  361. @decorators.attr(type=['nsxv3', 'negative'])
  362. @decorators.idempotent_id('8cc317db-4bcd-4f56-821a-9040b4a9c740')
  363. def test_update_router_nsxv3_with_ipv6_static_route_dest_0_0(self):
  364. """
  365. Check it should allow to add static route on router with
  366. ::/0 as destination.
  367. """
  368. kwargs = {"admin_state_up": "True"}
  369. topology_dict = self.create_topo_single_network("rtr_update",
  370. create_instance=False,
  371. set_gateway=False,
  372. **kwargs)
  373. router_state = topology_dict['router_state']
  374. next_hop = topology_dict['subnet_v6']['allocation_pools'][0]['end']
  375. dest = "::/0"
  376. routes = [{
  377. "destination": dest,
  378. "nexthop": next_hop
  379. }]
  380. router_id = router_state['id']
  381. self.assertRaises(exceptions.BadRequest,
  382. self.cmgr_adm.routers_client.update_router,
  383. router_id, routes=routes)
  384. @decorators.attr(type=['nsxv3', 'positive'])
  385. @decorators.idempotent_id('8155be15-cdc4-4834-be1a-99dbddbee920')
  386. def test_update_router_nsxv3_with_ipv6_static_route(self):
  387. """
  388. Check it should not allow to add static route on router with
  389. ::/0 next hop.
  390. """
  391. kwargs = {"admin_state_up": "True"}
  392. topology_dict = self.create_topo_single_network("rtr_update",
  393. create_instance=False,
  394. set_gateway=False,
  395. **kwargs)
  396. next_hop = topology_dict['subnet_v6']['allocation_pools'][0]['end']
  397. router_state = topology_dict['router_state']
  398. dest = "3700::/64"
  399. routes = [{
  400. "destination": dest,
  401. "nexthop": next_hop
  402. }]
  403. router_id = router_state['id']
  404. router = self.cmgr_adm.routers_client.update_router(
  405. router_id, routes=routes)['router']
  406. self.assertEqual(router['routes'][0]['nexthop'], next_hop)
  407. self.assertEqual(router['routes'][0]['destination'], dest)
  408. self.cmgr_adm.routers_client.update_router(router_id, routes=[])
  409. @decorators.attr(type=['nsxv3', 'negative'])
  410. @decorators.idempotent_id('93682a0b-253c-4077-9876-b20c75041010')
  411. def test_update_router_admin_state_ipv6_subnet(self):
  412. """
  413. Verify the router admin state can not to changed to False
  414. for router attached to IPv6 subnet
  415. """
  416. kwargs = {"admin_state_up": "True"}
  417. topology_dict = self.create_topo_single_network("rtr_update",
  418. create_instance=False,
  419. set_gateway=False,
  420. **kwargs)
  421. router = topology_dict['router_state']
  422. self.assertEqual(router['admin_state_up'], True)
  423. kwargs = {"admin_state_up": "False"}
  424. self.assertRaises(exceptions.BadRequest,
  425. self.cmgr_adm.routers_client.update_router,
  426. router['id'], **kwargs)
  427. @decorators.attr(type=['nsxv3', 'negative'])
  428. @decorators.idempotent_id('a712ca9a-bfa6-47b0-ac59-e971e3a7eb2d')
  429. def test_deletion_router_ipv6_slacc_interface_use(self):
  430. """
  431. Verify the router interface attached to IPv6 subnet
  432. can be deleted while port is attached to the subnet
  433. """
  434. kwargs = {"admin_state_up": "True"}
  435. topology_dict = self.create_topo_single_network("rtr_update",
  436. create_instance=True,
  437. set_gateway=True,
  438. **kwargs)
  439. router = topology_dict['router_state']
  440. subnet_v6 = topology_dict['subnet_v6']
  441. self.cmgr_adm.routers_client.remove_router_interface(
  442. router['id'], subnet_id=subnet_v6['id'])
  443. @decorators.attr(type=['nsxv3', 'negative'])
  444. @decorators.idempotent_id('4148f175-a33e-4690-ac1b-26f9876de689')
  445. def test_deletion_router_ipv6_static_interface_use(self):
  446. """
  447. Verify the router interface attached to IPv6 subnet
  448. can be deleted while port is attached to the subnet
  449. """
  450. kwargs = {"admin_state_up": "True"}
  451. topology_dict = self.create_topo_single_network("rtr_update",
  452. create_instance=True,
  453. slaac=False,
  454. set_gateway=True,
  455. **kwargs)
  456. router = topology_dict['router_state']
  457. subnet_v6 = topology_dict['subnet_v6']
  458. self.cmgr_adm.routers_client.remove_router_interface(
  459. router['id'], subnet_id=subnet_v6['id'])
  460. @decorators.attr(type=['nsxv3', 'negative'])
  461. @decorators.idempotent_id('38d5814e-3970-42d5-a4b1-6e8af9e0d8e9')
  462. def test_deletion_router_ipv6_slacc_use(self):
  463. """
  464. Verify the router attached to IPv6 subnet
  465. can not be deleted while port is attached to the subnet
  466. """
  467. kwargs = {"admin_state_up": "True"}
  468. topology_dict = self.create_topo_single_network("rtr_update",
  469. create_instance=True,
  470. set_gateway=True,
  471. **kwargs)
  472. router = topology_dict['router_state']
  473. self.assertRaises(exceptions.Conflict,
  474. self.cmgr_adm.routers_client.delete_router,
  475. router['id'])
  476. @decorators.attr(type=['nsxv3', 'negative'])
  477. @decorators.idempotent_id('fd2098e6-6343-4df9-a3d9-1e1e34216d22')
  478. def test_deletion_router_ipv6_static_use(self):
  479. """
  480. Verify the router attached to IPv6 subnet
  481. can not be deleted while port is attached to the subnet
  482. """
  483. kwargs = {"admin_state_up": "True"}
  484. topology_dict = self.create_topo_single_network("rtr_update",
  485. create_instance=True,
  486. slaac=False,
  487. set_gateway=True,
  488. **kwargs)
  489. router = topology_dict['router_state']
  490. self.assertRaises(exceptions.Conflict,
  491. self.cmgr_adm.routers_client.delete_router,
  492. router['id'])
  493. @decorators.attr(type=['nsxv3', 'positive'])
  494. @decorators.idempotent_id('85235d0f-89b5-48a0-a3ed-d1bd21be6b94')
  495. def test_multiple_dhcpv6_stateful_downlink_interface_rtr(self):
  496. """Test creating multiple dhcpv6 subnets attached
  497. to router downlink interface
  498. """
  499. name = data_utils.rand_name("ipv6-net")
  500. networks_client = self.cmgr_adm.networks_client
  501. network = self.create_topology_network(
  502. name, networks_client=networks_client)
  503. subnet = self._create_ipv6_subnet(
  504. network, ipv6_ra_mode="dhcpv6-stateful",
  505. ipv6_address_mode="dhcpv6-stateful", enable_dhcp=True,
  506. cidr="4012::/64")
  507. network_1 = self.create_topology_network(
  508. name, networks_client=networks_client)
  509. subnet_1 = self._create_ipv6_subnet(
  510. network_1, ipv6_ra_mode="dhcpv6-stateful",
  511. ipv6_address_mode="dhcpv6-stateful", enable_dhcp=True,
  512. cidr="4013::/64")
  513. rtr_name = data_utils.rand_name("ipv6-rtr")
  514. router = self.create_topology_router(
  515. rtr_name, routers_client=self.cmgr_adm.routers_client)
  516. interface = self.add_router_interface(
  517. router_client=self.cmgr_adm.routers_client,
  518. router_id=router['id'], subnet_id=subnet['id'])
  519. self.assertEqual(subnet['id'], interface['subnet_id'])
  520. interface = self.add_router_interface(
  521. router_client=self.cmgr_adm.routers_client,
  522. router_id=router['id'], subnet_id=subnet_1['id'])
  523. self.assertEqual(subnet_1['id'], interface['subnet_id'])
  524. @decorators.attr(type=['nsxv3', 'positive'])
  525. @decorators.idempotent_id('85235d0f-89b5-48a0-a3ed-d1bd21be6b94')
  526. def test_multiple_dhcpv6_stateless_downlink_interface_rtr(self):
  527. """Test creating multiple dhcpv6 subnets attached
  528. to router downlink interface
  529. """
  530. name = data_utils.rand_name("ipv6-net")
  531. networks_client = self.cmgr_adm.networks_client
  532. network = self.create_topology_network(
  533. name, networks_client=networks_client)
  534. mode = "dhcpv6-stateless"
  535. subnet = self._create_ipv6_subnet(network,
  536. ipv6_ra_mode=mode,
  537. ipv6_address_mode=mode,
  538. enable_dhcp=True,
  539. cidr="4012::/64")
  540. network_1 = self.create_topology_network(
  541. name, networks_client=networks_client)
  542. mode = "dhcpv6-stateless"
  543. subnet_1 = self._create_ipv6_subnet(network_1,
  544. ipv6_ra_mode=mode,
  545. ipv6_address_mode=mode,
  546. enable_dhcp=True,
  547. cidr="4013::/64")
  548. rtr_name = data_utils.rand_name("ipv6-rtr")
  549. router = self.create_topology_router(
  550. rtr_name, routers_client=self.cmgr_adm.routers_client)
  551. interface = self.add_router_interface(
  552. router_client=self.cmgr_adm.routers_client,
  553. router_id=router['id'], subnet_id=subnet['id'])
  554. self.assertEqual(subnet['id'], interface['subnet_id'])
  555. interface = self.add_router_interface(
  556. router_client=self.cmgr_adm.routers_client,
  557. router_id=router['id'], subnet_id=subnet_1['id'])
  558. self.assertEqual(subnet_1['id'], interface['subnet_id'])
  559. @decorators.attr(type=['nsxv3', 'positive'])
  560. @decorators.idempotent_id('85235d0f-89b5-48a0-a3ed-d1bd21be6b94')
  561. def test_multiple_dhcpv6_heterogeneous_downlink_interface_rtr(self):
  562. """Test creating multiple dhcpv6 subnets attached
  563. to router downlink interface
  564. """
  565. name = data_utils.rand_name("ipv6-net")
  566. networks_client = self.cmgr_adm.networks_client
  567. network = self.create_topology_network(
  568. name, networks_client=networks_client)
  569. subnet = self._create_ipv6_subnet(network,
  570. ipv6_ra_mode="dhcpv6-stateful",
  571. ipv6_address_mode="dhcpv6-stateful",
  572. enable_dhcp=True,
  573. cidr="4012::/64")
  574. network_1 = self.create_topology_network(
  575. name, networks_client=networks_client)
  576. mode = "dhcpv6-stateless"
  577. subnet_1 = self._create_ipv6_subnet(network_1,
  578. ipv6_ra_mode=mode,
  579. ipv6_address_mode=mode,
  580. enable_dhcp=True,
  581. cidr="4013::/64")
  582. rtr_name = data_utils.rand_name("ipv6-rtr")
  583. router = self.create_topology_router(
  584. rtr_name, routers_client=self.cmgr_adm.routers_client)
  585. interface = self.add_router_interface(
  586. router_client=self.cmgr_adm.routers_client,
  587. router_id=router['id'], subnet_id=subnet['id'])
  588. self.assertEqual(subnet['id'], interface['subnet_id'])
  589. self.assertRaises(exceptions.BadRequest,
  590. self.add_router_interface,
  591. router_client=self.cmgr_adm.routers_client,
  592. router_id=router['id'],
  593. subnet_id=subnet_1['id'])
  594. @decorators.attr(type=['nsxv3', 'positive'])
  595. @decorators.idempotent_id('8e7b1e28-e50e-458e-beb4-49ce5663c561')
  596. def test_dhcpv6_stateful_ipv4_ipv6_downlink_interface_rtr(self):
  597. """Test creating ipv4 and ipv6 slaac subnets attached
  598. to router downlink interface
  599. """
  600. name = data_utils.rand_name("ipv6-net")
  601. networks_client = self.cmgr_adm.networks_client
  602. network = self.create_topology_network(name,
  603. networks_client=networks_client)
  604. subnet_client = self.cmgr_adm.subnets_client
  605. subnet_name = network['name'] + 'ipv4-sub'
  606. subnet_ipv4 = self.create_topology_subnet(subnet_name, network,
  607. subnets_client=subnet_client,
  608. cidr='20.20.0.0/16')
  609. subnet = self._create_ipv6_subnet(network, cidr="4011::/64",
  610. ipv6_ra_mode="dhcpv6-stateful",
  611. ipv6_address_mode="dhcpv6-stateful")
  612. rtr_name = data_utils.rand_name("ipv6-rtr")
  613. router = self.create_topology_router(
  614. rtr_name, routers_client=self.cmgr_adm.routers_client)
  615. interface = self.add_router_interface(
  616. router_client=self.cmgr_adm.routers_client,
  617. router_id=router['id'], subnet_id=subnet_ipv4['id'])
  618. self.assertEqual(subnet_ipv4['id'], interface['subnet_id'])
  619. interface = self.add_router_interface(
  620. router_client=self.cmgr_adm.routers_client,
  621. router_id=router['id'], subnet_id=subnet['id'])
  622. self.assertEqual(subnet['id'], interface['subnet_id'])
  623. @decorators.attr(type=['nsxv3', 'positive'])
  624. @decorators.idempotent_id('8e7b1e28-e50e-458e-beb4-49ce5663c561')
  625. def test_dhcpv6_stateless_ipv4_ipv6_downlink_interface_rtr(self):
  626. """Test creating ipv4 and ipv6 slaac subnets attached
  627. to router downlink interface
  628. """
  629. name = data_utils.rand_name("ipv6-net")
  630. networks_client = self.cmgr_adm.networks_client
  631. network = self.create_topology_network(name,
  632. networks_client=networks_client)
  633. subnet_client = self.cmgr_adm.subnets_client
  634. subnet_name = network['name'] + 'ipv4-sub'
  635. subnet_ipv4 = self.create_topology_subnet(subnet_name, network,
  636. subnets_client=subnet_client,
  637. cidr='20.20.0.0/16')
  638. mode = "dhcpv6-stateless"
  639. subnet = self._create_ipv6_subnet(network, cidr="4011::/64",
  640. ipv6_ra_mode=mode,
  641. ipv6_address_mode=mode)
  642. rtr_name = data_utils.rand_name("ipv6-rtr")
  643. router = self.create_topology_router(
  644. rtr_name, routers_client=self.cmgr_adm.routers_client)
  645. interface = self.add_router_interface(
  646. router_client=self.cmgr_adm.routers_client,
  647. router_id=router['id'], subnet_id=subnet_ipv4['id'])
  648. self.assertEqual(subnet_ipv4['id'], interface['subnet_id'])
  649. interface = self.add_router_interface(
  650. router_client=self.cmgr_adm.routers_client,
  651. router_id=router['id'], subnet_id=subnet['id'])
  652. self.assertEqual(subnet['id'], interface['subnet_id'])
  653. @decorators.attr(type=['nsxv3', 'negative'])
  654. @decorators.idempotent_id('8cc317db-4bcd-4f56-821a-9040b4a9c740')
  655. def test_update_router_nsxv3_with_dhcpv6_static_route_via_0_0(self):
  656. """
  657. Check it should not allow to add static route on router with
  658. ::/0 next hop.
  659. """
  660. kwargs = {"admin_state_up": "True"}
  661. mode = "dhcpv6-stateless"
  662. topology_dict = self.create_topo_single_dhcpv6_network(
  663. "rtr_update", create_instance=False, set_gateway=False,
  664. ipv6_ra_mode=mode, ipv6_address_mode=mode, **kwargs)
  665. router_state = topology_dict['router_state']
  666. routes = [{
  667. "destination": "3700::/64",
  668. "nexthop": "::/0"
  669. }]
  670. router_id = router_state['id']
  671. self.assertRaises(exceptions.BadRequest,
  672. self.cmgr_adm.routers_client.update_router,
  673. router_id, routes=routes)
  674. @decorators.attr(type=['nsxv3', 'negative'])
  675. @decorators.idempotent_id('8cc317db-4bcd-4f56-821a-9040b4a9c740')
  676. def test_update_router_nsxv3_with_dhcpv6_stateful_static_via_0_0(self):
  677. """
  678. Check it should not allow to add static route on router with
  679. ::/0 next hop.
  680. """
  681. kwargs = {"admin_state_up": "True"}
  682. mode = "dhcpv6-stateful"
  683. topology_dict = self.create_topo_single_dhcpv6_network(
  684. "rtr_update", create_instance=False, set_gateway=False,
  685. ipv6_ra_mode=mode, ipv6_address_mode=mode, **kwargs)
  686. router_state = topology_dict['router_state']
  687. routes = [{
  688. "destination": "3700::/64",
  689. "nexthop": "::/0"
  690. }]
  691. router_id = router_state['id']
  692. self.assertRaises(exceptions.BadRequest,
  693. self.cmgr_adm.routers_client.update_router,
  694. router_id, routes=routes)