blob: 15703d2e2828397f0fbd1e9c7344d286632143cd [file] [log] [blame]
Oleksiy Petrenko5bfb8bc2018-08-23 15:08:17 +03001from neutronv2.common import send
2from neutronv2.arg_converter import get_by_name_or_uuid_multiple
3
4
5try:
6 from urllib.parse import urlencode
7except ImportError:
8 from urllib import urlencode
9
10
11@send('get')
12def agent_get_details(agent_id, **kwargs):
13 url = '/agents/{}?{}'.format(agent_id, urlencode(kwargs))
14 return url, {}
15
16
17@send('put')
18def agent_update(agent_id, **kwargs):
19 url = '/agents/{}'.format(agent_id)
20 json = {
21 'agent': kwargs,
22 }
23 return url, {'json': json}
24
25
26@send('delete')
27def agent_delete(agent_id, **kwargs):
28 url = '/agents/{}'.format(agent_id)
29 return url, {}
30
31
32@send('get')
33def l3_agent_router_list(agent_id, **kwargs):
34 url = '/agents/{}/l3-routers'.format(agent_id)
35 return url, {}
36
37
38@get_by_name_or_uuid_multiple([('router', 'router_id')])
39@send('post')
40def l3_agent_router_schedule(router_id, agent_id, **kwargs):
41 url = '/agents/{}/l3-routers'.format(agent_id)
42 json = {
43 'router_id': router_id,
44 }
45 return url, {'json': json}
46
47
48@get_by_name_or_uuid_multiple([('router', 'router_id')])
49@send('delete')
50def l3_agent_router_remove(router_id, agent_id, **kwargs):
51 url = '/agents/{}/l3-routers/{}'.format(agent_id, router_id)
52 return url, {}
53
54
55@get_by_name_or_uuid_multiple([('router', 'router_id')])
56@send('get')
57def l3_agent_by_router_list(router_id, **kwargs):
58 url = '/routers/{}/l3-agents'.format(router_id)
59 return url, {}
60
61
62@send('get')
63def dhcp_agent_list_networks(agent_id, **kwargs):
64 url = '/agents/{}/dhcp-networks'.format(agent_id)
65 return url, {}
66
67
68@get_by_name_or_uuid_multiple([('network', 'network_id')])
69@send('post')
70def dhcp_agent_network_schedule(network_id, agent_id, **kwargs):
71 url = '/agents/{}/dhcp-networks'.format(agent_id)
72 json = {
73 'network_id': network_id,
74 }
75 return url, {'json': json}
76
77
78@get_by_name_or_uuid_multiple([('network', 'network_id')])
79@send('delete')
80def dhcp_agent_network_remove(network_id, agent_id, **kwargs):
81 url = '/agents/{}/dhcp-networks/{}'.format(agent_id, network_id)
82 return url, {}
83
84
85@get_by_name_or_uuid_multiple([('network', 'network_id')])
86@send('get')
87def dhcp_agent_by_network_list(network_id, **kwargs):
88 url = '/networks/{}/dhcp-agents'.format(network_id)
89 return url, {}