Oleg Bondarev | 9250e61 | 2018-09-24 18:59:40 +0400 | [diff] [blame] | 1 | from octaviav2.common import send |
| 2 | from octaviav2.common import get_by_name_or_uuid |
| 3 | |
| 4 | try: |
| 5 | from urllib.parse import urlencode |
| 6 | except ImportError: |
| 7 | from urllib import urlencode |
| 8 | |
| 9 | RESOURCE_LIST_KEY = 'loadbalancers' |
| 10 | |
| 11 | |
| 12 | @send('get') |
| 13 | def loadbalancer_list(**kwargs): |
| 14 | url = '/v2.0/lbaas/loadbalancers?{}'.format(urlencode(kwargs)) |
| 15 | return url, {} |
| 16 | |
| 17 | @get_by_name_or_uuid(loadbalancer_list, RESOURCE_LIST_KEY) |
| 18 | @send('get') |
| 19 | def loadbalancer_get_details(loadbalancer_id, **kwargs): |
| 20 | url = '/v2.0/lbaas/loadbalancers/{}?{}'.format(loadbalancer_id, urlencode(kwargs)) |
| 21 | return url, {} |
| 22 | |
| 23 | |
| 24 | @get_by_name_or_uuid(loadbalancer_list, RESOURCE_LIST_KEY) |
| 25 | @send('put') |
| 26 | def loadbalancer_update(loadbalancer_id, **kwargs): |
| 27 | url = '/v2.0/lbaas/loadbalancers/{}'.format(loadbalancer_id) |
| 28 | json = { |
| 29 | 'loadbalancer': kwargs, |
| 30 | } |
| 31 | return url, {'json': json} |
| 32 | |
| 33 | |
| 34 | @get_by_name_or_uuid(loadbalancer_list, RESOURCE_LIST_KEY) |
| 35 | @send('delete') |
| 36 | def loadbalancer_delete(loadbalancer_id, **kwargs): |
| 37 | url = '/v2.0/lbaas/loadbalancers/{}'.format(loadbalancer_id) |
| 38 | return url, {} |
| 39 | |
| 40 | |
| 41 | @send('post') |
| 42 | def loadbalancer_create(**kwargs): |
| 43 | url = '/v2.0/lbaas/loadbalancers' |
| 44 | json = { |
| 45 | 'loadbalancer': kwargs, |
| 46 | } |
| 47 | return url, {'json': json} |