Revision a7394113

View differences:

include/VirtualMachine.h
141 141
        BOOT_UNDEPLOY       = 32,
142 142
        HOTPLUG_PROLOG_POWEROFF = 33,
143 143
        HOTPLUG_EPILOG_POWEROFF = 34,
144
        BOOT_MIGRATE        = 35,
145
        BOOT_FAILURE        = 36,
146
        BOOT_MIGRATE_FAILURE= 37
144
        BOOT_MIGRATE            = 35,
145
        BOOT_FAILURE            = 36,
146
        BOOT_MIGRATE_FAILURE    = 37,
147
        PROLOG_MIGRATE_FAILURE  = 38
147 148
    };
148 149

  
149 150
    static int lcm_state_from_str(string& st, LcmState& state)
......
188 189
        else if ( st == "BOOT_MIGRATE") { state = BOOT_MIGRATE; }
189 190
        else if ( st == "BOOT_FAILURE") { state = BOOT_FAILURE; }
190 191
        else if ( st == "BOOT_MIGRATE_FAILURE") { state = BOOT_MIGRATE_FAILURE; }
192
        else if ( st == "PROLOG_MIGRATE_FAILURE") { state = PROLOG_MIGRATE_FAILURE; }
191 193
        else {return -1;}
192 194

  
193 195
        return 0;
......
235 237
            case BOOT_MIGRATE: st = "BOOT_MIGRATE"; break;
236 238
            case BOOT_FAILURE: st = "BOOT_FAILURE"; break;
237 239
            case BOOT_MIGRATE_FAILURE: st = "BOOT_MIGRATE_FAILURE"; break;
240
            case PROLOG_MIGRATE_FAILURE: st = "PROLOG_MIGRATE_FAILURE"; break;
238 241
        }
239 242

  
240 243
        return st;
......
803 806
    };
804 807

  
805 808
    /**
809
     *  Sets end time of VM prolog state in the previous host.
810
     *    @param _etime time when the running state finished
811
     */
812
    void set_previous_prolog_etime(time_t _etime)
813
    {
814
        previous_history->prolog_etime=_etime;
815
    };
816

  
817
    /**
806 818
     *  Sets start time of VM epilog.
807 819
     *    @param _stime time when the epilog started
808 820
     */
share/doc/states/states-complete.dot
21 21
    subgraph { rank = min; user}
22 22
    subgraph { rank = same; boot; boot_stopped; boot_undeploy; boot_suspended; boot_unknown; boot_poweroff; boot_migrate; boot_failure; boot_migrate_failure; unknown; color="white"}
23 23
    subgraph { rank = same; pending; hold; color="white"}
24
    subgraph { rank = same; prolog; prolog_resume; prolog_migrate; color="white" }
24
    subgraph { rank = same; prolog; prolog_resume; prolog_migrate; prolog_migrate_failure; color="white" }
25 25
    subgraph { rank = same; hotplug_prolog_poweroff; hotplug_saveas_poweroff; hotplug_saveas_suspended; epilog_stop; epilog; epilog_undeploy; hotplug_epilog_poweroff; color="white" }
26 26
    subgraph { rank = same; suspended; stopped; undeployed; poweroff; color="white" }
27 27
    subgraph { rank = sink; done; failure; ANY; color="white" }
......
165 165
    epilog_undeploy -> failure [style="dotted"];
166 166

  
167 167
    prolog          -> failure [style="dotted"];
168
    prolog_migrate  -> failure [style="dotted"];
168

  
169
    prolog_migrate          -> prolog_migrate_failure [style="dotted"];
170
    prolog_migrate_failure  -> prolog_migrate [label="migrate"];
171

  
169 172
    prolog_resume   -> stopped [style="dotted"];
170 173
    prolog_undeploy -> undeployed [style="dotted"];
171 174

  
share/doc/xsd/acct.xsd
144 144
                BOOT_UNDEPLOY       = 32,
145 145
                HOTPLUG_PROLOG_POWEROFF = 33,
146 146
                HOTPLUG_EPILOG_POWEROFF = 34,
147
                BOOT_MIGRATE        = 35,
148
                BOOT_FAILURE        = 36,
149
                BOOT_MIGRATE_FAILURE= 37
147
                BOOT_MIGRATE            = 35,
148
                BOOT_FAILURE            = 36,
149
                BOOT_MIGRATE_FAILURE    = 37,
150
                PROLOG_MIGRATE_FAILURE  = 38
150 151
              -->
151 152
              <xs:element name="LCM_STATE" type="xs:integer"/>
152 153
              <xs:element name="PREV_STATE" type="xs:integer"/>
share/doc/xsd/vm.xsd
81 81
          BOOT_UNDEPLOY       = 32,
82 82
          HOTPLUG_PROLOG_POWEROFF = 33,
83 83
          HOTPLUG_EPILOG_POWEROFF = 34,
84
          BOOT_MIGRATE        = 35,
85
          BOOT_FAILURE        = 36,
86
          BOOT_MIGRATE_FAILURE= 37
84
          BOOT_MIGRATE            = 35,
85
          BOOT_FAILURE            = 36,
86
          BOOT_MIGRATE_FAILURE    = 37,
87
          PROLOG_MIGRATE_FAILURE  = 38
87 88
        -->
88 89
        <xs:element name="LCM_STATE" type="xs:integer"/>
89 90
        <xs:element name="PREV_STATE" type="xs:integer"/>
src/dm/DispatchManagerActions.cc
145 145

  
146 146
    if (vm->get_state()     == VirtualMachine::ACTIVE &&
147 147
        (vm->get_lcm_state() == VirtualMachine::RUNNING ||
148
         vm->get_lcm_state() == VirtualMachine::UNKNOWN ) )
148
         vm->get_lcm_state() == VirtualMachine::UNKNOWN ||
149
         vm->get_lcm_state() == VirtualMachine::PROLOG_MIGRATE_FAILURE) )
149 150
    {
150 151
        Nebula&             nd  = Nebula::instance();
151 152
        LifeCycleManager *  lcm = nd.get_lcm();
src/lcm/LifeCycleActions.cc
267 267

  
268 268
        vmm->trigger(VirtualMachineManager::SAVE,vid);
269 269
    }
270
    else if (vm->get_state() == VirtualMachine::ACTIVE &&
271
             vm->get_lcm_state() == VirtualMachine::PROLOG_MIGRATE_FAILURE)
272
    {
273
        //----------------------------------------------------
274
        //   Bypass SAVE_MIGRATE
275
        //----------------------------------------------------
276

  
277
        Nebula& nd = Nebula::instance();
278
        TransferManager * tm = nd.get_tm();
279

  
280
        int    cpu, mem, disk;
281
        time_t the_time = time(0);
282

  
283
        vm->set_resched(false);
284

  
285
        vm->set_state(VirtualMachine::PROLOG_MIGRATE);
286

  
287
        vm->delete_snapshots();
288

  
289
        map<string, string> empty;
290

  
291
        vm->update_info(0, 0, -1, -1, empty);
292

  
293
        vmpool->update(vm);
294

  
295
        vm->set_stime(the_time);
296

  
297
        vm->set_previous_action(History::MIGRATE_ACTION);
298

  
299
        vm->set_previous_prolog_etime(the_time);
300

  
301
        vm->set_previous_etime(the_time);
302

  
303
        vm->set_previous_vm_info();
304

  
305
        vm->set_previous_reason(History::USER);
306

  
307
        vmpool->update_previous_history(vm);
308

  
309
        vmpool->update_history(vm);
310

  
311
        vm->get_requirements(cpu,mem,disk);
312

  
313
        hpool->add_capacity(vm->get_hid(), vm->get_oid(), cpu, mem, disk);
314

  
315
        hpool->del_capacity(vm->get_previous_hid(), vm->get_oid(), cpu, mem, disk);
316

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

  
319
        //----------------------------------------------------
320

  
321
        tm->trigger(TransferManager::PROLOG_MIGR,vid);
322
    }
270 323
    else if (vm->get_state()     == VirtualMachine::ACTIVE &&
271 324
             vm->get_lcm_state() == VirtualMachine::UNKNOWN)
272 325
    {
......
1116 1169
        break;
1117 1170

  
1118 1171
        case VirtualMachine::PROLOG_MIGRATE:
1172
        case VirtualMachine::PROLOG_MIGRATE_FAILURE:
1119 1173
            vm->set_prolog_etime(the_time);
1120 1174
            vmpool->update_history(vm);
1121 1175

  
......
1182 1236
        //----------------------------------------------------------------------
1183 1237
        case VirtualMachine::PROLOG:
1184 1238
        case VirtualMachine::PROLOG_MIGRATE:
1239
        case VirtualMachine::PROLOG_MIGRATE_FAILURE:
1185 1240
        case VirtualMachine::PROLOG_RESUME:
1186 1241
        case VirtualMachine::PROLOG_UNDEPLOY:
1187 1242
            if (success)
src/lcm/LifeCycleStates.cc
731 731
    {
732 732
        vm->set_state(VirtualMachine::BOOT_UNDEPLOY);
733 733
    }
734
    else if ( lcm_state == VirtualMachine::PROLOG_MIGRATE )
734
    else if ( lcm_state == VirtualMachine::PROLOG_MIGRATE ||
735
              lcm_state == VirtualMachine::PROLOG_MIGRATE_FAILURE )
735 736
    {
736 737
        vm->set_state(VirtualMachine::BOOT_MIGRATE);
737 738
    }
......
780 781

  
781 782
    state = vm->get_lcm_state();
782 783

  
783
    if ( state == VirtualMachine::PROLOG ||
784
         state == VirtualMachine::PROLOG_MIGRATE )
784
    if ( state == VirtualMachine::PROLOG )
785 785
    {
786 786
        vm->set_prolog_etime(the_time);
787 787

  
788 788
        failure_action(vm);
789 789
    }
790
    else if ( state == VirtualMachine::PROLOG_MIGRATE )
791
    {
792
        vm->set_state(VirtualMachine::PROLOG_MIGRATE_FAILURE);
793
        vmpool->update(vm);
794

  
795
        vm->log("LCM", Log::INFO, "New VM state is PROLOG_MIGRATE_FAILURE");
796
    }
790 797
    else if ( state == VirtualMachine::PROLOG_RESUME )
791 798
    {
792 799
        //----------------------------------------------------
src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java
114 114
        "HOTPLUG_EPILOG_POWEROFF",
115 115
        "BOOT_MIGRATE",
116 116
        "BOOT_FAILURE",
117
        "BOOT_MIGRATE_FAILURE" };
117
        "BOOT_MIGRATE_FAILURE",
118
        "PROLOG_MIGRATE_FAILURE" };
118 119

  
119 120
    private static final String[] SHORT_LCM_STATES =
120 121
    {
......
155 156
        "hotp",
156 157
        "boot",
157 158
        "fail",
159
        "fail",
158 160
        "fail" };
159 161

  
160 162
    /**
src/oca/ruby/opennebula/virtual_machine.rb
88 88
            BOOT_MIGRATE
89 89
            BOOT_FAILURE
90 90
            BOOT_MIGRATE_FAILURE
91
            PROLOG_MIGRATE_FAILURE
91 92
        }
92 93

  
93 94
        SHORT_VM_STATES={
......
138 139
            "BOOT_UNDEPLOY"     => "boot",
139 140
            "HOTPLUG_PROLOG_POWEROFF"   => "hotp",
140 141
            "HOTPLUG_EPILOG_POWEROFF"   => "hotp",
141
            "BOOT_MIGRATE"      => "boot",
142
            "BOOT_FAILURE"      => "fail",
143
            "BOOT_MIGRATE_FAILURE" => "fail"
142
            "BOOT_MIGRATE"              => "boot",
143
            "BOOT_FAILURE"              => "fail",
144
            "BOOT_MIGRATE_FAILURE"      => "fail",
145
            "PROLOG_MIGRATE_FAILURE"    => "fail"
144 146
        }
145 147

  
146 148
        MIGRATE_REASON=%w{NONE ERROR USER}
src/rm/RequestManagerVirtualMachine.cc
915 915

  
916 916
    if((vm->get_state()     != VirtualMachine::ACTIVE)  ||
917 917
       (vm->get_lcm_state() != VirtualMachine::RUNNING &&
918
        vm->get_lcm_state() != VirtualMachine::UNKNOWN) ||
918
        vm->get_lcm_state() != VirtualMachine::UNKNOWN &&
919
        vm->get_lcm_state() != VirtualMachine::PROLOG_MIGRATE_FAILURE) ||
919 920
       (vm->hasPreviousHistory() && vm->get_previous_reason() == History::NONE))
920 921
    {
921 922
        failure_response(ACTION,
......
940 941

  
941 942
    c_hid = vm->get_hid();
942 943

  
943
    if (c_hid == hid)
944
    if (vm->get_state() == VirtualMachine::ACTIVE &&
945
        vm->get_lcm_state() == VirtualMachine::PROLOG_MIGRATE_FAILURE)
944 946
    {
945
        ostringstream oss;
947
        enforce = false;
948
        live = false;
946 949

  
947
        oss << "VM is already running on "
948
            << object_name(PoolObjectSQL::HOST) << " [" << c_hid << "]";
950
        int p_hid = c_hid;
949 951

  
950
        failure_response(ACTION,
951
                request_error(oss.str(),""),
952
                att);
952
        if(vm->hasPreviousHistory())
953
        {
954
            p_hid = vm->get_previous_hid();
955
        }
953 956

  
954
        vm->unlock();
955
        return;
957
        if (hid != c_hid && hid != p_hid)
958
        {
959
            ostringstream oss;
960

  
961
            oss << "VM in state PROLOG_MIGRATE_FAILURE can only be migrated to "
962
                << object_name(PoolObjectSQL::HOST) << " [" << c_hid << "] or "
963
                << object_name(PoolObjectSQL::HOST) << " [" << p_hid << "]";
964

  
965
            failure_response(ACTION,
966
                    request_error(oss.str(),""),
967
                    att);
968

  
969
            vm->unlock();
970
            return;
971
        }
972
    }
973
    else
974
    {
975
        if (c_hid == hid)
976
        {
977
            ostringstream oss;
978

  
979
            oss << "VM is already running on "
980
                << object_name(PoolObjectSQL::HOST) << " [" << c_hid << "]";
981

  
982
            failure_response(ACTION,
983
                    request_error(oss.str(),""),
984
                    att);
985

  
986
            vm->unlock();
987
            return;
988
        }
956 989
    }
957 990

  
958 991
    // Get System DS information from current History record
src/sunstone/OpenNebulaVNC.rb
65 65
        #30, #EPILOG_UNDEPLOY
66 66
        #31, #PROLOG_UNDEPLOY
67 67
        #32, #BOOT_UNDEPLOY
68
        #33, #BOOT_MIGRATE
69
        #34, #BOOT_FAILURE
70
        #35, #BOOT_MIGRATE_FAILURE
68
        #33, #HOTPLUG_PROLOG_POWEROFF
69
        #34, #HOTPLUG_EPILOG_POWEROFF
70
        #35, #BOOT_MIGRATE
71
        #36, #BOOT_FAILURE
72
        #37, #BOOT_MIGRATE_FAILURE
73
        #38, #PROLOG_MIGRATE_FAILURE
71 74
]
72 75

  
73 76
class OpenNebulaVNC
src/sunstone/public/js/opennebula.js
118 118
                    break;
119 119
                case "VM_LCM":
120 120
                case "vm_lcm":
121
                    state = tr(["LCM_INIT",
122
                               "PROLOG",
123
                               "BOOT",
124
                               "RUNNING",
125
                               "MIGRATE",
126
                               "SAVE",
127
                               "SAVE",
128
                               "SAVE",
129
                               "MIGRATE",
130
                               "PROLOG",
131
                               "EPILOG",
132
                               "EPILOG",
133
                               "SHUTDOWN",
134
                               "SHUTDOWN",
135
                               "FAILURE",
136
                               "CLEANUP",
137
                               "UNKNOWN",
138
                               "HOTPLUG",
139
                               "SHUTDOWN",
140
                               "BOOT",
141
                               "BOOT",
142
                               "BOOT",
143
                               "BOOT",
144
                               "CLEANUP",
145
                               "SNAPSHOT",
146
                               "HOTPLUG",
147
                               "HOTPLUG",
148
                               "HOTPLUG",
149
                               "HOTPLUG",
150
                               "SHUTDOWN",
151
                               "EPILOG",
152
                               "PROLOG",
153
                               "BOOT",
154
                               "BOOT",
155
                               "FAILURE",
156
                               "FAILURE"][value]);
121
                    state = tr(["LCM_INIT", // LCM_INIT
122
                               "PROLOG",    // PROLOG
123
                               "BOOT",      // BOOT
124
                               "RUNNING",   // RUNNING
125
                               "MIGRATE",   // MIGRATE
126
                               "SAVE",      // SAVE_STOP
127
                               "SAVE",      // SAVE_SUSPEND
128
                               "SAVE",      // SAVE_MIGRATE
129
                               "MIGRATE",   // PROLOG_MIGRATE
130
                               "PROLOG",    // PROLOG_RESUME
131
                               "EPILOG",    // EPILOG_STOP
132
                               "EPILOG",    // EPILOG
133
                               "SHUTDOWN",  // SHUTDOWN
134
                               "SHUTDOWN",  // CANCEL
135
                               "FAILURE",   // FAILURE
136
                               "CLEANUP",   // CLEANUP_RESUBMIT
137
                               "UNKNOWN",   // UNKNOWN
138
                               "HOTPLUG",   // HOTPLUG
139
                               "SHUTDOWN",  // SHUTDOWN_POWEROFF
140
                               "BOOT",      // BOOT_UNKNOWN
141
                               "BOOT",      // BOOT_POWEROFF
142
                               "BOOT",      // BOOT_SUSPENDED
143
                               "BOOT",      // BOOT_STOPPED
144
                               "CLEANUP",   // CLEANUP_DELETE
145
                               "SNAPSHOT",  // HOTPLUG_SNAPSHOT
146
                               "HOTPLUG",   // HOTPLUG_NIC
147
                               "HOTPLUG",   // HOTPLUG_SAVEAS
148
                               "HOTPLUG",   // HOTPLUG_SAVEAS_POWEROFF
149
                               "HOTPLUG",   // HOTPLUG_SAVEAS_SUSPENDED
150
                               "SHUTDOWN",  // SHUTDOWN_UNDEPLOY
151
                               "EPILOG",    // EPILOG_UNDEPLOY
152
                               "PROLOG",    // PROLOG_UNDEPLOY
153
                               "BOOT",      // BOOT_UNDEPLOY
154
                               "HOTPLUG",   // HOTPLUG_PROLOG_POWEROFF
155
                               "HOTPLUG",   // HOTPLUG_EPILOG_POWEROFF
156
                               "BOOT",      // BOOT_MIGRATE
157
                               "FAILURE",   // BOOT_FAILURE
158
                               "FAILURE",   // BOOT_MIGRATE_FAILURE
159
                               "FAILURE"][value]); // PROLOG_MIGRATE_FAILURE
157 160
                    break;
158 161
                case "IMAGE":
159 162
                case "image":
......
939 942
            "BOOT_UNDEPLOY"       : 32,
940 943
            "HOTPLUG_PROLOG_POWEROFF"   : 33,
941 944
            "HOTPLUG_EPILOG_POWEROFF"   : 34,
942
            "BOOT_MIGRATE"        : 35,
943
            "BOOT_FAILURE"        : 36,
944
            "BOOT_MIGRATE_FAILURE": 37
945
            "BOOT_MIGRATE"              : 35,
946
            "BOOT_FAILURE"              : 36,
947
            "BOOT_MIGRATE_FAILURE"      : 37,
948
            "PROLOG_MIGRATE_FAILURE"    : 38
945 949
        },
946 950

  
947 951
        "create": function(params){
src/sunstone/public/js/plugins/vms-tab.js
155 155
        ["VM.boot"],
156 156
    37: //OpenNebula.VM.lcm_state.BOOT_MIGRATE_FAILURE:
157 157
        ["VM.boot"],
158
    38: //OpenNebula.VM.lcm_state.PROLOG_MIGRATE_FAILURE:
159
        ["VM.migrate"],
158 160
}
159 161

  
160 162
//Permanent storage for last value of aggregated network usage

Also available in: Unified diff