Revision 17c2ed57 snf-cyclades-app/synnefo/api/networks.py
b/snf-cyclades-app/synnefo/api/networks.py | ||
---|---|---|
44 | 44 |
from synnefo.api import util |
45 | 45 |
from synnefo.api.actions import network_actions |
46 | 46 |
from synnefo.api.common import method_not_allowed |
47 |
from synnefo.api.faults import (ServiceUnavailable, BadRequest, Unauthorized,
|
|
47 |
from synnefo.api.faults import (ServiceUnavailable, BadRequest, Forbidden,
|
|
48 | 48 |
NetworkInUse, OverLimit) |
49 | 49 |
from synnefo.db.models import Network |
50 | 50 |
from synnefo.db.pools import EmptyPool |
... | ... | |
152 | 152 |
# unauthorized (401), |
153 | 153 |
# badMediaType(415), |
154 | 154 |
# badRequest (400), |
155 |
# forbidden (403) |
|
155 | 156 |
# overLimit (413) |
156 | 157 |
|
157 | 158 |
req = util.get_request_dict(request) |
... | ... | |
171 | 172 |
raise BadRequest('Malformed request.') |
172 | 173 |
|
173 | 174 |
if net_type == 'PUBLIC_ROUTED': |
174 |
raise Unauthorized('Can not create a public network.')
|
|
175 |
raise Forbidden('Can not create a public network.')
|
|
175 | 176 |
|
176 | 177 |
user_networks = len(Network.objects.filter(userid=request.user_uniq, |
177 | 178 |
deleted=False)) |
... | ... | |
239 | 240 |
# serviceUnavailable (503), |
240 | 241 |
# unauthorized (401), |
241 | 242 |
# badRequest (400), |
243 |
# forbidden (403) |
|
242 | 244 |
# badMediaType(415), |
243 | 245 |
# itemNotFound (404), |
244 | 246 |
# overLimit (413) |
... | ... | |
253 | 255 |
|
254 | 256 |
net = util.get_network(network_id, request.user_uniq) |
255 | 257 |
if net.public: |
256 |
raise Unauthorized('Can not rename the public network.')
|
|
258 |
raise Forbidden('Can not rename the public network.')
|
|
257 | 259 |
if net.deleted: |
258 | 260 |
raise Network.DeletedError |
259 | 261 |
net.name = name |
... | ... | |
268 | 270 |
# Error Response Codes: computeFault (400, 500), |
269 | 271 |
# serviceUnavailable (503), |
270 | 272 |
# unauthorized (401), |
273 |
# forbidden (403) |
|
271 | 274 |
# itemNotFound (404), |
272 |
# unauthorized (401), |
|
273 | 275 |
# overLimit (413) |
274 | 276 |
|
275 | 277 |
log.info('delete_network %s', network_id) |
276 | 278 |
net = util.get_network(network_id, request.user_uniq, for_update=True) |
277 | 279 |
if net.public: |
278 |
raise Unauthorized('Can not delete the public network.')
|
|
280 |
raise Forbidden('Can not delete the public network.')
|
|
279 | 281 |
|
280 | 282 |
if net.deleted: |
281 | 283 |
raise Network.DeletedError |
... | ... | |
300 | 302 |
|
301 | 303 |
net = util.get_network(network_id, request.user_uniq) |
302 | 304 |
if net.public: |
303 |
raise Unauthorized('Can not modify the public network.')
|
|
305 |
raise Forbidden('Can not modify the public network.')
|
|
304 | 306 |
if net.deleted: |
305 | 307 |
raise Network.DeletedError |
306 | 308 |
|
Also available in: Unified diff