diff --git a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java index aa904b36114e..4447d4b94664 100644 --- a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java +++ b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java @@ -2882,8 +2882,9 @@ public boolean destroyNetwork(final long networkId, final ReservationContext con for (final UserVmVO vm : userVms) { if (!(vm.getState() == VirtualMachine.State.Expunging && vm.getRemoved() != null)) { - s_logger.warn("Can't delete the network, not all user vms are expunged. Vm " + vm + " is in " + vm.getState() + " state"); - return false; + final String message = "Can't delete the network, not all user vms are expunged. Vm " + vm + " is in " + vm.getState() + " state"; + s_logger.warn(message); + throw new InvalidParameterValueException(message); } } @@ -2901,8 +2902,9 @@ public boolean destroyNetwork(final long networkId, final ReservationContext con if (zone.getNetworkType() == NetworkType.Basic) { final List systemVms = _vmDao.listNonRemovedVmsByTypeAndNetwork(network.getId(), Type.ConsoleProxy, Type.SecondaryStorageVm); if (systemVms != null && !systemVms.isEmpty()) { - s_logger.warn("Can't delete the network, not all consoleProxy/secondaryStorage vms are expunged"); - return false; + final String message = "Can't delete the network, not all consoleProxy/secondaryStorage vms are expunged"; + s_logger.warn(message); + throw new InvalidParameterValueException(message); } } @@ -2912,14 +2914,16 @@ public boolean destroyNetwork(final long networkId, final ReservationContext con // get updated state for the network network = _networksDao.findById(networkId); if (network.getState() != Network.State.Allocated && network.getState() != Network.State.Setup && !forced) { - s_logger.debug("Network is not not in the correct state to be destroyed: " + network.getState()); - return false; + final String message = "Network is not in the correct state to be destroyed: " + network.getState(); + s_logger.debug(message); + throw new InvalidParameterValueException(message); } boolean success = true; if (!cleanupNetworkResources(networkId, callerAccount, context.getCaller().getId())) { - s_logger.warn("Unable to delete network id=" + networkId + ": failed to cleanup network resources"); - return false; + final String message = "Unable to delete network id=" + networkId + ": failed to cleanup network resources"; + s_logger.warn(message); + throw new InvalidParameterValueException(message); } // get providers to destroy @@ -2935,12 +2939,6 @@ public boolean destroyNetwork(final long networkId, final ReservationContext con success = false; s_logger.warn("Unable to complete destroy of the network: failed to destroy network element " + element.getName()); } - } catch (final ResourceUnavailableException e) { - s_logger.warn("Unable to complete destroy of the network due to element: " + element.getName(), e); - success = false; - } catch (final ConcurrentOperationException e) { - s_logger.warn("Unable to complete destroy of the network due to element: " + element.getName(), e); - success = false; } catch (final Exception e) { s_logger.warn("Unable to complete destroy of the network due to element: " + element.getName(), e); success = false;