Commit 8a9bd8f0 authored by Anton Beloglazov's avatar Anton Beloglazov

Fixed a bug in PowerVmAllocationPolicySingleThreshold::optimizeAllocation()

parent 0408e710
...@@ -153,33 +153,33 @@ public class PowerVmAllocationPolicySingleThreshold extends VmAllocationPolicySi ...@@ -153,33 +153,33 @@ public class PowerVmAllocationPolicySingleThreshold extends VmAllocationPolicySi
List<Vm> vmsToRestore = new ArrayList<Vm>(); List<Vm> vmsToRestore = new ArrayList<Vm>();
vmsToRestore.addAll(vmList); vmsToRestore.addAll(vmList);
List<Vm> vmTmpList = new ArrayList<Vm>(); List<Vm> vmsToMigrate = new ArrayList<Vm>();
vmTmpList.addAll(vmList); for (Vm vm : vmList) {
PowerVmList.sortByCpuUtilization(vmTmpList); if (vm.isRecentlyCreated() || vm.isInMigration()) {
continue;
}
vmsToMigrate.add(vm);
vm.getHost().vmDestroy(vm);
}
PowerVmList.sortByCpuUtilization(vmsToMigrate);
for (PowerHost host : this.<PowerHost>getHostList()) { for (PowerHost host : this.<PowerHost>getHostList()) {
host.reallocateMigratingVms(); host.reallocateMigratingVms();
} }
for (Vm vm : vmTmpList) { for (Vm vm : vmsToMigrate) {
if (vm.isRecentlyCreated() || vm.isInMigration()) {
continue;
}
PowerHost oldHost = (PowerHost) getVmTable().get(vm.getUid()); PowerHost oldHost = (PowerHost) getVmTable().get(vm.getUid());
PowerHost allocatedHost = findHostForVm(vm); PowerHost allocatedHost = findHostForVm(vm);
if (allocatedHost != null) { if (allocatedHost != null && allocatedHost.getId() != oldHost.getId()) {
Log.printLine("VM #" + vm.getId() + " allocated to host #" + allocatedHost.getId());
allocatedHost.vmCreate(vm); allocatedHost.vmCreate(vm);
Log.printLine("VM #" + vm.getId() + " allocated to host #" + allocatedHost.getId());
if (allocatedHost.getId() != oldHost.getId()) {
Map<String, Object> migrate = new HashMap<String, Object>(); Map<String, Object> migrate = new HashMap<String, Object>();
migrate.put("vm", vm); migrate.put("vm", vm);
migrate.put("host", allocatedHost); migrate.put("host", allocatedHost);
migrationMap.add(migrate); migrationMap.add(migrate);
} }
} }
}
restoreAllocation(vmsToRestore, getHostList()); restoreAllocation(vmsToRestore, getHostList());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment