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

项目:photon-model    文件:AWSNetworkClient.java   
/**
 * Async create the subnet and return it.
 */
public DeferredResult<Subnet> createSubnetAsync(String subnetCidr, String vpcId, String zoneId) {

    CreateSubnetRequest req = new CreateSubnetRequest()
            .withCidrBlock(subnetCidr)
            .withVpcId(vpcId)
            .withAvailabilityZone(zoneId);

    String message = "Create AWS Subnet with CIDR [" + subnetCidr
            + "] for vpc id [" + vpcId + "].";

    AWSDeferredResultAsyncHandler<CreateSubnetRequest, CreateSubnetResult> handler = new
            AWSDeferredResultAsyncHandler<>(this.service, message);
    this.client.createSubnetAsync(req, handler);
    return handler.toDeferredResult()
            .thenApply(CreateSubnetResult::getSubnet);
}
项目:photon-model    文件:AWSNetworkClient.java   
/**
 * Creates the subnet and return it.
 */
public Subnet createSubnet(String subnetCidr, String vpcId) {
    CreateSubnetRequest req = new CreateSubnetRequest()
            .withCidrBlock(subnetCidr)
            .withVpcId(vpcId);
    CreateSubnetResult res = this.client.createSubnet(req);
    return res.getSubnet();
}
项目:photon-model    文件:TestAWSSetupUtils.java   
/**
 * Creates a Subnet if not exist and return the Subnet id.
 */
public static String createOrGetSubnet(AmazonEC2AsyncClient client, String subnetCidr,
        String vpcId, String zoneId) {
    List<Filter> filters = new ArrayList<>();
    Filter cidrBlockFilter = new Filter();
    cidrBlockFilter.withName("cidrBlock");
    cidrBlockFilter.withValues(subnetCidr);
    filters.add(cidrBlockFilter);

    if (zoneId != null) {
        Filter azFilter = new Filter();
        azFilter.withName("availabilityZone");
        azFilter.withValues(zoneId);
        filters.add(azFilter);
    }

    DescribeSubnetsResult result = client.describeSubnets(new DescribeSubnetsRequest()
            .withFilters(filters));
    if (result.getSubnets() != null && !result.getSubnets().isEmpty()) {
        return result.getSubnets().get(0).getSubnetId();
    } else {
        CreateSubnetRequest req = new CreateSubnetRequest()
                .withCidrBlock(subnetCidr)
                .withVpcId(vpcId);
        if (zoneId != null) {
            req.withAvailabilityZone(zoneId);
        }
        CreateSubnetResult res = client.createSubnet(req);
        return res.getSubnet().getSubnetId();
    }
}
项目:photon-model    文件:AWSSubnetTaskServiceTest.java   
private Subnet createAwsSubnet() {
    if (this.isMock) {
        Subnet subnet = new Subnet();
        subnet.setSubnetId(UUID.randomUUID().toString());
        return subnet;
    }

    CreateSubnetRequest createRequest = new CreateSubnetRequest(AWS_DEFAULT_VPC_ID,
            AWS_NON_EXISTING_SUBNET_CIDR);
    return this.client.createSubnet(createRequest).getSubnet();
}
项目:aws-sdk-java-resources    文件:VpcImpl.java   
@Override
public Subnet createSubnet(CreateSubnetRequest request,
        ResultCapture<CreateSubnetResult> extractor) {

    ActionResult result = resource.performAction("CreateSubnet", request,
            extractor);

    if (result == null) return null;
    return new SubnetImpl(result.getResource());
}
项目:aws-sdk-java-resources    文件:VpcImpl.java   
@Override
public Subnet createSubnet(String cidrBlock,
        ResultCapture<CreateSubnetResult> extractor) {

    CreateSubnetRequest request = new CreateSubnetRequest()
        .withCidrBlock(cidrBlock);
    return createSubnet(request, extractor);
}
项目:aws-sdk-java-resources    文件:EC2Impl.java   
@Override
public Subnet createSubnet(CreateSubnetRequest request,
        ResultCapture<CreateSubnetResult> extractor) {

    ActionResult result = service.performAction("CreateSubnet", request,
            extractor);

    if (result == null) return null;
    return new SubnetImpl(result.getResource());
}
项目:aws-sdk-java-resources    文件:EC2Impl.java   
@Override
public Subnet createSubnet(String cidrBlock, String vpcId,
        ResultCapture<CreateSubnetResult> extractor) {

    CreateSubnetRequest request = new CreateSubnetRequest()
        .withCidrBlock(cidrBlock)
        .withVpcId(vpcId);
    return createSubnet(request, extractor);
}
项目:aws-mock    文件:BaseTest.java   
/**
 * Create Subnet.
 *
 * @param cidrBlock the cidr block
 * @param vpcId the vpc id
 * @return Subnet
 */
protected final Subnet createSubnet(final String cidrBlock, final String vpcId) {
    Subnet subnet = null;

    CreateSubnetRequest req = new CreateSubnetRequest();
    req.setCidrBlock(cidrBlock);
    req.setVpcId(vpcId);
    CreateSubnetResult result = amazonEC2Client.createSubnet(req);
    if (result != null) {
        subnet = result.getSubnet();
    }

    return subnet;
}
项目:elasticsearch_my    文件:AmazonEC2Mock.java   
@Override
public CreateSubnetResult createSubnet(CreateSubnetRequest createSubnetRequest) throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Not supported in mock");
}
项目:cmn-project    文件:EC2VPC.java   
public com.amazonaws.services.ec2.model.Subnet createSubnet(CreateSubnetRequest request) {
    logger.info("create subnet, request={}", request);
    return ec2.createSubnet(request).getSubnet();
}
项目:cmn-project    文件:CreateSubnetTask.java   
@Override
public void execute(Context context) throws Exception {
    List<String> zones = AWS.ec2.availabilityZones();

    List<String> subnetIds = new ArrayList<>();

    for (int i = 0; i < resource.cidrs.size(); i++) {
        String cidr = resource.cidrs.get(i);
        com.amazonaws.services.ec2.model.Subnet subnet = AWS.vpc.createSubnet(new CreateSubnetRequest(resource.vpc.remoteVPC.getVpcId(), cidr)
            .withAvailabilityZone(zones.get(i)));
        subnetIds.add(subnet.getSubnetId());
    }

    while (true) {
        logger.info("wait until all subnets are available");
        Threads.sleepRoughly(Duration.ofSeconds(10));
        List<com.amazonaws.services.ec2.model.Subnet> subnets = AWS.vpc.describeSubnets(subnetIds);
        boolean allOK = subnets.stream().allMatch(subnet -> {
            logger.info("subnet {} => {}", subnet.getSubnetId(), subnet.getState());
            return "available".equals(subnet.getState());
        });
        if (allOK) {
            resource.remoteSubnets.addAll(subnets);
            break;
        }
    }

    if (resource.type == SubnetType.PUBLIC) {
        for (String subnetId : subnetIds) {
            AWS.vpc.ec2.modifySubnetAttribute(new ModifySubnetAttributeRequest()
                .withSubnetId(subnetId)
                .withMapPublicIpOnLaunch(true));
        }
    }

    EC2TagHelper tagHelper = new EC2TagHelper(context.env);

    AWS.ec2.createTags(new CreateTagsRequest()
        .withResources(subnetIds)
        .withTags(tagHelper.env(), tagHelper.resourceId(resource.id), tagHelper.name(resource.id)));

    logger.info("associate route table, subnet={}, routeTable={}", resource.id, resource.routeTable.id);
    for (com.amazonaws.services.ec2.model.Subnet remoteSubnet : resource.remoteSubnets) {
        AWS.vpc.ec2.associateRouteTable(new AssociateRouteTableRequest()
            .withRouteTableId(resource.routeTable.remoteRouteTable.getRouteTableId())
            .withSubnetId(remoteSubnet.getSubnetId()));
    }
}
项目:aws-sdk-java-resources    文件:VpcImpl.java   
@Override
public Subnet createSubnet(CreateSubnetRequest request) {
    return createSubnet(request, null);
}
项目:aws-sdk-java-resources    文件:EC2Impl.java   
@Override
public Subnet createSubnet(CreateSubnetRequest request) {
    return createSubnet(request, null);
}
项目:aws-sdk-java-resources    文件:Vpc.java   
/**
 * Performs the <code>CreateSubnet</code> action.
 *
 * <p>
 * The following request parameters will be populated from the data of this
 * <code>Vpc</code> resource, and any conflicting parameter value set in the
 * request will be overridden:
 * <ul>
 *   <li>
 *     <b><code>VpcId</code></b>
 *         - mapped from the <code>Id</code> identifier.
 *   </li>
 * </ul>
 *
 * <p>
 *
 * @return The <code>Subnet</code> resource object associated with the
 *         result of this action.
 * @see CreateSubnetRequest
 */
Subnet createSubnet(CreateSubnetRequest request);
项目:aws-sdk-java-resources    文件:Vpc.java   
/**
 * Performs the <code>CreateSubnet</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>Vpc</code> resource, and any conflicting parameter value set in the
 * request will be overridden:
 * <ul>
 *   <li>
 *     <b><code>VpcId</code></b>
 *         - mapped from the <code>Id</code> identifier.
 *   </li>
 * </ul>
 *
 * <p>
 *
 * @return The <code>Subnet</code> resource object associated with the
 *         result of this action.
 * @see CreateSubnetRequest
 */
Subnet createSubnet(CreateSubnetRequest request,
        ResultCapture<CreateSubnetResult> extractor);
项目:aws-sdk-java-resources    文件:EC2.java   
/**
 * Performs the <code>CreateSubnet</code> action.
 *
 * <p>
 *
 * @return The <code>Subnet</code> resource object associated with the
 *         result of this action.
 * @see CreateSubnetRequest
 */
com.amazonaws.resources.ec2.Subnet createSubnet(CreateSubnetRequest request)
        ;
项目:aws-sdk-java-resources    文件:EC2.java   
/**
 * Performs the <code>CreateSubnet</code> action and use a ResultCapture to
 * retrieve the low-level client response.
 *
 * <p>
 *
 * @return The <code>Subnet</code> resource object associated with the
 *         result of this action.
 * @see CreateSubnetRequest
 */
com.amazonaws.resources.ec2.Subnet createSubnet(CreateSubnetRequest request,
        ResultCapture<CreateSubnetResult> extractor);