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 | |
| 4 | try: |
| 5 | from urllib.parse import urlencode |
| 6 | except ImportError: |
| 7 | from urllib import urlencode |
| 8 | |
| 9 | |
| 10 | @send('post') |
| 11 | def router_create(name, **kwargs): |
| 12 | url = '/routers' |
| 13 | json = { |
| 14 | 'router': { |
| 15 | 'name': name, |
| 16 | } |
| 17 | } |
| 18 | json['router'].update(kwargs) |
| 19 | return url, {'json': json} |
| 20 | |
| 21 | |
| 22 | @get_by_name_or_uuid_multiple([('router', 'router_id')]) |
| 23 | @send('get') |
| 24 | def router_get_details(router_id, **kwargs): |
| 25 | url = '/routers/{}?{}'.format(router_id, urlencode(kwargs)) |
| 26 | return url, {} |
| 27 | |
| 28 | |
| 29 | @get_by_name_or_uuid_multiple([('router', 'router_id')]) |
| 30 | @send('put') |
| 31 | def router_update(router_id, **kwargs): |
| 32 | url = '/routers/{}'.format(router_id) |
| 33 | return url, {'json': {'router': kwargs}} |
| 34 | |
| 35 | |
| 36 | @get_by_name_or_uuid_multiple([('router', 'router_id')]) |
| 37 | @send('delete') |
| 38 | def router_delete(router_id, **kwargs): |
| 39 | url = '/routers/{}'.format(router_id) |
| 40 | return url, {} |
| 41 | |
| 42 | |
| 43 | @get_by_name_or_uuid_multiple([('router', 'router_id')]) |
| 44 | @send('put') |
| 45 | def router_interface_add(router_id, **kwargs): |
| 46 | url = '/routers/{}/add_role_interface'.format(router_id) |
| 47 | json = kwargs |
| 48 | return url, {'json': json} |
| 49 | |
| 50 | |
| 51 | @get_by_name_or_uuid_multiple([('router', 'router_id')]) |
| 52 | @send('put') |
| 53 | def router_interface_remove(router_id, **kwargs): |
| 54 | url = '/routers/{}/remove_role_interface'.format(router_id) |
| 55 | json = kwargs |
| 56 | return url, {'json': json} |