Revision 0196d9a3 snf-cyclades-app/synnefo/api/actions.py
b/snf-cyclades-app/synnefo/api/actions.py | ||
---|---|---|
39 | 39 |
from django.template.loader import render_to_string |
40 | 40 |
from django.utils import simplejson as json |
41 | 41 |
|
42 |
from synnefo.api.faults import BadRequest, ServiceUnavailable, ItemNotFound |
|
42 |
from synnefo.api.faults import (BadRequest, ServiceUnavailable, |
|
43 |
ItemNotFound, BuildInProgress) |
|
43 | 44 |
from synnefo.api.util import random_password, get_vm, get_nic_from_index |
44 | 45 |
from synnefo.db.models import NetworkInterface |
45 | 46 |
from synnefo.logic import backend |
... | ... | |
326 | 327 |
raise BadRequest('Malformed Request.') |
327 | 328 |
vm = get_vm(server_id, request.user_uniq) |
328 | 329 |
nic = get_nic_from_index(vm, nic_index) |
329 |
backend.disconnect_nic_from_vm(vm, nic) |
|
330 |
|
|
331 |
if nic.dirty: |
|
332 |
raise BuildInProgress('Machine is busy.') |
|
333 |
else: |
|
334 |
vm.nics.all().update(dirty=True) |
|
335 |
|
|
336 |
backend.disconnect_from_network(vm, nic) |
|
330 | 337 |
return HttpResponse(status=202) |
Also available in: Unified diff