use of com.amazonaws.services.ec2.model.InstanceState in project camel by apache.
the class AmazonEC2ClientMock method startInstances.
@Override
public StartInstancesResult startInstances(StartInstancesRequest startInstancesRequest) {
StartInstancesResult result = new StartInstancesResult();
if (startInstancesRequest.getInstanceIds().get(0).equals("test-1")) {
Collection<InstanceStateChange> coll = new ArrayList<InstanceStateChange>();
InstanceStateChange sc = new InstanceStateChange();
InstanceState previousState = new InstanceState();
previousState.setCode(80);
previousState.setName(InstanceStateName.Stopped);
InstanceState newState = new InstanceState();
newState.setCode(16);
newState.setName(InstanceStateName.Running);
sc.setPreviousState(previousState);
sc.setCurrentState(newState);
sc.setInstanceId("test-1");
coll.add(sc);
result.setStartingInstances(coll);
} else {
throw new AmazonServiceException("The image-id doesn't exists");
}
return result;
}
use of com.amazonaws.services.ec2.model.InstanceState 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;
}
use of com.amazonaws.services.ec2.model.InstanceState in project cloudbreak by hortonworks.
the class ASGroupStatusCheckerTaskTest method returnInstanceStatus.
private List<InstanceStatus> returnInstanceStatus(int start, int end) {
List<InstanceStatus> instanceStatuses = new ArrayList<>();
for (int i = start; i < end; i++) {
InstanceStatus instanceStatus = new InstanceStatus();
InstanceState instanceState = new InstanceState();
instanceState.setCode(16);
instanceStatus.setInstanceState(instanceState);
instanceStatus.setInstanceId(Integer.toString(i));
instanceStatuses.add(instanceStatus);
}
return instanceStatuses;
}
use of com.amazonaws.services.ec2.model.InstanceState in project camel by apache.
the class AmazonEC2ClientMock method stopInstances.
@Override
public StopInstancesResult stopInstances(StopInstancesRequest stopInstancesRequest) {
StopInstancesResult result = new StopInstancesResult();
if (stopInstancesRequest.getInstanceIds().get(0).equals("test-1")) {
Collection<InstanceStateChange> coll = new ArrayList<InstanceStateChange>();
InstanceStateChange sc = new InstanceStateChange();
InstanceState previousState = new InstanceState();
previousState.setCode(80);
previousState.setName(InstanceStateName.Running);
InstanceState newState = new InstanceState();
newState.setCode(16);
newState.setName(InstanceStateName.Stopped);
sc.setPreviousState(previousState);
sc.setCurrentState(newState);
sc.setInstanceId("test-1");
coll.add(sc);
result.setStoppingInstances(coll);
} else {
throw new AmazonServiceException("The image-id doesn't exists");
}
return result;
}
use of com.amazonaws.services.ec2.model.InstanceState in project camel by apache.
the class AmazonEC2ClientMock method terminateInstances.
@Override
public TerminateInstancesResult terminateInstances(TerminateInstancesRequest terminateInstancesRequest) {
TerminateInstancesResult result = new TerminateInstancesResult();
if (terminateInstancesRequest.getInstanceIds().contains("test-1")) {
Collection<InstanceStateChange> coll = new ArrayList<InstanceStateChange>();
InstanceStateChange sc = new InstanceStateChange();
InstanceState previousState = new InstanceState();
previousState.setCode(80);
previousState.setName(InstanceStateName.Running);
InstanceState newState = new InstanceState();
newState.setCode(16);
newState.setName(InstanceStateName.Terminated);
sc.setPreviousState(previousState);
sc.setCurrentState(newState);
sc.setInstanceId("test-1");
coll.add(sc);
result.setTerminatingInstances(coll);
} else {
throw new AmazonServiceException("The image-id doesn't exists");
}
return result;
}
Aggregations