Example usage for com.amazonaws.services.autoscaling.model TagDescription getValue

List of usage examples for com.amazonaws.services.autoscaling.model TagDescription getValue

Introduction

In this page you can find the example usage for com.amazonaws.services.autoscaling.model TagDescription getValue.

Prototype


public String getValue() 

Source Link

Document

The tag value.

Usage

From source file:com.haskins.cloudtrailviewer.dialog.resourcedetail.detailpanels.AsGroupDetail.java

License:Open Source License

private void buildUI(DescribeAutoScalingGroupsResult detail) {

    JTabbedPane tabs = new JTabbedPane();
    tabs.add("AS Group", primaryScrollPane);
    tabs.add("Tags", tagsScrollPane);

    this.add(tabs, BorderLayout.CENTER);

    List<AutoScalingGroup> groups = detail.getAutoScalingGroups();
    if (!groups.isEmpty()) {
        AutoScalingGroup group = groups.get(0);

        if (group.getAutoScalingGroupARN() != null) {
            primaryTableModel.addRow(new Object[] { "AutoScaling Group Arn", group.getAutoScalingGroupARN() });
        }/*from w w w  .ja  v  a2 s . c o m*/
        if (group.getAutoScalingGroupName() != null) {
            primaryTableModel
                    .addRow(new Object[] { "AutoScaling Group Name", group.getAutoScalingGroupName() });
        }

        if (!group.getAvailabilityZones().isEmpty()) {

            StringBuilder azs = new StringBuilder();
            for (String az : group.getAvailabilityZones()) {
                azs.append(az).append(", ");
            }

            primaryTableModel.addRow(new Object[] { "Availability Zones", azs.toString() });
        }

        if (group.getCreatedTime() != null) {
            primaryTableModel.addRow(new Object[] { "Created", getDateString(group.getCreatedTime()) });
        }
        if (group.getDefaultCooldown() != null) {
            primaryTableModel.addRow(new Object[] { "Default Cooldown", group.getDefaultCooldown() });
        }
        if (group.getDesiredCapacity() != null) {
            primaryTableModel.addRow(new Object[] { "Desired Capacity", group.getDesiredCapacity() });
        }
        if (group.getHealthCheckGracePeriod() != null) {
            primaryTableModel
                    .addRow(new Object[] { "HealthCheck Grace Period", group.getHealthCheckGracePeriod() });
        }
        if (group.getHealthCheckType() != null) {
            primaryTableModel.addRow(new Object[] { "HealthCheck Type", group.getHealthCheckType() });
        }

        if (!group.getInstances().isEmpty()) {

            StringBuilder instances = new StringBuilder();
            for (Instance instance : group.getInstances()) {
                instances.append(instance.getInstanceId()).append(", ");
            }

            primaryTableModel.addRow(new Object[] { "Instances", instances.toString() });
        }

        if (group.getLaunchConfigurationName() != null) {
            primaryTableModel
                    .addRow(new Object[] { "Launch Configuration Name", group.getLaunchConfigurationName() });
        }

        if (!group.getLoadBalancerNames().isEmpty()) {

            StringBuilder instances = new StringBuilder();
            for (String instance : group.getLoadBalancerNames()) {
                instances.append(instance).append(", ");
            }

            primaryTableModel.addRow(new Object[] { "LoadBalancer names", instances.toString() });
        }

        if (group.getMaxSize() != null) {
            primaryTableModel.addRow(new Object[] { "Max Size", group.getMaxSize() });
        }
        if (group.getMinSize() != null) {
            primaryTableModel.addRow(new Object[] { "Min Size", group.getMinSize() });
        }
        if (group.getPlacementGroup() != null) {
            primaryTableModel.addRow(new Object[] { "Placement Group", group.getPlacementGroup() });
        }
        if (group.getVPCZoneIdentifier() != null) {
            primaryTableModel.addRow(new Object[] { "VPC Zone Identifier", group.getVPCZoneIdentifier() });
        }

        List<TagDescription> tags = group.getTags();
        for (TagDescription tag : tags) {
            tagsTableModel.addRow(new Object[] { tag.getKey(), tag.getValue() });
        }
    }
}

From source file:com.netflix.simianarmy.aws.janitor.crawler.ASGJanitorCrawler.java

License:Apache License

private List<Resource> getASGResources(String... asgNames) {
    AWSClient awsClient = getAWSClient();

    List<LaunchConfiguration> launchConfigurations = awsClient.describeLaunchConfigurations();
    for (LaunchConfiguration lc : launchConfigurations) {
        nameToLaunchConfig.put(lc.getLaunchConfigurationName(), lc);
    }//from w ww.  j  a v  a2s  .c  o  m

    List<Resource> resources = new LinkedList<Resource>();
    for (AutoScalingGroup asg : awsClient.describeAutoScalingGroups(asgNames)) {
        Resource asgResource = new AWSResource().withId(asg.getAutoScalingGroupName())
                .withResourceType(AWSResourceType.ASG).withRegion(awsClient.region())
                .withLaunchTime(asg.getCreatedTime());
        for (TagDescription tag : asg.getTags()) {
            asgResource.setTag(tag.getKey(), tag.getValue());
        }
        asgResource.setDescription(String.format("%d instances", asg.getInstances().size()));
        asgResource.setOwnerEmail(getOwnerEmailForResource(asgResource));
        if (asg.getStatus() != null) {
            ((AWSResource) asgResource).setAWSResourceState(asg.getStatus());
        }
        Integer maxSize = asg.getMaxSize();
        if (maxSize != null) {
            asgResource.setAdditionalField(ASG_FIELD_MAX_SIZE, String.valueOf(maxSize));
        }
        // Adds instances and ELBs as additional fields.
        List<String> instances = new ArrayList<String>();
        for (Instance instance : asg.getInstances()) {
            instances.add(instance.getInstanceId());
        }
        asgResource.setAdditionalField(ASG_FIELD_INSTANCES, StringUtils.join(instances, ","));
        asgResource.setAdditionalField(ASG_FIELD_ELBS, StringUtils.join(asg.getLoadBalancerNames(), ","));
        String lcName = asg.getLaunchConfigurationName();
        LaunchConfiguration lc = nameToLaunchConfig.get(lcName);
        if (lc != null) {
            asgResource.setAdditionalField(ASG_FIELD_LC_NAME, lcName);
        }
        if (lc != null && lc.getCreatedTime() != null) {
            asgResource.setAdditionalField(ASG_FIELD_LC_CREATION_TIME,
                    String.valueOf(lc.getCreatedTime().getTime()));
        }
        // sets the field for the time when the ASG's traffic is suspended from ELB
        for (SuspendedProcess sp : asg.getSuspendedProcesses()) {
            if ("AddToLoadBalancer".equals(sp.getProcessName())) {
                String suspensionTime = getSuspensionTimeString(sp.getSuspensionReason());
                if (suspensionTime != null) {
                    LOGGER.info(String.format("Suspension time of ASG %s is %s", asg.getAutoScalingGroupName(),
                            suspensionTime));
                    asgResource.setAdditionalField(ASG_FIELD_SUSPENSION_TIME, suspensionTime);
                    break;
                }
            }
        }
        resources.add(asgResource);
    }
    return resources;
}

From source file:com.netflix.simianarmy.client.aws.chaos.TagPredicate.java

License:Apache License

@Override
public boolean apply(ChaosCrawler.InstanceGroup instanceGroup) {
    return Iterables.any(instanceGroup.tags(), new com.google.common.base.Predicate<TagDescription>() {
        @Override//from  ww w . ja va  2s.  c  o  m
        public boolean apply(TagDescription tagDescription) {
            return tagDescription.getKey().equals(key) && tagDescription.getValue().equals(value);
        }
    });
}

From source file:gobblin.aws.AWSSdkClient.java

License:Apache License

/***
 * Get list of {@link AutoScalingGroup}s for a given tag
 *
 * @param tag Tag to filter the auto scaling groups
 * @return List of {@link AutoScalingGroup}s qualifying the filter tag
 *///from   ww  w .  j av  a  2s  .  com
public List<AutoScalingGroup> getAutoScalingGroupsWithTag(Tag tag) {

    final AmazonAutoScaling autoScaling = getAmazonAutoScalingClient();

    final DescribeAutoScalingGroupsRequest describeAutoScalingGroupsRequest = new DescribeAutoScalingGroupsRequest();

    final List<AutoScalingGroup> allAutoScalingGroups = autoScaling
            .describeAutoScalingGroups(describeAutoScalingGroupsRequest).getAutoScalingGroups();

    final List<AutoScalingGroup> filteredAutoScalingGroups = Lists.newArrayList();
    for (AutoScalingGroup autoScalingGroup : allAutoScalingGroups) {
        for (TagDescription tagDescription : autoScalingGroup.getTags()) {
            if (tagDescription.getKey().equalsIgnoreCase(tag.getKey())
                    && tagDescription.getValue().equalsIgnoreCase(tag.getValue())) {
                filteredAutoScalingGroups.add(autoScalingGroup);
            }
        }
    }

    return filteredAutoScalingGroups;
}

From source file:gobblin.aws.GobblinAWSClusterLauncher.java

License:Apache License

@VisibleForTesting
Optional<String> getReconnectableClusterId() throws IOException {
    // List ASGs with Tag of cluster name
    final Tag clusterNameTag = new Tag().withKey(CLUSTER_NAME_ASG_TAG).withValue(this.clusterName);
    final List<AutoScalingGroup> autoScalingGroups = this.awsSdkClient
            .getAutoScalingGroupsWithTag(clusterNameTag);

    // If no auto scaling group is found, we don't have an existing cluster to connect to
    if (autoScalingGroups.size() == 0) {
        return Optional.absent();
    }//from  w  ww . ja  v  a  2s .  com

    // If more than 0 auto scaling groups are found, validate the setup
    if (autoScalingGroups.size() != 2) {
        throw new IOException("Expected 2 auto scaling groups (1 each for master and workers) but found: "
                + autoScalingGroups.size());
    }

    // Retrieve cluster information from ASGs
    Optional<String> clusterId = Optional.absent();
    Optional<AutoScalingGroup> masterAsg = Optional.absent();
    Optional<AutoScalingGroup> workersAsg = Optional.absent();

    for (TagDescription tagDescription : autoScalingGroups.get(0).getTags()) {
        LOGGER.info("Found tag: " + tagDescription);
        if (tagDescription.getKey().equalsIgnoreCase(CLUSTER_ID_ASG_TAG)) {
            clusterId = Optional.of(tagDescription.getValue());
        }
        if (tagDescription.getKey().equalsIgnoreCase(ASG_TYPE_ASG_TAG)) {
            if (tagDescription.getValue().equalsIgnoreCase(ASG_TYPE_MASTER)) {
                masterAsg = Optional.of(autoScalingGroups.get(0));
                workersAsg = Optional.of(autoScalingGroups.get(1));
            } else {
                masterAsg = Optional.of(autoScalingGroups.get(1));
                workersAsg = Optional.of(autoScalingGroups.get(0));
            }
        }
    }

    if (!clusterId.isPresent()) {
        throw new IOException("Found 2 auto scaling group names for: " + this.clusterName
                + " but tags seem to be corrupted, hence could not determine cluster id");
    }

    if (!masterAsg.isPresent() || !workersAsg.isPresent()) {
        throw new IOException("Found 2 auto scaling group names for: " + this.clusterName
                + " but tags seem to be corrupted, hence could not determine master and workers ASG");
    }

    // Get Master and Workers launch config name and auto scaling group name
    this.masterAutoScalingGroupName = masterAsg.get().getAutoScalingGroupName();
    this.masterLaunchConfigName = masterAsg.get().getLaunchConfigurationName();
    this.workerAutoScalingGroupName = workersAsg.get().getAutoScalingGroupName();
    this.workerLaunchConfigName = workersAsg.get().getLaunchConfigurationName();

    LOGGER.info("Trying to find cluster master public ip");
    this.masterPublicIp = getMasterPublicIp();
    LOGGER.info("Master public ip: " + this.masterPublicIp);

    return clusterId;
}

From source file:org.xmlsh.aws.asDescribeGroups.java

License:BSD License

private void writeTagDescription(TagDescription tag) throws XMLStreamException {
    startElement("tag");
    attribute("key", tag.getKey());
    attribute("propagate-at-launch", tag.getPropagateAtLaunch());
    attribute("resource-id", tag.getResourceId());
    attribute("resource-type", tag.getResourceType());
    attribute("value", tag.getValue());
    endElement();//  w  ww .  ja v  a2 s  .c  o  m

}