Merge ~jsseidel/maas:jsseidel-raid-api-annotations into maas:master

Proposed by Spencer Seidel
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)
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.

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b jsseidel-raid-api-annotations lp:~jsseidel/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 90ebd97100405d2e4ae9f7812ed5701c8d183412

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b jsseidel-raid-api-annotations lp:~jsseidel/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci-jenkins.internal:8080/job/maas/job/branch-tester/4800/console
COMMIT: f59de3bb0d2b0727097d24035620763cfd8f0ef5

review: Needs Fixing
Revision history for this message
Mike Pontillo (mpontillo) wrote :

Looks good; a few minor nits below.

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Revision history for this message
MAAS Lander (maas-lander) wrote :
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b jsseidel-raid-api-annotations lp:~jsseidel/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci-jenkins.internal:8080/job/maas/job/branch-tester/4808/console
COMMIT: 2c42cc18a25d5ed2daec1bb25f8712563b42283c

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/maasserver/api/examples/nodes.json b/src/maasserver/api/examples/nodes.json
index 3ea4a3a..dfebdee 100644
--- a/src/maasserver/api/examples/nodes.json
+++ b/src/maasserver/api/examples/nodes.json
@@ -5223,5 +5223,8 @@
5223 "system_id": "thr3am",5223 "system_id": "thr3am",
5224 "type": "physical",5224 "type": "physical",
5225 "resource_uri": "/MAAS/api/2.0/nodes/thr3am/interfaces/37/"5225 "resource_uri": "/MAAS/api/2.0/nodes/thr3am/interfaces/37/"
5226 },
5227 "raids-placeholder": {
5228 "message": "Information about this object is not available at this time."
5226 }5229 }
5227}5230}
diff --git a/src/maasserver/api/raid.py b/src/maasserver/api/raid.py
index 4e65157..a712e4c 100644
--- a/src/maasserver/api/raid.py
+++ b/src/maasserver/api/raid.py
@@ -40,7 +40,7 @@ DISPLAYED_RAID_FIELDS = (
4040
4141
42class RaidsHandler(OperationsHandler):42class RaidsHandler(OperationsHandler):
43 """Manage all RAID devices on a machine."""43 """Manage all RAIDs (Redundant Array of Independent Disks) on a machine."""
44 api_doc_section_name = "RAID Devices"44 api_doc_section_name = "RAID Devices"
45 update = delete = None45 update = delete = None
46 fields = DISPLAYED_RAID_FIELDS46 fields = DISPLAYED_RAID_FIELDS
@@ -51,18 +51,45 @@ class RaidsHandler(OperationsHandler):
51 return ('raid_devices_handler', ["system_id"])51 return ('raid_devices_handler', ["system_id"])
5252
53 def create(self, request, system_id):53 def create(self, request, system_id):
54 """Creates a RAID54 """@description-title Set up a RAID
5555 @description Set up a RAID on a machine with the given system_id.
56 :param name: Name of the RAID.56
57 :param uuid: UUID of the RAID.57 @param (string) "{system_id}" [required=true] The system_id of the
58 :param level: RAID level.58 machine on which to set up the RAID.
59 :param block_devices: Block devices to add to the RAID.59
60 :param spare_devices: Spare block devices to add to the RAID.60 @param (string) "name" [required=false] Name of the RAID.
61 :param partitions: Partitions to add to the RAID.61
62 :param spare_partitions: Spare partitions to add to the RAID.62 @param (string) "uuid" [required=false] UUID of the RAID.
6363
64 Returns 404 if the machine is not found.64 @param (int) "level" [required=true] RAID level.
65 Returns 409 if the machine is not Ready.65
66 @param (string) "block_devices" [required=false] Block devices to add
67 to the RAID.
68
69 @param (string) "spare_devices" [required=false] Spare block devices to
70 add to the RAID.
71
72 @param (string) "partitions" [required=false] Partitions to add to the
73 RAID.
74
75 @param (string) "spare_partitions" [required=false] Spare partitions to
76 add to the RAID.
77
78 @success (http-status-code) "200" 200
79 @success (json) "success-json" A JSON object containing information
80 about the new RAID.
81 @success-example "success-json" [exkey=raids-placeholder] placeholder
82 text
83
84 @error (http-status-code) "404" 404
85 @error (content) "not-found" The requested machine is not found.
86 @error-example "not-found"
87 Not Found
88
89 @error (http-status-code) "409" 409
90 @error (content) "not-ready" The requested machine is not ready.
91 @error-example "not-ready"
92 Cannot create RAID because the machine is not Ready.
66 """93 """
67 machine = Machine.objects.get_node_or_404(94 machine = Machine.objects.get_node_or_404(
68 system_id, request.user, NodePermission.admin)95 system_id, request.user, NodePermission.admin)
@@ -76,9 +103,23 @@ class RaidsHandler(OperationsHandler):
76 raise MAASAPIValidationError(form.errors)103 raise MAASAPIValidationError(form.errors)
77104
78 def read(self, request, system_id):105 def read(self, request, system_id):
79 """List all RAID devices belonging to a machine.106 """@description-title List all RAIDs
107 @description List all RAIDs belonging to a machine with the given
108 system_id.
109
110 @param (string) "{system_id}" [required=true] The system_id of the
111 machine containing the RAIDs.
80112
81 Returns 404 if the machine is not found.113 @success (http-status-code) "200" 200
114 @success (json) "success-json" A JSON object containing a list of
115 available RAIDs.
116 @success-example "success-json" [exkey=raids-placeholder] placeholder
117 text
118
119 @error (http-status-code) "404" 404
120 @error (content) "not-found" The requested machine is not found.
121 @error-example "not-found"
122 Not Found
82 """123 """
83 machine = Machine.objects.get_node_or_404(124 machine = Machine.objects.get_node_or_404(
84 system_id, request.user, NodePermission.view)125 system_id, request.user, NodePermission.view)
@@ -86,7 +127,10 @@ class RaidsHandler(OperationsHandler):
86127
87128
88class RaidHandler(OperationsHandler):129class RaidHandler(OperationsHandler):
89 """Manage a specific RAID device on a machine."""130 """
131 Manage a specific RAID (Redundant Array of Independent Disks) on a
132 machine.
133 """
90 api_doc_section_name = "RAID Device"134 api_doc_section_name = "RAID Device"
91 create = None135 create = None
92 model = RAID136 model = RAID
@@ -148,31 +192,80 @@ class RaidHandler(OperationsHandler):
148 ]192 ]
149193
150 def read(self, request, system_id, id):194 def read(self, request, system_id, id):
151 """Read RAID device on a machine.195 """@description-title Read a RAID
196 @description Read RAID with the given id on a machine with the
197 given system_id.
198
199 @param (string) "{system_id}" [required=true] The system_id of the
200 machine containing the RAID.
201 @param (int) "{id}" [required=true] A RAID id.
152202
153 Returns 404 if the machine or RAID is not found.203 @success (http-status-code) "200" 200
204 @success (json) "success-json" A JSON object containing the requested
205 RAID.
206 @success-example "success-json" [exkey=raids-placeholder] placeholder
207 text
208
209 @error (http-status-code) "404" 404
210 @error (content) "not-found" The requested machine or RAID is not
211 found.
212 @error-example "not-found"
213 Not Found
154 """214 """
155 return RAID.objects.get_object_or_404(215 return RAID.objects.get_object_or_404(
156 system_id, id, request.user, NodePermission.view)216 system_id, id, request.user, NodePermission.view)
157217
158 def update(self, request, system_id, id):218 def update(self, request, system_id, id):
159 """Update RAID on a machine.219 """@description-title Update a RAID
160220 @description Update a RAID with the given id on a machine with the
161 :param name: Name of the RAID.221 given system_id.
162 :param uuid: UUID of the RAID.222
163 :param add_block_devices: Block devices to add to the RAID.223 @param (string) "{system_id}" [required=true] The system_id of the
164 :param remove_block_devices: Block devices to remove from the RAID.224 machine containing the RAID.
165 :param add_spare_devices: Spare block devices to add to the RAID.225 @param (int) "{id}" [required=true] A RAID id.
166 :param remove_spare_devices: Spare block devices to remove226
167 from the RAID.227 @param (string) "name" [required=false] Name of the RAID.
168 :param add_partitions: Partitions to add to the RAID.228
169 :param remove_partitions: Partitions to remove from the RAID.229 @param (string) "uuid" [required=false] UUID of the RAID.
170 :param add_spare_partitions: Spare partitions to add to the RAID.230
171 :param remove_spare_partitions: Spare partitions to remove from the231 @param (string) "add_block_devices" [required=false] Block devices to
172 RAID.232 add to the RAID.
173233
174 Returns 404 if the machine or RAID is not found.234 @param (string) "remove_block_devices" [required=false] Block devices
175 Returns 409 if the machine is not Ready.235 to remove from the RAID.
236
237 @param (string) "add_spare_devices" [required=false] Spare block
238 devices to add to the RAID.
239
240 @param (string) "remove_spare_devices" [required=false] Spare block
241 devices to remove from the RAID.
242
243 @param (string) "add_partitions" [required=false] Partitions to add to
244 the RAID.
245
246 @param (string) "remove_partitions" [required=false] Partitions to
247 remove from the RAID.
248
249 @param (string) "add_spare_partitions" [required=false] Spare
250 partitions to add to the RAID.
251
252 @param (string) "remove_spare_partitions" [required=false] Spare
253 partitions to remove from the RAID.
254
255 @success (http-status-code) "200" 200
256 @success (json) "success-json" A JSON object containing the updated
257 RAID.
258 @success-example "success-json" [exkey=raids-placeholder] placeholder
259 text
260
261 @error (http-status-code) "404" 404
262 @error (content) "not-found" The requested machine or RAID id is not
263 found.
264 @error-example "not-found"
265 Not Found
266
267 @error (http-status-code) "409" 409
268 @error (content) "not-ready" The requested machine is not ready.
176 """269 """
177 raid = RAID.objects.get_object_or_404(270 raid = RAID.objects.get_object_or_404(
178 system_id, id, request.user, NodePermission.admin)271 system_id, id, request.user, NodePermission.admin)
@@ -187,10 +280,24 @@ class RaidHandler(OperationsHandler):
187 raise MAASAPIValidationError(form.errors)280 raise MAASAPIValidationError(form.errors)
188281
189 def delete(self, request, system_id, id):282 def delete(self, request, system_id, id):
190 """Delete RAID on a machine.283 """@description-title Delete a RAID
284 @description Delete a RAID with the given id on a machine with the
285 given system_id.
286
287 @param (string) "{system_id}" [required=true] The system_id of the
288 machine containing the RAID.
289 @param (int) "{id}" [required=true] A RAID id.
290
291 @success (http-status-code) "204" 204
292
293 @error (http-status-code) "404" 404
294 @error (content) "not-found" The requested machine or RAID is not
295 found.
296 @error-example "not-found"
297 Not Found
191298
192 Returns 404 if the machine or RAID is not found.299 @error (http-status-code) "409" 409
193 Returns 409 if the machine is not Ready.300 @error (content) "not-ready" The requested machine is not ready.
194 """301 """
195 raid = RAID.objects.get_object_or_404(302 raid = RAID.objects.get_object_or_404(
196 system_id, id, request.user, NodePermission.admin)303 system_id, id, request.user, NodePermission.admin)

Subscribers

People subscribed via source and target branches