diff --git a/app/Console/Commands/Node/MakeNodeCommand.php b/app/Console/Commands/Node/MakeNodeCommand.php index b431e8b864..c57d4ee907 100644 --- a/app/Console/Commands/Node/MakeNodeCommand.php +++ b/app/Console/Commands/Node/MakeNodeCommand.php @@ -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 @@ public function handle(): void $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); diff --git a/app/Filament/Resources/NodeResource/Pages/EditNode.php b/app/Filament/Resources/NodeResource/Pages/EditNode.php index ca0ac657fe..b7236232dd 100644 --- a/app/Filament/Resources/NodeResource/Pages/EditNode.php +++ b/app/Filament/Resources/NodeResource/Pages/EditNode.php @@ -215,6 +215,18 @@ public function form(Forms\Form $form): Forms\Form ->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() diff --git a/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php b/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php index 36013cc192..c7166e9df2 100644 --- a/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php +++ b/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php @@ -33,10 +33,9 @@ public function rules(array $rules = null): array '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 @@ public function attributes(): array 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; } } diff --git a/app/Models/Node.php b/app/Models/Node.php index 65aeaa0ea5..7fa89f511f 100644 --- a/app/Models/Node.php +++ b/app/Models/Node.php @@ -33,6 +33,7 @@ * @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', diff --git a/app/Transformers/Api/Client/ServerTransformer.php b/app/Transformers/Api/Client/ServerTransformer.php index 686a8e237c..07cd64dbd2 100644 --- a/app/Transformers/Api/Client/ServerTransformer.php +++ b/app/Transformers/Api/Client/ServerTransformer.php @@ -46,6 +46,7 @@ public function transform(Server $server): array '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, diff --git a/database/migrations/2024_06_04_085042_add_daemon_sftp_alias_column_to_nodes.php b/database/migrations/2024_06_04_085042_add_daemon_sftp_alias_column_to_nodes.php new file mode 100644 index 0000000000..b4310ac7d1 --- /dev/null +++ b/database/migrations/2024_06_04_085042_add_daemon_sftp_alias_column_to_nodes.php @@ -0,0 +1,28 @@ +string('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'); + }); + } +}; diff --git a/lang/en/commands.php b/lang/en/commands.php index fe3448310e..ba0cc07235 100644 --- a/lang/en/commands.php +++ b/lang/en/commands.php @@ -37,6 +37,7 @@ '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: ', diff --git a/resources/scripts/api/server/getServer.ts b/resources/scripts/api/server/getServer.ts index d2aa2e0543..ff0abc026a 100644 --- a/resources/scripts/api/server/getServer.ts +++ b/resources/scripts/api/server/getServer.ts @@ -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, diff --git a/resources/scripts/components/server/settings/SettingsContainer.tsx b/resources/scripts/components/server/settings/SettingsContainer.tsx index bcdc80b8e0..2539727553 100644 --- a/resources/scripts/components/server/settings/SettingsContainer.tsx +++ b/resources/scripts/components/server/settings/SettingsContainer.tsx @@ -31,8 +31,12 @@ export default () => {
- - + +
@@ -50,7 +54,10 @@ export default () => {
- + Launch SFTP