Oleksiy Petrenko | 5bfb8bc | 2018-08-23 15:08:17 +0300 | [diff] [blame] | 1 | from neutronv2.common import send |
| 2 | from neutronv2.arg_converter import get_by_name_or_uuid_multiple |
| 3 | |
Oleksiy Petrenko | caad203 | 2018-04-20 14:42:46 +0300 | [diff] [blame] | 4 | try: |
| 5 | from urllib.parse import urlencode |
| 6 | except ImportError: |
| 7 | from urllib import urlencode |
| 8 | |
Oleksiy Petrenko | caad203 | 2018-04-20 14:42:46 +0300 | [diff] [blame] | 9 | |
Oleksiy Petrenko | 5bfb8bc | 2018-08-23 15:08:17 +0300 | [diff] [blame] | 10 | @get_by_name_or_uuid_multiple([('network', 'network_id')]) |
Oleksiy Petrenko | caad203 | 2018-04-20 14:42:46 +0300 | [diff] [blame] | 11 | @send('post') |
| 12 | def 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') |
| 26 | def subnet_bulk_create(subnets, **kwargs): |
| 27 | url = '/subnets' |
| 28 | json = { |
| 29 | 'subnets': subnets, |
| 30 | } |
| 31 | return url, {'json': json} |
| 32 | |
| 33 | |
Oleksiy Petrenko | 5bfb8bc | 2018-08-23 15:08:17 +0300 | [diff] [blame] | 34 | @get_by_name_or_uuid_multiple([('subnet', 'subnet_id')]) |
Oleksiy Petrenko | caad203 | 2018-04-20 14:42:46 +0300 | [diff] [blame] | 35 | @send('get') |
| 36 | def subnet_get_details(subnet_id, **kwargs): |
| 37 | url = '/subnets/{}'.format(subnet_id) |
| 38 | return url, {} |
| 39 | |
| 40 | |
Oleksiy Petrenko | 5bfb8bc | 2018-08-23 15:08:17 +0300 | [diff] [blame] | 41 | @get_by_name_or_uuid_multiple([('subnet', 'subnet_id')]) |
Oleksiy Petrenko | caad203 | 2018-04-20 14:42:46 +0300 | [diff] [blame] | 42 | @send('put') |
| 43 | def 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 Petrenko | 5bfb8bc | 2018-08-23 15:08:17 +0300 | [diff] [blame] | 51 | @get_by_name_or_uuid_multiple([('subnet', 'subnet_id')]) |
Oleksiy Petrenko | caad203 | 2018-04-20 14:42:46 +0300 | [diff] [blame] | 52 | @send('delete') |
| 53 | def subnet_delete(subnet_id, **kwargs): |
| 54 | url = '/subnets/{}'.format(subnet_id) |
| 55 | return url, {} |