Revision d2e73c0c
b/snf-cyclades-app/synnefo/api/networks.py | ||
---|---|---|
268 | 268 |
# overLimit (413) |
269 | 269 |
|
270 | 270 |
log.debug('delete_network %s', network_id) |
271 |
net = util.get_network(network_id, request.user_uniq) |
|
271 |
net = util.get_network(network_id, request.user_uniq, for_update=True)
|
|
272 | 272 |
if net.public: |
273 | 273 |
raise Unauthorized('Can not delete the public network.') |
274 | 274 |
|
b/snf-cyclades-app/synnefo/api/util.py | ||
---|---|---|
199 | 199 |
raise ItemNotFound('Flavor not found.') |
200 | 200 |
|
201 | 201 |
|
202 |
def get_network(network_id, user_id): |
|
202 |
def get_network(network_id, user_id, for_update=False):
|
|
203 | 203 |
"""Return a Network instance or raise ItemNotFound.""" |
204 | 204 |
|
205 | 205 |
try: |
206 | 206 |
network_id = int(network_id) |
207 |
return Network.objects.get(id=network_id, userid=user_id) |
|
207 |
if for_update: |
|
208 |
return Network.objects.select_for_update().get(id=network_id, userid=user_id) |
|
209 |
else: |
|
210 |
return Network.objects.get(id=network_id, userid=user_id) |
|
208 | 211 |
except (ValueError, Network.DoesNotExist): |
209 | 212 |
raise ItemNotFound('Network not found.') |
210 | 213 |
|
b/snf-cyclades-app/synnefo/logic/callbacks.py | ||
---|---|---|
99 | 99 |
def wrapper(msg): |
100 | 100 |
try: |
101 | 101 |
network_id = utils.id_from_network_name(msg["network"]) |
102 |
network = Network.objects.get(id=network_id) |
|
102 |
network = Network.objects.select_for_update().get(id=network_id)
|
|
103 | 103 |
backend = Backend.objects.get(clustername=msg['cluster']) |
104 | 104 |
backend_network = BackendNetwork.objects.get(network=network, |
105 | 105 |
backend=backend) |
Also available in: Unified diff