CLOUDSTACK-1410: >4.1 agents should be able to communicatie with <=4.1 management servers

The recently added overcommit feature breaks compatibility between older management servers
and 4.2 agents.

This patch fixes that by falling back if needed.
This commit is contained in:
Wido den Hollander 2013-02-27 16:11:04 +01:00
parent ddd507bccc
commit 2e28f69d3e
2 changed files with 31 additions and 1 deletions

View File

@ -28,8 +28,20 @@ public class VirtualMachineTO {
private BootloaderType bootloader;
Type type;
int cpus;
/**
'speed' is still here since 4.0.X/4.1.X management servers do not support
the overcommit feature yet.
The overcommit feature sends minSpeed and maxSpeed
So this is here for backwards compatibility with 4.0.X/4.1.X management servers
and newer agents.
*/
Integer speed;
Integer minSpeed;
Integer maxSpeed;
long minRam;
long maxRam;
String hostName;
@ -103,6 +115,10 @@ public class VirtualMachineTO {
this.cpus = cpus;
}
public Integer getSpeed() {
return speed;
}
public Integer getMinSpeed() {
return minSpeed;
}

View File

@ -2934,7 +2934,21 @@ ServerResource {
vm.addComp(grd);
CpuTuneDef ctd = new CpuTuneDef();
ctd.setShares(vmTO.getCpus() * vmTO.getMinSpeed());
/**
A 4.0.X/4.1.X management server doesn't send the correct JSON
command for getMinSpeed, it only sends a 'speed' field.
So if getMinSpeed() returns null we fall back to getSpeed().
This way a >4.1 agent can work communicate a <=4.1 management server
This change is due to the overcommit feature in 4.2
*/
if (vmTO.getMinSpeed() != null) {
ctd.setShares(vmTO.getCpus() * vmTO.getMinSpeed());
} else {
ctd.setShares(vmTO.getCpus() * vmTO.getSpeed());
}
vm.addComp(ctd);
FeaturesDef features = new FeaturesDef();