blob: 23e9c4e6ed763573b92269b9c67f7e71cba23a56 [file] [log] [blame]
Ken'ichi Ohmichie35f4722015-12-22 04:57:11 +00001# 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
Ken'ichi Ohmichi2a0e7362016-03-08 12:07:16 -080013from tempest.lib.services.network import base
Ken'ichi Ohmichie35f4722015-12-22 04:57:11 +000014
15
16class RoutersClient(base.BaseNetworkClient):
17
Ken'ichi Ohmichi6665c972016-02-24 13:09:09 -080018 def create_router(self, **kwargs):
19 """Create a router.
20
21 Available params: see http://developer.openstack.org/
22 api-ref-networking-v2-ext.html#createRouter
23 """
Ken'ichi Ohmichie35f4722015-12-22 04:57:11 +000024 post_body = {'router': kwargs}
Ken'ichi Ohmichie35f4722015-12-22 04:57:11 +000025 uri = '/routers'
26 return self.create_resource(uri, post_body)
27
Ken'ichi Ohmichie35f4722015-12-22 04:57:11 +000028 def update_router(self, router_id, **kwargs):
Lv Fumei8efac682016-07-08 16:49:52 +080029 """Updates a logical router.
30
31 Available params: see http://developer.openstack.org/
32 api-ref-networking-v2-ext.html#updateRouter
33 """
Ken'ichi Ohmichib7cdaae2016-05-04 15:41:07 -070034 uri = '/routers/%s' % router_id
35 update_body = {'router': kwargs}
36 return self.update_resource(uri, update_body)
Ken'ichi Ohmichie35f4722015-12-22 04:57:11 +000037
38 def show_router(self, router_id, **fields):
Lv Fumei8efac682016-07-08 16:49:52 +080039 """Shows details for a router.
40
41 Available params: see http://developer.openstack.org/
42 api-ref-networking-v2-ext.html#showRouter
43 """
Ken'ichi Ohmichie35f4722015-12-22 04:57:11 +000044 uri = '/routers/%s' % router_id
45 return self.show_resource(uri, **fields)
46
47 def delete_router(self, router_id):
48 uri = '/routers/%s' % router_id
49 return self.delete_resource(uri)
50
51 def list_routers(self, **filters):
Lv Fumei8efac682016-07-08 16:49:52 +080052 """Lists logical routers.
53
54 Available params: see http://developer.openstack.org/
55 api-ref-networking-v2-ext.html#listRouters
56 """
Ken'ichi Ohmichie35f4722015-12-22 04:57:11 +000057 uri = '/routers'
58 return self.list_resources(uri, **filters)
59
Ken'ichi Ohmichie35f4722015-12-22 04:57:11 +000060 def add_router_interface(self, router_id, **kwargs):
61 """Add router interface.
62
63 Available params: see http://developer.openstack.org/
Lv Fumei8efac682016-07-08 16:49:52 +080064 api-ref-networking-v2-ext.html#
65 addRouterInterface
Ken'ichi Ohmichie35f4722015-12-22 04:57:11 +000066 """
67 uri = '/routers/%s/add_router_interface' % router_id
68 return self.update_resource(uri, kwargs)
69
70 def remove_router_interface(self, router_id, **kwargs):
71 """Remove router interface.
72
73 Available params: see http://developer.openstack.org/
Lv Fumei8efac682016-07-08 16:49:52 +080074 api-ref-networking-v2-ext.html#
75 deleteRouterInterface
Ken'ichi Ohmichie35f4722015-12-22 04:57:11 +000076 """
77 uri = '/routers/%s/remove_router_interface' % router_id
78 return self.update_resource(uri, kwargs)
79
80 def list_l3_agents_hosting_router(self, router_id):
81 uri = '/routers/%s/l3-agents' % router_id
82 return self.list_resources(uri)