blob: 6b8353a106c15e434dc166b8e816bdedbc60100b [file] [log] [blame]
Oleksiy Petrenkoe38f5a62018-11-21 12:58:07 +02001from cinderv3.common import send
2from cinderv3.arg_converter import get_by_name_or_uuid_multiple
3
4try:
5 from urllib.parse import urlencode
6except ImportError:
7 from urllib import urlencode
8
9
10@send("post")
11def volume_create(size, **kwargs):
12 url = '/volumes'
13 json = {'volume': {
14 'size': size,
15 }}
16 json['volume'].update(kwargs)
17 return url, json
18
19
20@get_by_name_or_uuid_multiple([('volume', 'volume_id')])
21@send("get")
22def volume_get_details(volume_id, **kwargs):
23 url = '/volumes/{}'.format(volume_id)
24 return url, None
25
26
27@get_by_name_or_uuid_multiple([('volume', 'volume_id')])
28@send("put")
29def volume_update(volume_id, **kwargs):
30 url = '/volumes/{}'.format(volume_id)
31 json = {'volume': kwargs}
32 return url, json
33
34
35@get_by_name_or_uuid_multiple([('volume', 'volume_id')])
36@send("delete")
37def volume_delete(volume_id, **kwargs):
38 url = '/volumes/{}'.format(volume_id)
39 return url, None
40
41
42@get_by_name_or_uuid_multiple([('volume', 'volume_id')])
43@send("post")
44def volume_metadata_create(volume_id, metadata, **kwargs):
45 url = '/volumes/{}/metadata'.format(volume_id)
46 json = {
47 'metadata': metadata,
48 }
49 return url, json
50
51
52@get_by_name_or_uuid_multiple([('volume', 'volume_id')])
53@send("get")
54def volume_metadata_show(volume_id, **kwargs):
55 url = '/volumes/{}/metadata'.format(volume_id)
56 return url, None
57
58
59@get_by_name_or_uuid_multiple([('volume', 'volume_id')])
60@send("put")
61def volume_metadata_update(volume_id, metadata, **kwargs):
62 url = '/volumes/{}/metadata'.format(volume_id)
63 json = {
64 'metadata': metadata,
65 }
66 return url, json
67
68
69@get_by_name_or_uuid_multiple([('volume', 'volume_id')])
70@send("get")
71def volume_metadata_show_key(volume_id, key, **kwargs):
72 url = '/volumes/{}/metadata/{}'.format(volume_id, key)
73 return url, None
74
75
76@get_by_name_or_uuid_multiple([('volume', 'volume_id')])
77@send("delete")
78def volume_metadata_delete(volume_id, key):
79 url = '/volumes/{}/metadata/{}'.format(volume_id, key)
80 return url, None
81
82
83@get_by_name_or_uuid_multiple([('volume', 'volume_id')])
84@send("put")
85def volume_metadata_update_key(volume_id, key, meta, **kwargs):
86 url = '/volumes/{}/metadata/{}'.format(volume_id, key)
87 json = {
88 'meta': meta,
89 }
90 return url, json