List of usage examples for com.amazonaws.services.ec2.model StartInstancesRequest withInstanceIds
public StartInstancesRequest withInstanceIds(java.util.Collection<String> instanceIds)
The IDs of the instances.
From source file:com.vmware.photon.controller.model.adapters.awsadapter.AWSPowerService.java
License:Open Source License
private void powerOn(AmazonEC2AsyncClient client, ComputePowerRequest pr, BaseAwsContext c) { AWSPowerService powerService = this; OperationContext opContext = OperationContext.getOperationContext(); StartInstancesRequest request = new StartInstancesRequest(); request.withInstanceIds(c.child.id); client.startInstancesAsync(request, new AsyncHandler<StartInstancesRequest, StartInstancesResult>() { @Override//from www . j ava 2 s . c o m public void onSuccess(StartInstancesRequest request, StartInstancesResult 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.EC2Starter.java
License:Apache License
private void prepareRequestsPerRegion(EC2RequestData<StartInstancesRequest> requestData, RegionType region) { StartInstancesRequest request = new StartInstancesRequest(); for (InstanceType server : region.getInstances()) { request.withInstanceIds(server.getInstanceID()); }/* w ww .j ava2 s . c o m*/ requestData.getRegion(region.getName()).addRequest(request); }
From source file:jp.primecloud.auto.process.aws.AwsInstanceProcess.java
License:Open Source License
public void start(AwsProcessClient awsProcessClient, Long instanceNo) { AwsInstance awsInstance = awsInstanceDao.read(instanceNo); String instanceId = awsInstance.getInstanceId(); // //www . j a v a 2 s .co m Instance instance = instanceDao.read(instanceNo); processLogger.debug(null, instance, "AwsInstanceStart", new Object[] { awsProcessClient.getPlatform().getPlatformName(), instanceId }); // ? StartInstancesRequest request = new StartInstancesRequest(); request.withInstanceIds(instanceId); StartInstancesResult result = awsProcessClient.getEc2Client().startInstances(request); List<InstanceStateChange> startingInstances = result.getStartingInstances(); // API?? if (startingInstances.size() == 0) { // throw new AutoException("EPROCESS-000125", instanceId); } else if (startingInstances.size() > 1) { // ????? AutoException exception = new AutoException("EPROCESS-000127", instanceId); exception.addDetailInfo("result=" + startingInstances); throw exception; } // if (log.isInfoEnabled()) { log.info(MessageUtils.getMessage("IPROCESS-100111", instanceId)); } // awsInstance.setStatus(startingInstances.get(0).getCurrentState().getName()); awsInstanceDao.update(awsInstance); }