Revision 39c0686c

View differences:

include/VirtualMachine.h
138 138
        SHUTDOWN_UNDEPLOY   = 29,
139 139
        EPILOG_UNDEPLOY     = 30,
140 140
        PROLOG_UNDEPLOY     = 31,
141
        BOOT_UNDEPLOY       = 32
141
        BOOT_UNDEPLOY       = 32,
142
        BOOT_MIGRATE        = 33,
143
        BOOT_FAILURE        = 34,
144
        BOOT_MIGRATE_FAILURE= 35
142 145
    };
143 146

  
144 147
    static int lcm_state_from_str(string& st, LcmState& state)
......
178 181
        else if ( st == "EPILOG_UNDEPLOY") { state = EPILOG_UNDEPLOY; }
179 182
        else if ( st == "PROLOG_UNDEPLOY") { state = PROLOG_UNDEPLOY; }
180 183
        else if ( st == "BOOT_UNDEPLOY") { state = BOOT_UNDEPLOY; }
184
        else if ( st == "BOOT_MIGRATE") { state = BOOT_MIGRATE; }
185
        else if ( st == "BOOT_FAILURE") { state = BOOT_FAILURE; }
186
        else if ( st == "BOOT_MIGRATE_FAILURE") { state = BOOT_MIGRATE_FAILURE; }
181 187
        else {return -1;}
182 188

  
183 189
        return 0;
......
220 226
            case EPILOG_UNDEPLOY: st = "EPILOG_UNDEPLOY"; break;
221 227
            case PROLOG_UNDEPLOY: st = "PROLOG_UNDEPLOY"; break;
222 228
            case BOOT_UNDEPLOY: st = "BOOT_UNDEPLOY"; break;
229
            case BOOT_MIGRATE: st = "BOOT_MIGRATE"; break;
230
            case BOOT_FAILURE: st = "BOOT_FAILURE"; break;
231
            case BOOT_MIGRATE_FAILURE: st = "BOOT_MIGRATE_FAILURE"; break;
223 232
        }
224 233

  
225 234
        return st;
src/dm/DispatchManagerActions.cc
687 687
         vm->get_lcm_state() == VirtualMachine::BOOT_POWEROFF ||
688 688
         vm->get_lcm_state() == VirtualMachine::BOOT_SUSPENDED ||
689 689
         vm->get_lcm_state() == VirtualMachine::BOOT_STOPPED ||
690
         vm->get_lcm_state() == VirtualMachine::BOOT_UNDEPLOY))
690
         vm->get_lcm_state() == VirtualMachine::BOOT_UNDEPLOY ||
691
         vm->get_lcm_state() == VirtualMachine::BOOT_MIGRATE ||
692
         vm->get_lcm_state() == VirtualMachine::BOOT_FAILURE ||
693
         vm->get_lcm_state() == VirtualMachine::BOOT_MIGRATE_FAILURE ))
691 694
    {
692 695
        Nebula&             nd  = Nebula::instance();
693 696
        LifeCycleManager *  lcm = nd.get_lcm();
src/lcm/LifeCycleActions.cc
706 706
         vm->get_lcm_state() == VirtualMachine::BOOT_POWEROFF ||
707 707
         vm->get_lcm_state() == VirtualMachine::BOOT_SUSPENDED ||
708 708
         vm->get_lcm_state() == VirtualMachine::BOOT_STOPPED ||
709
         vm->get_lcm_state() == VirtualMachine::BOOT_UNDEPLOY))
709
         vm->get_lcm_state() == VirtualMachine::BOOT_UNDEPLOY ||
710
         vm->get_lcm_state() == VirtualMachine::BOOT_MIGRATE ||
711
         vm->get_lcm_state() == VirtualMachine::BOOT_MIGRATE_FAILURE ||
712
         vm->get_lcm_state() == VirtualMachine::BOOT_FAILURE))
710 713
       ||vm->get_state() == VirtualMachine::POWEROFF)
711 714
    {
712 715
        Nebula&                 nd = Nebula::instance();
713 716
        VirtualMachineManager * vmm = nd.get_vmm();
714 717

  
718
        VirtualMachineManager::Actions action;
719

  
715 720
        //----------------------------------------------------
716 721
        //       RE-START THE VM IN THE SAME HOST
717 722
        //----------------------------------------------------
718 723

  
719
        if (vm->get_state() == VirtualMachine::ACTIVE &&
720
            (vm->get_lcm_state() == VirtualMachine::BOOT ||
721
             vm->get_lcm_state() == VirtualMachine::BOOT_UNKNOWN ||
722
             vm->get_lcm_state() == VirtualMachine::BOOT_POWEROFF ||
723
             vm->get_lcm_state() == VirtualMachine::BOOT_SUSPENDED ||
724
             vm->get_lcm_state() == VirtualMachine::BOOT_STOPPED ||
725
             vm->get_lcm_state() == VirtualMachine::BOOT_UNDEPLOY))
726
        {
727
            vm->log("LCM", Log::INFO, "Sending BOOT command to VM again");
728
        }
729
        else if (vm->get_state() == VirtualMachine::ACTIVE &&
730
                 vm->get_lcm_state() == VirtualMachine::UNKNOWN)
724
        if (vm->get_state() == VirtualMachine::ACTIVE)
731 725
        {
732
            vm->set_state(VirtualMachine::BOOT_UNKNOWN);
726
            switch (vm->get_lcm_state()) {
727
                case VirtualMachine::BOOT:
728
                case VirtualMachine::BOOT_UNKNOWN:
729
                case VirtualMachine::BOOT_POWEROFF:
730
                    action = VirtualMachineManager::DEPLOY;
733 731

  
734
            vmpool->update(vm);
732
                    vm->log("LCM", Log::INFO, "Sending BOOT command to VM again");
733

  
734
                    break;
735

  
736
                case VirtualMachine::BOOT_SUSPENDED:
737
                case VirtualMachine::BOOT_STOPPED:
738
                case VirtualMachine::BOOT_UNDEPLOY:
739
                case VirtualMachine::BOOT_MIGRATE:
740
                    action = VirtualMachineManager::RESTORE;
741

  
742
                    vm->log("LCM", Log::INFO, "Sending RESTORE command to VM again");
743

  
744
                    break;
745

  
746
                case VirtualMachine::UNKNOWN:
747
                    action = VirtualMachineManager::DEPLOY;
748

  
749
                    vm->set_state(VirtualMachine::BOOT_UNKNOWN);
750

  
751
                    vmpool->update(vm);
752

  
753
                    vm->log("LCM", Log::INFO, "New VM state is BOOT_UNKNOWN");
735 754

  
736
            vm->log("LCM", Log::INFO, "New VM state is BOOT_UNKNOWN");
755
                    break;
756

  
757
                case VirtualMachine::BOOT_FAILURE:
758
                    action = VirtualMachineManager::DEPLOY;
759

  
760
                    vm->set_state(VirtualMachine::BOOT);
761

  
762
                    vmpool->update(vm);
763

  
764
                    vm->log("LCM", Log::INFO, "New VM state is BOOT");
765

  
766
                    break;
767

  
768
                case VirtualMachine::BOOT_MIGRATE_FAILURE:
769
                    action = VirtualMachineManager::RESTORE;
770

  
771
                    vm->set_state(VirtualMachine::BOOT_MIGRATE);
772

  
773
                    vmpool->update(vm);
774

  
775
                    vm->log("LCM", Log::INFO, "New VM state is BOOT_MIGRATE");
776

  
777
                    break;
778

  
779
                default:
780
                    break;
781
            }
737 782
        }
738 783
        else // if ( vm->get_state() == VirtualMachine::POWEROFF )
739 784
        {
......
757 802
            vm->log("LCM", Log::INFO, "New VM state is BOOT_POWEROFF");
758 803
        }
759 804

  
760
        vmm->trigger(VirtualMachineManager::DEPLOY,vid);
805
        vmm->trigger(action,vid);
761 806
    }
762 807
    else
763 808
    {
......
971 1016
        case VirtualMachine::BOOT_SUSPENDED:
972 1017
        case VirtualMachine::BOOT_STOPPED:
973 1018
        case VirtualMachine::BOOT_UNDEPLOY:
1019
        case VirtualMachine::BOOT_MIGRATE:
1020
        case VirtualMachine::BOOT_FAILURE:
1021
        case VirtualMachine::BOOT_MIGRATE_FAILURE:
974 1022
        case VirtualMachine::RUNNING:
975 1023
        case VirtualMachine::UNKNOWN:
976 1024
        case VirtualMachine::SHUTDOWN:
......
1168 1216
        case VirtualMachine::BOOT_STOPPED:
1169 1217
        case VirtualMachine::BOOT_UNDEPLOY:
1170 1218
        case VirtualMachine::MIGRATE:
1219
        case VirtualMachine::BOOT_MIGRATE:
1220
        case VirtualMachine::BOOT_MIGRATE_FAILURE:
1221
        case VirtualMachine::BOOT_FAILURE:
1171 1222
            if (success)
1172 1223
            {
1173 1224
                //Auto-generate deploy-id it'll work for Xen, KVM and VMware
src/lcm/LifeCycleStates.cc
308 308
              vm->get_lcm_state() == VirtualMachine::BOOT_UNKNOWN  ||
309 309
              vm->get_lcm_state() == VirtualMachine::BOOT_SUSPENDED||
310 310
              vm->get_lcm_state() == VirtualMachine::BOOT_STOPPED ||
311
              vm->get_lcm_state() == VirtualMachine::BOOT_UNDEPLOY )
311
              vm->get_lcm_state() == VirtualMachine::BOOT_UNDEPLOY ||
312
              vm->get_lcm_state() == VirtualMachine::BOOT_MIGRATE ||
313
              vm->get_lcm_state() == VirtualMachine::BOOT_MIGRATE_FAILURE ||
314
              vm->get_lcm_state() == VirtualMachine::BOOT_FAILURE )
312 315
    {
313 316
        vm->set_state(VirtualMachine::RUNNING);
314 317

  
......
400 403

  
401 404
        vmm->trigger(VirtualMachineManager::POLL,vid);
402 405
    }
403
    else if (vm->get_lcm_state() == VirtualMachine::BOOT)
406
    else if (vm->get_lcm_state() == VirtualMachine::BOOT ||
407
             vm->get_lcm_state() == VirtualMachine::BOOT_FAILURE)
404 408
    {
405
        vm->set_running_etime(the_time);
409
        vm->set_state(VirtualMachine::BOOT_FAILURE);
406 410

  
407
        failure_action(vm);
411
        vmpool->update(vm);
412

  
413
        vm->log("LCM", Log::INFO, "Fail to boot VM. New VM state is BOOT_FAILURE");
414
    }
415
    else if (vm->get_lcm_state() == VirtualMachine::BOOT_MIGRATE ||
416
             vm->get_lcm_state() == VirtualMachine::BOOT_MIGRATE_FAILURE )
417
    {
418
        vm->set_state(VirtualMachine::BOOT_MIGRATE_FAILURE);
419

  
420
        vmpool->update(vm);
421

  
422
        vm->log("LCM", Log::INFO, "Fail to boot VM. New VM state is BOOT_MIGRATE_FAILURE");
408 423
    }
409 424
    else if (vm->get_lcm_state() == VirtualMachine::BOOT_UNKNOWN)
410 425
    {
......
716 731
    {
717 732
        vm->set_state(VirtualMachine::BOOT_UNDEPLOY);
718 733
    }
719
    else // PROLOG || PROLOG_MIGRATE
734
    else if ( lcm_state == VirtualMachine::PROLOG_MIGRATE )
735
    {
736
        vm->set_state(VirtualMachine::BOOT_MIGRATE);
737
    }
738
    else // PROLOG
720 739
    {
721 740
        vm->set_state(VirtualMachine::BOOT);
722 741
    }

Also available in: Unified diff