Revision e6fbada1 snf-cyclades-app/synnefo/logic/backend.py
b/snf-cyclades-app/synnefo/logic/backend.py | ||
---|---|---|
115 | 115 |
|
116 | 116 |
@transaction.commit_on_success |
117 | 117 |
def process_op_status(vm, etime, jobid, opcode, status, logmsg, nics=None, |
118 |
beparams=None):
|
|
118 |
job_fields=None):
|
|
119 | 119 |
"""Process a job progress notification from the backend |
120 | 120 |
|
121 | 121 |
Process an incoming message from the backend (currently Ganeti). |
... | ... | |
137 | 137 |
vm.save() |
138 | 138 |
return |
139 | 139 |
|
140 |
if job_fields is None: |
|
141 |
job_fields = {} |
|
140 | 142 |
state_for_success = VirtualMachine.OPER_STATE_FROM_OPCODE.get(opcode) |
141 | 143 |
|
142 | 144 |
# Notifications of success change the operating state |
143 | 145 |
if status == "success": |
144 | 146 |
if state_for_success is not None: |
145 | 147 |
vm.operstate = state_for_success |
148 |
beparams = job_fields.get("beparams", None) |
|
146 | 149 |
if beparams: |
147 | 150 |
# Change the flavor of the VM |
148 | 151 |
_process_resize(vm, beparams) |
... | ... | |
180 | 183 |
|
181 | 184 |
if status in ["success", "error", "canceled"]: |
182 | 185 |
# Job is finalized: Handle quotas/commissioning |
183 |
job_fields = {"nics": nics, "beparams": beparams}
|
|
186 |
fields = {"nics": nics, "beparams": beparams} |
|
184 | 187 |
vm = handle_vm_quotas(vm, job_id=jobid, job_opcode=opcode, |
185 |
job_status=status, job_fields=job_fields)
|
|
188 |
job_status=status, job_fields=fields) |
|
186 | 189 |
# and clear task fields |
187 | 190 |
if vm.task_job_id == jobid: |
188 | 191 |
vm.task = None |
... | ... | |
424 | 427 |
|
425 | 428 |
@transaction.commit_on_success |
426 | 429 |
def process_network_modify(back_network, etime, jobid, opcode, status, |
427 |
add_reserved_ips):
|
|
430 |
job_fields):
|
|
428 | 431 |
assert (opcode == "OP_NETWORK_SET_PARAMS") |
429 | 432 |
if status not in [x[0] for x in BACKEND_STATUSES]: |
430 | 433 |
raise Network.InvalidBackendMsgError(opcode, status) |
... | ... | |
433 | 436 |
back_network.backendjobstatus = status |
434 | 437 |
back_network.opcode = opcode |
435 | 438 |
|
439 |
add_reserved_ips = job_fields.get("add_reserved_ips") |
|
436 | 440 |
if add_reserved_ips: |
437 | 441 |
net = back_network.network |
438 | 442 |
pool = net.get_pool() |
Also available in: Unified diff