CLOUDSTACK-7045: save started/completed events for createPrivateGateway and createStaticRoute apis

This commit is contained in:
Alena Prokharchyk 2014-07-02 17:21:53 -07:00
parent ce390e907c
commit 324b5d5a57
4 changed files with 27 additions and 13 deletions

View File

@ -206,7 +206,7 @@ public interface VpcService {
* @return
* @throws ResourceUnavailableException
*/
public boolean applyStaticRoutes(long vpcId) throws ResourceUnavailableException;
public boolean applyStaticRoutesForVpc(long vpcId) throws ResourceUnavailableException;
/**
* Deletes static route from the backend and the database
@ -248,4 +248,10 @@ public interface VpcService {
IpAddress associateIPToVpc(long ipId, long vpcId) throws ResourceAllocationException, ResourceUnavailableException, InsufficientAddressCapacityException,
ConcurrentOperationException;
/**
* @param routeId
* @return
*/
public boolean applyStaticRoute(long routeId) throws ResourceUnavailableException;
}

View File

@ -191,7 +191,7 @@ public class CreatePrivateGatewayCmd extends BaseAsyncCreateCmd {
@Override
public String getEventDescription() {
return "creating private gateway";
return "Applying VPC private gateway. Private gateway Id: " + getEntityId();
}
@Override

View File

@ -89,18 +89,17 @@ public class CreateStaticRouteCmd extends BaseAsyncCreateCmd {
@Override
public String getEventDescription() {
return "creating static route";
return "Applying static route. Static route Id: " + getEntityId();
}
@Override
public void execute() throws ResourceUnavailableException {
boolean success = false;
StaticRoute route = _entityMgr.findById(StaticRoute.class, getEntityId());
StaticRoute route = null;
try {
CallContext.current().setEventDetails("Static route Id: " + getEntityId());
success = _vpcService.applyStaticRoutes(route.getVpcId());
// State is different after the route is applied, so get new object here
success = _vpcService.applyStaticRoute(getEntityId());
// State is different after the route is applied, so retrieve the object only here
route = _entityMgr.findById(StaticRoute.class, getEntityId());
StaticRouteResponse routeResponse = new StaticRouteResponse();
if (route != null) {

View File

@ -35,8 +35,6 @@ import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
import org.apache.cloudstack.api.command.user.vpc.ListPrivateGatewaysCmd;
import org.apache.cloudstack.api.command.user.vpc.ListStaticRoutesCmd;
@ -45,6 +43,7 @@ import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationSe
import org.apache.cloudstack.framework.config.ConfigDepot;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
import org.apache.log4j.Logger;
import com.cloud.configuration.Config;
import com.cloud.configuration.ConfigurationManager;
@ -1537,7 +1536,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_PRIVATE_GATEWAY_CREATE, eventDescription = "creating vpc private gateway", create = true)
@ActionEvent(eventType = EventTypes.EVENT_PRIVATE_GATEWAY_CREATE, eventDescription = "creating VPC private gateway", create = true)
public PrivateGateway createVpcPrivateGateway(final long vpcId, Long physicalNetworkId, final String broadcastUri, final String ipAddress, final String gateway,
final String netmask, final long gatewayOwnerId, final Long networkOfferingId, final Boolean isSourceNat, final Long aclId) throws ResourceAllocationException,
ConcurrentOperationException, InsufficientCapacityException {
@ -1653,10 +1652,12 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
throw new IllegalStateException(e);
}
CallContext.current().setEventDetails("Private Gateway Id: " + gatewayVO.getId());
return getVpcPrivateGateway(gatewayVO.getId());
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_PRIVATE_GATEWAY_CREATE, eventDescription = "Applying VPC private gateway", async = true)
public PrivateGateway applyVpcPrivateGateway(long gatewayId, boolean destroyOnFailure) throws ConcurrentOperationException, ResourceUnavailableException {
VpcGatewayVO vo = _vpcGatewayDao.findById(gatewayId);
@ -1679,6 +1680,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
_vpcGatewayDao.update(vo.getId(), vo);
s_logger.debug("Marke gateway " + gateway + " with state " + VpcGateway.State.Ready);
}
CallContext.current().setEventDetails("Private Gateway Id: " + gatewayId);
return getVpcPrivateGateway(gatewayId);
} else {
s_logger.warn("Private gateway " + gateway + " failed to apply on the backend");
@ -1864,7 +1866,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
}
@Override
public boolean applyStaticRoutes(long vpcId) throws ResourceUnavailableException {
public boolean applyStaticRoutesForVpc(long vpcId) throws ResourceUnavailableException {
Account caller = CallContext.current().getCallingAccount();
List<? extends StaticRoute> routes = _staticRouteDao.listByVpcId(vpcId);
return applyStaticRoutes(routes, caller, true);
@ -1944,7 +1946,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
markStaticRouteForRevoke(route, caller);
return applyStaticRoutes(route.getVpcId());
return applyStaticRoutesForVpc(route.getVpcId());
}
@DB
@ -1962,7 +1964,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
}
}
});
return applyStaticRoutes(vpcId);
return applyStaticRoutesForVpc(vpcId);
}
return true;
@ -2394,4 +2396,11 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
public void setVpcElements(List<VpcProvider> vpcElements) {
this.vpcElements = vpcElements;
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_STATIC_ROUTE_CREATE, eventDescription = "Applying static route", async = true)
public boolean applyStaticRoute(long routeId) throws ResourceUnavailableException {
StaticRoute route = _staticRouteDao.findById(routeId);
return applyStaticRoutesForVpc(route.getVpcId());
}
}