amazonSecurityContext.getInstanceType(), jobExecutionContext, KEY_PAIR_NAME).get(0);
else {
// already running instance
DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest();
DescribeInstancesResult describeInstancesResult =
ec2client.describeInstances(describeInstancesRequest.
withInstanceIds(amazonSecurityContext.getInstanceId()));
if (describeInstancesResult.getReservations().size() == 0 ||
describeInstancesResult.getReservations().get(0).getInstances().size() == 0) {
throw new GFacProviderException("Instance not found:" + amazonSecurityContext.getInstanceId());
}
instance = describeInstancesResult.getReservations().get(0).getInstances().get(0);
// check instance keypair
if (instance.getKeyName() == null || !instance.getKeyName().equals(KEY_PAIR_NAME)) {
throw new GFacProviderException("Keypair for instance:" + amazonSecurityContext.getInstanceId() +
" is not valid");