Merge ~jsseidel/maas:jsseidel-raid-api-annotations into maas:master
- Git
- lp:~jsseidel/maas
- jsseidel-raid-api-annotations
- Merge into master
Status: | Merged |
---|---|
Approved by: | Spencer Seidel |
Approved revision: | 2c42cc18a25d5ed2daec1bb25f8712563b42283c |
Merge reported by: | MAAS Lander |
Merged at revision: | not available |
Proposed branch: | ~jsseidel/maas:jsseidel-raid-api-annotations |
Merge into: | maas:master |
Diff against target: |
250 lines (+148/-38) 2 files modified
src/maasserver/api/examples/nodes.json (+3/-0) src/maasserver/api/raid.py (+145/-38) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
MAAS Lander | Needs Fixing | ||
Mike Pontillo (community) | Approve | ||
Review via email: mp+361200@code.launchpad.net |
Commit message
Added API annotations and examples. Note that placeholders were used for example data because the sample data doesn't cover RAID devices.
Description of the change
MAAS Lander (maas-lander) wrote : | # |
UNIT TESTS
-b jsseidel-
STATUS: FAILED
LOG: http://
COMMIT: f59de3bb0d2b072
Mike Pontillo (mpontillo) wrote : | # |
Looks good; a few minor nits below.
MAAS Lander (maas-lander) wrote : | # |
LANDING
-b jsseidel-
STATUS: FAILED BUILD
LOG: http://
MAAS Lander (maas-lander) wrote : | # |
LANDING
-b jsseidel-
STATUS: FAILED BUILD
LOG: http://
MAAS Lander (maas-lander) wrote : | # |
UNIT TESTS
-b jsseidel-
STATUS: FAILED
LOG: http://
COMMIT: 2c42cc18a25d5ed
Preview Diff
1 | diff --git a/src/maasserver/api/examples/nodes.json b/src/maasserver/api/examples/nodes.json | |||
2 | index 3ea4a3a..dfebdee 100644 | |||
3 | --- a/src/maasserver/api/examples/nodes.json | |||
4 | +++ b/src/maasserver/api/examples/nodes.json | |||
5 | @@ -5223,5 +5223,8 @@ | |||
6 | 5223 | "system_id": "thr3am", | 5223 | "system_id": "thr3am", |
7 | 5224 | "type": "physical", | 5224 | "type": "physical", |
8 | 5225 | "resource_uri": "/MAAS/api/2.0/nodes/thr3am/interfaces/37/" | 5225 | "resource_uri": "/MAAS/api/2.0/nodes/thr3am/interfaces/37/" |
9 | 5226 | }, | ||
10 | 5227 | "raids-placeholder": { | ||
11 | 5228 | "message": "Information about this object is not available at this time." | ||
12 | 5226 | } | 5229 | } |
13 | 5227 | } | 5230 | } |
14 | diff --git a/src/maasserver/api/raid.py b/src/maasserver/api/raid.py | |||
15 | index 4e65157..a712e4c 100644 | |||
16 | --- a/src/maasserver/api/raid.py | |||
17 | +++ b/src/maasserver/api/raid.py | |||
18 | @@ -40,7 +40,7 @@ DISPLAYED_RAID_FIELDS = ( | |||
19 | 40 | 40 | ||
20 | 41 | 41 | ||
21 | 42 | class RaidsHandler(OperationsHandler): | 42 | class RaidsHandler(OperationsHandler): |
23 | 43 | """Manage all RAID devices on a machine.""" | 43 | """Manage all RAIDs (Redundant Array of Independent Disks) on a machine.""" |
24 | 44 | api_doc_section_name = "RAID Devices" | 44 | api_doc_section_name = "RAID Devices" |
25 | 45 | update = delete = None | 45 | update = delete = None |
26 | 46 | fields = DISPLAYED_RAID_FIELDS | 46 | fields = DISPLAYED_RAID_FIELDS |
27 | @@ -51,18 +51,45 @@ class RaidsHandler(OperationsHandler): | |||
28 | 51 | return ('raid_devices_handler', ["system_id"]) | 51 | return ('raid_devices_handler', ["system_id"]) |
29 | 52 | 52 | ||
30 | 53 | def create(self, request, system_id): | 53 | def create(self, request, system_id): |
43 | 54 | """Creates a RAID | 54 | """@description-title Set up a RAID |
44 | 55 | 55 | @description Set up a RAID on a machine with the given system_id. | |
45 | 56 | :param name: Name of the RAID. | 56 | |
46 | 57 | :param uuid: UUID of the RAID. | 57 | @param (string) "{system_id}" [required=true] The system_id of the |
47 | 58 | :param level: RAID level. | 58 | machine on which to set up the RAID. |
48 | 59 | :param block_devices: Block devices to add to the RAID. | 59 | |
49 | 60 | :param spare_devices: Spare block devices to add to the RAID. | 60 | @param (string) "name" [required=false] Name of the RAID. |
50 | 61 | :param partitions: Partitions to add to the RAID. | 61 | |
51 | 62 | :param spare_partitions: Spare partitions to add to the RAID. | 62 | @param (string) "uuid" [required=false] UUID of the RAID. |
52 | 63 | 63 | ||
53 | 64 | Returns 404 if the machine is not found. | 64 | @param (int) "level" [required=true] RAID level. |
54 | 65 | Returns 409 if the machine is not Ready. | 65 | |
55 | 66 | @param (string) "block_devices" [required=false] Block devices to add | ||
56 | 67 | to the RAID. | ||
57 | 68 | |||
58 | 69 | @param (string) "spare_devices" [required=false] Spare block devices to | ||
59 | 70 | add to the RAID. | ||
60 | 71 | |||
61 | 72 | @param (string) "partitions" [required=false] Partitions to add to the | ||
62 | 73 | RAID. | ||
63 | 74 | |||
64 | 75 | @param (string) "spare_partitions" [required=false] Spare partitions to | ||
65 | 76 | add to the RAID. | ||
66 | 77 | |||
67 | 78 | @success (http-status-code) "200" 200 | ||
68 | 79 | @success (json) "success-json" A JSON object containing information | ||
69 | 80 | about the new RAID. | ||
70 | 81 | @success-example "success-json" [exkey=raids-placeholder] placeholder | ||
71 | 82 | text | ||
72 | 83 | |||
73 | 84 | @error (http-status-code) "404" 404 | ||
74 | 85 | @error (content) "not-found" The requested machine is not found. | ||
75 | 86 | @error-example "not-found" | ||
76 | 87 | Not Found | ||
77 | 88 | |||
78 | 89 | @error (http-status-code) "409" 409 | ||
79 | 90 | @error (content) "not-ready" The requested machine is not ready. | ||
80 | 91 | @error-example "not-ready" | ||
81 | 92 | Cannot create RAID because the machine is not Ready. | ||
82 | 66 | """ | 93 | """ |
83 | 67 | machine = Machine.objects.get_node_or_404( | 94 | machine = Machine.objects.get_node_or_404( |
84 | 68 | system_id, request.user, NodePermission.admin) | 95 | system_id, request.user, NodePermission.admin) |
85 | @@ -76,9 +103,23 @@ class RaidsHandler(OperationsHandler): | |||
86 | 76 | raise MAASAPIValidationError(form.errors) | 103 | raise MAASAPIValidationError(form.errors) |
87 | 77 | 104 | ||
88 | 78 | def read(self, request, system_id): | 105 | def read(self, request, system_id): |
90 | 79 | """List all RAID devices belonging to a machine. | 106 | """@description-title List all RAIDs |
91 | 107 | @description List all RAIDs belonging to a machine with the given | ||
92 | 108 | system_id. | ||
93 | 109 | |||
94 | 110 | @param (string) "{system_id}" [required=true] The system_id of the | ||
95 | 111 | machine containing the RAIDs. | ||
96 | 80 | 112 | ||
98 | 81 | Returns 404 if the machine is not found. | 113 | @success (http-status-code) "200" 200 |
99 | 114 | @success (json) "success-json" A JSON object containing a list of | ||
100 | 115 | available RAIDs. | ||
101 | 116 | @success-example "success-json" [exkey=raids-placeholder] placeholder | ||
102 | 117 | text | ||
103 | 118 | |||
104 | 119 | @error (http-status-code) "404" 404 | ||
105 | 120 | @error (content) "not-found" The requested machine is not found. | ||
106 | 121 | @error-example "not-found" | ||
107 | 122 | Not Found | ||
108 | 82 | """ | 123 | """ |
109 | 83 | machine = Machine.objects.get_node_or_404( | 124 | machine = Machine.objects.get_node_or_404( |
110 | 84 | system_id, request.user, NodePermission.view) | 125 | system_id, request.user, NodePermission.view) |
111 | @@ -86,7 +127,10 @@ class RaidsHandler(OperationsHandler): | |||
112 | 86 | 127 | ||
113 | 87 | 128 | ||
114 | 88 | class RaidHandler(OperationsHandler): | 129 | class RaidHandler(OperationsHandler): |
116 | 89 | """Manage a specific RAID device on a machine.""" | 130 | """ |
117 | 131 | Manage a specific RAID (Redundant Array of Independent Disks) on a | ||
118 | 132 | machine. | ||
119 | 133 | """ | ||
120 | 90 | api_doc_section_name = "RAID Device" | 134 | api_doc_section_name = "RAID Device" |
121 | 91 | create = None | 135 | create = None |
122 | 92 | model = RAID | 136 | model = RAID |
123 | @@ -148,31 +192,80 @@ class RaidHandler(OperationsHandler): | |||
124 | 148 | ] | 192 | ] |
125 | 149 | 193 | ||
126 | 150 | def read(self, request, system_id, id): | 194 | def read(self, request, system_id, id): |
128 | 151 | """Read RAID device on a machine. | 195 | """@description-title Read a RAID |
129 | 196 | @description Read RAID with the given id on a machine with the | ||
130 | 197 | given system_id. | ||
131 | 198 | |||
132 | 199 | @param (string) "{system_id}" [required=true] The system_id of the | ||
133 | 200 | machine containing the RAID. | ||
134 | 201 | @param (int) "{id}" [required=true] A RAID id. | ||
135 | 152 | 202 | ||
137 | 153 | Returns 404 if the machine or RAID is not found. | 203 | @success (http-status-code) "200" 200 |
138 | 204 | @success (json) "success-json" A JSON object containing the requested | ||
139 | 205 | RAID. | ||
140 | 206 | @success-example "success-json" [exkey=raids-placeholder] placeholder | ||
141 | 207 | text | ||
142 | 208 | |||
143 | 209 | @error (http-status-code) "404" 404 | ||
144 | 210 | @error (content) "not-found" The requested machine or RAID is not | ||
145 | 211 | found. | ||
146 | 212 | @error-example "not-found" | ||
147 | 213 | Not Found | ||
148 | 154 | """ | 214 | """ |
149 | 155 | return RAID.objects.get_object_or_404( | 215 | return RAID.objects.get_object_or_404( |
150 | 156 | system_id, id, request.user, NodePermission.view) | 216 | system_id, id, request.user, NodePermission.view) |
151 | 157 | 217 | ||
152 | 158 | def update(self, request, system_id, id): | 218 | def update(self, request, system_id, id): |
170 | 159 | """Update RAID on a machine. | 219 | """@description-title Update a RAID |
171 | 160 | 220 | @description Update a RAID with the given id on a machine with the | |
172 | 161 | :param name: Name of the RAID. | 221 | given system_id. |
173 | 162 | :param uuid: UUID of the RAID. | 222 | |
174 | 163 | :param add_block_devices: Block devices to add to the RAID. | 223 | @param (string) "{system_id}" [required=true] The system_id of the |
175 | 164 | :param remove_block_devices: Block devices to remove from the RAID. | 224 | machine containing the RAID. |
176 | 165 | :param add_spare_devices: Spare block devices to add to the RAID. | 225 | @param (int) "{id}" [required=true] A RAID id. |
177 | 166 | :param remove_spare_devices: Spare block devices to remove | 226 | |
178 | 167 | from the RAID. | 227 | @param (string) "name" [required=false] Name of the RAID. |
179 | 168 | :param add_partitions: Partitions to add to the RAID. | 228 | |
180 | 169 | :param remove_partitions: Partitions to remove from the RAID. | 229 | @param (string) "uuid" [required=false] UUID of the RAID. |
181 | 170 | :param add_spare_partitions: Spare partitions to add to the RAID. | 230 | |
182 | 171 | :param remove_spare_partitions: Spare partitions to remove from the | 231 | @param (string) "add_block_devices" [required=false] Block devices to |
183 | 172 | RAID. | 232 | add to the RAID. |
184 | 173 | 233 | ||
185 | 174 | Returns 404 if the machine or RAID is not found. | 234 | @param (string) "remove_block_devices" [required=false] Block devices |
186 | 175 | Returns 409 if the machine is not Ready. | 235 | to remove from the RAID. |
187 | 236 | |||
188 | 237 | @param (string) "add_spare_devices" [required=false] Spare block | ||
189 | 238 | devices to add to the RAID. | ||
190 | 239 | |||
191 | 240 | @param (string) "remove_spare_devices" [required=false] Spare block | ||
192 | 241 | devices to remove from the RAID. | ||
193 | 242 | |||
194 | 243 | @param (string) "add_partitions" [required=false] Partitions to add to | ||
195 | 244 | the RAID. | ||
196 | 245 | |||
197 | 246 | @param (string) "remove_partitions" [required=false] Partitions to | ||
198 | 247 | remove from the RAID. | ||
199 | 248 | |||
200 | 249 | @param (string) "add_spare_partitions" [required=false] Spare | ||
201 | 250 | partitions to add to the RAID. | ||
202 | 251 | |||
203 | 252 | @param (string) "remove_spare_partitions" [required=false] Spare | ||
204 | 253 | partitions to remove from the RAID. | ||
205 | 254 | |||
206 | 255 | @success (http-status-code) "200" 200 | ||
207 | 256 | @success (json) "success-json" A JSON object containing the updated | ||
208 | 257 | RAID. | ||
209 | 258 | @success-example "success-json" [exkey=raids-placeholder] placeholder | ||
210 | 259 | text | ||
211 | 260 | |||
212 | 261 | @error (http-status-code) "404" 404 | ||
213 | 262 | @error (content) "not-found" The requested machine or RAID id is not | ||
214 | 263 | found. | ||
215 | 264 | @error-example "not-found" | ||
216 | 265 | Not Found | ||
217 | 266 | |||
218 | 267 | @error (http-status-code) "409" 409 | ||
219 | 268 | @error (content) "not-ready" The requested machine is not ready. | ||
220 | 176 | """ | 269 | """ |
221 | 177 | raid = RAID.objects.get_object_or_404( | 270 | raid = RAID.objects.get_object_or_404( |
222 | 178 | system_id, id, request.user, NodePermission.admin) | 271 | system_id, id, request.user, NodePermission.admin) |
223 | @@ -187,10 +280,24 @@ class RaidHandler(OperationsHandler): | |||
224 | 187 | raise MAASAPIValidationError(form.errors) | 280 | raise MAASAPIValidationError(form.errors) |
225 | 188 | 281 | ||
226 | 189 | def delete(self, request, system_id, id): | 282 | def delete(self, request, system_id, id): |
228 | 190 | """Delete RAID on a machine. | 283 | """@description-title Delete a RAID |
229 | 284 | @description Delete a RAID with the given id on a machine with the | ||
230 | 285 | given system_id. | ||
231 | 286 | |||
232 | 287 | @param (string) "{system_id}" [required=true] The system_id of the | ||
233 | 288 | machine containing the RAID. | ||
234 | 289 | @param (int) "{id}" [required=true] A RAID id. | ||
235 | 290 | |||
236 | 291 | @success (http-status-code) "204" 204 | ||
237 | 292 | |||
238 | 293 | @error (http-status-code) "404" 404 | ||
239 | 294 | @error (content) "not-found" The requested machine or RAID is not | ||
240 | 295 | found. | ||
241 | 296 | @error-example "not-found" | ||
242 | 297 | Not Found | ||
243 | 191 | 298 | ||
246 | 192 | Returns 404 if the machine or RAID is not found. | 299 | @error (http-status-code) "409" 409 |
247 | 193 | Returns 409 if the machine is not Ready. | 300 | @error (content) "not-ready" The requested machine is not ready. |
248 | 194 | """ | 301 | """ |
249 | 195 | raid = RAID.objects.get_object_or_404( | 302 | raid = RAID.objects.get_object_or_404( |
250 | 196 | system_id, id, request.user, NodePermission.admin) | 303 | system_id, id, request.user, NodePermission.admin) |
UNIT TESTS raid-api- annotations lp:~jsseidel/maas/+git/maas into -b master lp:~maas-committers/maas
-b jsseidel-
STATUS: SUCCESS e4ae9f7812ed570 1c8d183412
COMMIT: 90ebd97100405d2