Repository: camel Updated Branches: refs/heads/camel-2.18.x 33dd5eb61 -> 4765927aa
[CAMEL-11141] Add support for VPC instances Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f8d7e8a6 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f8d7e8a6 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f8d7e8a6 Branch: refs/heads/camel-2.18.x Commit: f8d7e8a657cb546318ca1dddd40b249c73228938 Parents: 33dd5eb Author: Thomas Diesler <thomas.dies...@jboss.com> Authored: Wed Apr 12 18:56:24 2017 +0200 Committer: Andrea Cosentino <anco...@gmail.com> Committed: Thu Apr 13 08:14:51 2017 +0200 ---------------------------------------------------------------------- .../camel/component/aws/ec2/EC2Constants.java | 1 + .../camel/component/aws/ec2/EC2Producer.java | 31 ++++++++------------ 2 files changed, 14 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/f8d7e8a6/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Constants.java ---------------------------------------------------------------------- diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Constants.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Constants.java index c7dfa65..dd927e5 100644 --- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Constants.java +++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Constants.java @@ -36,4 +36,5 @@ public interface EC2Constants { String INSTANCES_CLIENT_TOKEN = "CamelAwsEC2InstancesClientToken"; String INSTANCES_PLACEMENT = "CamelAwsEC2InstancesPlacement"; String INSTANCES_TAGS = "CamelAwsEC2InstancesTags"; + String SUBNET_ID = "CamelAwsEC2SubnetId"; } http://git-wip-us.apache.org/repos/asf/camel/blob/f8d7e8a6/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Producer.java ---------------------------------------------------------------------- diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Producer.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Producer.java index 3c3450c..8053c16 100644 --- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Producer.java +++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ec2/EC2Producer.java @@ -138,15 +138,6 @@ public class EC2Producer extends DefaultProducer { private void createAndRunInstance(AmazonEC2Client ec2Client, Exchange exchange) { String ami; InstanceType instanceType; - int minCount; - int maxCount; - boolean monitoring; - String kernelId; - boolean ebsOptimized; - Collection securityGroups; - String keyName; - String clientToken; - Placement placement; RunInstancesRequest request = new RunInstancesRequest(); if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.IMAGE_ID))) { ami = exchange.getIn().getHeader(EC2Constants.IMAGE_ID, String.class); @@ -161,45 +152,49 @@ public class EC2Producer extends DefaultProducer { throw new IllegalArgumentException("Instance Type must be specified"); } if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCE_MIN_COUNT))) { - minCount = exchange.getIn().getHeader(EC2Constants.INSTANCE_MIN_COUNT, Integer.class); + int minCount = exchange.getIn().getHeader(EC2Constants.INSTANCE_MIN_COUNT, Integer.class); request.withMinCount(minCount); } else { throw new IllegalArgumentException("Min instances count must be specified"); } if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCE_MAX_COUNT))) { - maxCount = exchange.getIn().getHeader(EC2Constants.INSTANCE_MAX_COUNT, Integer.class); + int maxCount = exchange.getIn().getHeader(EC2Constants.INSTANCE_MAX_COUNT, Integer.class); request.withMaxCount(maxCount); } else { throw new IllegalArgumentException("Max instances count must be specified"); } if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCE_MONITORING))) { - monitoring = exchange.getIn().getHeader(EC2Constants.INSTANCE_MONITORING, Boolean.class); + boolean monitoring = exchange.getIn().getHeader(EC2Constants.INSTANCE_MONITORING, Boolean.class); request.withMonitoring(monitoring); } if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCE_KERNEL_ID))) { - kernelId = exchange.getIn().getHeader(EC2Constants.INSTANCE_KERNEL_ID, String.class); + String kernelId = exchange.getIn().getHeader(EC2Constants.INSTANCE_KERNEL_ID, String.class); request.withKernelId(kernelId); } if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCE_EBS_OPTIMIZED))) { - ebsOptimized = exchange.getIn().getHeader(EC2Constants.INSTANCE_EBS_OPTIMIZED, Boolean.class); + boolean ebsOptimized = exchange.getIn().getHeader(EC2Constants.INSTANCE_EBS_OPTIMIZED, Boolean.class); request.withEbsOptimized(ebsOptimized); } if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCE_SECURITY_GROUPS))) { - securityGroups = exchange.getIn().getHeader(EC2Constants.INSTANCE_SECURITY_GROUPS, Collection.class); + Collection securityGroups = exchange.getIn().getHeader(EC2Constants.INSTANCE_SECURITY_GROUPS, Collection.class); request.withSecurityGroups(securityGroups); } if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCES_KEY_PAIR))) { - keyName = exchange.getIn().getHeader(EC2Constants.INSTANCES_KEY_PAIR, String.class); + String keyName = exchange.getIn().getHeader(EC2Constants.INSTANCES_KEY_PAIR, String.class); request.withKeyName(keyName); } if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCES_CLIENT_TOKEN))) { - clientToken = exchange.getIn().getHeader(EC2Constants.INSTANCES_CLIENT_TOKEN, String.class); + String clientToken = exchange.getIn().getHeader(EC2Constants.INSTANCES_CLIENT_TOKEN, String.class); request.withClientToken(clientToken); } if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCES_PLACEMENT))) { - placement = exchange.getIn().getHeader(EC2Constants.INSTANCES_PLACEMENT, Placement.class); + Placement placement = exchange.getIn().getHeader(EC2Constants.INSTANCES_PLACEMENT, Placement.class); request.withPlacement(placement); } + if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.SUBNET_ID))) { + String subnetId = exchange.getIn().getHeader(EC2Constants.SUBNET_ID, String.class); + request.withSubnetId(subnetId); + } RunInstancesResult result; try { result = ec2Client.runInstances(request);