blob: 1b580b07e4d57a473da15422a610a57cbf335c65 [file] [log] [blame]
rossellae02431e2013-11-15 17:58:29 +01001# Copyright 2013 OpenStack Foundation
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16from tempest.api.network import base
17
18
19class BaseRouterTest(base.BaseAdminNetworkTest):
20 # NOTE(salv-orlando): This class inherits from BaseAdminNetworkTest
21 # as some router operations, such as enabling or disabling SNAT
22 # require admin credentials by default
23
24 @classmethod
Andrea Frittolida4a2452014-09-15 13:12:08 +010025 def resource_setup(cls):
26 super(BaseRouterTest, cls).resource_setup()
rossellae02431e2013-11-15 17:58:29 +010027
28 def _delete_router(self, router_id):
Rohan Kanadeeeb21642014-08-14 12:00:26 +020029 self.client.delete_router(router_id)
rossellae02431e2013-11-15 17:58:29 +010030 # Asserting that the router is not found in the list
31 # after deletion
David Kranz34e88122014-12-11 15:24:05 -050032 list_body = self.client.list_routers()
rossellae02431e2013-11-15 17:58:29 +010033 routers_list = list()
34 for router in list_body['routers']:
35 routers_list.append(router['id'])
36 self.assertNotIn(router_id, routers_list)
37
armando-migliaccioee90a4d2014-05-06 11:54:07 -070038 def _add_router_interface_with_subnet_id(self, router_id, subnet_id):
David Kranz34e88122014-12-11 15:24:05 -050039 interface = self.client.add_router_interface_with_subnet_id(
armando-migliaccioee90a4d2014-05-06 11:54:07 -070040 router_id, subnet_id)
armando-migliaccioee90a4d2014-05-06 11:54:07 -070041 self.addCleanup(self._remove_router_interface_with_subnet_id,
42 router_id, subnet_id)
43 self.assertEqual(subnet_id, interface['subnet_id'])
44 return interface
45
rossellae02431e2013-11-15 17:58:29 +010046 def _remove_router_interface_with_subnet_id(self, router_id, subnet_id):
David Kranz34e88122014-12-11 15:24:05 -050047 body = self.client.remove_router_interface_with_subnet_id(
rossellae02431e2013-11-15 17:58:29 +010048 router_id, subnet_id)
liudongfbdfc7e2014-02-15 10:52:17 +080049 self.assertEqual(subnet_id, body['subnet_id'])
rossellae02431e2013-11-15 17:58:29 +010050
51 def _remove_router_interface_with_port_id(self, router_id, port_id):
David Kranz34e88122014-12-11 15:24:05 -050052 body = self.client.remove_router_interface_with_port_id(router_id,
53 port_id)
liudongfbdfc7e2014-02-15 10:52:17 +080054 self.assertEqual(port_id, body['port_id'])