Revision 4dba0480 snf-cyclades-app/synnefo/api/actions.py
b/snf-cyclades-app/synnefo/api/actions.py | ||
---|---|---|
62 | 62 |
return func |
63 | 63 |
return decorator |
64 | 64 |
|
65 |
|
|
65 | 66 |
def network_action(name): |
66 | 67 |
'''Decorator for functions implementing network actions. |
67 | 68 |
`name` is the key in the dict passed by the client. |
... | ... | |
85 | 86 |
# buildInProgress (409), |
86 | 87 |
# overLimit (413) |
87 | 88 |
|
88 |
try: |
|
89 |
password = args['adminPass'] |
|
90 |
except KeyError: |
|
91 |
raise BadRequest('Malformed request.') |
|
92 |
|
|
93 | 89 |
raise ServiceUnavailable('Changing password is not supported.') |
94 | 90 |
|
95 | 91 |
@server_action('reboot') |
... | ... | |
195 | 191 |
|
196 | 192 |
raise ServiceUnavailable('Resize not supported.') |
197 | 193 |
|
194 |
|
|
198 | 195 |
@server_action('console') |
199 | 196 |
def get_console(request, vm, args): |
200 | 197 |
"""Arrange for an OOB console of the specified type |
... | ... | |
270 | 267 |
|
271 | 268 |
return HttpResponse(data, mimetype=mimetype, status=200) |
272 | 269 |
|
270 |
|
|
273 | 271 |
@server_action('firewallProfile') |
272 |
@transaction.commit_on_success |
|
274 | 273 |
def set_firewall_profile(request, vm, args): |
275 | 274 |
# Normal Response Code: 200 |
276 | 275 |
# Error Response Codes: computeFault (400, 500), |
... | ... | |
281 | 280 |
# itemNotFound (404), |
282 | 281 |
# buildInProgress (409), |
283 | 282 |
# overLimit (413) |
284 |
|
|
283 |
|
|
285 | 284 |
profile = args.get('profile', '') |
286 | 285 |
if profile not in [x[0] for x in NetworkInterface.FIREWALL_PROFILES]: |
287 | 286 |
raise BadRequest("Unsupported firewall profile") |
... | ... | |
322 | 321 |
|
323 | 322 |
|
324 | 323 |
@network_action('remove') |
324 |
@transaction.commit_on_success |
|
325 | 325 |
def remove(request, net, args): |
326 | 326 |
# Normal Response Code: 202 |
327 | 327 |
# Error Response Codes: computeFault (400, 500), |
... | ... | |
332 | 332 |
# itemNotFound (404), |
333 | 333 |
# overLimit (413) |
334 | 334 |
|
335 |
try: #attachment string: nic-<vm-id>-<nic-index>
|
|
335 |
try: # attachment string: nic-<vm-id>-<nic-index>
|
|
336 | 336 |
server_id = args.get('attachment', None).split('-')[1] |
337 | 337 |
nic_index = args.get('attachment', None).split('-')[2] |
338 | 338 |
except IndexError: |
Also available in: Unified diff