Revision b2b59ded src/lcm/LifeCycleActions.cc

View differences:

src/lcm/LifeCycleActions.cc
1141 1141
        //----------------------------------------------------------------------
1142 1142
        case VirtualMachine::PROLOG:
1143 1143
        case VirtualMachine::PROLOG_MIGRATE:
1144
        case VirtualMachine::PROLOG_MIGRATE_FAILURE:
1145 1144
        case VirtualMachine::PROLOG_RESUME:
1146 1145
        case VirtualMachine::PROLOG_RESUME_FAILURE:
1147 1146
        case VirtualMachine::PROLOG_UNDEPLOY:
1148 1147
        case VirtualMachine::PROLOG_UNDEPLOY_FAILURE:
1149 1148
        case VirtualMachine::PROLOG_FAILURE:
1150 1149
        case VirtualMachine::PROLOG_MIGRATE_POWEROFF:
1151
        case VirtualMachine::PROLOG_MIGRATE_POWEROFF_FAILURE:
1152 1150
        case VirtualMachine::PROLOG_MIGRATE_SUSPEND:
1153
        case VirtualMachine::PROLOG_MIGRATE_SUSPEND_FAILURE:
1154 1151
        case VirtualMachine::PROLOG_MIGRATE_UNKNOWN:
1155
        case VirtualMachine::PROLOG_MIGRATE_UNKNOWN_FAILURE:
1156 1152
            if (success)
1157 1153
            {
1158 1154
                lcm_action = LifeCycleManager::PROLOG_SUCCESS;
......
1163 1159
            }
1164 1160
        break;
1165 1161

  
1162
        case VirtualMachine::PROLOG_MIGRATE_FAILURE:
1163
        case VirtualMachine::PROLOG_MIGRATE_POWEROFF_FAILURE:
1164
        case VirtualMachine::PROLOG_MIGRATE_SUSPEND_FAILURE:
1165
        case VirtualMachine::PROLOG_MIGRATE_UNKNOWN_FAILURE:
1166
            if (success)
1167
            {
1168
                lcm_action = LifeCycleManager::PROLOG_SUCCESS;
1169
            }
1170
            else
1171
            {
1172
                int cpu, mem, disk;
1173
                vector<VectorAttribute *> pci;
1174

  
1175
                time_t t = time(0);
1176

  
1177
                // Close current history record
1178
                vm->set_prolog_etime(t);
1179
                vm->set_etime(t);
1180
                vm->set_reason(History::ERROR);
1181
                vm->set_action(History::MIGRATE_ACTION);
1182

  
1183
                vm->set_vm_info();
1184

  
1185
                vmpool->update_history(vm);
1186

  
1187
                vm->get_requirements(cpu, mem, disk, pci);
1188
                hpool->del_capacity(vm->get_hid(), vm->get_oid(), cpu, mem, disk, pci);
1189

  
1190
                // Clone previous history record into a new one
1191
                vm->cp_previous_history();
1192

  
1193
                vm->set_stime(t);
1194

  
1195
                vm->set_prolog_stime(t);
1196

  
1197
                vm->set_last_poll(0);
1198

  
1199
                switch (vm->get_lcm_state())
1200
                {
1201
                    case VirtualMachine::PROLOG_MIGRATE_FAILURE:
1202
                        vm->set_state(VirtualMachine::PROLOG_MIGRATE);
1203
                        break;
1204
                    case VirtualMachine::PROLOG_MIGRATE_POWEROFF_FAILURE:
1205
                        vm->set_state(VirtualMachine::PROLOG_MIGRATE_POWEROFF);
1206
                        break;
1207
                    case VirtualMachine::PROLOG_MIGRATE_SUSPEND_FAILURE:
1208
                        vm->set_state(VirtualMachine::PROLOG_MIGRATE_SUSPEND);
1209
                        break;
1210
                    case VirtualMachine::PROLOG_MIGRATE_UNKNOWN_FAILURE:
1211
                        vm->set_state(VirtualMachine::PROLOG_MIGRATE_UNKNOWN);
1212
                        break;
1213
                    default:
1214
                        break;
1215
                }
1216

  
1217
                vmpool->update(vm); //update last_seq & state
1218
                vmpool->update_history(vm);
1219

  
1220
                hpool->add_capacity(vm->get_hid(), vm->get_oid(), cpu, mem, disk, pci);
1221

  
1222
                lcm_action = LifeCycleManager::PROLOG_SUCCESS;
1223
            }
1224
        break;
1225

  
1226

  
1166 1227
        case VirtualMachine::EPILOG:
1167 1228
        case VirtualMachine::EPILOG_STOP:
1168 1229
        case VirtualMachine::EPILOG_UNDEPLOY:

Also available in: Unified diff