Skip to content

Commit 16d333f

Browse files
committed
Fix coverity issue 606007, 606008
1 parent 044a207 commit 16d333f

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/agent/OpenDaylightControllerResourceManagerImpl.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ public OpenDaylightControllerVO addController(AddOpenDaylightControllerCmd cmd)
9292

9393
final String deviceName = NetworkDevice.OpenDaylightController.getName();
9494
NetworkDevice networkDevice = NetworkDevice.getNetworkDevice(deviceName);
95+
if (networkDevice == null) {
96+
throw new CloudRuntimeException("No network device found for name " + deviceName);
97+
}
9598
final Long physicalNetworkId = cmd.getPhysicalNetworkId();
9699
PhysicalNetworkVO physicalNetwork = physicalNetworkDao.findById(physicalNetworkId);
97100
if (physicalNetwork == null) {
@@ -156,11 +159,13 @@ public void deleteController(DeleteOpenDaylightControllerCmd cmd) throws Invalid
156159
// Lets see if there are networks that use us
157160
List<NetworkVO> networkList = networkDao.listByPhysicalNetwork(physicalNetworkId);
158161

159-
// Networks with broadcast type lswitch are ours
160-
for (NetworkVO network : networkList) {
161-
if (network.getBroadcastDomainType() == Networks.BroadcastDomainType.OpenDaylight) {
162-
if ((network.getState() != Network.State.Shutdown) && (network.getState() != Network.State.Destroy)) {
163-
throw new CloudRuntimeException("This Controller can not be deleted as there are one or more logical networks provisioned by cloudstack.");
162+
if (networkList != null) {
163+
// Networks with broadcast type lswitch are ours
164+
for (NetworkVO network : networkList) {
165+
if (network.getBroadcastDomainType() == Networks.BroadcastDomainType.OpenDaylight) {
166+
if ((network.getState() != Network.State.Shutdown) && (network.getState() != Network.State.Destroy)) {
167+
throw new CloudRuntimeException("This Controller can not be deleted as there are one or more logical networks provisioned by cloudstack.");
168+
}
164169
}
165170
}
166171
}

0 commit comments

Comments
 (0)