Example usage for com.amazonaws.services.ec2.model DescribeVpcsRequest setVpcIds

List of usage examples for com.amazonaws.services.ec2.model DescribeVpcsRequest setVpcIds

Introduction

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

Prototype


public void setVpcIds(java.util.Collection<String> vpcIds) 

Source Link

Document

One or more VPC IDs.

Usage

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  .j  a v  a 2s . com*/
 *
 * @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;
}