Revision 9dcfad23 snf-cyclades-app/synnefo/logic/servers.py

b/snf-cyclades-app/synnefo/logic/servers.py
1 1
import logging
2
import datetime
3 2

  
4 3
from socket import getfqdn
5 4
from functools import wraps
......
171 170
        # Create the server in Ganeti.
172 171
        create_server(vm, nics, flavor, image, personality, password)
173 172
    except:
174
        # If an exception is raised, then the user will never get the VM id.
175
        # In order to delete it from DB and release it's resources, we
176
        # mock a successful OP_INSTANCE_REMOVE job.
177
        backend.process_op_status(vm=vm, etime=datetime.datetime.now(),
178
                                  jobid=-0,
179
                                  opcode="OP_INSTANCE_REMOVE",
180
                                  status="success",
181
                                  logmsg="Reconciled eventd: VM creation"
182
                                         " failed.")
183
        raise
173
        log.exception("Failed create instance '%s'", vm)
174
        vm.operstate = "ERROR"
175
        vm.backendlogmsg = "Failed to send job to Ganeti."
176
        vm.save()
177
        vm.nics.all().update(state="ERROR")
184 178

  
185 179
    return vm
186 180

  

Also available in: Unified diff