2015-12-06 18:58:49 +00:00
|
|
|
<?php
|
2016-12-07 22:46:38 +00:00
|
|
|
|
2015-12-06 18:58:49 +00:00
|
|
|
namespace Pterodactyl\Models;
|
|
|
|
|
2022-11-06 03:04:54 +00:00
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
use Illuminate\Database\Eloquent\Collection;
|
2017-01-25 00:15:03 +00:00
|
|
|
use Illuminate\Notifications\Notifiable;
|
2020-08-23 15:45:39 +00:00
|
|
|
use Illuminate\Database\Query\JoinClause;
|
2022-11-06 03:04:54 +00:00
|
|
|
use Illuminate\Support\Carbon;
|
2017-09-24 01:45:25 +00:00
|
|
|
use Znck\Eloquent\Traits\BelongsToThrough;
|
2022-10-14 16:59:20 +00:00
|
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
2022-05-29 20:19:04 +00:00
|
|
|
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
2022-10-14 16:59:20 +00:00
|
|
|
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
2021-01-30 21:28:31 +00:00
|
|
|
use Pterodactyl\Exceptions\Http\Server\ServerStateConflictException;
|
2015-12-06 18:58:49 +00:00
|
|
|
|
2019-08-17 23:03:10 +00:00
|
|
|
/**
|
2022-05-29 22:20:54 +00:00
|
|
|
* \Pterodactyl\Models\Server.
|
2022-05-22 18:10:01 +00:00
|
|
|
*
|
2021-01-28 04:52:11 +00:00
|
|
|
* @property int $id
|
|
|
|
* @property string|null $external_id
|
|
|
|
* @property string $uuid
|
|
|
|
* @property string $uuidShort
|
|
|
|
* @property int $node_id
|
|
|
|
* @property string $name
|
|
|
|
* @property string $description
|
2021-01-30 18:10:29 +00:00
|
|
|
* @property string|null $status
|
2021-01-28 04:52:11 +00:00
|
|
|
* @property bool $skip_scripts
|
|
|
|
* @property int $owner_id
|
|
|
|
* @property int $memory
|
|
|
|
* @property int $swap
|
|
|
|
* @property int $disk
|
|
|
|
* @property int $io
|
|
|
|
* @property int $cpu
|
2022-05-22 18:10:01 +00:00
|
|
|
* @property string|null $threads
|
2021-01-28 04:52:11 +00:00
|
|
|
* @property bool $oom_disabled
|
|
|
|
* @property int $allocation_id
|
|
|
|
* @property int $nest_id
|
|
|
|
* @property int $egg_id
|
|
|
|
* @property string $startup
|
|
|
|
* @property string $image
|
2022-05-22 18:10:01 +00:00
|
|
|
* @property int|null $allocation_limit
|
|
|
|
* @property int|null $database_limit
|
2021-01-28 04:52:11 +00:00
|
|
|
* @property int $backup_limit
|
2022-11-06 03:04:54 +00:00
|
|
|
* @property Carbon|null $created_at
|
|
|
|
* @property Carbon|null $updated_at
|
|
|
|
* @property Carbon|null $installed_at
|
|
|
|
* @property Collection|ActivityLog[] $activity
|
2022-05-29 22:20:54 +00:00
|
|
|
* @property int|null $activity_count
|
2022-11-06 03:04:54 +00:00
|
|
|
* @property Allocation|null $allocation
|
|
|
|
* @property Collection|Allocation[] $allocations
|
2022-05-22 18:10:01 +00:00
|
|
|
* @property int|null $allocations_count
|
2022-11-06 03:04:54 +00:00
|
|
|
* @property Collection|Backup[] $backups
|
2022-05-22 18:10:01 +00:00
|
|
|
* @property int|null $backups_count
|
2022-11-06 03:04:54 +00:00
|
|
|
* @property Collection|Database[] $databases
|
2022-05-22 18:10:01 +00:00
|
|
|
* @property int|null $databases_count
|
2022-11-06 03:04:54 +00:00
|
|
|
* @property Egg|null $egg
|
|
|
|
* @property Collection|Mount[] $mounts
|
2022-05-22 18:10:01 +00:00
|
|
|
* @property int|null $mounts_count
|
2022-11-06 03:04:54 +00:00
|
|
|
* @property Nest $nest
|
|
|
|
* @property Node $node
|
2022-05-22 18:10:01 +00:00
|
|
|
* @property \Illuminate\Notifications\DatabaseNotificationCollection|\Illuminate\Notifications\DatabaseNotification[] $notifications
|
|
|
|
* @property int|null $notifications_count
|
2022-11-06 03:04:54 +00:00
|
|
|
* @property Collection|Schedule[] $schedules
|
2022-05-22 18:10:01 +00:00
|
|
|
* @property int|null $schedules_count
|
2022-11-06 03:04:54 +00:00
|
|
|
* @property Collection|Subuser[] $subusers
|
2022-05-22 18:10:01 +00:00
|
|
|
* @property int|null $subusers_count
|
2022-11-06 03:04:54 +00:00
|
|
|
* @property ServerTransfer|null $transfer
|
|
|
|
* @property User $user
|
|
|
|
* @property Collection|EggVariable[] $variables
|
2022-05-22 18:10:01 +00:00
|
|
|
* @property int|null $variables_count
|
|
|
|
*
|
|
|
|
* @method static \Database\Factories\ServerFactory factory(...$parameters)
|
2022-11-06 03:04:54 +00:00
|
|
|
* @method static Builder|Server newModelQuery()
|
|
|
|
* @method static Builder|Server newQuery()
|
|
|
|
* @method static Builder|Server query()
|
|
|
|
* @method static Builder|Server whereAllocationId($value)
|
|
|
|
* @method static Builder|Server whereAllocationLimit($value)
|
|
|
|
* @method static Builder|Server whereBackupLimit($value)
|
|
|
|
* @method static Builder|Server whereCpu($value)
|
|
|
|
* @method static Builder|Server whereCreatedAt($value)
|
|
|
|
* @method static Builder|Server whereDatabaseLimit($value)
|
|
|
|
* @method static Builder|Server whereDescription($value)
|
|
|
|
* @method static Builder|Server whereDisk($value)
|
|
|
|
* @method static Builder|Server whereEggId($value)
|
|
|
|
* @method static Builder|Server whereExternalId($value)
|
|
|
|
* @method static Builder|Server whereId($value)
|
|
|
|
* @method static Builder|Server whereImage($value)
|
|
|
|
* @method static Builder|Server whereIo($value)
|
|
|
|
* @method static Builder|Server whereMemory($value)
|
|
|
|
* @method static Builder|Server whereName($value)
|
|
|
|
* @method static Builder|Server whereNestId($value)
|
|
|
|
* @method static Builder|Server whereNodeId($value)
|
|
|
|
* @method static Builder|Server whereOomDisabled($value)
|
|
|
|
* @method static Builder|Server whereOwnerId($value)
|
|
|
|
* @method static Builder|Server whereSkipScripts($value)
|
|
|
|
* @method static Builder|Server whereStartup($value)
|
|
|
|
* @method static Builder|Server whereStatus($value)
|
|
|
|
* @method static Builder|Server whereSwap($value)
|
|
|
|
* @method static Builder|Server whereThreads($value)
|
|
|
|
* @method static Builder|Server whereUpdatedAt($value)
|
|
|
|
* @method static Builder|Server whereUuid($value)
|
|
|
|
* @method static Builder|Server whereUuidShort($value)
|
2022-10-14 16:59:20 +00:00
|
|
|
*
|
2022-05-22 18:10:01 +00:00
|
|
|
* @mixin \Eloquent
|
2019-08-17 23:03:10 +00:00
|
|
|
*/
|
2020-04-04 06:22:35 +00:00
|
|
|
class Server extends Model
|
2015-12-06 18:58:49 +00:00
|
|
|
{
|
2020-04-04 06:22:35 +00:00
|
|
|
use BelongsToThrough;
|
|
|
|
use Notifiable;
|
2016-10-28 00:05:29 +00:00
|
|
|
|
2018-01-20 03:47:06 +00:00
|
|
|
/**
|
|
|
|
* The resource name for this model when it is transformed into an
|
|
|
|
* API representation using fractal.
|
|
|
|
*/
|
2021-01-23 20:33:34 +00:00
|
|
|
public const RESOURCE_NAME = 'server';
|
2018-01-20 03:47:06 +00:00
|
|
|
|
2021-01-26 03:20:51 +00:00
|
|
|
public const STATUS_INSTALLING = 'installing';
|
|
|
|
public const STATUS_INSTALL_FAILED = 'install_failed';
|
|
|
|
public const STATUS_SUSPENDED = 'suspended';
|
|
|
|
public const STATUS_RESTORING_BACKUP = 'restoring_backup';
|
2020-04-03 20:46:45 +00:00
|
|
|
|
2015-12-06 18:58:49 +00:00
|
|
|
/**
|
|
|
|
* The table associated with the model.
|
|
|
|
*/
|
|
|
|
protected $table = 'servers';
|
|
|
|
|
2019-08-03 20:41:24 +00:00
|
|
|
/**
|
|
|
|
* Default values when creating the model. We want to switch to disabling OOM killer
|
|
|
|
* on server instances unless the user specifies otherwise in the request.
|
|
|
|
*/
|
|
|
|
protected $attributes = [
|
2021-01-17 23:51:56 +00:00
|
|
|
'status' => self::STATUS_INSTALLING,
|
2019-08-03 20:41:24 +00:00
|
|
|
'oom_disabled' => true,
|
2022-09-25 19:16:58 +00:00
|
|
|
'installed_at' => null,
|
2019-08-03 20:41:24 +00:00
|
|
|
];
|
|
|
|
|
2020-10-31 18:14:28 +00:00
|
|
|
/**
|
|
|
|
* The default relationships to load for all server models.
|
|
|
|
*/
|
|
|
|
protected $with = ['allocation'];
|
|
|
|
|
2016-10-28 00:05:29 +00:00
|
|
|
/**
|
|
|
|
* The attributes that should be mutated to dates.
|
|
|
|
*/
|
2022-09-25 19:16:58 +00:00
|
|
|
protected $dates = [self::CREATED_AT, self::UPDATED_AT, 'deleted_at', 'installed_at'];
|
2015-12-06 18:58:49 +00:00
|
|
|
|
2015-12-15 20:08:41 +00:00
|
|
|
/**
|
|
|
|
* Fields that are not mass assignable.
|
|
|
|
*/
|
2022-09-25 19:16:58 +00:00
|
|
|
protected $guarded = ['id', self::CREATED_AT, self::UPDATED_AT, 'deleted_at', 'installed_at'];
|
2015-12-15 20:08:41 +00:00
|
|
|
|
2022-10-14 16:59:20 +00:00
|
|
|
public static array $validationRules = [
|
2019-09-05 05:19:57 +00:00
|
|
|
'external_id' => 'sometimes|nullable|string|between:1,191|unique:servers',
|
|
|
|
'owner_id' => 'required|integer|exists:users,id',
|
2020-09-26 23:29:26 +00:00
|
|
|
'name' => 'required|string|min:1|max:191',
|
2019-09-05 05:19:57 +00:00
|
|
|
'node_id' => 'required|exists:nodes,id',
|
2018-01-01 18:23:45 +00:00
|
|
|
'description' => 'string',
|
2021-01-17 23:51:56 +00:00
|
|
|
'status' => 'nullable|string',
|
2019-09-05 05:19:57 +00:00
|
|
|
'memory' => 'required|numeric|min:0',
|
|
|
|
'swap' => 'required|numeric|min:-1',
|
|
|
|
'io' => 'required|numeric|between:10,1000',
|
|
|
|
'cpu' => 'required|numeric|min:0',
|
2020-04-04 00:59:47 +00:00
|
|
|
'threads' => 'nullable|regex:/^[0-9-,]+$/',
|
2019-09-05 05:19:57 +00:00
|
|
|
'oom_disabled' => 'sometimes|boolean',
|
|
|
|
'disk' => 'required|numeric|min:0',
|
|
|
|
'allocation_id' => 'required|bail|unique:servers|exists:allocations,id',
|
|
|
|
'nest_id' => 'required|exists:nests,id',
|
|
|
|
'egg_id' => 'required|exists:eggs,id',
|
|
|
|
'startup' => 'required|string',
|
|
|
|
'skip_scripts' => 'sometimes|boolean',
|
2020-09-26 23:29:26 +00:00
|
|
|
'image' => 'required|string|max:191',
|
2019-09-05 05:19:57 +00:00
|
|
|
'database_limit' => 'present|nullable|integer|min:0',
|
|
|
|
'allocation_limit' => 'sometimes|nullable|integer|min:0',
|
2020-10-17 21:23:00 +00:00
|
|
|
'backup_limit' => 'present|nullable|integer|min:0',
|
2017-07-20 01:49:41 +00:00
|
|
|
];
|
|
|
|
|
2017-03-15 01:18:36 +00:00
|
|
|
/**
|
|
|
|
* Cast values to correct type.
|
|
|
|
*/
|
|
|
|
protected $casts = [
|
|
|
|
'node_id' => 'integer',
|
2017-04-21 21:52:44 +00:00
|
|
|
'skip_scripts' => 'boolean',
|
2017-03-15 01:18:36 +00:00
|
|
|
'owner_id' => 'integer',
|
|
|
|
'memory' => 'integer',
|
|
|
|
'swap' => 'integer',
|
|
|
|
'disk' => 'integer',
|
|
|
|
'io' => 'integer',
|
|
|
|
'cpu' => 'integer',
|
2019-08-03 20:41:24 +00:00
|
|
|
'oom_disabled' => 'boolean',
|
2017-03-15 01:18:36 +00:00
|
|
|
'allocation_id' => 'integer',
|
2017-10-07 04:57:53 +00:00
|
|
|
'nest_id' => 'integer',
|
|
|
|
'egg_id' => 'integer',
|
2018-03-02 02:08:27 +00:00
|
|
|
'database_limit' => 'integer',
|
|
|
|
'allocation_limit' => 'integer',
|
2020-04-26 19:12:29 +00:00
|
|
|
'backup_limit' => 'integer',
|
2017-03-15 01:18:36 +00:00
|
|
|
];
|
2016-01-27 03:17:51 +00:00
|
|
|
|
2019-11-24 23:08:54 +00:00
|
|
|
/**
|
|
|
|
* Returns the format for server allocations when communicating with the Daemon.
|
|
|
|
*/
|
|
|
|
public function getAllocationMappings(): array
|
|
|
|
{
|
2020-04-04 22:16:18 +00:00
|
|
|
return $this->allocations->where('node_id', $this->node_id)->groupBy('ip')->map(function ($item) {
|
2019-11-24 23:08:54 +00:00
|
|
|
return $item->pluck('port');
|
|
|
|
})->toArray();
|
|
|
|
}
|
|
|
|
|
2018-08-25 22:07:42 +00:00
|
|
|
public function isInstalled(): bool
|
|
|
|
{
|
2021-01-17 23:51:56 +00:00
|
|
|
return $this->status !== self::STATUS_INSTALLING && $this->status !== self::STATUS_INSTALL_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isSuspended(): bool
|
|
|
|
{
|
|
|
|
return $this->status === self::STATUS_SUSPENDED;
|
2018-08-25 22:07:42 +00:00
|
|
|
}
|
|
|
|
|
2017-02-03 21:50:28 +00:00
|
|
|
/**
|
|
|
|
* Gets the user who owns the server.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function user(): BelongsTo
|
2017-02-03 21:50:28 +00:00
|
|
|
{
|
2017-02-05 23:00:39 +00:00
|
|
|
return $this->belongsTo(User::class, 'owner_id');
|
2017-02-03 21:50:28 +00:00
|
|
|
}
|
|
|
|
|
2017-02-10 00:38:54 +00:00
|
|
|
/**
|
|
|
|
* Gets the subusers associated with a server.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function subusers(): HasMany
|
2017-02-10 00:38:54 +00:00
|
|
|
{
|
2019-12-28 19:39:44 +00:00
|
|
|
return $this->hasMany(Subuser::class, 'server_id', 'id');
|
2017-02-10 00:38:54 +00:00
|
|
|
}
|
|
|
|
|
2017-02-06 00:19:46 +00:00
|
|
|
/**
|
|
|
|
* Gets the default allocation for a server.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function allocation(): HasOne
|
2017-02-06 00:19:46 +00:00
|
|
|
{
|
|
|
|
return $this->hasOne(Allocation::class, 'id', 'allocation_id');
|
|
|
|
}
|
|
|
|
|
2017-02-02 21:24:08 +00:00
|
|
|
/**
|
|
|
|
* Gets all allocations associated with this server.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function allocations(): HasMany
|
2017-02-02 21:24:08 +00:00
|
|
|
{
|
2017-02-03 21:50:28 +00:00
|
|
|
return $this->hasMany(Allocation::class, 'server_id');
|
2017-02-02 21:24:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-10-07 04:57:53 +00:00
|
|
|
* Gets information for the nest associated with this server.
|
2017-02-02 21:24:08 +00:00
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function nest(): BelongsTo
|
2017-02-02 21:24:08 +00:00
|
|
|
{
|
2017-10-07 04:57:53 +00:00
|
|
|
return $this->belongsTo(Nest::class);
|
2017-02-02 21:24:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-10-07 04:57:53 +00:00
|
|
|
* Gets information for the egg associated with this server.
|
2017-02-02 21:24:08 +00:00
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function egg(): HasOne
|
2017-02-02 21:24:08 +00:00
|
|
|
{
|
2020-01-18 23:26:15 +00:00
|
|
|
return $this->hasOne(Egg::class, 'id', 'egg_id');
|
2017-02-02 21:24:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets information for the service variables associated with this server.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function variables(): HasMany
|
2017-02-02 21:24:08 +00:00
|
|
|
{
|
2020-08-22 22:43:28 +00:00
|
|
|
return $this->hasMany(EggVariable::class, 'egg_id', 'egg_id')
|
|
|
|
->select(['egg_variables.*', 'server_variables.variable_value as server_value'])
|
2020-08-23 15:45:39 +00:00
|
|
|
->leftJoin('server_variables', function (JoinClause $join) {
|
|
|
|
// Don't forget to join against the server ID as well since the way we're using this relationship
|
2022-10-14 16:59:20 +00:00
|
|
|
// would actually return all the variables and their values for _all_ servers using that egg,
|
2020-08-23 15:45:39 +00:00
|
|
|
// rather than only the server for this model.
|
|
|
|
//
|
|
|
|
// @see https://github.com/pterodactyl/panel/issues/2250
|
|
|
|
$join->on('server_variables.variable_id', 'egg_variables.id')
|
|
|
|
->where('server_variables.server_id', $this->id);
|
|
|
|
});
|
2017-02-02 21:24:08 +00:00
|
|
|
}
|
2017-02-02 23:21:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets information for the node associated with this server.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function node(): BelongsTo
|
2017-02-02 23:21:36 +00:00
|
|
|
{
|
2017-02-05 23:00:39 +00:00
|
|
|
return $this->belongsTo(Node::class);
|
2017-02-02 23:21:36 +00:00
|
|
|
}
|
2017-02-03 00:41:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets information for the tasks associated with this server.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function schedules(): HasMany
|
2017-02-03 00:41:38 +00:00
|
|
|
{
|
2017-09-24 01:45:25 +00:00
|
|
|
return $this->hasMany(Schedule::class);
|
2017-02-03 00:41:38 +00:00
|
|
|
}
|
2017-02-09 22:43:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets all databases associated with a server.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function databases(): HasMany
|
2017-02-09 22:43:54 +00:00
|
|
|
{
|
|
|
|
return $this->hasMany(Database::class);
|
|
|
|
}
|
2017-04-08 00:28:58 +00:00
|
|
|
|
|
|
|
/**
|
2017-09-24 01:45:25 +00:00
|
|
|
* Returns the location that a server belongs to.
|
2017-04-08 00:28:58 +00:00
|
|
|
*
|
2017-09-24 01:45:25 +00:00
|
|
|
* @throws \Exception
|
2017-04-08 00:28:58 +00:00
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function location(): \Znck\Eloquent\Relations\BelongsToThrough
|
2017-04-08 00:28:58 +00:00
|
|
|
{
|
2017-09-24 01:45:25 +00:00
|
|
|
return $this->belongsToThrough(Location::class, Node::class);
|
|
|
|
}
|
|
|
|
|
2020-04-04 20:10:18 +00:00
|
|
|
/**
|
2020-04-04 22:28:02 +00:00
|
|
|
* Returns the associated server transfer.
|
2020-04-04 20:10:18 +00:00
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function transfer(): HasOne
|
2020-04-04 20:10:18 +00:00
|
|
|
{
|
2020-12-16 16:34:47 +00:00
|
|
|
return $this->hasOne(ServerTransfer::class)->whereNull('successful')->orderByDesc('id');
|
2020-04-04 20:10:18 +00:00
|
|
|
}
|
2020-04-04 22:28:02 +00:00
|
|
|
|
2022-10-14 16:59:20 +00:00
|
|
|
public function backups(): HasMany
|
2020-04-04 17:59:25 +00:00
|
|
|
{
|
|
|
|
return $this->hasMany(Backup::class);
|
|
|
|
}
|
2020-05-21 20:23:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns all mounts that have this server has mounted.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function mounts(): HasManyThrough
|
2020-05-21 20:23:12 +00:00
|
|
|
{
|
2020-09-13 16:59:54 +00:00
|
|
|
return $this->hasManyThrough(Mount::class, MountServer::class, 'server_id', 'id', 'id', 'mount_id');
|
2020-05-21 20:23:12 +00:00
|
|
|
}
|
2021-01-17 18:49:36 +00:00
|
|
|
|
|
|
|
/**
|
2022-05-29 20:19:04 +00:00
|
|
|
* Returns all of the activity log entries where the server is the subject.
|
2021-01-17 18:49:36 +00:00
|
|
|
*/
|
2022-05-29 20:19:04 +00:00
|
|
|
public function activity(): MorphToMany
|
2021-01-17 18:49:36 +00:00
|
|
|
{
|
2022-05-29 20:19:04 +00:00
|
|
|
return $this->morphToMany(ActivityLog::class, 'subject', 'activity_log_subjects');
|
2021-01-17 18:49:36 +00:00
|
|
|
}
|
2021-01-30 21:28:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the server is currently in a user-accessible state. If not, an
|
|
|
|
* exception is raised. This should be called whenever something needs to make
|
|
|
|
* sure the server is not in a weird state that should block user access.
|
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\Http\Server\ServerStateConflictException
|
|
|
|
*/
|
|
|
|
public function validateCurrentState()
|
|
|
|
{
|
|
|
|
if (
|
|
|
|
$this->isSuspended() ||
|
|
|
|
!$this->isInstalled() ||
|
|
|
|
$this->status === self::STATUS_RESTORING_BACKUP ||
|
|
|
|
!is_null($this->transfer)
|
|
|
|
) {
|
|
|
|
throw new ServerStateConflictException($this);
|
|
|
|
}
|
|
|
|
}
|
2022-10-05 01:57:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the server is currently in a transferable state. If not, an
|
|
|
|
* exception is raised. This should be called whenever something needs to make
|
|
|
|
* sure the server is able to be transferred and is not currently being transferred
|
|
|
|
* or installed.
|
|
|
|
*/
|
|
|
|
public function validateTransferState()
|
|
|
|
{
|
|
|
|
if (
|
|
|
|
!$this->isInstalled() ||
|
|
|
|
$this->status === self::STATUS_RESTORING_BACKUP ||
|
|
|
|
!is_null($this->transfer)
|
|
|
|
) {
|
|
|
|
throw new ServerStateConflictException($this);
|
|
|
|
}
|
|
|
|
}
|
2015-12-06 18:58:49 +00:00
|
|
|
}
|