1) Remove customer field applied to virtual machine in VMware. 2) always track VM host change in VMware regardless whether or not native HA is enabled

This commit is contained in:
Kelven Yang 2011-06-15 18:36:51 -07:00
parent d039164645
commit 2a6307f272
4 changed files with 35 additions and 18 deletions

View File

@ -43,4 +43,11 @@ public interface HypervisorGuru extends Adapter {
* @return delegated host id if the command will be delegated
*/
long getCommandHostDelegation(long hostId, Command cmd);
/**
* @return true if VM can be migrated independently with CloudStack, and therefore CloudStack needs to track and reflect host change
* into CloudStack database, false if CloudStack enforces VM sync logic
*
*/
boolean trackVmHostChange();
}

View File

@ -52,4 +52,9 @@ public class KVMGuru extends HypervisorGuruBase implements HypervisorGuru {
return to;
}
@Override
public boolean trackVmHostChange() {
return false;
}
}

View File

@ -58,4 +58,9 @@ public class XenServerGuru extends HypervisorGuruBase implements HypervisorGuru
return to;
}
@Override
public boolean trackVmHostChange() {
return false;
}
}

View File

@ -1416,8 +1416,6 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
Map<Long, AgentVmInfo> states = convertToInfos(newStates);
Commands commands = new Commands(OnError.Continue);
boolean nativeHA = _agentMgr.isHostNativeHAEnabled(hostId);
for (Map.Entry<Long, AgentVmInfo> entry : states.entrySet()) {
AgentVmInfo info = entry.getValue();
@ -1425,7 +1423,8 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
Command command = null;
if (vm != null) {
command = compareState(vm, info, false, nativeHA);
HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType());
command = compareState(vm, info, false, hvGuru.trackVmHostChange());
} else {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Cleaning up a VM that is no longer found: " + info.name);
@ -1638,8 +1637,6 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
Map<Long, AgentVmInfo> infos = convertToInfos(newStates);
boolean nativeHA = _agentMgr.isHostNativeHAEnabled(hostId);
for (VMInstanceVO vm : vms) {
AgentVmInfo info = infos.remove(vm.getId());
@ -1650,30 +1647,33 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
} else {
castedVm = info.vm;
}
HypervisorGuru hvGuru = _hvGuruMgr.getGuru(castedVm.getHypervisorType());
Command command = compareState(castedVm, info, true, nativeHA);
Command command = compareState(castedVm, info, true, hvGuru.trackVmHostChange());
if (command != null) {
commands.addCommand(command);
}
}
for (final AgentVmInfo left : infos.values()) {
if (nativeHA) {
for (VirtualMachineGuru<? extends VMInstanceVO> vmGuru : _vmGurus.values()) {
VMInstanceVO vm = vmGuru.findByName(left.name);
if (vm == null) {
for (VirtualMachineGuru<? extends VMInstanceVO> vmGuru : _vmGurus.values()) {
VMInstanceVO vm = vmGuru.findByName(left.name);
if (vm == null) {
s_logger.warn("Stopping a VM that we have no record of: " + left.name);
commands.addCommand(cleanup(left.name));
} else {
HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType());
if(hvGuru.trackVmHostChange()) {
Command command = compareState(vm, left, true, true);
if (command != null) {
commands.addCommand(command);
}
} else {
s_logger.warn("Stopping a VM that we have no record of: " + left.name);
commands.addCommand(cleanup(left.name));
} else {
Command command = compareState(vm, left, true, nativeHA);
if (command != null) {
commands.addCommand(command);
}
}
}
} else {
s_logger.warn("Stopping a VM that we have no record of: " + left.name);
commands.addCommand(cleanup(left.name));
}
}