Example usage for com.amazonaws.services.autoscaling.model LaunchConfiguration getCreatedTime

List of usage examples for com.amazonaws.services.autoscaling.model LaunchConfiguration getCreatedTime

Introduction

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

Prototype


public java.util.Date getCreatedTime() 

Source Link

Document

The creation date and time for the launch configuration.

Usage

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

License:Open Source License

private void buildUI(DescribeLaunchConfigurationsResult detail) {

    this.add(primaryScrollPane, BorderLayout.CENTER);

    if (!detail.getLaunchConfigurations().isEmpty()) {

        List<LaunchConfiguration> lcs = detail.getLaunchConfigurations();
        LaunchConfiguration lc = lcs.get(0);

        if (lc.getAssociatePublicIpAddress() != null) {
            primaryTableModel.addRow(new Object[] { "Has EIP", lc.getAssociatePublicIpAddress() });
        }//from  w w w  .jav  a  2  s  .  co m
        if (lc.getClassicLinkVPCId() != null) {
            primaryTableModel.addRow(new Object[] { "Classic Link VPC Id", lc.getClassicLinkVPCId() });
        }

        if (!lc.getClassicLinkVPCSecurityGroups().isEmpty()) {

            StringBuilder sgs = new StringBuilder();
            for (String sg : lc.getClassicLinkVPCSecurityGroups()) {
                sgs.append(sg).append(", ");
            }

            primaryTableModel.addRow(new Object[] { "Classic Link VPC Security Groups", sgs.toString() });
        }

        if (lc.getCreatedTime() != null) {
            primaryTableModel.addRow(new Object[] { "Created", getDateString(lc.getCreatedTime()) });
        }
        if (lc.getEbsOptimized() != null) {
            primaryTableModel.addRow(new Object[] { "EBS Optimised", lc.getEbsOptimized() });
        }
        if (lc.getIamInstanceProfile() != null) {
            primaryTableModel.addRow(new Object[] { "Instance Profile", lc.getIamInstanceProfile() });
        }
        if (lc.getImageId() != null) {
            primaryTableModel.addRow(new Object[] { "Image Id", lc.getImageId() });
        }
        if (lc.getInstanceType() != null) {
            primaryTableModel.addRow(new Object[] { "Instance Type", lc.getInstanceType() });
        }
        if (lc.getKernelId() != null) {
            primaryTableModel.addRow(new Object[] { "Kernal Id", lc.getKernelId() });
        }
        if (lc.getKeyName() != null) {
            primaryTableModel.addRow(new Object[] { "Key Name", lc.getKeyName() });
        }
        if (lc.getLaunchConfigurationARN() != null) {
            primaryTableModel
                    .addRow(new Object[] { "Launch Configuration Arn", lc.getLaunchConfigurationARN() });
        }
        if (lc.getLaunchConfigurationName() != null) {
            primaryTableModel
                    .addRow(new Object[] { "Launch Configuration Name", lc.getLaunchConfigurationName() });
        }
        if (lc.getPlacementTenancy() != null) {
            primaryTableModel.addRow(new Object[] { "Placement Tenancy", lc.getPlacementTenancy() });
        }
        if (lc.getRamdiskId() != null) {
            primaryTableModel.addRow(new Object[] { "Ram Disk ID", lc.getRamdiskId() });
        }

        if (!lc.getSecurityGroups().isEmpty()) {

            StringBuilder sgs = new StringBuilder();
            for (String sg : lc.getSecurityGroups()) {
                sgs.append(sg).append(", ");
            }

            primaryTableModel.addRow(new Object[] { "Security Groups", sgs.toString() });
        }

        if (lc.getSpotPrice() != null) {
            primaryTableModel.addRow(new Object[] { "Spot Price", lc.getSpotPrice() });
        }
    }

}

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 . ja v  a2  s .co 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.aws.janitor.crawler.LaunchConfigJanitorCrawler.java

License:Apache License

private List<Resource> getLaunchConfigResources(String... launchConfigNames) {
    List<Resource> resources = Lists.newArrayList();

    AWSClient awsClient = getAWSClient();

    Set<String> usedLCs = Sets.newHashSet();
    for (AutoScalingGroup asg : awsClient.describeAutoScalingGroups()) {
        usedLCs.add(asg.getLaunchConfigurationName());
    }/*from  w ww .  j a v a 2  s .c o  m*/

    for (LaunchConfiguration launchConfiguration : awsClient.describeLaunchConfigurations(launchConfigNames)) {
        String lcName = launchConfiguration.getLaunchConfigurationName();
        Resource lcResource = new AWSResource().withId(lcName).withRegion(getAWSClient().region())
                .withResourceType(AWSResourceType.LAUNCH_CONFIG)
                .withLaunchTime(launchConfiguration.getCreatedTime());
        lcResource.setOwnerEmail(getOwnerEmailForResource(lcResource));

        lcResource.setAdditionalField(LAUNCH_CONFIG_FIELD_USED_BY_ASG,
                String.valueOf(usedLCs.contains(lcName)));
        resources.add(lcResource);
    }
    return resources;
}