Revision f2080d16 snf-cyclades-app/synnefo/api/servers.py
b/snf-cyclades-app/synnefo/api/servers.py | ||
---|---|---|
31 | 31 |
# interpreted as representing official policies, either expressed |
32 | 32 |
# or implied, of GRNET S.A. |
33 | 33 |
|
34 |
import datetime |
|
34 | 35 |
from django import dispatch |
35 | 36 |
from django.conf import settings |
36 | 37 |
from django.conf.urls.defaults import patterns |
... | ... | |
45 | 46 |
from synnefo.api.actions import server_actions |
46 | 47 |
from synnefo.db.models import (VirtualMachine, VirtualMachineMetadata, |
47 | 48 |
NetworkInterface) |
48 |
from synnefo.logic.backend import create_instance, delete_instance |
|
49 |
from synnefo.logic.backend import (create_instance, delete_instance, |
|
50 |
process_op_status) |
|
49 | 51 |
from synnefo.logic.utils import get_rsapi_state |
50 | 52 |
from synnefo.logic.backend_allocator import BackendAllocator |
51 | 53 |
from synnefo import quotas |
... | ... | |
404 | 406 |
userid, vm, nic, backend, str(jobID)) |
405 | 407 |
except: |
406 | 408 |
# If an exception is raised, then the user will never get the VM id. |
407 |
# So, the VM must be marked as 'deleted'. We do not delete the VM row |
|
408 |
# from DB, because the job may have been enqueued to Ganeti. We must |
|
409 |
# also release the VM resources. |
|
410 |
if not vm.deleted: # just an extra check for reconciliation... |
|
411 |
vm.deleted = True |
|
412 |
vm.operstate = "ERROR" |
|
413 |
vm.backendlogmsg = "Error while enqueuing job to Ganeti." |
|
414 |
vm.save() |
|
415 |
# The following call performs commit. |
|
416 |
quotas.issue_and_accept_commission(vm, delete=True) |
|
409 |
# In order to delete it from DB and release it's resources, we |
|
410 |
# mock a successful OP_INSTANCE_REMOVE job. |
|
411 |
process_op_status(vm=vm, |
|
412 |
etime=datetime.datetime.now(), |
|
413 |
jobid=-0, |
|
414 |
opcode="OP_INSTANCE_REMOVE", |
|
415 |
status="success", |
|
416 |
logmsg="Reconciled eventd: VM creation failed.") |
|
417 | 417 |
raise |
418 | 418 |
|
419 | 419 |
return vm |
Also available in: Unified diff