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
1diff --git a/src/maasserver/api/examples/nodes.json b/src/maasserver/api/examples/nodes.json
2index 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 "system_id": "thr3am",
7 "type": "physical",
8 "resource_uri": "/MAAS/api/2.0/nodes/thr3am/interfaces/37/"
9+ },
10+ "raids-placeholder": {
11+ "message": "Information about this object is not available at this time."
12 }
13 }
14diff --git a/src/maasserver/api/raid.py b/src/maasserver/api/raid.py
15index 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
20
21 class RaidsHandler(OperationsHandler):
22- """Manage all RAID devices on a machine."""
23+ """Manage all RAIDs (Redundant Array of Independent Disks) on a machine."""
24 api_doc_section_name = "RAID Devices"
25 update = delete = None
26 fields = DISPLAYED_RAID_FIELDS
27@@ -51,18 +51,45 @@ class RaidsHandler(OperationsHandler):
28 return ('raid_devices_handler', ["system_id"])
29
30 def create(self, request, system_id):
31- """Creates a RAID
32-
33- :param name: Name of the RAID.
34- :param uuid: UUID of the RAID.
35- :param level: RAID level.
36- :param block_devices: Block devices to add to the RAID.
37- :param spare_devices: Spare block devices to add to the RAID.
38- :param partitions: Partitions to add to the RAID.
39- :param spare_partitions: Spare partitions to add to the RAID.
40-
41- Returns 404 if the machine is not found.
42- Returns 409 if the machine is not Ready.
43+ """@description-title Set up a RAID
44+ @description Set up a RAID on a machine with the given system_id.
45+
46+ @param (string) "{system_id}" [required=true] The system_id of the
47+ machine on which to set up the RAID.
48+
49+ @param (string) "name" [required=false] Name of the RAID.
50+
51+ @param (string) "uuid" [required=false] UUID of the RAID.
52+
53+ @param (int) "level" [required=true] RAID level.
54+
55+ @param (string) "block_devices" [required=false] Block devices to add
56+ to the RAID.
57+
58+ @param (string) "spare_devices" [required=false] Spare block devices to
59+ add to the RAID.
60+
61+ @param (string) "partitions" [required=false] Partitions to add to the
62+ RAID.
63+
64+ @param (string) "spare_partitions" [required=false] Spare partitions to
65+ add to the RAID.
66+
67+ @success (http-status-code) "200" 200
68+ @success (json) "success-json" A JSON object containing information
69+ about the new RAID.
70+ @success-example "success-json" [exkey=raids-placeholder] placeholder
71+ text
72+
73+ @error (http-status-code) "404" 404
74+ @error (content) "not-found" The requested machine is not found.
75+ @error-example "not-found"
76+ Not Found
77+
78+ @error (http-status-code) "409" 409
79+ @error (content) "not-ready" The requested machine is not ready.
80+ @error-example "not-ready"
81+ Cannot create RAID because the machine is not Ready.
82 """
83 machine = Machine.objects.get_node_or_404(
84 system_id, request.user, NodePermission.admin)
85@@ -76,9 +103,23 @@ class RaidsHandler(OperationsHandler):
86 raise MAASAPIValidationError(form.errors)
87
88 def read(self, request, system_id):
89- """List all RAID devices belonging to a machine.
90+ """@description-title List all RAIDs
91+ @description List all RAIDs belonging to a machine with the given
92+ system_id.
93+
94+ @param (string) "{system_id}" [required=true] The system_id of the
95+ machine containing the RAIDs.
96
97- Returns 404 if the machine is not found.
98+ @success (http-status-code) "200" 200
99+ @success (json) "success-json" A JSON object containing a list of
100+ available RAIDs.
101+ @success-example "success-json" [exkey=raids-placeholder] placeholder
102+ text
103+
104+ @error (http-status-code) "404" 404
105+ @error (content) "not-found" The requested machine is not found.
106+ @error-example "not-found"
107+ Not Found
108 """
109 machine = Machine.objects.get_node_or_404(
110 system_id, request.user, NodePermission.view)
111@@ -86,7 +127,10 @@ class RaidsHandler(OperationsHandler):
112
113
114 class RaidHandler(OperationsHandler):
115- """Manage a specific RAID device on a machine."""
116+ """
117+ Manage a specific RAID (Redundant Array of Independent Disks) on a
118+ machine.
119+ """
120 api_doc_section_name = "RAID Device"
121 create = None
122 model = RAID
123@@ -148,31 +192,80 @@ class RaidHandler(OperationsHandler):
124 ]
125
126 def read(self, request, system_id, id):
127- """Read RAID device on a machine.
128+ """@description-title Read a RAID
129+ @description Read RAID with the given id on a machine with the
130+ given system_id.
131+
132+ @param (string) "{system_id}" [required=true] The system_id of the
133+ machine containing the RAID.
134+ @param (int) "{id}" [required=true] A RAID id.
135
136- Returns 404 if the machine or RAID is not found.
137+ @success (http-status-code) "200" 200
138+ @success (json) "success-json" A JSON object containing the requested
139+ RAID.
140+ @success-example "success-json" [exkey=raids-placeholder] placeholder
141+ text
142+
143+ @error (http-status-code) "404" 404
144+ @error (content) "not-found" The requested machine or RAID is not
145+ found.
146+ @error-example "not-found"
147+ Not Found
148 """
149 return RAID.objects.get_object_or_404(
150 system_id, id, request.user, NodePermission.view)
151
152 def update(self, request, system_id, id):
153- """Update RAID on a machine.
154-
155- :param name: Name of the RAID.
156- :param uuid: UUID of the RAID.
157- :param add_block_devices: Block devices to add to the RAID.
158- :param remove_block_devices: Block devices to remove from the RAID.
159- :param add_spare_devices: Spare block devices to add to the RAID.
160- :param remove_spare_devices: Spare block devices to remove
161- from the RAID.
162- :param add_partitions: Partitions to add to the RAID.
163- :param remove_partitions: Partitions to remove from the RAID.
164- :param add_spare_partitions: Spare partitions to add to the RAID.
165- :param remove_spare_partitions: Spare partitions to remove from the
166- RAID.
167-
168- Returns 404 if the machine or RAID is not found.
169- Returns 409 if the machine is not Ready.
170+ """@description-title Update a RAID
171+ @description Update a RAID with the given id on a machine with the
172+ given system_id.
173+
174+ @param (string) "{system_id}" [required=true] The system_id of the
175+ machine containing the RAID.
176+ @param (int) "{id}" [required=true] A RAID id.
177+
178+ @param (string) "name" [required=false] Name of the RAID.
179+
180+ @param (string) "uuid" [required=false] UUID of the RAID.
181+
182+ @param (string) "add_block_devices" [required=false] Block devices to
183+ add to the RAID.
184+
185+ @param (string) "remove_block_devices" [required=false] Block devices
186+ to remove from the RAID.
187+
188+ @param (string) "add_spare_devices" [required=false] Spare block
189+ devices to add to the RAID.
190+
191+ @param (string) "remove_spare_devices" [required=false] Spare block
192+ devices to remove from the RAID.
193+
194+ @param (string) "add_partitions" [required=false] Partitions to add to
195+ the RAID.
196+
197+ @param (string) "remove_partitions" [required=false] Partitions to
198+ remove from the RAID.
199+
200+ @param (string) "add_spare_partitions" [required=false] Spare
201+ partitions to add to the RAID.
202+
203+ @param (string) "remove_spare_partitions" [required=false] Spare
204+ partitions to remove from the RAID.
205+
206+ @success (http-status-code) "200" 200
207+ @success (json) "success-json" A JSON object containing the updated
208+ RAID.
209+ @success-example "success-json" [exkey=raids-placeholder] placeholder
210+ text
211+
212+ @error (http-status-code) "404" 404
213+ @error (content) "not-found" The requested machine or RAID id is not
214+ found.
215+ @error-example "not-found"
216+ Not Found
217+
218+ @error (http-status-code) "409" 409
219+ @error (content) "not-ready" The requested machine is not ready.
220 """
221 raid = RAID.objects.get_object_or_404(
222 system_id, id, request.user, NodePermission.admin)
223@@ -187,10 +280,24 @@ class RaidHandler(OperationsHandler):
224 raise MAASAPIValidationError(form.errors)
225
226 def delete(self, request, system_id, id):
227- """Delete RAID on a machine.
228+ """@description-title Delete a RAID
229+ @description Delete a RAID with the given id on a machine with the
230+ given system_id.
231+
232+ @param (string) "{system_id}" [required=true] The system_id of the
233+ machine containing the RAID.
234+ @param (int) "{id}" [required=true] A RAID id.
235+
236+ @success (http-status-code) "204" 204
237+
238+ @error (http-status-code) "404" 404
239+ @error (content) "not-found" The requested machine or RAID is not
240+ found.
241+ @error-example "not-found"
242+ Not Found
243
244- Returns 404 if the machine or RAID is not found.
245- Returns 409 if the machine is not Ready.
246+ @error (http-status-code) "409" 409
247+ @error (content) "not-ready" The requested machine is not ready.
248 """
249 raid = RAID.objects.get_object_or_404(
250 system_id, id, request.user, NodePermission.admin)

Subscribers

People subscribed via source and target branches