public function rebootAction($serverId)
{
$server = $this->getServer($serverId);
$this->checkPermissions($server, Acl::PERM_FARMS_SERVERS);
if (in_array($server->status, [Server::STATUS_TERMINATED, Server::STATUS_IMPORTING, Server::STATUS_PENDING_LAUNCH, Server::STATUS_PENDING_TERMINATE, Server::STATUS_TEMPORARY])) {
throw new ApiErrorException(409, ErrorMessage::ERR_UNACCEPTABLE_STATE, sprintf("The Server can't be rebooted in %s state.", $server->status));
}
if ($server->platform == SERVER_PLATFORMS::AZURE) {
throw new ApiNotImplementedErrorException('Reboot action has not been implemented for Azure cloud platform yet.');
}
$object = $this->request->getJsonBody();
$hard = isset($object->hard) ? ServerAdapter::convertInputValue('boolean', $object->hard) : false;
try {
$server->reboot($hard);
} catch (InstanceNotFound $e) {
throw new ApiErrorException(409, ErrorMessage::ERR_OBJECT_NOT_FOUND_ON_CLOUD, "The Server that you are trying to use does not exist on the cloud.");
} catch (Exception $e) {
throw new ApiErrorException(409, ErrorMessage::ERR_UNACCEPTABLE_OBJECT_CONFIGURATION, $e->getMessage());
}
$this->response->setStatus(200);
return $this->result($this->adapter('server')->toData($server));
}