Repository: cloudstack Updated Branches: refs/heads/master ce390e907 -> 324b5d5a5
CLOUDSTACK-7045: save started/completed events for createPrivateGateway and createStaticRoute apis Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/324b5d5a Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/324b5d5a Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/324b5d5a Branch: refs/heads/master Commit: 324b5d5a577f7b34afe9c9fc0ad7e6b08b01a543 Parents: ce390e9 Author: Alena Prokharchyk <[email protected]> Authored: Wed Jul 2 17:21:53 2014 -0700 Committer: Alena Prokharchyk <[email protected]> Committed: Wed Jul 2 17:23:35 2014 -0700 ---------------------------------------------------------------------- api/src/com/cloud/network/vpc/VpcService.java | 8 +++++++- .../admin/vpc/CreatePrivateGatewayCmd.java | 2 +- .../command/user/vpc/CreateStaticRouteCmd.java | 9 ++++----- .../com/cloud/network/vpc/VpcManagerImpl.java | 21 ++++++++++++++------ 4 files changed, 27 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/324b5d5a/api/src/com/cloud/network/vpc/VpcService.java ---------------------------------------------------------------------- diff --git a/api/src/com/cloud/network/vpc/VpcService.java b/api/src/com/cloud/network/vpc/VpcService.java index d1166df..dd9cabc 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; + } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/324b5d5a/api/src/org/apache/cloudstack/api/command/admin/vpc/CreatePrivateGatewayCmd.java ---------------------------------------------------------------------- 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 01db44e..d2a7ffb 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 http://git-wip-us.apache.org/repos/asf/cloudstack/blob/324b5d5a/api/src/org/apache/cloudstack/api/command/user/vpc/CreateStaticRouteCmd.java ---------------------------------------------------------------------- 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 e2f2029..622143f 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) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/324b5d5a/server/src/com/cloud/network/vpc/VpcManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java index a1029ee..c7237c1 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<? 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()); + } }
