mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
bug 8659: deleteNetwork is async now
status 8659: resolved fixed
This commit is contained in:
parent
63cff8de26
commit
6424042cac
@ -21,15 +21,19 @@ package com.cloud.api.commands;
|
|||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.ApiConstants;
|
import com.cloud.api.ApiConstants;
|
||||||
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.exception.InvalidParameterValueException;
|
||||||
|
import com.cloud.network.Network;
|
||||||
import com.cloud.user.UserContext;
|
import com.cloud.user.UserContext;
|
||||||
|
|
||||||
@Implementation(description="Deletes a network", responseObject=SuccessResponse.class)
|
@Implementation(description="Deletes a network", responseObject=SuccessResponse.class)
|
||||||
public class DeleteNetworkCmd extends BaseCmd{
|
public class DeleteNetworkCmd extends BaseAsyncCmd{
|
||||||
public static final Logger s_logger = Logger.getLogger(DeleteNetworkOfferingCmd.class.getName());
|
public static final Logger s_logger = Logger.getLogger(DeleteNetworkOfferingCmd.class.getName());
|
||||||
private static final String s_name = "deletenetworkresponse";
|
private static final String s_name = "deletenetworkresponse";
|
||||||
|
|
||||||
@ -70,4 +74,35 @@ public class DeleteNetworkCmd extends BaseCmd{
|
|||||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete network");
|
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete network");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSyncObjType() {
|
||||||
|
return BaseAsyncCmd.networkSyncObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getSyncObjId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_NETWORK_DELETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "Deleting network: " + id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getEntityOwnerId() {
|
||||||
|
Network network = _networkService.getNetwork(id);
|
||||||
|
if (network == null) {
|
||||||
|
throw new InvalidParameterValueException("Networkd id=" + id + " doesn't exist");
|
||||||
|
} else {
|
||||||
|
return _networkService.getNetwork(id).getAccountId();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,23 +53,6 @@ public class RestartNetworkCmd extends BaseAsyncCmd {
|
|||||||
/////////////////// Accessors ///////////////////////
|
/////////////////// Accessors ///////////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
public String getEventDescription() {
|
|
||||||
return "Restarting network: " + getNetworkId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEventType() {
|
|
||||||
return EventTypes.NETWORK_RESTART;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getEntityOwnerId() {
|
|
||||||
Network network = _networkService.getNetwork(id);
|
|
||||||
if (network == null) {
|
|
||||||
throw new InvalidParameterValueException("Networkd id=" + id + " doesn't exist");
|
|
||||||
} else {
|
|
||||||
return _networkService.getNetwork(id).getAccountId();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getNetworkId() {
|
public Long getNetworkId() {
|
||||||
Network network = _networkService.getNetwork(id);
|
Network network = _networkService.getNetwork(id);
|
||||||
if (network == null) {
|
if (network == null) {
|
||||||
@ -105,7 +88,6 @@ public class RestartNetworkCmd extends BaseAsyncCmd {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSyncObjType() {
|
public String getSyncObjType() {
|
||||||
return BaseAsyncCmd.networkSyncObject;
|
return BaseAsyncCmd.networkSyncObject;
|
||||||
@ -115,4 +97,23 @@ public class RestartNetworkCmd extends BaseAsyncCmd {
|
|||||||
public Long getSyncObjId() {
|
public Long getSyncObjId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "Restarting network: " + getNetworkId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_NETWORK_RESTART;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getEntityOwnerId() {
|
||||||
|
Network network = _networkService.getNetwork(id);
|
||||||
|
if (network == null) {
|
||||||
|
throw new InvalidParameterValueException("Networkd id=" + id + " doesn't exist");
|
||||||
|
} else {
|
||||||
|
return _networkService.getNetwork(id).getAccountId();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -179,7 +179,7 @@ public class EventTypes {
|
|||||||
public static final String EVENT_VPN_USER_REMOVE = "VPN.USER.REMOVE";
|
public static final String EVENT_VPN_USER_REMOVE = "VPN.USER.REMOVE";
|
||||||
|
|
||||||
//Network
|
//Network
|
||||||
public static final String NETWORK_RESTART = "NETWORK.RESTART";
|
public static final String EVENT_NETWORK_RESTART = "NETWORK.RESTART";
|
||||||
|
|
||||||
//Custom certificates
|
//Custom certificates
|
||||||
public static final String EVENT_UPLOAD_CUSTOM_CERTIFICATE = "UPLOAD.CUSTOM.CERTIFICATE";
|
public static final String EVENT_UPLOAD_CUSTOM_CERTIFICATE = "UPLOAD.CUSTOM.CERTIFICATE";
|
||||||
|
|||||||
@ -1757,8 +1757,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
return networks;
|
return networks;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override @ActionEvent (eventType=EventTypes.EVENT_NETWORK_DELETE, eventDescription="deleting network", async=true)
|
||||||
@ActionEvent (eventType=EventTypes.EVENT_NETWORK_DELETE, eventDescription="deleting network")
|
|
||||||
public boolean deleteNetwork(long networkId){
|
public boolean deleteNetwork(long networkId){
|
||||||
//Don't allow to delete network via api call when it has vms assigned to it
|
//Don't allow to delete network via api call when it has vms assigned to it
|
||||||
int nicCount = getActiveNicsInNetwork(networkId);
|
int nicCount = getActiveNicsInNetwork(networkId);
|
||||||
@ -2022,7 +2021,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override @ActionEvent (eventType=EventTypes.EVENT_NETWORK_RESTART, eventDescription="restarting network", async=true)
|
||||||
public boolean restartNetwork(RestartNetworkCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
|
public boolean restartNetwork(RestartNetworkCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
|
||||||
// This method restarts all network elements belonging to the network
|
// This method restarts all network elements belonging to the network
|
||||||
Long networkId = cmd.getNetworkId();
|
Long networkId = cmd.getNetworkId();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user