Examples of AWSClient


Examples of com.netflix.simianarmy.client.aws.AWSClient

    }

    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());
        }

        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));
View Full Code Here

Examples of com.netflix.simianarmy.client.aws.AWSClient

    }

    private List<Resource> getVolumeResources(String... volumeIds) {
        List<Resource> resources = new LinkedList<Resource>();

        AWSClient awsClient = getAWSClient();

        for (Volume volume : awsClient.describeVolumes(volumeIds)) {
            Resource volumeResource = new AWSResource().withId(volume.getVolumeId())
                    .withRegion(getAWSClient().region()).withResourceType(AWSResourceType.EBS_VOLUME)
                    .withLaunchTime(volume.getCreateTime());
            for (Tag tag : volume.getTags()) {
                LOGGER.info(String.format("Adding tag %s = %s to resource %s",
View Full Code Here

Examples of com.netflix.simianarmy.client.aws.AWSClient

    private List<Resource> getSnapshotResources(String... snapshotIds) {
        refreshSnapshotToAMIs();

        List<Resource> resources = new LinkedList<Resource>();
        AWSClient awsClient = getAWSClient();

        for (Snapshot snapshot : awsClient.describeSnapshots(snapshotIds)) {
            Resource snapshotResource = new AWSResource().withId(snapshot.getSnapshotId())
                    .withRegion(getAWSClient().region()).withResourceType(AWSResourceType.EBS_SNAPSHOT)
                    .withLaunchTime(snapshot.getStartTime()).withDescription(snapshot.getDescription());
            for (Tag tag : snapshot.getTags()) {
                LOGGER.debug(String.format("Adding tag %s = %s to resource %s",
View Full Code Here

Examples of com.netflix.simianarmy.client.aws.AWSClient

    public List<Resource> resources(String... asgNames) {
        return getASGResources(asgNames);
    }

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

        List<LaunchConfiguration> launchConfigurations = awsClient.describeLaunchConfigurations();
        for (LaunchConfiguration lc : launchConfigurations) {
            nameToLaunchConfig.put(lc.getLaunchConfigurationName(), lc);
        }

        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()));
View Full Code Here

Examples of com.netflix.simianarmy.client.aws.AWSClient

    }

    private List<Resource> getInstanceResources(String... instanceIds) {
        List<Resource> resources = new LinkedList<Resource>();

        AWSClient awsClient = getAWSClient();
        Map<String, AutoScalingInstanceDetails> idToASGInstance = new HashMap<String, AutoScalingInstanceDetails>();
        for (AutoScalingInstanceDetails instanceDetails : awsClient.describeAutoScalingInstances(instanceIds)) {
            idToASGInstance.put(instanceDetails.getInstanceId(), instanceDetails);
        }

        for (Instance instance : awsClient.describeInstances(instanceIds)) {
            Resource instanceResource = new AWSResource().withId(instance.getInstanceId())
                    .withRegion(getAWSClient().region()).withResourceType(AWSResourceType.INSTANCE)
                    .withLaunchTime(instance.getLaunchTime());
            for (Tag tag : instance.getTags()) {
                instanceResource.setTag(tag.getKey(), tag.getValue());
View Full Code Here

Examples of com.netflix.simianarmy.client.aws.AWSClient

    /**
     * Create the specific client within passed region, using the appropriate AWS credentials provider.
     * @param clientRegion
     */
    protected void createClient(String clientRegion) {
        this.client = new AWSClient(clientRegion, awsCredentialsProvider);
        setCloudClient(this.client);
    }
View Full Code Here

Examples of com.netflix.simianarmy.client.aws.AWSClient

    @Override
    public List<Cluster> clusters(String... clusterNames) {
        List<Cluster> list = Lists.newArrayList();
        for (Map.Entry<String, AWSClient> entry : regionToAwsClient.entrySet()) {
            String region = entry.getKey();
            AWSClient awsClient = entry.getValue();
            Set<String> asgInstances = Sets.newHashSet();
            LOGGER.info(String.format("Crawling clusters in region %s", region));
            for (AutoScalingGroup asg : awsClient.describeAutoScalingGroups(clusterNames)) {
                List<String> instances = Lists.newArrayList();
                for (Instance instance : asg.getInstances()) {
                    instances.add(instance.getInstanceId());
                    asgInstances.add(instance.getInstanceId());
                }
                com.netflix.simianarmy.conformity.AutoScalingGroup conformityAsg =
                        new com.netflix.simianarmy.conformity.AutoScalingGroup(
                                asg.getAutoScalingGroupName(),
                                instances.toArray(new String[instances.size()]));

                for (SuspendedProcess sp : asg.getSuspendedProcesses()) {
                    if ("AddToLoadBalancer".equals(sp.getProcessName())) {
                        LOGGER.info(String.format("ASG %s is suspended: %s", asg.getAutoScalingGroupName(),
                                asg.getSuspendedProcesses()));
                        conformityAsg.setSuspended(true);
                    }
                }
                Cluster cluster = new Cluster(asg.getAutoScalingGroupName(), region, conformityAsg);
                updateCluster(cluster);
                list.add(cluster);
            }
            //Cluster containing all solo instances
            Set<String> instances = Sets.newHashSet();
            for (com.amazonaws.services.ec2.model.Instance awsInstance : awsClient.describeInstances()) {
                if (!asgInstances.contains(awsInstance.getInstanceId())) {
                    LOGGER.info(String.format("Adding instance %s to soloInstances cluster.",
                            awsInstance.getInstanceId()));
                    instances.add(awsInstance.getInstanceId());
                }
View Full Code Here

Examples of com.netflix.simianarmy.client.aws.AWSClient

            return asgs.get(0).getLoadBalancerNames();
        }
    }

    private AWSClient getAwsClient(String region) {
        AWSClient awsClient = regionToAwsClient.get(region);
        if (awsClient == null) {
            awsClient = new AWSClient(region, awsCredentialsProvider);
            regionToAwsClient.put(region, awsClient);
        }
        return awsClient;
    }
View Full Code Here

Examples of com.netflix.simianarmy.client.aws.AWSClient

    protected Map<String, Long> getInstanceLaunchTimes(String region, String... instanceIds) {
        Map<String, Long> result = Maps.newHashMap();
        if (instanceIds == null || instanceIds.length == 0) {
            return result;
        }
        AWSClient awsClient = new AWSClient(region, awsCredentialsProvider);
        for (Instance instance : awsClient.describeInstances(instanceIds)) {
            if (instance.getLaunchTime() != null) {
                result.put(instance.getInstanceId(), instance.getLaunchTime().getTime());
            } else {
                LOGGER.warn(String.format("No launch time found for instance %s", instance.getInstanceId()));
            }
View Full Code Here

Examples of com.netflix.simianarmy.client.aws.AWSClient

    public String getNonconformingReason() {
        return REASON;
    }

    private AWSClient getAwsClient(String region) {
        AWSClient awsClient = regionToAwsClient.get(region);
        if (awsClient == null) {
            awsClient = new AWSClient(region, awsCredentialsProvider);
            regionToAwsClient.put(region, awsClient);
        }
        return awsClient;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.