Example usage for com.amazonaws.services.ec2.model Vpc isDefault

List of usage examples for com.amazonaws.services.ec2.model Vpc isDefault

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2.model Vpc isDefault.

Prototype

Boolean isDefault

To view the source code for com.amazonaws.services.ec2.model Vpc isDefault.

Click Source Link

Document

Indicates whether the VPC is the default VPC.

Usage

From source file:com.vmware.photon.controller.model.adapters.awsadapter.AWSNetworkService.java

License:Open Source License

public Vpc getDefaultVPC(AmazonEC2AsyncClient client) {
    DescribeVpcsRequest req = new DescribeVpcsRequest();
    DescribeVpcsResult result = client.describeVpcs(req);
    List<Vpc> vpcs = result.getVpcs();
    for (Vpc vpc : vpcs) {
        if (vpc.isDefault()) {
            return vpc;
        }//from w w w  .  ja v  a 2  s. c o  m
    }
    return null;
}

From source file:com.vmware.photon.controller.model.adapters.awsadapter.AWSUtils.java

License:Open Source License

/**
 * Gets the subnet associated with the default VPC.
 *//*from   w  ww.j  a va 2 s  . co  m*/
public static String getDefaultVPCSubnet(AWSAllocation aws) {
    String subnet = null;
    DescribeVpcsResult result = aws.amazonEC2Client.describeVpcs();
    List<Vpc> vpcs = result.getVpcs();

    for (Vpc vpc : vpcs) {
        if (vpc.isDefault()) {
            subnet = vpc.getCidrBlock();
        }
    }
    return subnet;
}

From source file:de.unibi.cebitec.bibigrid.meta.aws.CreateClusterEnvironmentAWS.java

/**
 * Return a VPC that currently exists in selected region. Returns either the
 * *default* vpc from all or the given vpcIds list. If only one vpcId is
 * given it is returned wether it is default or not. Return null in the case
 * no default or fitting VPC is found./*from  w  w w  . ja  v a 2 s  .  c  om*/
 *
 * @param ec2 - AmazonEC2Client
 * @param vpcIds - String...
 * @return
 */
private Vpc getVPC(String... vpcIds) {
    DescribeVpcsRequest dvreq = new DescribeVpcsRequest();
    dvreq.setVpcIds(Arrays.asList(vpcIds));

    DescribeVpcsResult describeVpcsResult = cluster.getEc2().describeVpcs(dvreq);
    List<Vpc> lvpcs = describeVpcsResult.getVpcs();

    if (vpcIds.length == 1 && lvpcs.size() == 1) {
        return lvpcs.get(0);
    }
    if (!lvpcs.isEmpty()) {
        for (Vpc vpc_d : lvpcs) {
            if (vpc_d.isDefault()) {
                return vpc_d;
            }
        }
    }
    return null;
}