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

项目:photon-model    文件:AWSNetworkClient.java   
/**
 * Add a 0.0.0.0/0 route to NAT gateway on an existing route table
 */
public DeferredResult<Void> addRouteToNatGateway(String routeTableId, String natGatewayId) {
    CreateRouteRequest req = new CreateRouteRequest()
            .withNatGatewayId(natGatewayId)
            .withDestinationCidrBlock(ROUTE_DEST_ALL)
            .withRouteTableId(routeTableId);

    String message = "Create AWS Route to NAT Gateway [" + natGatewayId + "] for Internet "
            + "traffic on route table [" + routeTableId + "].";

    AWSDeferredResultAsyncHandler<CreateRouteRequest, CreateRouteResult> handler = new
            AWSDeferredResultAsyncHandler<>(this.service, message);
    this.client.createRouteAsync(req, handler);
    return handler.toDeferredResult()
            .thenAccept(ignore -> { });
}
项目:cmn-project    文件:CreateRouteTableTask.java   
@Override
public void execute(Context context) throws Exception {
    logger.info("create route table, routeTable={}", resource.id);
    resource.remoteRouteTable = AWS.vpc.ec2.createRouteTable(new CreateRouteTableRequest().withVpcId(resource.vpc.remoteVPC.getVpcId())).getRouteTable();

    if (resource.internetGateway != null) {
        AWS.vpc.ec2.createRoute(new CreateRouteRequest()
            .withRouteTableId(resource.remoteRouteTable.getRouteTableId())
            .withGatewayId(resource.internetGateway.remoteInternetGatewayId)
            .withDestinationCidrBlock("0.0.0.0/0"));
    } else {
        AWS.vpc.ec2.createRoute(new CreateRouteRequest()
            .withRouteTableId(resource.remoteRouteTable.getRouteTableId())
            .withNatGatewayId(resource.nat.remoteNATGateway.getNatGatewayId())
            .withDestinationCidrBlock("0.0.0.0/0"));
    }

    EC2TagHelper tagHelper = new EC2TagHelper(context.env);

    AWS.ec2.createTags(new CreateTagsRequest()
        .withResources(resource.remoteRouteTable.getRouteTableId())
        .withTags(tagHelper.env(), tagHelper.name(resource.id), tagHelper.resourceId(resource.id)));
}
项目:photon-model    文件:AWSNetworkClient.java   
/**
 * Create a route from a specified CIDR Subnet to a specific GW / Route Table
 */
public void createInternetRoute(String gatewayId, String routeTableId, String subnetCidr) {
    CreateRouteRequest req = new CreateRouteRequest()
            .withGatewayId(gatewayId)
            .withRouteTableId(routeTableId)
            .withDestinationCidrBlock(subnetCidr);
    this.client.createRoute(req);
}
项目:vpc2vpc    文件:CreateConnection.java   
/**
 * Create routes
 *
 * @param vpnEndpoints
 */
private void createAndAssociateRoutes(List<VPNEndpoint> vpnEndpoints) {

  for (VPNEndpoint vpnEndpoint : vpnEndpoints) {
    ec2Client.setEndpoint(vpnEndpoint.getRegion().getEndpoint());

    for (VPNEndpoint extVpnEndpoint : vpnEndpoints) {
      if (!vpnEndpoint.equals(extVpnEndpoint)) {

        // Get route tables
        DescribeRouteTablesResult descRouteTablesResult = ec2Client.describeRouteTables();
        List<RouteTable> routeTables = descRouteTablesResult.getRouteTables();
        for (RouteTable routeTable : routeTables) {
          if (routeTable.getVpcId().equals(vpnEndpoint.getVpc().getVpcId())) {
            // Create the route
            CreateRouteRequest createRouteReq = new CreateRouteRequest();
            createRouteReq.setDestinationCidrBlock(extVpnEndpoint.getVpc().getCidrBlock());
            createRouteReq.setInstanceId(vpnEndpoint.getInstance().getInstanceId());
            createRouteReq.setRouteTableId(routeTable.getRouteTableId());
            LOG.debug("About to create a route in " + vpnEndpoint.getVpc().getVpcId() + " to " + extVpnEndpoint.getVpc().getVpcId() + " in route table: " + routeTable.getRouteTableId());
            ec2Client.createRoute(createRouteReq);
            LOG.debug("Created route in " + vpnEndpoint.getVpc().getVpcId() + " to " + extVpnEndpoint.getVpc().getVpcId() + " in route table: " + routeTable.getRouteTableId());
          }
        }
      }
    }

  }

}
项目:aws-mock    文件:BaseTest.java   
/**
 * Create route with gateway and route table.
 *
 * @param routeTableId the route table id
 * @param gatewayId the gateway id
 * @param destinationCidrBlock the destination cidr block
 * @return true if Created Route
 */
protected final boolean createRoute(final String routeTableId, final String gatewayId, final String destinationCidrBlock) {

    CreateRouteRequest req = new CreateRouteRequest();
    req.setDestinationCidrBlock(destinationCidrBlock);
    req.setGatewayId(gatewayId);
    req.setRouteTableId(routeTableId);
    CreateRouteResult result = amazonEC2Client.createRoute(req);

    if (result != null) {
        return true;
    }

    return false;
}
项目:elasticsearch_my    文件:AmazonEC2Mock.java   
@Override
public CreateRouteResult createRoute(CreateRouteRequest createRouteRequest) throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Not supported in mock");
}
项目:aws-sdk-java-resources    文件:RouteTableImpl.java   
@Override
public void createRoute(CreateRouteRequest request) {
    createRoute(request, null);
}
项目:aws-sdk-java-resources    文件:RouteTableImpl.java   
@Override
public void createRoute(CreateRouteRequest request, ResultCapture<Void>
        extractor) {

    resource.performAction("CreateRoute", request, extractor);
}
项目:aws-sdk-java-resources    文件:RouteTable.java   
/**
 * Performs the <code>CreateRoute</code> action.
 *
 * <p>
 * The following request parameters will be populated from the data of this
 * <code>RouteTable</code> resource, and any conflicting parameter value set
 * in the request will be overridden:
 * <ul>
 *   <li>
 *     <b><code>RouteTableId</code></b>
 *         - mapped from the <code>Id</code> identifier.
 *   </li>
 * </ul>
 *
 * <p>
 *
 * @see CreateRouteRequest
 */
void createRoute(CreateRouteRequest request);
项目:aws-sdk-java-resources    文件:RouteTable.java   
/**
 * Performs the <code>CreateRoute</code> action and use a ResultCapture to
 * retrieve the low-level client response.
 *
 * <p>
 * The following request parameters will be populated from the data of this
 * <code>RouteTable</code> resource, and any conflicting parameter value set
 * in the request will be overridden:
 * <ul>
 *   <li>
 *     <b><code>RouteTableId</code></b>
 *         - mapped from the <code>Id</code> identifier.
 *   </li>
 * </ul>
 *
 * <p>
 *
 * @see CreateRouteRequest
 */
void createRoute(CreateRouteRequest request, ResultCapture<Void> extractor);