Revision e97288bc snf-cyclades-app/synnefo/logic/backend.py
b/snf-cyclades-app/synnefo/logic/backend.py | ||
---|---|---|
77 | 77 |
state_for_success = VirtualMachine.OPER_STATE_FROM_OPCODE.get(opcode, None) |
78 | 78 |
if status == 'success' and state_for_success is not None: |
79 | 79 |
vm.operstate = state_for_success |
80 |
# Set the deleted flag explicitly, cater for admin-initiated removals |
|
81 |
if opcode == 'OP_INSTANCE_REMOVE': |
|
82 |
release_instance_nics(vm) |
|
83 |
vm.deleted = True |
|
84 |
vm.nics.all().delete() |
|
85 | 80 |
|
86 | 81 |
# Special case: if OP_INSTANCE_CREATE fails --> ERROR |
87 | 82 |
if status in ('canceled', 'error') and opcode == 'OP_INSTANCE_CREATE': |
88 | 83 |
vm.operstate = 'ERROR' |
89 | 84 |
vm.backendtime = etime |
90 | 85 |
|
91 |
# Special case: OP_INSTANCE_REMOVE fails for machines in ERROR, |
|
92 |
# when no instance exists at the Ganeti backend. |
|
93 |
# See ticket #799 for all the details. |
|
94 |
# |
|
95 |
if (status == 'error' and vm.operstate == 'ERROR' and\ |
|
96 |
opcode == 'OP_INSTANCE_REMOVE'): |
|
97 |
vm.deleted = True |
|
98 |
vm.nics.all().delete() |
|
99 |
vm.operstate = 'DESTROYED' |
|
100 |
vm.backendtime = etime |
|
86 |
if opcode == 'OP_INSTANCE_REMOVE': |
|
87 |
# Set the deleted flag explicitly, cater for admin-initiated removals |
|
88 |
# Special case: OP_INSTANCE_REMOVE fails for machines in ERROR, |
|
89 |
# when no instance exists at the Ganeti backend. |
|
90 |
# See ticket #799 for all the details. |
|
91 |
# |
|
92 |
if status == 'success' or (status == 'error' and |
|
93 |
vm.operstate == 'ERROR'): |
|
94 |
release_instance_nics(vm) |
|
95 |
vm.nics.all().delete() |
|
96 |
vm.deleted = True |
|
97 |
vm.operstate = state_for_success |
|
98 |
vm.backendtime = etime |
|
101 | 99 |
|
102 | 100 |
# Update backendtime only for jobs that have been successfully completed, |
103 | 101 |
# since only these jobs update the state of the VM. Else a "race condition" |
... | ... | |
177 | 175 |
state_for_success = BackendNetwork.OPER_STATE_FROM_OPCODE.get(opcode, None) |
178 | 176 |
if status == 'success' and state_for_success is not None: |
179 | 177 |
back_network.operstate = state_for_success |
180 |
if opcode == 'OP_NETWORK_REMOVE': |
|
181 |
back_network.deleted = True |
|
182 | 178 |
|
183 | 179 |
if status in ('canceled', 'error') and opcode == 'OP_NETWORK_CREATE': |
184 | 180 |
utils.update_state(back_network, 'ERROR') |
181 |
back_network.backendtime = etime |
|
185 | 182 |
|
186 |
if (status == 'error' and opcode == 'OP_NETWORK_REMOVE'): |
|
187 |
back_network.deleted = True |
|
188 |
back_network.operstate = 'DELETED' |
|
183 |
if opcode == 'OP_NETWORK_REMOVE': |
|
184 |
if status == 'success' or (status == 'error' and |
|
185 |
back_network.operstate == 'ERROR'): |
|
186 |
back_network.operstate = state_for_success |
|
187 |
back_network.deleted = True |
|
188 |
back_network.backendtime = etime |
|
189 | 189 |
|
190 |
if status == 'success': |
|
191 |
back_network.backendtime = etime |
|
190 | 192 |
back_network.save() |
191 | 193 |
|
192 | 194 |
|
Also available in: Unified diff