public String retriableCall() throws IllegalStateException { DescribeInstancesRequest desc = new DescribeInstancesRequest().withInstanceIds(getInstanceId()); DescribeInstancesResult res = client.describeInstances(desc); for (Reservation resr : res.getReservations()) { for (Instance ins : resr.getInstances()) { for (com.amazonaws.services.ec2.model.Tag tag : ins.getTags()) { if (tag.getKey().equals("aws:autoscaling:groupName")) return tag.getValue(); } } } throw new IllegalStateException("Couldn't determine ASG name"); } }.call();
hashCode = prime * hashCode + ((getSriovNetSupport() == null) ? 0 : getSriovNetSupport().hashCode()); hashCode = prime * hashCode + ((getStateReason() == null) ? 0 : getStateReason().hashCode()); hashCode = prime * hashCode + ((getTags() == null) ? 0 : getTags().hashCode()); hashCode = prime * hashCode + ((getVirtualizationType() == null) ? 0 : getVirtualizationType().hashCode()); hashCode = prime * hashCode + ((getCpuOptions() == null) ? 0 : getCpuOptions().hashCode());
/** * Any tags assigned to the instance. * <p> * Returns a reference to this object so that method calls can be chained together. * * @param tags Any tags assigned to the instance. * * @return A reference to this updated object so that method calls can be chained * together. */ public Instance withTags(Tag... tags) { if (getTags() == null) setTags(new java.util.ArrayList<Tag>(tags.length)); for (Tag value : tags) { getTags().add(value); } return this; }
if (other.getStateReason() != null && other.getStateReason().equals(this.getStateReason()) == false) return false; if (other.getTags() == null ^ this.getTags() == null) return false; if (other.getTags() != null && other.getTags().equals(this.getTags()) == false) return false; if (other.getVirtualizationType() == null ^ this.getVirtualizationType() == null)
if (getSpotInstanceRequestId() != null) sb.append("SpotInstanceRequestId: " + getSpotInstanceRequestId() + ","); if (getClientToken() != null) sb.append("ClientToken: " + getClientToken() + ","); if (getTags() != null) sb.append("Tags: " + getTags() + ","); if (getSecurityGroups() != null) sb.append("SecurityGroups: " + getSecurityGroups() + ","); if (isSourceDestCheck() != null) sb.append("SourceDestCheck: " + isSourceDestCheck() + ",");
hashCode = prime * hashCode + ((getSpotInstanceRequestId() == null) ? 0 : getSpotInstanceRequestId().hashCode()); hashCode = prime * hashCode + ((getClientToken() == null) ? 0 : getClientToken().hashCode()); hashCode = prime * hashCode + ((getTags() == null) ? 0 : getTags().hashCode()); hashCode = prime * hashCode + ((getSecurityGroups() == null) ? 0 : getSecurityGroups().hashCode()); hashCode = prime * hashCode + ((isSourceDestCheck() == null) ? 0 : isSourceDestCheck().hashCode());
@Override public boolean test(Instance instance) { if (instance == null) { return false; } return instance.getTags().contains(this.requiredTag); } }
if (other.getClientToken() == null ^ this.getClientToken() == null) return false; if (other.getClientToken() != null && other.getClientToken().equals(this.getClientToken()) == false) return false; if (other.getTags() == null ^ this.getTags() == null) return false; if (other.getTags() != null && other.getTags().equals(this.getTags()) == false) return false; if (other.getSecurityGroups() == null ^ this.getSecurityGroups() == null) return false; if (other.getSecurityGroups() != null && other.getSecurityGroups().equals(this.getSecurityGroups()) == false) return false;
public static Tag getAwsTag(Instance awsInstance, String tagName) { List<Tag> tags = awsInstance.getTags(); java.util.Optional<Tag> tag = tags.stream().filter(t -> StringUtils.equals(t.getKey(), tagName)).findFirst(); return tag.isPresent() ? tag.get() : null; } }
private boolean hasTag(final Instance instance, final Tag theTag) { for (final Tag tag : instance.getTags()) { if (tag.equals(theTag)) { return true; } } return false; }
protected boolean isEc2ProvisionedSlave(Instance i, String ami) { // Check if the ami matches if (ami == null || StringUtils.equals(ami, i.getImageId())) { // Check if there is a ec2slave tag... for (Tag tag : i.getTags()) { if (StringUtils.equals(tag.getKey(), EC2Tag.TAG_NAME_JENKINS_SLAVE_TYPE)) { return true; } } return false; } return false; }
/** * Retrieves a certain tag value from an {@link Instance}. * * @param instance * @param tagKey * @return */ private Optional<String> getTagValue(Instance instance, String tagKey) { List<Tag> tags = instance.getTags(); for (Tag tag : tags) { if (tag.getKey().equals(tagKey)) { return Optional.of(tag.getValue()); } } return Optional.empty(); } }
public Optional<Tag> getTag(Instance instance, String name) { return Lists.findFirst(instance.getTags(), t -> t.getKey().equals(name)); }
private List<Tag> getInstanceTags(String instanceId) { final List<Tag> tags = new ArrayList<>(); final DescribeInstancesRequest request = new DescribeInstancesRequest().withInstanceIds(singletonList(instanceId)); final DescribeInstancesResult response = getEc2().describeInstances( request ); for (final Reservation res : response.getReservations()) for (final Instance inst : res.getInstances()) { final List<Tag> instanceTags = inst.getTags(); if (instanceTags != null && instanceTags.size() > 0) tags.addAll(instanceTags); } return tags; }
DescribeInstancesRequest request =new DescribeInstancesRequest(); request.setInstanceIds(instancesList); DescribeInstancesResult disresult = ec2.describeInstances(request); List <Reservation> list = disresult.getReservations(); for (Reservation res:list){ List <Instance> instancelist = res.getInstances(); for (Instance instance:instancelist){ List <Tag> tags = instance.getTags(); for (Tag tag:tags){ if (tag.getKey().equals("aws:cloudformation:stack-name")) { tag.getValue(); // name of the stack } }
protected EC2OndemandSlave newOndemandSlave(Instance inst) throws FormException, IOException { return new EC2OndemandSlave(inst.getInstanceId(), description, remoteFS, getNumExecutors(), labels, mode, initScript, tmpDir, remoteAdmin, jvmopts, stopOnTerminate, idleTerminationMinutes, inst.getPublicDnsName(), inst.getPrivateDnsName(), EC2Tag.fromAmazonTags(inst.getTags()), parent.name, usePrivateDnsName, useDedicatedTenancy, getLaunchTimeout(), amiType, maxTotalUses); }
protected EC2OndemandSlave newOndemandSlave(Instance inst) throws FormException, IOException { return new EC2OndemandSlave(inst.getInstanceId(), description, remoteFS, getNumExecutors(), labels, mode, initScript, tmpDir, remoteAdmin, jvmopts, stopOnTerminate, idleTerminationMinutes, inst.getPublicDnsName(), inst.getPrivateDnsName(), EC2Tag.fromAmazonTags(inst.getTags()), parent.name, usePrivateDnsName, useDedicatedTenancy, getLaunchTimeout(), amiType); }
instance.getTags().add(TagStaxUnmarshaller.getInstance().unmarshall(context)); continue;