Java 类com.amazonaws.services.ec2.model.Route 实例源码

项目:cmn-project    文件:RouteTableTaskPlanner.java   
private void linkDeleteTasks() {
    for (DeleteRouteTableTask routeTableTask : all(DeleteRouteTableTask.class)) {
        RouteTable routeTable = routeTableTask.resource;
        find(DeleteVPCTask.class)
            .ifPresent(task -> task.dependsOn(routeTableTask));

        for (final Route route : routeTable.remoteRouteTable.getRoutes()) {
            if (route.getGatewayId() != null) {
                all(DeleteInternetGatewayTask.class).stream()
                    .filter(task -> task.resource.remoteInternetGatewayId.equals(route.getGatewayId()))
                    .findAny().ifPresent(task -> task.dependsOn(routeTableTask));
            } else if (route.getNatGatewayId() != null) {
                all(DeleteNATGatewayTask.class).stream()
                    .filter(task -> task.resource.remoteNATGateway.getNatGatewayId().equals(route.getNatGatewayId()))
                    .findAny().ifPresent(task -> task.dependsOn(routeTableTask));
            }
        }
    }
}
项目:vpcviewer    文件:RouteDTO.java   
public RouteDTO(final Route route) {
    this.origin = route.getOrigin();
    this.destinationCidrBlock = route.getDestinationCidrBlock();
    this.instanceId = route.getInstanceId();
    this.gatewayId = route.getGatewayId();
    this.vpcPeeringConnectionId = route.getVpcPeeringConnectionId();
    this.state = route.getState();
    this.networkInterfaceId = route.getNetworkInterfaceId();
}
项目:vpc2vpc    文件:CreateConnection.java   
/**
 * Checks if routes between the selected VPCs already exist
 *
 * @param vpnEndpoints
 * @return
 */
private boolean checkIfRoutesExist(List<VPNEndpoint> vpnEndpoints) {
  boolean routesExist = false;

  for (VPNEndpoint vpnEndpoint : vpnEndpoints) {
    ec2Client.setEndpoint(vpnEndpoint.getRegion().getEndpoint());
    DescribeRouteTablesResult descRouteTableResult = ec2Client.describeRouteTables();
    List<RouteTable> routeTables = descRouteTableResult.getRouteTables();

    for (RouteTable routeTable : routeTables) {
      if (routeTable.getVpcId().equals(vpnEndpoint.getVpc().getVpcId())) {
        List<Route> routes = routeTable.getRoutes();
        for (Route route : routes) {
          for (VPNEndpoint extVpnEndpoint : vpnEndpoints) {
            if (!vpnEndpoint.equals(extVpnEndpoint)) {
              LOG.debug("Checking if route allows requested traffic: " + route);
              if (route.getDestinationCidrBlock().endsWith(extVpnEndpoint.getVpc().getCidrBlock())) {
                routesExist = true;
                LOG.error("A route already exists between " + vpnEndpoint.getVpc().getCidrBlock() + " and " + extVpnEndpoint.getVpc().getCidrBlock());
              }
            }
          }
        }
      }
    }

  }

  return routesExist;
}
项目:cfnassist    文件:VPCVisitor.java   
private void visitRouteTable(VPCDiagramBuilder vpcDiagram, RouteTable routeTable) throws CfnAssistException {
logger.debug("visit routetable " + routeTable.getRouteTableId());
List<Route> routes = routeTable.getRoutes();
List<RouteTableAssociation> usersOfTable = routeTable.getAssociations();
for (RouteTableAssociation usedBy : usersOfTable) {
    String subnetId = usedBy.getSubnetId(); // can subnet ever be null in an association?

    if (subnetId!=null) {
        vpcDiagram.addAsssociatedRouteTable(routeTable, subnetId); // possible duplication if route table reused?
        for (Route route : routes) {
            vpcDiagram.addRoute(routeTable.getRouteTableId(), subnetId, route);
        }
    } 
}
}
项目:cfnassist    文件:VPCDiagramBuilder.java   
public void addRoute(String routeTableId, String subnetId, Route route) throws CfnAssistException {
    String string = route.getDestinationCidrBlock();
    Cidr subnet = parseCidr(string);

    String state = route.getState();
    if (ROUTE_ACTIVE.equals(state)) {
        addActiveRoute(routeTableId, subnetId, route, subnet);
    } else if (ROUTE_BLACKHOLE.equals(state)){
        logger.warn("Route state is not active, cidr block is " + route.getDestinationCidrBlock());
        networkDiagram.addConnectionFromSubDiagram(ROUTE_BLACKHOLE, subnetId, subnetDiagramBuilders.get(subnetId), string);
    } else {
        throw new CfnAssistException(String.format("Unexpected state for route with cidr %s, state was %s", string, state));
    }
}
项目:cfnassist    文件:VPCDiagramBuilder.java   
private void addActiveRoute(String routeTableId, String subnetId, Route route, Cidr subnet) throws CfnAssistException {
    String destination = getDestination(route);
    String cidr = subnetAsCidrString(subnet);

    if (!destination.equals("local")) { 
        String diagramId = formRouteTableIdForDiagram(subnetId, routeTableId);
        networkDiagram.addRouteToInstance(destination, diagramId, subnetDiagramBuilders.get(subnetId), cidr);
    } else { 
        // this associates the cidr block with the current subnet
        networkDiagram.associateWithSubDiagram(cidr, subnetId, subnetDiagramBuilders.get(subnetId));
    }
}
项目:cfnassist    文件:VPCDiagramBuilder.java   
private String getDestination(Route route) {
    String dest = route.getGatewayId();
    if (dest==null) {
        dest = route.getInstanceId(); // api docs say this is a NAT instance, but could it be any instance?
    }
    return dest;
}
项目:aws-sdk-java-resources    文件:RouteTableImpl.java   
@Override
public List<Route> getRoutes() {
    return (List<Route>) resource.getAttribute("Routes");
}
项目:aws-sdk-java-resources    文件:RouteTable.java   
/**
 * Gets the value of the Routes attribute. If this resource is not yet
 * loaded, a call to {@code load()} is made to retrieve the value of the
 * attribute.
 */
List<Route> getRoutes();