Examples of AWSClient


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

     * @param region the region
     * @param instanceId the instance id.
     * @return the list of the AWS instances with the given id.
     */
    protected List<Instance> getAWSInstances(String region, String instanceId) {
        AWSClient awsClient = getAwsClient(region);
        return awsClient.describeInstances(instanceId);
    }
View Full Code Here

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

            return lbs.get(0).getAvailabilityZones();
        }
    }

    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, List<String>> getInstanceSecurityGroups(String region, String... instanceIds) {
        Map<String, List<String>> result = Maps.newHashMap();
        if (instanceIds == null || instanceIds.length == 0) {
            return result;
        }
        AWSClient awsClient = new AWSClient(region, awsCredentialsProvider);
        for (Instance instance : awsClient.describeInstances(instanceIds)) {
            // Ignore instances that are in VPC
            if (StringUtils.isNotEmpty(instance.getVpcId())) {
                LOGGER.info(String.format("Instance %s is in VPC and is ignored.", instance.getInstanceId()));
                continue;
            }
View Full Code Here

Examples of com.streamreduce.util.AWSClient

                .authType(AuthType.USERNAME_PASSWORD)
                .build();

        connectionService.createConnection(connection);

        AWSClient awsClient = new AWSClient(connection);
        int realInventoryItemCount = Iterables.size(Iterables.concat(awsClient.getEC2Instances(),
                awsClient.getS3BucketsAsJson()));
        List<InventoryItem> internalInventoryItems = inventoryService.getInventoryItems(connection);
        int iterationCount = 0;

        while (realInventoryItemCount != internalInventoryItems.size()) {
            Thread.sleep(10000);
View Full Code Here

Examples of com.streamreduce.util.AWSClient

        awsConnection.setAccount(testAccount);
        awsConnection.setUser(testUser);

        connectionService.createConnection(awsConnection);

        AWSClient awsClient = new AWSClient(awsConnection);
        Set<? extends StorageMetadata> buckets = awsClient.getS3Buckets();
        Set<String> bucketNames = new HashSet<>();
        for (StorageMetadata bucket : buckets) {
            bucketNames.add(bucket.getName());
        }
        assertTrue(bucketNames.contains(actualBucketName));
View Full Code Here

Examples of com.streamreduce.util.AWSClient

                .dataTypes(OutboundDataType.PROCESSED)
                .namespace(bucketName)
                .build();

        //Do something that makes the bucket appear
        AWSClient awsClient = new AWSClient(preexistingOutboundConfig);
        awsClient.createBucket(preexistingOutboundConfig);
    }
View Full Code Here

Examples of com.streamreduce.util.AWSClient

        ExternalIntegrationClient externalClient = null;
        try {
            for (OutboundConfiguration outboundConfiguration : outboundConfigurations) {
                if (outboundConfiguration.getProtocol().equals("s3")) {
                    AWSClient awsClient = new AWSClient(outboundConfiguration);
                    externalClient = awsClient;
                    externalClient.validateConnection();
                    try {
                        awsClient.createBucket(outboundConfiguration);
                    } catch (IllegalStateException e) { //thrown when a bucket name is already taken
                        throw new InvalidOutboundConfigurationException(e.getMessage(), e);
                    }
                } else if (outboundConfiguration.getProtocol().equals("webhdfs")) {
                    externalClient = new WebHDFSClient(outboundConfiguration);
View Full Code Here

Examples of com.streamreduce.util.AWSClient

    public void destroyComputeInstance(InventoryItem inventoryItem) throws InvalidCredentialsException {
        Preconditions.checkNotNull(inventoryItem, "inventoryItem cannot be null.");
        Preconditions.checkArgument(inventoryItem.getType().equals(Constants.COMPUTE_INSTANCE_TYPE),
                                    "Inventory item of type '" + inventoryItem.getType() + "' cannot be destroyed.");

        AWSClient client = (AWSClient)getClient(inventoryItem.getConnection());

        logger.debug("Terminating node: " + inventoryItem.getExternalId());

        BasicDBObject payload = getInventoryItemPayload(inventoryItem);
        String jcloudsNodeId = payload.getString("id");
        NodeMetadata nodeMetadata = client.getEC2Instance(jcloudsNodeId);

        if (nodeMetadata.getStatus().equals(NodeMetadata.Status.TERMINATED)) {
            return;
        }

        EventId eventId;

        if (client.destroyEC2Instance(jcloudsNodeId)) {
            eventId = EventId.CLOUD_INVENTORY_ITEM_TERMINATE;
        } else {
            // TODO: Handle this issue but it can be a false positive if the time it takes surpasses the time we wait
            eventId = EventId.CLOUD_INVENTORY_ITEM_TERMINATE_FAILURE;
        }
View Full Code Here

Examples of com.streamreduce.util.AWSClient

            }
        }

        if (externalType.equals(ComputeType.NODE.toString())) {
            name = json.getString("name");
            AWSClient client = null;
            try {
                client = new AWSClient(inventoryItem.getConnection());
                Set<Tag> ec2Tags = client.getEC2InstanceTags(externalId);

                // Handle adding new hashtags based on the EC2 tags and the instance name
                for (Tag tag : ec2Tags) {
                    String key = tag.getKey();
                    String value = tag.getValue();

                    if (key.equals("Name")) {
                        if (value.length() > 0) {
                            name = value;
                        }
                    } else {
                        inventoryItem.addHashtag(key + "=" + value);
                    }
                }
            } finally {
                if (client != null) {
                    client.cleanUp();
                }
            }

            internalType = Constants.COMPUTE_INSTANCE_TYPE;
        } else {
View Full Code Here

Examples of com.streamreduce.util.AWSClient

            ec2CloudWatchMetricNames.put(EC2Constants.MetricName.DISK_WRITE_OPS, Unit.COUNT);
            ec2CloudWatchMetricNames.put(EC2Constants.MetricName.NETWORK_IN, Unit.BYTES);
            ec2CloudWatchMetricNames.put(EC2Constants.MetricName.NETWORK_OUT, Unit.BYTES);
        }

        try (RestContext<CloudWatchApi, CloudWatchAsyncApi> context = new AWSClient(connection).getCloudWatchServiceContext()) {
            CloudWatchApi cloudWatchClient = context.getApi();
            List<InventoryItem> inventoryItems = getInventoryItems(connection);
            String metricNamespace = Namespaces.EC2;
            Calendar cal = Calendar.getInstance();
            Date endTime = new Date();
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.