mirror of https://github.com/apache/cloudstack.git
Fixed few coverity issues
Signed-off-by: Santhosh Edukulla <santhosh.edukulla@gmail.com>
(cherry picked from commit 0a9742f914)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
db379bf0e8
commit
86943da26e
|
|
@ -426,7 +426,7 @@ public class Agent implements HandlerFactory, IAgentControl {
|
|||
s_logger.info("Proccess agent startup answer, agent id = " + startup.getHostId());
|
||||
|
||||
setId(startup.getHostId());
|
||||
_pingInterval = startup.getPingInterval() * 1000; // change to ms.
|
||||
_pingInterval = (long)startup.getPingInterval() * 1000; // change to ms.
|
||||
|
||||
setLastPingResponseTime();
|
||||
scheduleWatch(link, response, _pingInterval, _pingInterval);
|
||||
|
|
@ -461,7 +461,7 @@ public class Agent implements HandlerFactory, IAgentControl {
|
|||
|
||||
if (cmd instanceof CronCommand) {
|
||||
final CronCommand watch = (CronCommand)cmd;
|
||||
scheduleWatch(link, request, watch.getInterval() * 1000, watch.getInterval() * 1000);
|
||||
scheduleWatch(link, request, (long)watch.getInterval() * 1000, watch.getInterval() * 1000);
|
||||
answer = new Answer(cmd, true, null);
|
||||
} else if (cmd instanceof ShutdownCommand) {
|
||||
ShutdownCommand shutdown = (ShutdownCommand)cmd;
|
||||
|
|
|
|||
|
|
@ -435,7 +435,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
}
|
||||
|
||||
private VirtualMachineGuru getVmGuru(VirtualMachine vm) {
|
||||
return _vmGurus.get(vm.getType());
|
||||
if(vm != null)
|
||||
return _vmGurus.get(vm.getType());
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -76,24 +76,20 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement
|
|||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
super.configure(name, params);
|
||||
|
||||
Map<String, String> configs = _configDao.getConfiguration(null, params);
|
||||
|
||||
String globalStorageOverprovisioningFactor = configs.get("storage.overprovisioning.factor");
|
||||
_storageOverprovisioningFactor = new BigDecimal(NumbersUtil.parseFloat(globalStorageOverprovisioningFactor, 2.0f));
|
||||
|
||||
_extraBytesPerVolume = 0;
|
||||
|
||||
_rand = new Random(System.currentTimeMillis());
|
||||
|
||||
_dontMatter = Boolean.parseBoolean(configs.get("storage.overwrite.provisioning"));
|
||||
|
||||
String allocationAlgorithm = configs.get("vm.allocation.algorithm");
|
||||
if (allocationAlgorithm != null) {
|
||||
_allocationAlgorithm = allocationAlgorithm;
|
||||
if(_configDao != null) {
|
||||
Map<String, String> configs = _configDao.getConfiguration(null, params);
|
||||
String globalStorageOverprovisioningFactor = configs.get("storage.overprovisioning.factor");
|
||||
_storageOverprovisioningFactor = new BigDecimal(NumbersUtil.parseFloat(globalStorageOverprovisioningFactor, 2.0f));
|
||||
_extraBytesPerVolume = 0;
|
||||
_rand = new Random(System.currentTimeMillis());
|
||||
_dontMatter = Boolean.parseBoolean(configs.get("storage.overwrite.provisioning"));
|
||||
String allocationAlgorithm = configs.get("vm.allocation.algorithm");
|
||||
if (allocationAlgorithm != null) {
|
||||
_allocationAlgorithm = allocationAlgorithm;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract List<StoragePool> select(DiskProfile dskCh, VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid, int returnUpTo);
|
||||
|
|
|
|||
|
|
@ -64,6 +64,6 @@ public class RpcServerCallImpl implements RpcServerCall {
|
|||
pdu.setSerializedResult(_rpcProvider.getMessageSerializer().serializeTo(returnObject.getClass(), returnObject));
|
||||
}
|
||||
|
||||
_rpcProvider.sendRpcPdu(_targetAddress, _sourceAddress, _rpcProvider.getMessageSerializer().serializeTo(RpcCallResponsePdu.class, pdu));
|
||||
_rpcProvider.sendRpcPdu(_sourceAddress,_targetAddress,_rpcProvider.getMessageSerializer().serializeTo(RpcCallResponsePdu.class, pdu));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -964,7 +964,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
|
||||
String unameKernelVersion = Script.runSimpleBashScript("uname -r");
|
||||
String[] kernelVersions = unameKernelVersion.split("[\\.\\-]");
|
||||
_kernelVersion = Integer.parseInt(kernelVersions[0]) * 1000 * 1000 + Integer.parseInt(kernelVersions[1]) * 1000 + Integer.parseInt(kernelVersions[2]);
|
||||
_kernelVersion = Integer.parseInt(kernelVersions[0]) * 1000 * 1000 + (long)Integer.parseInt(kernelVersions[1]) * 1000 + Integer.parseInt(kernelVersions[2]);
|
||||
|
||||
getOsVersion();
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -108,8 +108,8 @@ public class Connection {
|
|||
throw new XmlRpcException(-2, e.getMessage());
|
||||
} finally {
|
||||
long endTime = System.currentTimeMillis();
|
||||
float during = (endTime - startTime) / 1000; // in secs
|
||||
s_logger.debug("Ovm call " + method + " finished in " + during + " secs");
|
||||
long during = (endTime - startTime) / 1000; // in secs
|
||||
s_logger.debug("Ovm call " + method + " finished in " + String.valueOf(during) + " secs");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2228,21 +2228,18 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
}
|
||||
|
||||
VolumeObjectTO volInSpec = getVolumeInSpec(vmSpec, volumeTO);
|
||||
|
||||
if (managed) {
|
||||
String datastoreVolumePath = diskChain[0];
|
||||
|
||||
iqnToPath.put(details.get(DiskTO.IQN), datastoreVolumePath);
|
||||
|
||||
vol.setPath(datastoreVolumePath);
|
||||
volumeTO.setPath(datastoreVolumePath);
|
||||
volInSpec.setPath(datastoreVolumePath);
|
||||
if (volInSpec != null) {
|
||||
if (managed) {
|
||||
String datastoreVolumePath = diskChain[0];
|
||||
iqnToPath.put(details.get(DiskTO.IQN), datastoreVolumePath);
|
||||
vol.setPath(datastoreVolumePath);
|
||||
volumeTO.setPath(datastoreVolumePath);
|
||||
volInSpec.setPath(datastoreVolumePath);
|
||||
} else {
|
||||
volInSpec.setPath(file.getFileBaseName());
|
||||
}
|
||||
volInSpec.setChainInfo(_gson.toJson(diskInfo));
|
||||
}
|
||||
else {
|
||||
volInSpec.setPath(file.getFileBaseName());
|
||||
}
|
||||
|
||||
volInSpec.setChainInfo(_gson.toJson(diskInfo));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -562,7 +562,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
Pair<String, String> result = copyVolumeFromSecStorage(hyperHost, srcVolume.getPath(), new DatastoreMO(context, morDatastore), srcStore.getUrl(), cmd.getWait() * 1000);
|
||||
Pair<String, String> result = copyVolumeFromSecStorage(hyperHost, srcVolume.getPath(), new DatastoreMO(context, morDatastore), srcStore.getUrl(), (long)cmd.getWait() * 1000);
|
||||
deleteVolumeDirOnSecondaryStorage(result.first(), srcStore.getUrl());
|
||||
VolumeObjectTO newVolume = new VolumeObjectTO();
|
||||
newVolume.setPath(result.second());
|
||||
|
|
@ -1013,7 +1013,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
|||
}
|
||||
|
||||
NfsTO nfsSvr = (NfsTO)imageStore;
|
||||
Ternary<String, Long, Long> result = createTemplateFromSnapshot(template.getPath(), uniqeName, nfsSvr.getUrl(), snapshot.getPath(), template.getId(), cmd.getWait() * 1000);
|
||||
Ternary<String, Long, Long> result = createTemplateFromSnapshot(template.getPath(), uniqeName, nfsSvr.getUrl(), snapshot.getPath(), template.getId(), (long)cmd.getWait() * 1000);
|
||||
|
||||
TemplateObjectTO newTemplate = new TemplateObjectTO();
|
||||
newTemplate.setPath(result.first());
|
||||
|
|
@ -2183,7 +2183,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
|||
backedUpSnapshotUuid = backedUpSnapshotUuid.replace(".ovf", "");
|
||||
}
|
||||
DatastoreMO primaryDsMo = new DatastoreMO(hyperHost.getContext(), morPrimaryDs);
|
||||
restoreVolumeFromSecStorage(hyperHost, primaryDsMo, newVolumeName, secondaryStorageUrl, backupPath, backedUpSnapshotUuid, cmd.getWait() * 1000);
|
||||
restoreVolumeFromSecStorage(hyperHost, primaryDsMo, newVolumeName, secondaryStorageUrl, backupPath, backedUpSnapshotUuid, (long)cmd.getWait() * 1000);
|
||||
|
||||
VolumeObjectTO newVol = new VolumeObjectTO();
|
||||
newVol.setPath(newVolumeName);
|
||||
|
|
|
|||
|
|
@ -3391,7 +3391,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
try {
|
||||
task = vdi.copyAsync(conn, sr);
|
||||
// poll every 1 seconds , timeout after 2 hours
|
||||
waitForTask(conn, task, 1000, wait * 1000);
|
||||
waitForTask(conn, task, 1000, (long)wait * 1000);
|
||||
checkForSuccess(conn, task);
|
||||
VDI dvdi = Types.toVDI(task, conn);
|
||||
return dvdi;
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat
|
|||
|
||||
// test for enough CPU in the pod
|
||||
enoughCapacity =
|
||||
dataCenterAndPodHasEnoughCapacity(zoneId, podId, (offering.getCpu() * offering.getSpeed()), Capacity.CAPACITY_TYPE_CPU, hostCandiates);
|
||||
dataCenterAndPodHasEnoughCapacity(zoneId, podId, ((long)offering.getCpu() * offering.getSpeed()), Capacity.CAPACITY_TYPE_CPU, hostCandiates);
|
||||
if (!enoughCapacity) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Not enough cpu available in zone/pod to allocate storage for user VM (zone: " + zoneId + ", pod: " + podId + ")");
|
||||
|
|
|
|||
|
|
@ -782,7 +782,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
|
|||
_forceHA = Boolean.parseBoolean(value);
|
||||
|
||||
value = params.get("time.to.sleep");
|
||||
_timeToSleep = NumbersUtil.parseInt(value, 60) * 1000;
|
||||
_timeToSleep = (long)NumbersUtil.parseInt(value, 60) * 1000;
|
||||
|
||||
value = params.get("max.retries");
|
||||
_maxRetries = NumbersUtil.parseInt(value, 5);
|
||||
|
|
|
|||
|
|
@ -577,7 +577,7 @@ public class VmwareHelper {
|
|||
|
||||
ResourceAllocationInfo cpuInfo = new ResourceAllocationInfo();
|
||||
if (limitCpuUse) {
|
||||
cpuInfo.setLimit((long)(cpuSpeedMHz * cpuCount));
|
||||
cpuInfo.setLimit(((long)cpuSpeedMHz * cpuCount));
|
||||
} else {
|
||||
cpuInfo.setLimit(-1L);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue