| Oleksiy Petrenko | a5eb060 | 2018-07-26 15:12:25 +0300 | [diff] [blame] | 1 | from ironicv1.common import send | 
|  | 2 | try: | 
|  | 3 | from urllib.parse import urlencode | 
|  | 4 | except ImportError: | 
|  | 5 | from urllib import urlencode | 
|  | 6 |  | 
|  | 7 |  | 
|  | 8 | @send('get') | 
|  | 9 | def volume_resource_list(**kwargs): | 
|  | 10 | url = '/volume' | 
|  | 11 | return url, {} | 
|  | 12 |  | 
|  | 13 |  | 
|  | 14 | @send('get') | 
|  | 15 | def volume_connector_list(**kwargs): | 
|  | 16 | url = '/volume/connectors?{}'.format(urlencode(kwargs)) | 
|  | 17 | return url, {} | 
|  | 18 |  | 
|  | 19 |  | 
|  | 20 | @send('post') | 
|  | 21 | def volume_connector_create(node_uuid, volume_type, connector_id, **kwargs): | 
|  | 22 | url = '/volume/connectors' | 
|  | 23 | json = { | 
|  | 24 | 'node_uuid': node_uuid, | 
|  | 25 | 'type': volume_type, | 
|  | 26 | 'connector_id': connector_id, | 
|  | 27 | } | 
|  | 28 | json.update(kwargs) | 
|  | 29 | return url, {'json': json} | 
|  | 30 |  | 
|  | 31 |  | 
|  | 32 | @send('get') | 
|  | 33 | def volume_connector_get_details(volume_connector_id, **kwargs): | 
|  | 34 | url = '/volume/connectors/{}?{}'.format( | 
|  | 35 | volume_connector_id, urlencode(kwargs)) | 
|  | 36 | return url, {} | 
|  | 37 |  | 
|  | 38 |  | 
|  | 39 | @send('patch') | 
|  | 40 | def volume_connector_update(volume_connector_id, properties, **kwargs): | 
|  | 41 | url = '/volume/connectors/{}'.format(volume_connector_id) | 
|  | 42 | return url, {'json': properties} | 
|  | 43 |  | 
|  | 44 |  | 
|  | 45 | @send('delete') | 
|  | 46 | def volume_connector_delete(volume_connector_id, **kwargs): | 
|  | 47 | url = '/volume/connectors/{}'.format(volume_connector_id) | 
|  | 48 | return url, {} | 
|  | 49 |  | 
|  | 50 |  | 
|  | 51 | @send('get') | 
|  | 52 | def volume_target_list(**kwargs): | 
|  | 53 | url = '/volume/targets?{}'.format(urlencode(kwargs)) | 
|  | 54 | return url, {} | 
|  | 55 |  | 
|  | 56 |  | 
|  | 57 | @send('post') | 
|  | 58 | def volume_target_create(node_uuid, volume_type, properties, | 
|  | 59 | boot_index, volume_id, **kwargs): | 
|  | 60 | url = '/volume/targets' | 
|  | 61 | json = { | 
|  | 62 | 'node_uuid': node_uuid, | 
|  | 63 | 'volume_type': volume_type, | 
|  | 64 | 'properties': properties, | 
|  | 65 | 'boot_index': boot_index, | 
|  | 66 | 'volume_id': volume_id, | 
|  | 67 | } | 
|  | 68 | json.update(kwargs) | 
|  | 69 | return url, {'json': json} | 
|  | 70 |  | 
|  | 71 |  | 
|  | 72 | @send('get') | 
|  | 73 | def volume_target_get_details(target_id, **kwargs): | 
|  | 74 | url = '/volume/targets/{}?{}'.format(target_id, urlencode(kwargs)) | 
|  | 75 | return url, {} | 
|  | 76 |  | 
|  | 77 |  | 
|  | 78 | @send('patch') | 
|  | 79 | def volume_target_update(target_id, properties, **kwargs): | 
|  | 80 | url = '/volume/targets/{}'.format(target_id) | 
|  | 81 | return url, {'json': properties} | 
|  | 82 |  | 
|  | 83 |  | 
|  | 84 | @send('delete') | 
|  | 85 | def volume_target_delete(target_id, **kwargs): | 
|  | 86 | url = '/volume/targets/{}'.format(target_id) | 
|  | 87 | return url, {} |