Fix coverity issue 606007, 606008

This commit is contained in:
Hugo Trippaers 2014-01-13 11:58:51 +01:00
parent 044a2078a1
commit 16d333f06d

View File

@ -92,6 +92,9 @@ public class OpenDaylightControllerResourceManagerImpl implements OpenDaylightCo
final String deviceName = NetworkDevice.OpenDaylightController.getName(); final String deviceName = NetworkDevice.OpenDaylightController.getName();
NetworkDevice networkDevice = NetworkDevice.getNetworkDevice(deviceName); NetworkDevice networkDevice = NetworkDevice.getNetworkDevice(deviceName);
if (networkDevice == null) {
throw new CloudRuntimeException("No network device found for name " + deviceName);
}
final Long physicalNetworkId = cmd.getPhysicalNetworkId(); final Long physicalNetworkId = cmd.getPhysicalNetworkId();
PhysicalNetworkVO physicalNetwork = physicalNetworkDao.findById(physicalNetworkId); PhysicalNetworkVO physicalNetwork = physicalNetworkDao.findById(physicalNetworkId);
if (physicalNetwork == null) { if (physicalNetwork == null) {
@ -156,11 +159,13 @@ public class OpenDaylightControllerResourceManagerImpl implements OpenDaylightCo
// Lets see if there are networks that use us // Lets see if there are networks that use us
List<NetworkVO> networkList = networkDao.listByPhysicalNetwork(physicalNetworkId); List<NetworkVO> networkList = networkDao.listByPhysicalNetwork(physicalNetworkId);
// Networks with broadcast type lswitch are ours if (networkList != null) {
for (NetworkVO network : networkList) { // Networks with broadcast type lswitch are ours
if (network.getBroadcastDomainType() == Networks.BroadcastDomainType.OpenDaylight) { for (NetworkVO network : networkList) {
if ((network.getState() != Network.State.Shutdown) && (network.getState() != Network.State.Destroy)) { if (network.getBroadcastDomainType() == Networks.BroadcastDomainType.OpenDaylight) {
throw new CloudRuntimeException("This Controller can not be deleted as there are one or more logical networks provisioned by cloudstack."); if ((network.getState() != Network.State.Shutdown) && (network.getState() != Network.State.Destroy)) {
throw new CloudRuntimeException("This Controller can not be deleted as there are one or more logical networks provisioned by cloudstack.");
}
} }
} }
} }