Revision b04d666d

View differences:

src/flow/lib/models/role.rb
207 207
                    vm_state = node['vm_info']['VM']['STATE']
208 208
                    lcm_state = node['vm_info']['VM']['LCM_STATE']
209 209

  
210
                    running = vm_state == '3' && lcm_state >= '3'
210
                    running = (!Role.vm_failure?(vm_state, lcm_state) &&
211
                                vm_state == '3' && lcm_state >= '3')
211 212

  
212 213
                    if running && @service.ready_status_gate
213 214
                        running_status = node['vm_info']['VM']['USER_TEMPLATE']['READY'] || ""
......
460 461
            end
461 462
        end
462 463

  
464
        # Returns true if the VM state is failure
465
        # @param [Integer] vm_state VM state
466
        # @param [Integer] lcm_state VM LCM state
467
        # @return [true,false] True if the lcm state is one of *_FAILURE
468
        def self.vm_failure?(vm_state, lcm_state)
469
            vm_state_str = VirtualMachine::VM_STATE[vm_state.to_i]
470
            lcm_state_str = VirtualMachine::LCM_STATE[lcm_state.to_i]
471

  
472
            if vm_state_str == 'ACTIVE' &&
473
                (   lcm_state_str == 'BOOT_FAILURE' ||
474
                    lcm_state_str == 'BOOT_MIGRATE_FAILURE' ||
475
                    lcm_state_str == 'PROLOG_MIGRATE_FAILURE' ||
476
                    lcm_state_str == 'PROLOG_FAILURE' ||
477
                    lcm_state_str == 'EPILOG_FAILURE' ||
478
                    lcm_state_str == 'EPILOG_STOP_FAILURE' ||
479
                    lcm_state_str == 'EPILOG_UNDEPLOY_FAILURE' ||
480
                    lcm_state_str == 'PROLOG_MIGRATE_POWEROFF_FAILURE' ||
481
                    lcm_state_str == 'PROLOG_MIGRATE_SUSPEND_FAILURE' ||
482
                    lcm_state_str == 'BOOT_UNDEPLOY_FAILURE' ||
483
                    lcm_state_str == 'BOOT_STOPPED_FAILURE' ||
484
                    lcm_state_str == 'PROLOG_RESUME_FAILURE' ||
485
                    lcm_state_str == 'PROLOG_UNDEPLOY_FAILURE')
486

  
487
                return true
488
            end
489

  
490
            return false
491
        end
492

  
463 493
        ########################################################################
464 494
        # Scalability
465 495
        ########################################################################
......
848 878
                    # Store the VM id in the array of disposed nodes
849 879
                    disposed_nodes << vm_id
850 880

  
851
                elsif ( vm_state_str == 'FAILED' ||
852
                        vm_state_str == 'ACTIVE' &&
853
                        (   lcm_state_str == 'FAILURE' ||
854
                            lcm_state_str == 'BOOT_FAILURE' ||
855
                            lcm_state_str == 'BOOT_MIGRATE_FAILURE' ||
856
                            lcm_state_str == 'PROLOG_MIGRATE_FAILURE' ||
857
                            lcm_state_str == 'PROLOG_FAILURE' ||
858
                            lcm_state_str == 'EPILOG_FAILURE' ||
859
                            lcm_state_str == 'EPILOG_STOP_FAILURE' ||
860
                            lcm_state_str == 'EPILOG_UNDEPLOY_FAILURE' ||
861
                            lcm_state_str == 'PROLOG_MIGRATE_POWEROFF_FAILURE' ||
862
                            lcm_state_str == 'PROLOG_MIGRATE_SUSPEND_FAILURE' ||
863
                            lcm_state_str == 'PROLOG_UNDEPLOY_FAILURE' ||
864
                            lcm_state_str == 'PROLOG_RESUME_FAILURE' ||
865
                            lcm_state_str == 'BOOT_UNDEPLOY_FAILURE' ||
866
                            lcm_state_str == 'BOOT_STOPPED_FAILURE' ))
867

  
881
                elsif ( Role.vm_failure?(vm_state, lcm_state) )
868 882
                    vm = OpenNebula::VirtualMachine.new_with_id(vm_id, @service.client)
869 883
                    rc = vm.finalize
870 884

  
src/flow/lib/strategy.rb
276 276
                vm_state = node['vm_info']['VM']['STATE']
277 277
                lcm_state = node['vm_info']['VM']['LCM_STATE']
278 278

  
279
                if vm_state == '7' ||            # FAILED
280
                    (vm_state == '3' &&          # ACTIVE
281
                        (   lcm_state == '14' || # FAILURE
282
                            lcm_state == '16' || # UNKNOWN
283
                            lcm_state == '36' || # BOOT_FAILURE
284
                            lcm_state == '37' || # BOOT_MIGRATE_FAILURE
285
                            lcm_state == '38' || # PROLOG_MIGRATE_FAILURE
286
                            lcm_state == '39' || # PROLOG_FAILURE
287
                            lcm_state == '40' || # EPILOG_FAILURE
288
                            lcm_state == '41' || # EPILOG_STOP_FAILURE
289
                            lcm_state == '42' || # EPILOG_UNDEPLOY_FAILURE
290
                            lcm_state == '44' || # PROLOG_MIGRATE_POWEROFF_FAILURE
291
                            lcm_state == '46' || # PROLOG_MIGRATE_SUSPEND_FAILURE
292
                            lcm_state == '47' || # BOOT_UNDEPLOY_FAILURE
293
                            lcm_state == '48' || # BOOT_STOPPED_FAILURE
294
                            lcm_state == '49' || # PROLOG_RESUME_FAILURE
295
                            lcm_state == '50' )  # PROLOG_UNDEPLOY_FAILURE
296
                    )
279
                # Failure or UNKNOWN
280
                if vm_failure?(node) || (vm_state == '3' && lcm_state == '16')
297 281
                    return true
298 282
                end
299 283
            end
......
307 291
    # @return [true|false]
308 292
    def any_node_failed?(role)
309 293
        role.get_nodes.each { |node|
310
            if node && node['vm_info']
311
                vm_state = node['vm_info']['VM']['STATE']
312

  
313
                if vm_state == '7' # FAILED
314
                    return true
315
                end
294
            if vm_failure?(node)
295
                return true
316 296
            end
317 297
        }
318 298

  
......
343 323
    # @return [true|false]
344 324
    def any_node_failed_scaling?(role)
345 325
        role.get_nodes.each { |node|
346
            if node && node['vm_info'] &&
326
            if  node && node['vm_info'] &&
347 327
                (node['disposed'] == '1' || node['scale_up'] == '1') &&
348
                node['vm_info']['VM']['STATE'] == '7' # FAILED
328
                vm_failure?(node)
349 329

  
350 330
                return true
351 331
            end
......
372 352
        # For scale down, it will finish when scaling nodes are deleted
373 353
        return role.get_nodes.size() == role.cardinality()
374 354
    end
355

  
356
    def vm_failure?(node)
357
        if node && node['vm_info']
358
            return Role.vm_failure?(
359
                vm_state = node['vm_info']['VM']['STATE'],
360
                lcm_state = node['vm_info']['VM']['LCM_STATE'])
361
        end
362

  
363
        return false
364
    end
375 365
end

Also available in: Unified diff