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