Commit f960a517 authored by Christos Stavrakakis's avatar Christos Stavrakakis

cyclades: Update NICs even if job failed

Make snf-ganeti-eventd send the NICs of the instance not only on
success, but also if the job has failed or has been canceled. Also,
update snf-dispatcher to handle those messages. This step is required to
clear BUILDING NICs that fail.
parent c42c52fe
......@@ -140,9 +140,6 @@ def process_op_status(vm, etime, jobid, opcode, status, logmsg, nics=None,
if status == "success":
if state_for_success is not None:
vm.operstate = state_for_success
if nics is not None:
# Update the NICs of the VM
_process_net_status(vm, etime, nics)
if beparams:
# Change the flavor of the VM
_process_resize(vm, beparams)
......@@ -153,6 +150,10 @@ def process_op_status(vm, etime, jobid, opcode, status, logmsg, nics=None,
# in reversed order.
vm.backendtime = etime
if status in ["success", "error", "canceled"] and nics is not None:
# Update the NICs of the VM
_process_net_status(vm, etime, nics)
# Special case: if OP_INSTANCE_CREATE fails --> ERROR
if opcode == 'OP_INSTANCE_CREATE' and status in ('canceled', 'error'):
vm.operstate = 'ERROR'
......
......@@ -247,9 +247,10 @@ class JobFileHandler(pyinotify.ProcessEvent):
if op.status == "success":
msg["result"] = op.result
if op_id in ["OP_INSTANCE_CREATE", "OP_INSTANCE_SET_PARAMS",
"OP_INSTANCE_STARTUP"]:
if op.status == "success":
if ((op_id in ["OP_INSTANCE_CREATE", "OP_INSTANCE_STARTUP"] and
op.status == "success") or
(op_id == "OP_INSTANCE_SET_PARAMS" and
op.status in ["success", "error", "cancelled"])):
nics = get_instance_nics(msg["instance"], self.logger)
msg["nics"] = nics
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment