mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 00:34:44 +02:00
add alias for node sftp address
This commit is contained in:
parent
33f10cbcb9
commit
8f2261f6cd
@ -25,6 +25,7 @@ class MakeNodeCommand extends Command
|
||||
{--uploadSize= : Enter the maximum upload filesize.}
|
||||
{--daemonListeningPort= : Enter the daemon listening port.}
|
||||
{--daemonSFTPPort= : Enter the daemon SFTP listening port.}
|
||||
{--daemonSFTPAlias= : Enter the daemon SFTP alias.}
|
||||
{--daemonBase= : Enter the base folder.}';
|
||||
|
||||
protected $description = 'Creates a new node on the system via the CLI.';
|
||||
@ -65,6 +66,7 @@ class MakeNodeCommand extends Command
|
||||
$data['upload_size'] = $this->option('uploadSize') ?? $this->ask(__('commands.make_node.upload_size'), '100');
|
||||
$data['daemon_listen'] = $this->option('daemonListeningPort') ?? $this->ask(__('commands.make_node.daemonListen'), '8080');
|
||||
$data['daemon_sftp'] = $this->option('daemonSFTPPort') ?? $this->ask(__('commands.make_node.daemonSFTP'), '2022');
|
||||
$data['daemon_sftp_alias'] = $this->option('daemonSFTPAlias') ?? $this->ask(__('commands.make_node.daemonSFTPAlias'), '');
|
||||
$data['daemon_base'] = $this->option('daemonBase') ?? $this->ask(__('commands.make_node.daemonBase'), '/var/lib/pelican/volumes');
|
||||
|
||||
$node = $this->creationService->handle($data);
|
||||
|
@ -215,6 +215,18 @@ class EditNode extends EditRecord
|
||||
->minValue(1)
|
||||
->maxValue(1024)
|
||||
->suffix('MiB'),
|
||||
Forms\Components\TextInput::make('daemon_sftp')
|
||||
->columnSpan(['default' => 1, 'sm' => 1, 'md' => 1, 'lg' => 3])
|
||||
->label('SFTP Port')
|
||||
->minValue(0)
|
||||
->maxValue(65536)
|
||||
->default(2022)
|
||||
->required()
|
||||
->integer(),
|
||||
Forms\Components\TextInput::make('daemon_sftp_alias')
|
||||
->columnSpan(['default' => 1, 'sm' => 1, 'md' => 1, 'lg' => 3])
|
||||
->label('SFTP Alias')
|
||||
->helperText('Display alias for the SFTP address. Leave empty to use the Node FQDN.'),
|
||||
Forms\Components\ToggleButtons::make('public')
|
||||
->columnSpan(['default' => 1, 'sm' => 1, 'md' => 1, 'lg' => 3])
|
||||
->label('Automatic Allocation')->inline()
|
||||
|
@ -33,10 +33,9 @@ class StoreNodeRequest extends ApplicationApiRequest
|
||||
'upload_size',
|
||||
'daemon_listen',
|
||||
'daemon_sftp',
|
||||
'daemon_sftp_alias',
|
||||
'daemon_base',
|
||||
])->mapWithKeys(function ($value, $key) {
|
||||
$key = ($key === 'daemon_sftp') ? 'daemon_sftp' : $key;
|
||||
|
||||
return [snake_case($key) => $value];
|
||||
})->toArray();
|
||||
}
|
||||
@ -60,12 +59,8 @@ class StoreNodeRequest extends ApplicationApiRequest
|
||||
public function validated($key = null, $default = null): array
|
||||
{
|
||||
$response = parent::validated();
|
||||
$response['daemon_listen'] = $response['daemon_listen'];
|
||||
$response['daemon_sftp'] = $response['daemon_sftp'];
|
||||
$response['daemon_base'] = $response['daemon_base'] ?? (new Node())->getAttribute('daemon_base');
|
||||
|
||||
unset($response['daemon_base'], $response['daemon_listen'], $response['daemon_sftp']);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
* @property string $daemon_token
|
||||
* @property int $daemon_listen
|
||||
* @property int $daemon_sftp
|
||||
* @property string|null $daemon_sftp_alias
|
||||
* @property string $daemon_base
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
@ -72,7 +73,7 @@ class Node extends Model
|
||||
'memory', 'memory_overallocate', 'disk',
|
||||
'disk_overallocate', 'cpu', 'cpu_overallocate',
|
||||
'upload_size', 'daemon_base',
|
||||
'daemon_sftp', 'daemon_listen',
|
||||
'daemon_sftp', 'daemon_sftp_alias', 'daemon_listen',
|
||||
'description', 'maintenance_mode',
|
||||
];
|
||||
|
||||
@ -91,6 +92,7 @@ class Node extends Model
|
||||
'cpu_overallocate' => 'required|numeric|min:-1',
|
||||
'daemon_base' => 'sometimes|required|regex:/^([\/][\d\w.\-\/]+)$/',
|
||||
'daemon_sftp' => 'required|numeric|between:1,65535',
|
||||
'daemon_sftp_alias' => 'nullable|string',
|
||||
'daemon_listen' => 'required|numeric|between:1,65535',
|
||||
'maintenance_mode' => 'boolean',
|
||||
'upload_size' => 'int|between:1,1024',
|
||||
|
@ -46,6 +46,7 @@ class ServerTransformer extends BaseClientTransformer
|
||||
'is_node_under_maintenance' => $server->node->isUnderMaintenance(),
|
||||
'sftp_details' => [
|
||||
'ip' => $server->node->fqdn,
|
||||
'alias' => $server->node->daemon_sftp_alias,
|
||||
'port' => $server->node->daemon_sftp,
|
||||
],
|
||||
'description' => $server->description,
|
||||
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('nodes', function (Blueprint $table) {
|
||||
$table->text('daemon_sftp_alias')->nullable()->after('daemon_sftp');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('nodes', function (Blueprint $table) {
|
||||
$table->dropColumn('daemon_sftp_alias');
|
||||
});
|
||||
}
|
||||
};
|
@ -37,6 +37,7 @@ return [
|
||||
'upload_size' => "'Enter the maximum filesize upload",
|
||||
'daemonListen' => 'Enter the daemon listening port',
|
||||
'daemonSFTP' => 'Enter the daemon SFTP listening port',
|
||||
'daemonSFTPAlias' => 'Enter the daemon SFTP alias (can be empty)',
|
||||
'daemonBase' => 'Enter the base folder',
|
||||
'succes1' => 'Successfully created a new node with the name: ',
|
||||
'succes2' => 'and has an id of: ',
|
||||
|
@ -21,6 +21,7 @@ export interface Server {
|
||||
status: ServerStatus;
|
||||
sftpDetails: {
|
||||
ip: string;
|
||||
alias: string;
|
||||
port: number;
|
||||
};
|
||||
invocation: string;
|
||||
@ -57,6 +58,7 @@ export const rawDataToServerObject = ({ attributes: data }: FractalResponseData)
|
||||
dockerImage: data.docker_image,
|
||||
sftpDetails: {
|
||||
ip: data.sftp_details.ip,
|
||||
alias: data.sftp_details.alias,
|
||||
port: data.sftp_details.port,
|
||||
},
|
||||
description: data.description ? (data.description.length > 0 ? data.description : null) : null,
|
||||
|
@ -31,8 +31,12 @@ export default () => {
|
||||
<TitledGreyBox title={'SFTP Details'} css={tw`mb-6 md:mb-10`}>
|
||||
<div>
|
||||
<Label>Server Address</Label>
|
||||
<CopyOnClick text={`sftp://${ip(sftp.ip)}:${sftp.port}`}>
|
||||
<Input type={'text'} value={`sftp://${ip(sftp.ip)}:${sftp.port}`} readOnly />
|
||||
<CopyOnClick text={`sftp://${sftp.alias ? sftp.alias : ip(sftp.ip)}:${sftp.port}`}>
|
||||
<Input
|
||||
type={'text'}
|
||||
value={`sftp://${sftp.alias ? sftp.alias : ip(sftp.ip)}:${sftp.port}`}
|
||||
readOnly
|
||||
/>
|
||||
</CopyOnClick>
|
||||
</div>
|
||||
<div css={tw`mt-6`}>
|
||||
@ -50,7 +54,10 @@ export default () => {
|
||||
</div>
|
||||
</div>
|
||||
<div css={tw`ml-4`}>
|
||||
<a href={`sftp://${username}.${id}@${ip(sftp.ip)}:${sftp.port}`}>
|
||||
<a
|
||||
href={`sftp://${username}.${id}@${sftp.alias ? sftp.alias : ip(sftp.ip)}:${sftp.port
|
||||
}`}
|
||||
>
|
||||
<Button.Text variant={Button.Variants.Secondary}>Launch SFTP</Button.Text>
|
||||
</a>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user