Revision 39c0686c src/lcm/LifeCycleActions.cc

View differences:

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

Also available in: Unified diff