Package com.netflix.simianarmy.client.aws

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


    @Test
    public void testInstancesWithNullIds() {
        List<AutoScalingInstanceDetails> instanceDetailsList = createInstanceDetailsList();
        List<Instance> instanceList = createInstanceList();
        AWSClient awsMock = createMockAWSClient(instanceDetailsList, instanceList);
        InstanceJanitorCrawler crawler = new InstanceJanitorCrawler(awsMock);
        List<Resource> resources = crawler.resources();
        verifyInstanceList(resources, instanceDetailsList);
    }
View Full Code Here


    @Test
    public void testInstancesWithIds() {
        List<AutoScalingInstanceDetails> instanceDetailsList = createInstanceDetailsList();
        List<Instance> instanceList = createInstanceList();
        String[] ids = {"i-123456780", "i-123456780"};
        AWSClient awsMock = createMockAWSClient(instanceDetailsList, instanceList, ids);
        InstanceJanitorCrawler crawler = new InstanceJanitorCrawler(awsMock);
        List<Resource> resources = crawler.resources(ids);
        verifyInstanceList(resources, instanceDetailsList);
    }
View Full Code Here

    @Test
    public void testInstancesWithResourceType() {
        List<AutoScalingInstanceDetails> instanceDetailsList = createInstanceDetailsList();
        List<Instance> instanceList = createInstanceList();
        AWSClient awsMock = createMockAWSClient(instanceDetailsList, instanceList);
        InstanceJanitorCrawler crawler = new InstanceJanitorCrawler(awsMock);
        for (AWSResourceType resourceType : AWSResourceType.values()) {
            List<Resource> resources = crawler.resources(resourceType);
            if (resourceType == AWSResourceType.INSTANCE) {
                verifyInstanceList(resources, instanceDetailsList);
View Full Code Here

    @Test
    public void testInstancesNotExistingInASG() {
        List<AutoScalingInstanceDetails> instanceDetailsList = Collections.emptyList();
        List<Instance> instanceList = createInstanceList();
        AWSClient awsMock = createMockAWSClient(instanceDetailsList, instanceList);
        InstanceJanitorCrawler crawler = new InstanceJanitorCrawler(awsMock);
        List<Resource> resources = crawler.resources();
        Assert.assertEquals(resources.size(), instanceList.size());
    }
View Full Code Here

        Assert.assertEquals(((AWSResource) instance).getAWSResourceState(), "running");
    }

    private AWSClient createMockAWSClient(List<AutoScalingInstanceDetails> instanceDetailsList,
            List<Instance> instanceList, String... ids) {
        AWSClient awsMock = mock(AWSClient.class);
        when(awsMock.describeAutoScalingInstances(ids)).thenReturn(instanceDetailsList);
        when(awsMock.describeInstances(ids)).thenReturn(instanceList);
        when(awsMock.region()).thenReturn("us-east-1");
        return awsMock;
    }
View Full Code Here

    }

    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

    }

    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

    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

    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

    }

    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

TOP

Related Classes of com.netflix.simianarmy.client.aws.AWSClient

Copyright © 2018 www.massapicom. 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.