use of com.amazonaws.services.ec2.model.DescribeInstanceStatusRequest in project camel by apache.
the class EC2Producer method describeInstancesStatus.
private void describeInstancesStatus(AmazonEC2Client ec2Client, Exchange exchange) {
Collection instanceIds;
DescribeInstanceStatusRequest request = new DescribeInstanceStatusRequest();
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCES_IDS))) {
instanceIds = exchange.getIn().getHeader(EC2Constants.INSTANCES_IDS, Collection.class);
request.withInstanceIds(instanceIds);
}
DescribeInstanceStatusResult result;
try {
result = ec2Client.describeInstanceStatus(request);
} catch (AmazonServiceException ase) {
LOG.trace("Describe Instances Status command returned the error code {}", ase.getErrorCode());
throw ase;
}
Message message = getMessageForResponse(exchange);
message.setBody(result);
}
use of com.amazonaws.services.ec2.model.DescribeInstanceStatusRequest in project camel by apache.
the class AmazonEC2ClientMock method describeInstanceStatus.
@Override
public DescribeInstanceStatusResult describeInstanceStatus(DescribeInstanceStatusRequest describeInstanceStatusRequest) {
DescribeInstanceStatusResult result = new DescribeInstanceStatusResult();
Collection<InstanceStatus> instanceStatuses = new ArrayList();
if (describeInstanceStatusRequest.getInstanceIds().isEmpty()) {
InstanceStatus status = new InstanceStatus();
status.setInstanceId("test-1");
status.setInstanceState(new InstanceState().withName(InstanceStateName.Running));
instanceStatuses.add(status);
status.setInstanceId("test-2");
status.setInstanceState(new InstanceState().withName(InstanceStateName.Stopped));
instanceStatuses.add(status);
} else {
if (describeInstanceStatusRequest.getInstanceIds().contains("test-1")) {
InstanceStatus status = new InstanceStatus();
status.setInstanceId("test-1");
status.setInstanceState(new InstanceState().withName(InstanceStateName.Running));
instanceStatuses.add(status);
}
if (describeInstanceStatusRequest.getInstanceIds().contains("test-2")) {
InstanceStatus status = new InstanceStatus();
status.setInstanceId("test-2");
status.setInstanceState(new InstanceState().withName(InstanceStateName.Stopped));
instanceStatuses.add(status);
}
}
result.setInstanceStatuses(instanceStatuses);
return result;
}
Aggregations