Revision b04d666d src/flow/lib/strategy.rb

View differences:

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