blob: 78ffa772efd7dc585ca44fe485300b5cb239d5c0 [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):
Ken'ichi Ohmichib7cdaae2016-05-04 15:41:07 -070029 uri = '/routers/%s' % router_id
30 update_body = {'router': kwargs}
31 return self.update_resource(uri, update_body)
Ken'ichi Ohmichie35f4722015-12-22 04:57:11 +000032
33 def show_router(self, router_id, **fields):
34 uri = '/routers/%s' % router_id
35 return self.show_resource(uri, **fields)
36
37 def delete_router(self, router_id):
38 uri = '/routers/%s' % router_id
39 return self.delete_resource(uri)
40
41 def list_routers(self, **filters):
42 uri = '/routers'
43 return self.list_resources(uri, **filters)
44
Ken'ichi Ohmichie35f4722015-12-22 04:57:11 +000045 def add_router_interface(self, router_id, **kwargs):
46 """Add router interface.
47
48 Available params: see http://developer.openstack.org/
49 api-ref-networking-v2-ext.html#addRouterInterface
50 """
51 uri = '/routers/%s/add_router_interface' % router_id
52 return self.update_resource(uri, kwargs)
53
54 def remove_router_interface(self, router_id, **kwargs):
55 """Remove router interface.
56
57 Available params: see http://developer.openstack.org/
58 api-ref-networking-v2-ext.html#removeRouterInterface
59 """
60 uri = '/routers/%s/remove_router_interface' % router_id
61 return self.update_resource(uri, kwargs)
62
63 def list_l3_agents_hosting_router(self, router_id):
64 uri = '/routers/%s/l3-agents' % router_id
65 return self.list_resources(uri)