diff --git a/api/src/com/cloud/network/vpc/VpcService.java b/api/src/com/cloud/network/vpc/VpcService.java index d1166df4065..dd9cabc39eb 100644 --- a/api/src/com/cloud/network/vpc/VpcService.java +++ b/api/src/com/cloud/network/vpc/VpcService.java @@ -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; + } diff --git a/api/src/org/apache/cloudstack/api/command/admin/vpc/CreatePrivateGatewayCmd.java b/api/src/org/apache/cloudstack/api/command/admin/vpc/CreatePrivateGatewayCmd.java index 01db44e25df..d2a7ffb397a 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/vpc/CreatePrivateGatewayCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/vpc/CreatePrivateGatewayCmd.java @@ -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 diff --git a/api/src/org/apache/cloudstack/api/command/user/vpc/CreateStaticRouteCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpc/CreateStaticRouteCmd.java index e2f2029ce0a..622143fa38d 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpc/CreateStaticRouteCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpc/CreateStaticRouteCmd.java @@ -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) { diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java index a1029eed155..c7237c1541c 100644 --- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java +++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java @@ -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 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 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()); + } }