@Override public void execute() { try { boolean result = _vpcService.deleteVpc(getId()); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete VPC"); } } catch (ResourceUnavailableException ex) { s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage()); } catch (ConcurrentOperationException ex) { s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); } }
@Override public Long getSyncObjId() { VpcGateway gateway = _vpcService.getVpcPrivateGateway(getId()); if (gateway == null) { throw new InvalidParameterValueException("Invalid private gateway id"); } return gateway.getVpcId(); }
@Override public void startVpc(Vpc vpc) { if (vpc.getState() != Vpc.State.Enabled) { try { _vpcService.startVpc(vpc.getId(), true); } catch (ResourceUnavailableException | InsufficientCapacityException e) { s_logger.error("Vpc can not be started. Aborting migration process"); throw new CloudRuntimeException("Vpc can not be started.", e); } } }
@Override public void execute() throws ResourceUnavailableException { boolean success = false; StaticRoute route = null; try { CallContext.current().setEventDetails("Static route Id: " + getEntityId()); 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) { routeResponse = _responseGenerator.createStaticRouteResponse(route); setResponseObject(routeResponse); } routeResponse.setResponseName(getCommandName()); } finally { if (!success || route == null) { _vpcService.revokeStaticRoute(getEntityId()); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create static route"); } } }
@Override public void execute() throws ResourceUnavailableException, ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException { CallContext.current().setEventDetails("IP ID: " + getEntityId()); IpAddress result = null; if (getVpcId() != null) { result = _vpcService.associateIPToVpc(getEntityId(), getVpcId()); } else if (getNetworkId() != null) { result = _networkService.associateIPToNetwork(getEntityId(), getNetworkId()); } if (result != null) { IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ResponseView.Restricted, result); ipResponse.setResponseName(getCommandName()); setResponseObject(ipResponse); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to assign IP address"); } }
@Override public void create() throws ResourceAllocationException { Vpc vpc = _vpcService.createVpc(getZoneId(), getVpcOffering(), getEntityOwnerId(), getVpcName(), getDisplayText(), getCidr(), getNetworkDomain(), getDisplayVpc()); if (vpc != null) { setEntityId(vpc.getId()); setEntityUuid(vpc.getUuid()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a VPC"); } }
@Override public void execute() throws ResourceUnavailableException, ConcurrentOperationException { CallContext.current().setEventDetails("Network ACL Id: " + id); boolean result = _vpcService.deleteVpcPrivateGateway(id); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete private gateway"); } }
@Override public void create() throws ResourceAllocationException { try { StaticRoute result = _vpcService.createStaticRoute(getGatewayId(), getCidr()); setEntityId(result.getId()); setEntityUuid(result.getUuid()); } catch (NetworkRuleConflictException ex) { s_logger.info("Network rule conflict: " + ex.getMessage()); s_logger.trace("Network rule conflict: ", ex); throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, ex.getMessage()); } }
@Override public void execute() throws InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException, ResourceUnavailableException { PrivateGateway result = _vpcService.applyVpcPrivateGateway(getEntityId(), true); if (result != null) { PrivateGatewayResponse response = _responseGenerator.createPrivateGatewayResponse(result); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create private gateway"); } }
@Override public void create() throws ResourceAllocationException { PrivateGateway result = null; try { result = _vpcService.createVpcPrivateGateway(getVpcId(), getPhysicalNetworkId(), getBroadcastUri(), getStartIp(), getGateway(), getNetmask(), getEntityOwnerId(), getNetworkOfferingId(), getIsSourceNat(), getAclId()); } catch (InsufficientCapacityException ex) { s_logger.info(ex); s_logger.trace(ex); throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage()); } catch (ConcurrentOperationException ex) { s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); } if (result != null) { setEntityId(result.getId()); setEntityUuid(result.getUuid()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create private gateway"); } }
@Override public void execute() throws ResourceUnavailableException, ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException { CallContext.current().setEventDetails("Ip Id: " + getEntityId()); IpAddress result = null; if (getVpcId() != null) { result = _vpcService.associateIPToVpc(getEntityId(), getVpcId()); } else if (getNetworkId() != null) { result = _networkService.associateIPToNetwork(getEntityId(), getNetworkId()); } if (result != null) { IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ResponseView.Full, result); ipResponse.setResponseName(getCommandName()); setResponseObject(ipResponse); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to assign ip address"); } }
@Override public void execute() throws ResourceUnavailableException { boolean success = false; StaticRoute route = null; try { CallContext.current().setEventDetails("Static route Id: " + getEntityId()); 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) { routeResponse = _responseGenerator.createStaticRouteResponse(route); setResponseObject(routeResponse); } routeResponse.setResponseName(getCommandName()); } finally { if (!success || route == null) { _vpcService.revokeStaticRoute(getEntityId()); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create static route"); } } }
long copyOfVpcId; try { copyOfVpc = _vpcService.createVpc(vpc.getZoneId(), vpcOfferingId, vpc.getAccountId(), vpc.getName(), vpc.getDisplayText(), vpc.getCidr(), vpc.getNetworkDomain(), vpc.isDisplay()); copyOfVpcId = copyOfVpc.getId();
@Override public void execute() throws ResourceUnavailableException, ConcurrentOperationException { CallContext.current().setEventDetails("Network ACL Id: " + id); final boolean result = _vpcService.deleteVpcPrivateGateway(id); if (result) { final SuccessResponse response = new SuccessResponse(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete private gateway"); } }
@Override public void create() throws ResourceAllocationException { try { checkDeprecatedParameters(); final StaticRoute result = _vpcService.createStaticRoute(getVpcId(), getCidr(), getNextHop()); setEntityId(result.getId()); setEntityUuid(result.getUuid()); } catch (final NetworkRuleConflictException ex) { s_logger.info("Network rule conflict: " + ex.getMessage()); s_logger.trace("Network rule conflict: ", ex); throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, ex.getMessage()); } }
@Override public void execute() throws InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException, ResourceUnavailableException { final PrivateGateway result = _vpcService.applyVpcPrivateGateway(getEntityId(), true); if (result != null) { final PrivateGatewayResponse response = _responseGenerator.createPrivateGatewayResponse(result); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create private gateway"); } }
@Override public void create() throws ResourceAllocationException { PrivateGateway result; try { result = _vpcService.createVpcPrivateGateway(getVpcId(), getStartIp(), getGateway(), getNetmask(), getEntityDomainId(), getNetworkId(), getIsSourceNat(), getAclId()); } catch (final InsufficientCapacityException ex) { s_logger.info(ex.toString()); throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage()); } catch (final ConcurrentOperationException ex) { s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); } if (result != null) { setEntityId(result.getId()); setEntityUuid(result.getUuid()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create private gateway"); } }
@Override public void execute() { Vpc vpc = null; try { if (isStart()) { _vpcService.startVpc(getEntityId(), true); } else { s_logger.debug("Not starting VPC as " + ApiConstants.START + "=false was passed to the API"); } vpc = _entityMgr.findById(Vpc.class, getEntityId()); } catch (ResourceUnavailableException ex) { s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage()); } catch (ConcurrentOperationException ex) { s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); } catch (InsufficientCapacityException ex) { s_logger.info(ex); s_logger.trace(ex); throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage()); } if (vpc != null) { VpcResponse response = _responseGenerator.createVpcResponse(ResponseView.Restricted, vpc); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create VPC"); } }
_vpcSvc.associateIPToVpc(ipId, network.getVpcId());
final PrivateGateway privateGateway = _vpcSvc.getVpcPrivateGateway(vpcGateway.getId());