@Override public Long getSyncObjId() { StaticRoute route = _vpcService.getStaticRoute(id); if (route == null) { throw new InvalidParameterValueException("Invalid id is specified for the static route"); } return route.getVpcId(); }
@Override @ActionEvent(eventType = EventTypes.EVENT_STATIC_ROUTE_CREATE, eventDescription = "Applying static route", async = true) public boolean applyStaticRoute(final long routeId) throws ResourceUnavailableException { final StaticRoute route = _staticRouteDao.findById(routeId); return applyStaticRoutesForVpc(route.getVpcId()); }
protected void detectRoutesConflict(final StaticRoute newRoute) throws NetworkRuleConflictException { // Multiple private gateways can exist within Vpc. Check for conflicts // for all static routes in Vpc // and not just the gateway final List<? extends StaticRoute> routes = _staticRouteDao.listByVpcIdAndNotRevoked(newRoute.getVpcId()); assert routes.size() >= 1 : "For static routes, we now always first persist the route and then check for " + "network conflicts so we should at least have one rule at this point."; for (final StaticRoute route : routes) { if (route.getId() == newRoute.getId()) { continue; // Skips my own route. } if (NetUtils.isNetworksOverlap(route.getCidr(), newRoute.getCidr())) { throw new NetworkRuleConflictException("New static route cidr conflicts with existing route " + route); } } }
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; }