mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	Fixed Coverity Issues
This commit is contained in:
		
							parent
							
								
									80846ba98a
								
							
						
					
					
						commit
						1aef5cba66
					
				| @ -222,9 +222,6 @@ public class TrafficSentinelResource implements ServerResource { | ||||
|                         String publicIp = st.nextToken(); | ||||
|                         Long bytesSent = new Long(st.nextToken()); | ||||
|                         Long bytesRcvd = new Long(st.nextToken()); | ||||
|                         if (bytesSent == null || bytesRcvd == null) { | ||||
|                             s_logger.debug("Incorrect bytes for IP: " + publicIp); | ||||
|                         } | ||||
|                         long[] bytesSentAndReceived = new long[2]; | ||||
|                         bytesSentAndReceived[0] = bytesSent; | ||||
|                         bytesSentAndReceived[1] = bytesRcvd; | ||||
|  | ||||
| @ -2675,12 +2675,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac | ||||
|             s_logger.debug("Not processing listener " + this + " as connect happens on rebalance process"); | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         if (forRebalance) { | ||||
|             s_logger.debug("Not processing listener " + this + " as connect happens on rebalance process"); | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         Long clusterId = agent.getClusterId(); | ||||
|         long agentId = agent.getId(); | ||||
| 
 | ||||
|  | ||||
| @ -404,14 +404,14 @@ public class StorageSystemSnapshotStrategy extends SnapshotStrategyBase { | ||||
|         DataStore dataStore = _dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary); | ||||
| 
 | ||||
|         Map<String, String> mapCapabilities = dataStore.getDriver().getCapabilities(); | ||||
| 
 | ||||
|         if(mapCapabilities != null) { | ||||
|             String value = mapCapabilities.get(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString()); | ||||
|             Boolean supportsStorageSystemSnapshots = new Boolean(value); | ||||
| 
 | ||||
|             if (supportsStorageSystemSnapshots) { | ||||
|                 return StrategyPriority.HIGHEST; | ||||
|             } | ||||
| 
 | ||||
|         } | ||||
|         return StrategyPriority.CANT_HANDLE; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1082,7 +1082,9 @@ public class KVMStorageProcessor implements StorageProcessor { | ||||
|                                                  volume.getProvisioningType(), disksize); | ||||
| 
 | ||||
|             VolumeObjectTO newVol = new VolumeObjectTO(); | ||||
|             if(vol != null) { | ||||
|                 newVol.setPath(vol.getName()); | ||||
|             } | ||||
|             newVol.setSize(volume.getSize()); | ||||
|             newVol.setFormat(ImageFormat.valueOf(format.toString().toUpperCase())); | ||||
| 
 | ||||
|  | ||||
| @ -915,6 +915,9 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { | ||||
|             try { | ||||
|                 String newUuid = name; | ||||
|                 disk = destPool.createPhysicalDisk(newUuid, format, provisioningType, template.getVirtualSize()); | ||||
|                 if (disk == null) { | ||||
|                     throw new CloudRuntimeException("Failed to create disk from template " + template.getName()); | ||||
|                 } | ||||
|                 if (template.getFormat() == PhysicalDiskFormat.TAR) { | ||||
|                     Script.runSimpleBashScript("tar -x -f " + template.getPath() + " -C " + disk.getPath(), timeout); // TO BE FIXED to aware provisioningType | ||||
|                 } else if (template.getFormat() == PhysicalDiskFormat.DIR) { | ||||
| @ -960,9 +963,6 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         if (disk == null) { | ||||
|             throw new CloudRuntimeException("Failed to create disk from template " + template.getName()); | ||||
|         } | ||||
| 
 | ||||
|         return disk; | ||||
|     } | ||||
|  | ||||
| @ -100,6 +100,9 @@ public class ManagedNfsStorageAdaptor implements StorageAdaptor { | ||||
|         LibvirtStoragePoolDef spd = null; | ||||
|         try { | ||||
|             conn = LibvirtConnection.getConnection(); | ||||
|             if (conn == null) { | ||||
|                 throw new CloudRuntimeException("Failed to create Libvrt Connection"); | ||||
|             } | ||||
| 
 | ||||
|             targetPath = "/mnt" + volumeUuid; | ||||
|             spd = new LibvirtStoragePoolDef(poolType.NETFS, volumeUuid, details.get(DiskTO.UUID), pool.getSourceHost(), details.get(DiskTO.MOUNT_POINT), targetPath); | ||||
| @ -140,7 +143,7 @@ public class ManagedNfsStorageAdaptor implements StorageAdaptor { | ||||
|                 if (result == null) { | ||||
|                     s_logger.error("Succeeded in unmounting " + targetPath); | ||||
|                     try { | ||||
|                         sp = conn.storagePoolCreateXML(spd.toString(), 0); | ||||
|                         conn.storagePoolCreateXML(spd.toString(), 0); | ||||
|                         s_logger.error("Succeeded in redefining storage"); | ||||
|                         return true; | ||||
|                     } catch (LibvirtException l) { | ||||
| @ -176,9 +179,6 @@ public class ManagedNfsStorageAdaptor implements StorageAdaptor { | ||||
|         } | ||||
| 
 | ||||
|         LibvirtStorageVolumeDef.volFormat libvirtformat = null; | ||||
|         String volPath = null; | ||||
|         String volName = null; | ||||
|         long volAllocation = 0; | ||||
|         long volCapacity = 0; | ||||
|         // check whether the volume is present on the given pool | ||||
|         StorageVol vol = getVolume(virtPool, volumeUuid); | ||||
| @ -194,13 +194,8 @@ public class ManagedNfsStorageAdaptor implements StorageAdaptor { | ||||
|                 s_logger.debug(volDef.toString()); | ||||
| 
 | ||||
|                 vol = virtPool.storageVolCreateXML(volDef.toString(), 0); | ||||
|                 volPath = vol.getPath(); | ||||
|                 volName = vol.getName(); | ||||
|                 volAllocation = vol.getInfo().allocation; | ||||
|                 volCapacity = vol.getInfo().capacity; | ||||
| 
 | ||||
|             } | ||||
| 
 | ||||
|             KVMPhysicalDisk disk = new KVMPhysicalDisk(vol.getPath(), volumeUuid, pool); | ||||
|             disk.setFormat(PhysicalDiskFormat.QCOW2); | ||||
|             disk.setSize(vol.getInfo().allocation); | ||||
|  | ||||
| @ -294,7 +294,7 @@ public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl impleme | ||||
|                     CiscoNexusVSMDeviceVO vsm = null; | ||||
|                     if (_vsmDao.getVSMbyIpaddress(vsmIp) == null) { | ||||
|                         vsm = new CiscoNexusVSMDeviceVO(vsmIp, vsmUser, vsmPassword); | ||||
|                         vsm = _vsmDao.persist(vsm); | ||||
|                         _vsmDao.persist(vsm); | ||||
|                     } | ||||
|                     // Create a mapping between the cluster and the vsm. | ||||
|                     vsm = _vsmDao.getVSMbyIpaddress(vsmIp); | ||||
|  | ||||
| @ -309,17 +309,21 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager, | ||||
|             throw new InvalidParameterValueException("Volume is not in ready state"); | ||||
|         } | ||||
| 
 | ||||
|         boolean backedUp = false; | ||||
| 
 | ||||
|         // does the caller have the authority to act on this volume | ||||
|         _accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, volume); | ||||
| 
 | ||||
|         SnapshotInfo snapshot = snapshotFactory.getSnapshot(snapshotId, DataStoreRole.Primary); | ||||
| 
 | ||||
|         if(snapshot != null) | ||||
|         { | ||||
|             s_logger.debug("Failed to create snapshot"); | ||||
|             throw new CloudRuntimeException("Failed to create snapshot"); | ||||
|         } | ||||
|         try { | ||||
|             postCreateSnapshot(volumeId, snapshot.getId(), policyId); | ||||
|             //Check if the snapshot was removed while backingUp. If yes, do not log snapshot create usage event | ||||
|             SnapshotVO freshSnapshot = _snapshotDao.findById(snapshot.getId()); | ||||
|             if ((freshSnapshot != null) && backedUp) { | ||||
|             if (freshSnapshot != null)  { | ||||
|                 UsageEventUtils.publishUsageEvent(EventTypes.EVENT_SNAPSHOT_CREATE, snapshot.getAccountId(), snapshot.getDataCenterId(), snapshotId, snapshot.getName(), | ||||
|                     null, null, volume.getSize(), snapshot.getClass().getName(), snapshot.getUuid()); | ||||
|             } | ||||
|  | ||||
| @ -156,7 +156,6 @@ import com.cloud.user.AccountManager; | ||||
| import com.cloud.user.AccountService; | ||||
| import com.cloud.user.AccountVO; | ||||
| import com.cloud.user.ResourceLimitService; | ||||
| import com.cloud.user.User; | ||||
| import com.cloud.user.dao.AccountDao; | ||||
| import com.cloud.uservm.UserVm; | ||||
| import com.cloud.utils.DateUtil; | ||||
| @ -1350,10 +1349,6 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, | ||||
|     @DB | ||||
|     @ActionEvent(eventType = EventTypes.EVENT_TEMPLATE_CREATE, eventDescription = "creating template", async = true) | ||||
|     public VirtualMachineTemplate createPrivateTemplate(CreateTemplateCmd command) throws CloudRuntimeException { | ||||
|         Long userId = CallContext.current().getCallingUserId(); | ||||
|         if (userId == null) { | ||||
|             userId = User.UID_SYSTEM; | ||||
|         } | ||||
|         final long templateId = command.getEntityId(); | ||||
|         Long volumeId = command.getVolumeId(); | ||||
|         Long snapshotId = command.getSnapshotId(); | ||||
|  | ||||
| @ -748,12 +748,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir | ||||
|         } catch (CloudException e) { | ||||
|             throw new CloudRuntimeException("Unable to contact the agent to stop the virtual machine " + vm, e); | ||||
|         } | ||||
| 
 | ||||
|         if (status) { | ||||
|         return status; | ||||
|         } else { | ||||
|             return status; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private UserVm rebootVirtualMachine(long userId, long vmId) throws InsufficientCapacityException, ResourceUnavailableException { | ||||
| @ -1328,8 +1323,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir | ||||
|             if (vmSnapshots.size() > 0) { | ||||
|                 throw new InvalidParameterValueException("Unable to scale VM, please remove VM snapshots before scaling VM"); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|             if (vmInstance.getState().equals(State.Stopped)) { | ||||
|                 upgradeStoppedVirtualMachine(vmId, newServiceOfferingId, customParameters); | ||||
|                 return true; | ||||
| @ -1337,6 +1330,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir | ||||
|             if (vmInstance.getState().equals(State.Running)) { | ||||
|                 return upgradeRunningVirtualMachine(vmId, newServiceOfferingId, customParameters); | ||||
|             } | ||||
|         } | ||||
|     return false; | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -237,11 +237,6 @@ public class RegionsApiUtil { | ||||
| 
 | ||||
|         String apiKey = ""; | ||||
|         String secretKey = ""; | ||||
| 
 | ||||
|         if (apiKey == null || secretKey == null) { | ||||
|             return region.getEndPoint() + "?" + apiParams; | ||||
|         } | ||||
| 
 | ||||
|         String encodedApiKey; | ||||
|         try { | ||||
|             encodedApiKey = URLEncoder.encode(apiKey, "UTF-8"); | ||||
|  | ||||
| @ -988,11 +988,12 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar | ||||
|             if (host != null) { | ||||
|                 s_logger.debug("Removing host entry for ssvm id=" + vmId); | ||||
|                 _hostDao.remove(host.getId()); | ||||
|             } | ||||
|                 //Expire the download urls in the entire zone for templates and volumes. | ||||
|                 _tmplStoreDao.expireDnldUrlsForZone(host.getDataCenterId()); | ||||
|                 _volumeStoreDao.expireDnldUrlsForZone(host.getDataCenterId()); | ||||
|                 return true; | ||||
|             } | ||||
|             return false; | ||||
|         } catch (ResourceUnavailableException e) { | ||||
|             s_logger.warn("Unable to expunge " + ssvm, e); | ||||
|             return false; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user