本文整理汇总了Java中com.amazonaws.services.ec2.model.DescribeSubnetsRequest.withFilters方法的典型用法代码示例。如果您正苦于以下问题:Java DescribeSubnetsRequest.withFilters方法的具体用法?Java DescribeSubnetsRequest.withFilters怎么用?Java DescribeSubnetsRequest.withFilters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.ec2.model.DescribeSubnetsRequest
的用法示例。
在下文中一共展示了DescribeSubnetsRequest.withFilters方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hasSubnets
import com.amazonaws.services.ec2.model.DescribeSubnetsRequest; //导入方法依赖的package包/类
@Override
public boolean hasSubnets(String vpcId) throws AutoException {
if (StringUtils.isEmpty(vpcId)) {
log.info(platform.getPlatformName() + " にvpcIdが有りません");
System.out.println("VPCID_EMPTY");
return false;
}
DescribeSubnetsRequest request = new DescribeSubnetsRequest();
request.withFilters(new Filter().withName("vpc-id").withValues(vpcId));
DescribeSubnetsResult result = ec2Client.describeSubnets(request);
List<Subnet> subnets = result.getSubnets();
if (subnets.isEmpty()) {
log.info(platform.getPlatformName() + " にサブネットが有りません");
System.out.println("SUBNET_EMPTY");
return false;
}
return true;
}
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:22,代码来源:AwsIaasGatewayScriptService.java
示例2: getSubnets
import com.amazonaws.services.ec2.model.DescribeSubnetsRequest; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public List<Subnet> getSubnets(Long userNo, Long platformNo) {
// VPCかどうかのチェック
PlatformAws platformAws = platformAwsDao.read(platformNo);
if (BooleanUtils.isNotTrue(platformAws.getVpc())) {
// 非VPCの場合、サブネットはない
return new ArrayList<Subnet>();
}
// サブネットを取得
AwsProcessClient awsProcessClient = awsProcessClientFactory.createAwsProcessClient(userNo, platformNo);
DescribeSubnetsRequest request = new DescribeSubnetsRequest();
request.withFilters(new Filter().withName("vpc-id").withValues(platformAws.getVpcId()));
DescribeSubnetsResult result = awsProcessClient.getEc2Client().describeSubnets(request);
List<Subnet> subnets = result.getSubnets();
// プラットフォームにサブネットが指定されている場合、そのサブネットのみに制限する
if (StringUtils.isNotEmpty(awsProcessClient.getPlatformAws().getSubnetId())) {
List<String> subnetIds = new ArrayList<String>();
for (String subnetId : StringUtils.split(awsProcessClient.getPlatformAws().getSubnetId(), ",")) {
subnetIds.add(subnetId.trim());
}
List<Subnet> subnets2 = new ArrayList<Subnet>();
for (Subnet subnet : subnets) {
if (subnetIds.contains(subnet.getSubnetId())) {
subnets2.add(subnet);
}
}
subnets = subnets2;
}
// ソート
Collections.sort(subnets, Comparators.COMPARATOR_SUBNET);
return subnets;
}
示例3: describeSubnetsByVpcId
import com.amazonaws.services.ec2.model.DescribeSubnetsRequest; //导入方法依赖的package包/类
public List<Subnet> describeSubnetsByVpcId(AwsProcessClient awsProcessClient, String vpcId) {
DescribeSubnetsRequest request = new DescribeSubnetsRequest();
request.withFilters(new Filter().withName("vpc-id").withValues(vpcId));
DescribeSubnetsResult result = awsProcessClient.getEc2Client().describeSubnets(request);
List<Subnet> subnets = result.getSubnets();
return subnets;
}
示例4: describeSubnets
import com.amazonaws.services.ec2.model.DescribeSubnetsRequest; //导入方法依赖的package包/类
@Override
public List<AbstractResource<?>> describeSubnets(Account account, Region region, DateTime dt, Ec2Filter... filters) {
AmazonEC2 ec2 = findClient(account, region);
DescribeSubnetsRequest req = new DescribeSubnetsRequest();
for (Ec2Filter filter : filters) {
Filter f = new Filter().withName(filter.getName()).withValues(filter.getValues());
req.withFilters(f);
}
log.debug("start describing subnets for account:{} in region:{} via api", account.getId() + "=>" + account.getName(), region);
DescribeSubnetsResult res = ec2.describeSubnets(req);
return converter.toVpcSubnets(res.getSubnets(), account.getId(), region, dt);
}