@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getSubnets() == null) ? 0 : getSubnets().hashCode()); return hashCode; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof DescribeSubnetsResult == false) return false; DescribeSubnetsResult other = (DescribeSubnetsResult) obj; if (other.getSubnets() == null ^ this.getSubnets() == null) return false; if (other.getSubnets() != null && other.getSubnets().equals(this.getSubnets()) == false) return false; return true; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getSubnets() != null) sb.append("Subnets: ").append(getSubnets()); sb.append("}"); return sb.toString(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof DescribeSubnetsResult == false) return false; DescribeSubnetsResult other = (DescribeSubnetsResult)obj; if (other.getSubnets() == null ^ this.getSubnets() == null) return false; if (other.getSubnets() != null && other.getSubnets().equals(this.getSubnets()) == false) return false; return true; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getSubnets() == null) ? 0 : getSubnets().hashCode()); return hashCode; }
/** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getSubnets() != null) sb.append("Subnets: " + getSubnets() ); sb.append("}"); return sb.toString(); }
/** * Information about one or more subnets. * <p> * Returns a reference to this object so that method calls can be chained together. * * @param subnets Information about one or more subnets. * * @return A reference to this updated object so that method calls can be chained * together. */ public DescribeSubnetsResult withSubnets(Subnet... subnets) { if (getSubnets() == null) setSubnets(new java.util.ArrayList<Subnet>(subnets.length)); for (Subnet value : subnets) { getSubnets().add(value); } return this; }
public DescribeSubnetsResult unmarshall(StaxUnmarshallerContext context) throws Exception { DescribeSubnetsResult describeSubnetsResult = new DescribeSubnetsResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { int xmlEvent = context.nextEvent(); if (xmlEvent == XmlPullParser.END_DOCUMENT) return describeSubnetsResult; if (xmlEvent == XmlPullParser.START_TAG) { if (context.testExpression("subnetSet/item", targetDepth)) { describeSubnetsResult.getSubnets().add(SubnetStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) { return describeSubnetsResult; } } } }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getSubnets() == null) ? 0 : getSubnets().hashCode()); return hashCode; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof DescribeSubnetsResult == false) return false; DescribeSubnetsResult other = (DescribeSubnetsResult) obj; if (other.getSubnets() == null ^ this.getSubnets() == null) return false; if (other.getSubnets() != null && other.getSubnets().equals(this.getSubnets()) == false) return false; return true; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getSubnets() != null) sb.append("Subnets: ").append(getSubnets()); sb.append("}"); return sb.toString(); }
/** * Gets the subnets for region. * * @param ec2ServiceClient the ec 2 service client * @param region the region * @param describeSubnetsRequest the describe subnets request * @return the subnets for region */ public static List<Subnet> getSubnetsForRegion(AmazonEC2 ec2ServiceClient, Region region, DescribeSubnetsRequest describeSubnetsRequest) { ec2ServiceClient.setRegion(region); DescribeSubnetsResult describeSubnetsResult = ec2ServiceClient.describeSubnets(describeSubnetsRequest); return describeSubnetsResult.getSubnets(); }
/** * * @param subnetIds * @param ec2Client * @return */ public List<Subnet> getSubnets(List<String> subnetIds, AmazonEC2 ec2Client) { DescribeSubnetsRequest request = new DescribeSubnetsRequest(); if (subnetIds != null && !subnetIds.isEmpty()) { request = request.withSubnetIds(subnetIds); } DescribeSubnetsResult result = ec2Client.describeSubnets(request); return result.getSubnets(); }
public static String getSubnetId(AmazonEC2Client ec2Client) { Subnet subnet = null; for (Subnet aux : ec2Client.describeSubnets().getSubnets()) { System.out.println(); if (aux.getState().equals("available") && aux.getAvailabilityZone().startsWith("eu-west-1")) { subnet = aux; break; } } Assert.assertNotNull("Subnet not null", subnet); return subnet.getSubnetId(); } }
public static String getSubnetId(AmazonEC2Client ec2Client) { Subnet subnet = null; for (Subnet aux : ec2Client.describeSubnets().getSubnets()) { System.out.println(); if (aux.getState().equals("available") && aux.getAvailabilityZone().startsWith("eu-west-1")) { subnet = aux; break; } } Assert.assertNotNull("Subnet not null", subnet); return subnet.getSubnetId(); } }
ec2Client = AmazonEC2ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(region.getName()).build(); DescribeSubnetsResult rslt = ec2Client.describeSubnets(); List<Subnet> subnetsTemp =rslt.getSubnets(); if(! subnetsTemp.isEmpty() ){ log.debug(InventoryConstants.ACCOUNT + account +" Type : Subnet "+region.getName() + " >> "+subnetsTemp.size());
/** * Get a list of security group ids for the slave */ private List<String> getEc2SecurityGroups(AmazonEC2 ec2) throws AmazonClientException { List<String> groupIds = new ArrayList<String>(); DescribeSecurityGroupsResult groupResult = getSecurityGroupsBy("group-name", securityGroupSet, ec2); if (groupResult.getSecurityGroups().size() == 0) { groupResult = getSecurityGroupsBy("group-id", securityGroupSet, ec2); } for (SecurityGroup group : groupResult.getSecurityGroups()) { if (group.getVpcId() != null && !group.getVpcId().isEmpty()) { List<Filter> filters = new ArrayList<Filter>(); filters.add(new Filter("vpc-id").withValues(group.getVpcId())); filters.add(new Filter("state").withValues("available")); filters.add(new Filter("subnet-id").withValues(getCurrentSubnetId())); DescribeSubnetsRequest subnetReq = new DescribeSubnetsRequest(); subnetReq.withFilters(filters); DescribeSubnetsResult subnetResult = ec2.describeSubnets(subnetReq); List<Subnet> subnets = subnetResult.getSubnets(); if (subnets != null && !subnets.isEmpty()) { groupIds.add(group.getGroupId()); } } } if (securityGroupSet.size() != groupIds.size()) { throw new AmazonClientException("Security groups must all be VPC security groups to work in a VPC context"); } return groupIds; }
/** * Get a list of security group ids for the slave */ private List<String> getEc2SecurityGroups(AmazonEC2 ec2) throws AmazonClientException{ List<String> group_ids = new ArrayList<String>(); DescribeSecurityGroupsResult group_result = getSecurityGroupsBy("group-name", securityGroupSet, ec2); if (group_result.getSecurityGroups().size() == 0) { group_result = getSecurityGroupsBy("group-id", securityGroupSet, ec2); } for (SecurityGroup group : group_result.getSecurityGroups()) { if (group.getVpcId() != null && !group.getVpcId().isEmpty()) { List<Filter> filters = new ArrayList<Filter>(); filters.add(new Filter("vpc-id").withValues(group.getVpcId())); filters.add(new Filter("state").withValues("available")); filters.add(new Filter("subnet-id").withValues(getSubnetId())); DescribeSubnetsRequest subnet_req = new DescribeSubnetsRequest(); subnet_req.withFilters(filters); DescribeSubnetsResult subnet_result = ec2.describeSubnets(subnet_req); List<Subnet> subnets = subnet_result.getSubnets(); if(subnets != null && !subnets.isEmpty()) { group_ids.add(group.getGroupId()); } } } if (securityGroupSet.size() != group_ids.size()) { throw new AmazonClientException( "Security groups must all be VPC security groups to work in a VPC context" ); } return group_ids; }
return describeSubnetsResult.getSubnets();
@Override protected void doScan() { rateLimit(); DescribeSubnetsResult result = getClient().describeSubnets(); GraphNodeGarbageCollector gc = newGarbageCollector().label("AwsSubnet").region(getRegion()); result.getSubnets().forEach(it -> { try { ObjectNode n = convertAwsObject(it, getRegion()); String cypher = "MERGE (v:AwsSubnet {aws_arn:{aws_arn}}) set v+={props}, v.updateTs=timestamp() return v"; NeoRxClient client = getNeoRxClient(); Preconditions.checkNotNull(client); client.execCypher(cypher, "aws_arn",n.get("aws_arn").asText(),"props",n).forEach(r->{ gc.MERGE_ACTION.accept(r); getShadowAttributeRemover().removeTagAttributes("AwsSubnet", n, r); }); incrementEntityCount(); } catch (RuntimeException e) { gc.markException(e); maybeThrow(e,"problem scanning subnets"); } }); gc.invoke(); }