/** * Invoked when a network deletion is requested to indicate if the specified network can be * deleted. * * @param network An instance of the Neutron Network object to be deleted. * @return A HTTP status code to the deletion request. */ @Override public int canDeleteNetwork(NeutronNetwork network) { apiConnector = Activator.apiConnector; VirtualNetwork virtualNetwork = null; try { virtualNetwork = (VirtualNetwork) apiConnector.findById(VirtualNetwork.class, network.getNetworkUUID()); if (virtualNetwork != null) { if (virtualNetwork.getVirtualMachineInterfaceBackRefs() != null) { LOGGER.info( "Network with UUID : " + network.getNetworkUUID() + " cannot be deleted as it has port(s) associated with it...."); return HttpURLConnection.HTTP_FORBIDDEN; } else { apiConnector.delete(virtualNetwork); LOGGER.info( "Network with UUID : " + network.getNetworkUUID() + " has been deleted successfully...."); return HttpURLConnection.HTTP_OK; } } else { LOGGER.info("No Network exists with UUID : " + network.getNetworkUUID()); return HttpURLConnection.HTTP_BAD_REQUEST; } } catch (Exception e) { LOGGER.error("Exception : " + e); return HttpURLConnection.HTTP_INTERNAL_ERROR; } }