@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()); } }
public StaticRouteProfile(StaticRoute staticRoute, VpcGateway gateway) { id = staticRoute.getId(); uuid = staticRoute.getUuid(); targetCidr = staticRoute.getCidr(); accountId = staticRoute.getAccountId(); domainId = staticRoute.getDomainId(); gatewayId = staticRoute.getVpcGatewayId(); state = staticRoute.getState(); vpcId = staticRoute.getVpcId(); vlanTag = gateway.getBroadcastUri(); this.gateway = gateway.getGateway(); netmask = gateway.getNetmask(); ipAddress = gateway.getIp4Address(); }
@Override public StaticRouteResponse createStaticRouteResponse(StaticRoute result) { StaticRouteResponse response = new StaticRouteResponse(); response.setId(result.getUuid()); if (result.getVpcId() != null) { Vpc vpc = ApiDBUtils.findVpcById(result.getVpcId()); if (vpc != null) { response.setVpcId(vpc.getUuid()); } } response.setCidr(result.getCidr()); StaticRoute.State state = result.getState(); if (state.equals(StaticRoute.State.Revoke)) { state = StaticRoute.State.Deleting; } response.setState(state.toString()); populateAccount(response, result.getAccountId()); populateDomain(response, result.getDomainId()); // set tag information List<? extends ResourceTag> tags = ApiDBUtils.listByResourceTypeAndId(ResourceObjectType.StaticRoute, result.getId()); List<ResourceTagResponse> tagResponses = new ArrayList<ResourceTagResponse>(); for (ResourceTag tag : tags) { ResourceTagResponse tagResponse = createResourceTagResponse(tag, true); CollectionUtils.addIgnoreNull(tagResponses,tagResponse); } response.setTags(tagResponses); response.setObjectName("staticroute"); return response; }