@Override public void process(Instance instance) { ec2UserClient.amazonEC2Async().rebootInstancesAsync( new RebootInstancesRequest().withInstanceIds(instance.getInstanceId()), new AsyncHandler<RebootInstancesRequest, RebootInstancesResult>() { @Override public void onError(Exception exception) { log.warn("something went wrong starting the server {}", exception.getLocalizedMessage()); } @Override public void onSuccess(RebootInstancesRequest request, RebootInstancesResult result) { ec2UserClient.amazonEC2Async().waiters() .instanceRunning() .runAsync(ec2Waiter.describeInstancesRequestWaiterParameters(instance.getInstanceId()), ec2Waiter.describeInstancesRequestWaiterHandler()); } }); }
public static void main(String[] args) { final String USAGE = "To run this example, supply an instance id\n" + "Ex: RebootInstnace <instance_id>\n"; if (args.length != 1) { System.out.println(USAGE); System.exit(1); } String instance_id = args[0]; final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); RebootInstancesRequest request = new RebootInstancesRequest() .withInstanceIds(instance_id); RebootInstancesResult response = ec2.rebootInstances(request); System.out.printf( "Successfully rebooted instance %s", instance_id); }
private void rebootInstances(AmazonEC2Client ec2Client, Exchange exchange) { Collection instanceIds; RebootInstancesRequest request = new RebootInstancesRequest(); if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCES_IDS))) { instanceIds = exchange.getIn().getHeader(EC2Constants.INSTANCES_IDS, Collection.class); request.withInstanceIds(instanceIds); } else { throw new IllegalArgumentException("Instances Ids must be specified"); } try { LOG.trace("Rebooting instances with Ids [{}] ", Arrays.toString(instanceIds.toArray())); ec2Client.rebootInstances(request); } catch (AmazonServiceException ase) { LOG.trace("Reboot Instances command returned the error code {}", ase.getErrorCode()); throw ase; } }
@Test public void testRebootInstancesHappy() { String instanceId = "instance id"; ec2Service.rebootEc2Instance(instanceId); verify(ec2Client).rebootInstances(new RebootInstancesRequest() .withInstanceIds(instanceId) ); }
public void attachVolume(String volumneId, String instanceId, String device) { AttachVolumeRequest attachVolumeRequest = new AttachVolumeRequest(volumneId, instanceId, device); asynchEc2Client.attachVolume(attachVolumeRequest); RebootInstancesRequest rebootInstancesRequest = new RebootInstancesRequest(); rebootInstancesRequest.withInstanceIds(instanceId); asynchEc2Client.rebootInstances(rebootInstancesRequest); }
@Override public void reboot(List<VMInformation> instances) { List<String> instanceIds = new ArrayList<String>(instances.size()); for (VMInformation instance : instances) { instanceIds.add(instance.getInstanceId()); } asynchEc2Client.rebootInstancesAsync(new RebootInstancesRequest(instanceIds)); // ec2Interface.rebootInstances(instanceIds); }
public void reboot() { com.amazonaws.services.ec2.AmazonEC2 client = AmazonEC2.connect(); RebootInstancesRequest req = new RebootInstancesRequest(); List<String> instanceIds = new ArrayList<String>(); instanceIds.add(id); req.setInstanceIds(instanceIds); client.rebootInstances(req); }
public void restartMachine(IMachine machine) throws InvalidObjectException, ConnectorException { try { getConnector(machine.getImage(), machine.getComputeCenter(), controllerServices). rebootInstances(new RebootInstancesRequest(Lists.newArrayList(machine.getName()))); } catch (Exception e) { throw new ConnectorException("Machine restart failed: " + machine.getName(), e); } }
@Override public void rebootInstances(RebootInstancesRequest rebootInstancesRequest) throws AmazonServiceException, AmazonClientException { throw new UnsupportedOperationException("Not supported in mock"); }
@Override public RebootInstancesResult rebootInstances(RebootInstancesRequest rebootInstancesRequest) { return new RebootInstancesResult(); }
@Override public void reboot(RebootInstancesRequest request) { reboot(request, null); }
@Override public void reboot(RebootInstancesRequest request, ResultCapture<Void> extractor) { resource.performAction("Reboot", request, extractor); }
@Override public void reboot(ResultCapture<Void> extractor) { RebootInstancesRequest request = new RebootInstancesRequest(); reboot(request, extractor); }
/** * Reboots the EC2 instance with the given ID * @param instanceId - EC2 instance ID */ public void rebootEc2Instance(final String instanceId) { final RebootInstancesRequest request = new RebootInstancesRequest().withInstanceIds(instanceId); ec2Client.rebootInstances(request); }
/** * Performs the <code>Reboot</code> action. * * <p> * The following request parameters will be populated from the data of this * <code>Instance</code> resource, and any conflicting parameter value set * in the request will be overridden: * <ul> * <li> * <b><code>InstanceIds.0</code></b> * - mapped from the <code>Id</code> identifier. * </li> * </ul> * * <p> * * @see RebootInstancesRequest */ void reboot(RebootInstancesRequest request);
/** * Performs the <code>Reboot</code> action and use a ResultCapture to * retrieve the low-level client response. * * <p> * The following request parameters will be populated from the data of this * <code>Instance</code> resource, and any conflicting parameter value set * in the request will be overridden: * <ul> * <li> * <b><code>InstanceIds.0</code></b> * - mapped from the <code>Id</code> identifier. * </li> * </ul> * * <p> * * @see RebootInstancesRequest */ void reboot(RebootInstancesRequest request, ResultCapture<Void> extractor);