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([('subnetpool', 'subnetpool_id')]) |
Oleksiy Petrenko | caad203 | 2018-04-20 14:42:46 +0300 | [diff] [blame] | 11 | @send('get') |
| 12 | def subnetpool_get_details(subnetpool_id, **kwargs): |
| 13 | url = '/subnetpools/{}?{}'.format( |
| 14 | subnetpool_id, urlencode(kwargs) |
| 15 | ) |
| 16 | return url, {} |
| 17 | |
| 18 | |
Oleksiy Petrenko | 5bfb8bc | 2018-08-23 15:08:17 +0300 | [diff] [blame] | 19 | @get_by_name_or_uuid_multiple([('subnetpool', 'subnetpool_id')]) |
Oleksiy Petrenko | caad203 | 2018-04-20 14:42:46 +0300 | [diff] [blame] | 20 | @send('put') |
| 21 | def subnetpool_update(subnetpool_id, **kwargs): |
| 22 | url = '/subnetpools/{}'.format(subnetpool_id) |
| 23 | json = { |
| 24 | 'subnetpool': kwargs, |
| 25 | } |
| 26 | return url, {'json': json} |
| 27 | |
| 28 | |
Oleksiy Petrenko | 5bfb8bc | 2018-08-23 15:08:17 +0300 | [diff] [blame] | 29 | @get_by_name_or_uuid_multiple([('subnetpool', 'subnetpool_id')]) |
Oleksiy Petrenko | caad203 | 2018-04-20 14:42:46 +0300 | [diff] [blame] | 30 | @send('delete') |
| 31 | def subnetpool_delete(subnetpool_id, **kwargs): |
| 32 | url = '/subnetpools/{}'.format(subnetpool_id) |
| 33 | return url, {} |
| 34 | |
| 35 | |
| 36 | @send('post') |
| 37 | def subnetpool_create(name, prefixes, **kwargs): |
| 38 | url = '/subnetpools' |
| 39 | json = { |
| 40 | 'subnetpool': { |
| 41 | 'name': name, |
| 42 | 'prefixes': prefixes, |
| 43 | } |
| 44 | } |
| 45 | json['subnetpool'].update(kwargs) |
| 46 | return url, {'json': json} |