mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 7705: deletePortForwardingRule is Async now
status 7705: resolved fixed Couple of other fixes: * don't allow to send ipAssoc command when domR is in Starting/Stopping states as the command not async so it might be sent in parallel with domR stop/start and fail on the backend. * DeleteIpForwardingRule api: set ownerId to rule owner id instead of hardcoding it to 1(System)
This commit is contained in:
parent
34cec61ff7
commit
dceab9f18a
@ -21,6 +21,7 @@ public class ApiConstants {
|
||||
public static final String ACCOUNT = "account";
|
||||
public static final String ACCOUNTS = "accounts";
|
||||
public static final String ACCOUNT_TYPE = "accounttype";
|
||||
public static final String ACCOUNT_ID = "accountid";
|
||||
public static final String ALGORITHM = "algorithm";
|
||||
public static final String ALLOCATED_ONLY = "allocatedonly";
|
||||
public static final String API_KEY = "apikey";
|
||||
|
||||
@ -29,7 +29,6 @@ import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.SuccessResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.network.rules.PortForwardingRule;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@Implementation(description="Deletes an ip forwarding rule", responseObject=SuccessResponse.class)
|
||||
public class DeleteIpForwardingRuleCmd extends BaseAsyncCmd {
|
||||
@ -44,6 +43,10 @@ public class DeleteIpForwardingRuleCmd extends BaseAsyncCmd {
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the id of the forwarding rule")
|
||||
private Long id;
|
||||
|
||||
|
||||
// unexposed parameter needed for events logging
|
||||
@Parameter(name=ApiConstants.ACCOUNT_ID, type=CommandType.LONG, expose=false)
|
||||
private Long ownerId;
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@ -74,7 +77,10 @@ public class DeleteIpForwardingRuleCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||
if (ownerId == null) {
|
||||
ownerId = _entityMgr.findById(PortForwardingRule.class, id).getAccountId();
|
||||
}
|
||||
return ownerId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -20,16 +20,18 @@ package com.cloud.api.commands;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.SuccessResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.rules.PortForwardingRule;
|
||||
|
||||
@Implementation(description="Deletes a port forwarding rule", responseObject=SuccessResponse.class)
|
||||
public class DeletePortForwardingRuleCmd extends BaseCmd {
|
||||
public class DeletePortForwardingRuleCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(DeletePortForwardingRuleCmd.class.getName());
|
||||
private static final String s_name = "deleteportforwardingruleresponse";
|
||||
|
||||
@ -40,7 +42,9 @@ public class DeletePortForwardingRuleCmd extends BaseCmd {
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the port forwarding rule")
|
||||
private Long id;
|
||||
|
||||
|
||||
// unexposed parameter needed for events logging
|
||||
@Parameter(name=ApiConstants.ACCOUNT_ID, type=CommandType.LONG, expose=false)
|
||||
private Long ownerId;
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@ -52,12 +56,29 @@ public class DeletePortForwardingRuleCmd extends BaseCmd {
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_NET_RULE_DELETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return ("Deleting port forwarding rule for id=" + id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
if (ownerId == null) {
|
||||
ownerId = _entityMgr.findById(PortForwardingRule.class, id).getAccountId();
|
||||
}
|
||||
return ownerId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException {
|
||||
PortForwardingRule result = _rulesService.revokePortForwardingRule(id, true);
|
||||
|
||||
@ -50,13 +50,10 @@ import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.DataCenterIpAddressDao;
|
||||
import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.StorageManager;
|
||||
@ -70,11 +67,6 @@ import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.vm.ConsoleProxyVO;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.SecondaryStorageVmVO;
|
||||
import com.cloud.vm.State;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.cloud.vm.dao.ConsoleProxyDao;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.SecondaryStorageVmDao;
|
||||
|
||||
@ -84,7 +84,6 @@ import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.event.Event;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventUtils;
|
||||
import com.cloud.event.EventVO;
|
||||
@ -108,14 +107,14 @@ import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.IsolationType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
import com.cloud.network.RemoteAccessVpnVO;
|
||||
import com.cloud.network.SshKeysDistriMonitor;
|
||||
import com.cloud.network.VirtualNetworkApplianceService;
|
||||
import com.cloud.network.VpnUserVO;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.IsolationType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.network.dao.FirewallRulesDao;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
@ -1902,13 +1901,13 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
throw new ResourceUnavailableException("Unable to assign ip addresses", DataCenter.class, network.getDataCenterId());
|
||||
}
|
||||
|
||||
if (router.getState() == State.Running || router.getState() == State.Starting) {
|
||||
if (router.getState() == State.Running) {
|
||||
Commands cmds = new Commands(OnError.Continue);
|
||||
//Have to resend all already associated ip addresses
|
||||
cmds = getAssociateIPCommands(router, ipAddress, cmds, 0);
|
||||
|
||||
return sendCommandsToRouter(router, cmds);
|
||||
} else if (router.getState() == State.Stopped || router.getState() == State.Stopping) {
|
||||
} else if (router.getState() == State.Stopped) {
|
||||
return true;
|
||||
} else {
|
||||
s_logger.warn("Unable to associate ip addresses, virtual router is not in the right state " + router.getState());
|
||||
|
||||
@ -27,8 +27,6 @@ import javax.naming.ConfigurationException;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.commands.ListPortForwardingRulesCmd;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventUtils;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
@ -147,7 +145,6 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
IPAddressVO ipAddress = _ipAddressDao.findById(ipAddr);
|
||||
|
||||
Ip dstIp = rule.getDestinationIpAddress();
|
||||
Long instanceId = null;
|
||||
long networkId;
|
||||
UserVmVO vm = null;
|
||||
Network network = null;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user