Example usage for com.amazonaws.services.ec2.model StopInstancesRequest withInstanceIds

List of usage examples for com.amazonaws.services.ec2.model StopInstancesRequest withInstanceIds

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2.model StopInstancesRequest withInstanceIds.

Prototype


public StopInstancesRequest withInstanceIds(java.util.Collection<String> instanceIds) 

Source Link

Document

The IDs of the instances.

Usage

From source file:com.vmware.photon.controller.model.adapters.awsadapter.AWSPowerService.java

License:Open Source License

private void powerOff(AmazonEC2AsyncClient client, ComputePowerRequest pr, BaseAwsContext c) {
    AWSPowerService powerService = this;
    OperationContext opContext = OperationContext.getOperationContext();

    StopInstancesRequest request = new StopInstancesRequest();
    request.withInstanceIds(c.child.id);
    client.stopInstancesAsync(request, new AsyncHandler<StopInstancesRequest, StopInstancesResult>() {
        @Override//from  w  w w. ja  va 2  s .c  om
        public void onSuccess(StopInstancesRequest request, StopInstancesResult result) {
            OperationContext.restoreOperationContext(opContext);
            updateComputeState(pr);
        }

        @Override
        public void onError(Exception e) {
            OperationContext.restoreOperationContext(opContext);
            AdapterUtils.sendPatchToTask(powerService, pr.taskReference,
                    ResourceOperationResponse.fail(pr.resourceLink(), e));
        }
    });
}

From source file:de.fischer.thotti.ec2.clients.EC2Stopper.java

License:Apache License

private void prepareRequestsPerRegion(EC2RequestData<StopInstancesRequest> requestData, RegionType region) {
    StopInstancesRequest request = new StopInstancesRequest();

    for (InstanceType server : region.getInstances()) {
        request.withInstanceIds(server.getInstanceID());
    }/*from ww  w .j av a  2  s.c  om*/

    requestData.getRegion(region.getName()).addRequest(request);
}

From source file:jp.primecloud.auto.process.aws.AwsInstanceProcess.java

License:Open Source License

public void stop(AwsProcessClient awsProcessClient, Long instanceNo) {
    AwsInstance awsInstance = awsInstanceDao.read(instanceNo);
    String instanceId = awsInstance.getInstanceId();

    // /*from  ww  w  . j av a  2s. c  o m*/
    Instance instance = instanceDao.read(instanceNo);
    processLogger.debug(null, instance, "AwsInstanceStop",
            new Object[] { awsProcessClient.getPlatform().getPlatformName(), instanceId });

    // ??
    StopInstancesRequest request = new StopInstancesRequest();
    request.withInstanceIds(instanceId);
    StopInstancesResult result = awsProcessClient.getEc2Client().stopInstances(request);
    List<InstanceStateChange> stoppingInstances = result.getStoppingInstances();

    // API??
    if (stoppingInstances.size() == 0) {
        // ?
        throw new AutoException("EPROCESS-000128", instanceId);

    } else if (stoppingInstances.size() > 1) {
        // ??????
        AutoException exception = new AutoException("EPROCESS-000130", instanceId);
        exception.addDetailInfo("result=" + stoppingInstances);
        throw exception;
    }

    // 
    if (log.isInfoEnabled()) {
        log.info(MessageUtils.getMessage("IPROCESS-100113", instanceId));
    }

    // 
    awsInstance.setStatus(stoppingInstances.get(0).getCurrentState().getName());
    awsInstanceDao.update(awsInstance);
}