blob: 8bec8477e04ea76e142608e343f830b9983aaf7b [file] [log] [blame]
Ken'ichi Ohmichi71860062015-12-15 08:20:13 +00001# Copyright 2015 NEC Corporation. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# 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, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from tempest.services.network.json import base
16
17
18class AgentsClient(base.BaseNetworkClient):
19
20 def update_agent(self, agent_id, **kwargs):
21 """Update agent."""
22 # TODO(piyush): Current api-site doesn't contain this API description.
23 # After fixing the api-site, we need to fix here also for putting the
24 # link to api-site.
25 # LP: https://bugs.launchpad.net/openstack-api-site/+bug/1526673
26 uri = '/agents/%s' % agent_id
27 return self.update_resource(uri, kwargs)
28
29 def show_agent(self, agent_id, **fields):
30 uri = '/agents/%s' % agent_id
31 return self.show_resource(uri, **fields)
32
33 def list_agents(self, **filters):
34 uri = '/agents'
35 return self.list_resources(uri, **filters)
36
37 def list_routers_on_l3_agent(self, agent_id):
38 uri = '/agents/%s/l3-routers' % agent_id
39 return self.list_resources(uri)
40
Ken'ichi Ohmichi70a24e92016-01-06 01:08:27 +000041 def create_router_on_l3_agent(self, agent_id, **kwargs):
Ken'ichi Ohmichi71860062015-12-15 08:20:13 +000042 # TODO(piyush): Current api-site doesn't contain this API description.
43 # After fixing the api-site, we need to fix here also for putting the
44 # link to api-site.
45 # LP: https://bugs.launchpad.net/openstack-api-site/+bug/1526670
46 uri = '/agents/%s/l3-routers' % agent_id
47 return self.create_resource(uri, kwargs)
48
Ken'ichi Ohmichi70a24e92016-01-06 01:08:27 +000049 def delete_router_from_l3_agent(self, agent_id, router_id):
Ken'ichi Ohmichi71860062015-12-15 08:20:13 +000050 uri = '/agents/%s/l3-routers/%s' % (agent_id, router_id)
51 return self.delete_resource(uri)
52
53 def list_networks_hosted_by_one_dhcp_agent(self, agent_id):
54 uri = '/agents/%s/dhcp-networks' % agent_id
55 return self.list_resources(uri)
56
Ken'ichi Ohmichi70a24e92016-01-06 01:08:27 +000057 def delete_network_from_dhcp_agent(self, agent_id, network_id):
Ken'ichi Ohmichi71860062015-12-15 08:20:13 +000058 uri = '/agents/%s/dhcp-networks/%s' % (agent_id,
59 network_id)
60 return self.delete_resource(uri)
61
62 def add_dhcp_agent_to_network(self, agent_id, **kwargs):
63 # TODO(piyush): Current api-site doesn't contain this API description.
64 # After fixing the api-site, we need to fix here also for putting the
65 # link to api-site.
66 # LP: https://bugs.launchpad.net/openstack-api-site/+bug/1526212
67 uri = '/agents/%s/dhcp-networks' % agent_id
68 return self.create_resource(uri, kwargs)