throws CommandNotAllowedException, InvalidCredentialsException {
Preconditions.checkNotNull(inventoryItem, "inventoryItem cannot be null.");
Preconditions.checkArgument(inventoryItem.getType().equals(Constants.COMPUTE_INSTANCE_TYPE),
"Inventory item of type '" + inventoryItem.getType() + "' cannot be rebooted.");
AWSClient client = (AWSClient)getClient(inventoryItem.getConnection());
logger.debug("Rebooting node: " + inventoryItem.getExternalId());
BasicDBObject payload = getInventoryItemPayload(inventoryItem);
String jcloudsNodeId = payload.getString("id");
NodeMetadata nodeMetadata = client.getEC2Instance(jcloudsNodeId);
if (nodeMetadata.getStatus().equals(NodeMetadata.Status.TERMINATED)) {
throw new CommandNotAllowedException("You cannot reboot a terminated node.");
}
EventId eventId;
if (client.rebootEC2Instance(jcloudsNodeId)) {
eventId = EventId.CLOUD_INVENTORY_ITEM_REBOOT;
} else {
// TODO: Handle this issue but it can be a false positive if the time it takes surpasses the time we wait
eventId = EventId.CLOUD_INVENTORY_ITEM_REBOOT_FAILURE;
}