Revision b04d666d src/flow/lib/models/role.rb

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

  

Also available in: Unified diff