blob: 7388584e263f60a10d30d3aef52256bcd3a9a877 [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
Oleksiy Petrenkocaad2032018-04-20 14:42:46 +03004try:
5 from urllib.parse import urlencode
6except ImportError:
7 from urllib import urlencode
8
Oleksiy Petrenkocaad2032018-04-20 14:42:46 +03009
Oleksiy Petrenko5bfb8bc2018-08-23 15:08:17 +030010@get_by_name_or_uuid_multiple([('network', 'network_id')])
Oleksiy Petrenkocaad2032018-04-20 14:42:46 +030011@send('post')
12def subnet_create(network_id, ip_version, cidr, **kwargs):
13 url = '/subnets'
14 json = {
15 'subnet': {
16 'network_id': network_id,
17 'ip_version': ip_version,
18 'cidr': cidr,
19 }
20 }
21 json['subnet'].update(kwargs)
22 return url, {'json': json}
23
24
25@send('post')
26def subnet_bulk_create(subnets, **kwargs):
27 url = '/subnets'
28 json = {
29 'subnets': subnets,
30 }
31 return url, {'json': json}
32
33
Oleksiy Petrenko5bfb8bc2018-08-23 15:08:17 +030034@get_by_name_or_uuid_multiple([('subnet', 'subnet_id')])
Oleksiy Petrenkocaad2032018-04-20 14:42:46 +030035@send('get')
36def subnet_get_details(subnet_id, **kwargs):
37 url = '/subnets/{}'.format(subnet_id)
38 return url, {}
39
40
Oleksiy Petrenko5bfb8bc2018-08-23 15:08:17 +030041@get_by_name_or_uuid_multiple([('subnet', 'subnet_id')])
Oleksiy Petrenkocaad2032018-04-20 14:42:46 +030042@send('put')
43def subnet_update(subnet_id, **kwargs):
44 url = '/subnets/{}'.format(subnet_id)
45 json = {
46 'subnet': kwargs,
47 }
48 return url, {'json': json}
49
50
Oleksiy Petrenko5bfb8bc2018-08-23 15:08:17 +030051@get_by_name_or_uuid_multiple([('subnet', 'subnet_id')])
Oleksiy Petrenkocaad2032018-04-20 14:42:46 +030052@send('delete')
53def subnet_delete(subnet_id, **kwargs):
54 url = '/subnets/{}'.format(subnet_id)
55 return url, {}