Revision dd3edff6 src/lcm/LifeCycleActions.cc

View differences:

src/lcm/LifeCycleActions.cc
688 688
/* -------------------------------------------------------------------------- */
689 689
/* -------------------------------------------------------------------------- */
690 690

  
691
void LifeCycleManager::retry_action(int vid)
692
{
693
    Nebula& nd  = Nebula::instance();
694

  
695
    TransferManager *       tm  = nd.get_tm();
696
    VirtualMachineManager * vmm = nd.get_vmm();
697

  
698
    VirtualMachine * vm;
699

  
700
    vm = vmpool->get(vid,true);
701

  
702
    if ( vm == 0 )
703
    {
704
        return;
705
    }
706

  
707
    if ( vm->get_state() != VirtualMachine::ACTIVE )
708
    {
709
        vm->unlock();
710
        return;
711
    }
712

  
713
    VirtualMachine::LcmState state = vm->get_lcm_state();
714

  
715
    switch (state)
716
    {
717
        case VirtualMachine::BOOT_FAILURE:
718
            vm->set_state(VirtualMachine::BOOT);
719

  
720
            vmpool->update(vm);
721

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

  
724
            vmm->trigger(VirtualMachineManager::DEPLOY, vid);
725
            break;
726

  
727
        case VirtualMachine::BOOT_MIGRATE_FAILURE:
728
            vm->set_state(VirtualMachine::BOOT_MIGRATE);
729

  
730
            vmpool->update(vm);
731

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

  
734
            vmm->trigger(VirtualMachineManager::RESTORE, vid);
735
            break;
736

  
737
        case VirtualMachine::PROLOG_MIGRATE_FAILURE:
738
            vm->set_state(VirtualMachine::PROLOG_MIGRATE);
739

  
740
            vmpool->update(vm);
741

  
742
            vm->log("LCM", Log::INFO, "New VM state is PROLOG_MIGRATE");
743

  
744
            tm->trigger(TransferManager::PROLOG_MIGR, vid);
745
            break;
746

  
747
        case VirtualMachine::LCM_INIT:
748
        case VirtualMachine::BOOT:
749
        case VirtualMachine::BOOT_MIGRATE:
750
        case VirtualMachine::BOOT_POWEROFF:
751
        case VirtualMachine::BOOT_SUSPENDED:
752
        case VirtualMachine::BOOT_STOPPED:
753
        case VirtualMachine::BOOT_UNDEPLOY:
754
        case VirtualMachine::BOOT_UNKNOWN:
755
        case VirtualMachine::CANCEL:
756
        case VirtualMachine::CLEANUP_RESUBMIT:
757
        case VirtualMachine::CLEANUP_DELETE:
758
        case VirtualMachine::EPILOG:
759
        case VirtualMachine::EPILOG_STOP:
760
        case VirtualMachine::EPILOG_UNDEPLOY:
761
        case VirtualMachine::FAILURE:
762
        case VirtualMachine::HOTPLUG:
763
        case VirtualMachine::HOTPLUG_NIC:
764
        case VirtualMachine::HOTPLUG_SNAPSHOT:
765
        case VirtualMachine::HOTPLUG_SAVEAS:
766
        case VirtualMachine::HOTPLUG_SAVEAS_POWEROFF:
767
        case VirtualMachine::HOTPLUG_SAVEAS_SUSPENDED:
768
        case VirtualMachine::HOTPLUG_PROLOG_POWEROFF:
769
        case VirtualMachine::HOTPLUG_EPILOG_POWEROFF:
770
        case VirtualMachine::PROLOG:
771
        case VirtualMachine::PROLOG_MIGRATE:
772
        case VirtualMachine::PROLOG_RESUME:
773
        case VirtualMachine::PROLOG_UNDEPLOY:
774
        case VirtualMachine::MIGRATE:
775
        case VirtualMachine::RUNNING:
776
        case VirtualMachine::SAVE_STOP:
777
        case VirtualMachine::SAVE_SUSPEND:
778
        case VirtualMachine::SAVE_MIGRATE:
779
        case VirtualMachine::SHUTDOWN:
780
        case VirtualMachine::SHUTDOWN_POWEROFF:
781
        case VirtualMachine::SHUTDOWN_UNDEPLOY:
782
        case VirtualMachine::UNKNOWN:
783
            break;
784
    }
785

  
786
    vm->unlock();
787

  
788
    return;
789
}
790

  
791
/* -------------------------------------------------------------------------- */
792
/* -------------------------------------------------------------------------- */
793

  
691 794
void  LifeCycleManager::restart_action(int vid)
692 795
{
693 796
    VirtualMachine *    vm;
......
699 802
        return;
700 803
    }
701 804

  
702
    if ((vm->get_state() == VirtualMachine::ACTIVE &&
703
        (vm->get_lcm_state() == VirtualMachine::UNKNOWN ||
704
         vm->get_lcm_state() == VirtualMachine::BOOT ||
705
         vm->get_lcm_state() == VirtualMachine::BOOT_UNKNOWN ||
706
         vm->get_lcm_state() == VirtualMachine::BOOT_POWEROFF ||
707
         vm->get_lcm_state() == VirtualMachine::BOOT_SUSPENDED ||
708
         vm->get_lcm_state() == VirtualMachine::BOOT_STOPPED ||
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 ||
713
         vm->get_lcm_state() == VirtualMachine::PROLOG_MIGRATE_FAILURE))
714
       ||vm->get_state() == VirtualMachine::POWEROFF)
805
    VirtualMachine::LcmState lstate = vm->get_lcm_state();
806
    VirtualMachine::VmState  vstate = vm->get_state();
807

  
808
    if (vstate == VirtualMachine::POWEROFF || ( vstate == VirtualMachine::ACTIVE &&
809
        (lstate == VirtualMachine::UNKNOWN        || lstate == VirtualMachine::BOOT ||
810
         lstate == VirtualMachine::BOOT_UNKNOWN   || lstate == VirtualMachine::BOOT_POWEROFF ||
811
         lstate == VirtualMachine::BOOT_SUSPENDED || lstate == VirtualMachine::BOOT_STOPPED ||
812
         lstate == VirtualMachine::BOOT_UNDEPLOY  || lstate == VirtualMachine::BOOT_MIGRATE)))
715 813
    {
716 814
        Nebula& nd  = Nebula::instance();
717 815

  
......
723 821
        //       RE-START THE VM IN THE SAME HOST
724 822
        //----------------------------------------------------
725 823

  
726
        if (vm->get_state() == VirtualMachine::ACTIVE)
824
        if (vstate == VirtualMachine::ACTIVE)
727 825
        {
728
            switch (vm->get_lcm_state()) {
826
            switch (lstate) {
729 827
                case VirtualMachine::BOOT:
730 828
                case VirtualMachine::BOOT_UNKNOWN:
731 829
                case VirtualMachine::BOOT_POWEROFF:
732 830
                    action = VirtualMachineManager::DEPLOY;
733 831

  
734 832
                    vm->log("LCM", Log::INFO, "Sending BOOT command to VM again");
735

  
736 833
                    break;
737 834

  
738 835
                case VirtualMachine::BOOT_SUSPENDED:
......
742 839
                    action = VirtualMachineManager::RESTORE;
743 840

  
744 841
                    vm->log("LCM", Log::INFO, "Sending RESTORE command to VM again");
745

  
746 842
                    break;
747 843

  
748 844
                case VirtualMachine::UNKNOWN:
......
753 849
                    vmpool->update(vm);
754 850

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

  
757
                    break;
758

  
759
                case VirtualMachine::BOOT_FAILURE:
760
                    action = VirtualMachineManager::DEPLOY;
761

  
762
                    vm->set_state(VirtualMachine::BOOT);
763

  
764
                    vmpool->update(vm);
765

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

  
768
                    break;
769

  
770
                case VirtualMachine::BOOT_MIGRATE_FAILURE:
771
                    action = VirtualMachineManager::RESTORE;
772

  
773
                    vm->set_state(VirtualMachine::BOOT_MIGRATE);
774

  
775
                    vmpool->update(vm);
776

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

  
779 852
                    break;
780 853

  
781 854
                default:
......
808 881

  
809 882
            vmm->trigger(VirtualMachineManager::DEPLOY, vid);
810 883
        }
811
        else if ( vm->get_state() == VirtualMachine::PROLOG_MIGRATE_FAILURE )
812
        {
813
            TransferManager * tm  = nd.get_tm();
814

  
815
            vm->set_state(VirtualMachine::PROLOG_MIGRATE);
816

  
817
            vmpool->update(vm);
818

  
819
            vm->log("LCM", Log::INFO, "New VM state is PROLOG_MIGRATE");
820

  
821
            tm->trigger(TransferManager::PROLOG_MIGR, vid);
822
        }
823 884
    }
824 885
    else
825 886
    {
......
1040 1101
        case VirtualMachine::UNKNOWN:
1041 1102
        case VirtualMachine::SHUTDOWN:
1042 1103
        case VirtualMachine::SHUTDOWN_POWEROFF:
1104
        case VirtualMachine::SHUTDOWN_UNDEPLOY:
1043 1105
        case VirtualMachine::CANCEL:
1044 1106
        case VirtualMachine::HOTPLUG_SNAPSHOT:
1045 1107
            vm->set_running_etime(the_time);

Also available in: Unified diff