mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fixed few coverity reported issues:Aug22 2014
This commit is contained in:
parent
6c0a4f766e
commit
19ffc93e2e
@ -50,7 +50,6 @@ public class VirtualMachineTO {
|
||||
String platformEmulator;
|
||||
String bootArgs;
|
||||
String[] bootupScripts;
|
||||
boolean rebootOnCrash;
|
||||
boolean enableHA;
|
||||
boolean limitCpuUse;
|
||||
boolean enableDynamicallyScaleVm;
|
||||
|
||||
@ -127,8 +127,10 @@ public class ConfigureVirtualRouterElementCmd extends BaseAsyncCmd {
|
||||
VirtualRouterProvider result = _service.get(0).configure(this);
|
||||
if (result != null) {
|
||||
VirtualRouterProviderResponse routerResponse = _responseGenerator.createVirtualRouterProviderResponse(result);
|
||||
routerResponse.setResponseName(getCommandName());
|
||||
this.setResponseObject(routerResponse);
|
||||
if(routerResponse != null) {
|
||||
routerResponse.setResponseName(getCommandName());
|
||||
this.setResponseObject(routerResponse);
|
||||
}
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to configure the virtual router provider");
|
||||
}
|
||||
|
||||
@ -110,8 +110,10 @@ public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
|
||||
VirtualRouterProvider result = _service.get(0).getCreatedElement(getEntityId());
|
||||
if (result != null) {
|
||||
VirtualRouterProviderResponse response = _responseGenerator.createVirtualRouterProviderResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
if(response != null) {
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Virtual Router entity to physical network");
|
||||
}
|
||||
|
||||
@ -80,13 +80,14 @@ public class ListTrafficTypesCmd extends BaseListCmd {
|
||||
Pair<List<? extends PhysicalNetworkTrafficType>, Integer> trafficTypes = _networkService.listTrafficTypes(getPhysicalNetworkId());
|
||||
ListResponse<TrafficTypeResponse> response = new ListResponse<TrafficTypeResponse>();
|
||||
List<TrafficTypeResponse> trafficTypesResponses = new ArrayList<TrafficTypeResponse>();
|
||||
for (PhysicalNetworkTrafficType trafficType : trafficTypes.first()) {
|
||||
TrafficTypeResponse trafficTypeResponse = _responseGenerator.createTrafficTypeResponse(trafficType);
|
||||
trafficTypesResponses.add(trafficTypeResponse);
|
||||
if(trafficTypes != null) {
|
||||
for (PhysicalNetworkTrafficType trafficType : trafficTypes.first()) {
|
||||
TrafficTypeResponse trafficTypeResponse = _responseGenerator.createTrafficTypeResponse(trafficType);
|
||||
trafficTypesResponses.add(trafficTypeResponse);
|
||||
}
|
||||
response.setResponses(trafficTypesResponses, trafficTypes.second());
|
||||
response.setResponseName(getCommandName());
|
||||
}
|
||||
|
||||
response.setResponses(trafficTypesResponses, trafficTypes.second());
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,8 +75,10 @@ public class RegisterCmd extends BaseCmd {
|
||||
public void execute() {
|
||||
String[] keys = _accountService.createApiKeyAndSecretKey(this);
|
||||
RegisterResponse response = new RegisterResponse();
|
||||
response.setApiKey(keys[0]);
|
||||
response.setSecretKey(keys[1]);
|
||||
if (keys != null) {
|
||||
response.setApiKey(keys[0]);
|
||||
response.setSecretKey(keys[1]);
|
||||
}
|
||||
response.setObjectName("userkeys");
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
|
||||
@ -129,7 +129,7 @@ public class CreateVlanIpRangeCmd extends BaseCmd {
|
||||
}
|
||||
|
||||
public Boolean isForVirtualNetwork() {
|
||||
return forVirtualNetwork == null ? true : forVirtualNetwork;
|
||||
return forVirtualNetwork == null ? Boolean.TRUE : forVirtualNetwork;
|
||||
}
|
||||
|
||||
public String getGateway() {
|
||||
|
||||
@ -172,10 +172,6 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
|
||||
}
|
||||
Long zoneId = getZoneId();
|
||||
|
||||
if (zoneId == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId);
|
||||
if (zone.getNetworkType() == NetworkType.Advanced) {
|
||||
List<? extends Network> networks = _networkService.getIsolatedNetworksOwnedByAccountInZone(getZoneId(), _accountService.getAccount(getEntityOwnerId()));
|
||||
|
||||
@ -127,8 +127,10 @@ public class UpdateIPAddrCmd extends BaseAsyncCustomIdCmd {
|
||||
NetworkRuleConflictException {
|
||||
|
||||
IpAddress result = _networkService.updateIP(getId(), getCustomId(), getDisplayIp());
|
||||
IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ResponseView.Restricted, result);
|
||||
ipResponse.setResponseName(getCommandName());
|
||||
setResponseObject(ipResponse);
|
||||
if(result != null) {
|
||||
IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ResponseView.Restricted, result);
|
||||
ipResponse.setResponseName(getCommandName());
|
||||
setResponseObject(ipResponse);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -749,14 +749,15 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
||||
}
|
||||
|
||||
Pair<NicProfile, Integer> vmNicPair = allocateNic(requested, config, isDefaultNic, deviceId, vm);
|
||||
|
||||
NicProfile vmNic = vmNicPair.first();
|
||||
if (vmNic == null) {
|
||||
continue;
|
||||
NicProfile vmNic = null;
|
||||
if(vmNicPair != null) {
|
||||
vmNic = vmNicPair.first();
|
||||
if (vmNic == null) {
|
||||
continue;
|
||||
}
|
||||
deviceId = vmNicPair.second();
|
||||
}
|
||||
|
||||
deviceId = vmNicPair.second();
|
||||
|
||||
int devId = vmNic.getDeviceId();
|
||||
if (devId > deviceIds.length) {
|
||||
throw new IllegalArgumentException("Device id for nic is too large: " + vmNic);
|
||||
|
||||
@ -3174,7 +3174,9 @@ public class NetscalerResource implements ServerResource {
|
||||
scaleUpAction.set_vserver(nsVirtualServerName); // Actions Vserver, the one that is autoscaled, with CS
|
||||
// now both are same. Not exposed in API.
|
||||
scaleUpAction.set_profilename(profileName);
|
||||
scaleUpAction.set_quiettime(scaleUpQuietTime);
|
||||
if(scaleUpQuietTime != null) {
|
||||
scaleUpAction.set_quiettime(scaleUpQuietTime);
|
||||
}
|
||||
String scaleUpParameters =
|
||||
"command=deployVirtualMachine" + "&" + ApiConstants.ZONE_ID + "=" + profileTO.getZoneId() + "&" + ApiConstants.SERVICE_OFFERING_ID + "=" +
|
||||
profileTO.getServiceOfferingId() + "&" + ApiConstants.TEMPLATE_ID + "=" + profileTO.getTemplateId() + "&" + ApiConstants.DISPLAY_NAME + "=" +
|
||||
|
||||
@ -341,11 +341,14 @@ public class ParamProcessWorker implements DispatchWorker {
|
||||
field.set(cmdObj, Short.valueOf(paramObj.toString()));
|
||||
break;
|
||||
case STRING:
|
||||
if ((paramObj != null) && paramObj.toString().length() > annotation.length()) {
|
||||
s_logger.error("Value greater than max allowed length " + annotation.length() + " for param: " + field.getName());
|
||||
throw new InvalidParameterValueException("Value greater than max allowed length " + annotation.length() + " for param: " + field.getName());
|
||||
if ((paramObj != null)) {
|
||||
if (paramObj.toString().length() > annotation.length()) {
|
||||
s_logger.error("Value greater than max allowed length " + annotation.length() + " for param: " + field.getName());
|
||||
throw new InvalidParameterValueException("Value greater than max allowed length " + annotation.length() + " for param: " + field.getName());
|
||||
} else {
|
||||
field.set(cmdObj, paramObj.toString());
|
||||
}
|
||||
}
|
||||
field.set(cmdObj, paramObj.toString());
|
||||
break;
|
||||
case TZDATE:
|
||||
field.set(cmdObj, DateUtil.parseTZDateString(paramObj.toString()));
|
||||
|
||||
@ -1600,7 +1600,9 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
|
||||
NetworkOffering off = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
|
||||
if (off.getElasticLb() && ipVO == null && network.getVpcId() == null) {
|
||||
systemIp = _ipAddrMgr.assignSystemIp(networkId, lbOwner, true, false);
|
||||
ipVO = _ipAddressDao.findById(systemIp.getId());
|
||||
if (systemIp != null) {
|
||||
ipVO = _ipAddressDao.findById(systemIp.getId());
|
||||
}
|
||||
}
|
||||
|
||||
// Validate ip address
|
||||
|
||||
@ -2141,7 +2141,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
||||
}
|
||||
|
||||
if (sendCommand) {
|
||||
if (host.getHypervisorType() == HypervisorType.KVM &&
|
||||
if (host != null && host.getHypervisorType() == HypervisorType.KVM &&
|
||||
volumeToAttachStoragePool.isManaged() &&
|
||||
volumeToAttach.getPath() == null) {
|
||||
volumeToAttach.setPath(volumeToAttach.get_iScsiName());
|
||||
@ -2178,8 +2178,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
||||
try {
|
||||
answer = (AttachAnswer)_agentMgr.send(hostId, cmd);
|
||||
} catch (Exception e) {
|
||||
volService.disconnectVolumeFromHost(volFactory.getVolume(volumeToAttach.getId()), host, dataStore);
|
||||
|
||||
if(host!=null) {
|
||||
volService.disconnectVolumeFromHost(volFactory.getVolume(volumeToAttach.getId()), host, dataStore);
|
||||
}
|
||||
throw new CloudRuntimeException(errorMsg + " due to: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
@ -2216,9 +2217,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
||||
errorMsg += "; " + details;
|
||||
}
|
||||
}
|
||||
|
||||
volService.disconnectVolumeFromHost(volFactory.getVolume(volumeToAttach.getId()), host, dataStore);
|
||||
|
||||
if(host!= null) {
|
||||
volService.disconnectVolumeFromHost(volFactory.getVolume(volumeToAttach.getId()), host, dataStore);
|
||||
}
|
||||
throw new CloudRuntimeException(errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,21 +182,23 @@ public class DownloadMonitorImpl extends ManagerBase implements DownloadMonitor
|
||||
|
||||
@Override
|
||||
public void downloadTemplateToStorage(DataObject template, AsyncCompletionCallback<DownloadAnswer> callback) {
|
||||
long templateId = template.getId();
|
||||
DataStore store = template.getDataStore();
|
||||
if (isTemplateUpdateable(templateId, store.getId())) {
|
||||
if (template != null && template.getUri() != null) {
|
||||
initiateTemplateDownload(template, callback);
|
||||
if(template != null) {
|
||||
long templateId = template.getId();
|
||||
DataStore store = template.getDataStore();
|
||||
if (isTemplateUpdateable(templateId, store.getId())) {
|
||||
if (template.getUri() != null) {
|
||||
initiateTemplateDownload(template, callback);
|
||||
} else {
|
||||
s_logger.info("Template url is null, cannot download");
|
||||
DownloadAnswer ans = new DownloadAnswer("Template url is null", Status.UNKNOWN);
|
||||
callback.complete(ans);
|
||||
}
|
||||
} else {
|
||||
s_logger.info("Template url is null, cannot download");
|
||||
DownloadAnswer ans = new DownloadAnswer("Template url is null", Status.UNKNOWN);
|
||||
s_logger.info("Template download is already in progress or already downloaded");
|
||||
DownloadAnswer ans =
|
||||
new DownloadAnswer("Template download is already in progress or already downloaded", Status.UNKNOWN);
|
||||
callback.complete(ans);
|
||||
}
|
||||
} else {
|
||||
s_logger.info("Template download is already in progress or already downloaded");
|
||||
DownloadAnswer ans =
|
||||
new DownloadAnswer("Template download is already in progress or already downloaded", Status.UNKNOWN);
|
||||
callback.complete(ans);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user