Files
Virtnet.bond/extensions/Servers/Proxmox/Admin/Resources/LocationResource.php
Joseph.Rawlings ef1499cde4 fix: OS template type matching for LXC/KVM nodes
- Add is_lxc column to ext_proxmox_oses for tracking template type
- OS model now has vmType() helper returning 'lxc' or 'qemu'
- Install uses OS template's type for clone API path (not node type)
- createServer validates OS type matches node type before provisioning
- calculateNode filters nodes by LXC/KVM type based on selected OS
- Reinstall OS list filtered to only show matching template types
- Admin location OS repeater now has LXC Template checkbox
2026-03-02 21:23:10 -05:00

127 lines
5.1 KiB
PHP

<?php
namespace Paymenter\Extensions\Servers\Proxmox\Admin\Resources;
use Filament\Forms;
use Filament\Forms\Components\Tabs;
use Filament\Forms\Form;
use Filament\Forms\Get;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Validation\Rules\Unique;
use Paymenter\Extensions\Servers\Proxmox\Admin\Resources\LocationResource\Pages;
use Paymenter\Extensions\Servers\Proxmox\Models\Location;
class LocationResource extends Resource
{
protected static ?string $model = Location::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Proxmox';
protected static ?string $label = 'Location';
protected static ?string $slug = 'proxmox-locations';
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('name')
->label('Name')
->required()
->maxLength(255)
->unique(ignoreRecord: true)
->live(onBlur: true),
Forms\Components\Select::make('server_placement')
->label('Server Placement')
->options([
'random' => 'Random Node',
'fill' => 'Fill Nodes (fill each node before moving to the next)',
'least_loaded_server' => 'Least Loaded Node (based on server count)',
'least_loaded_ram' => 'Least Loaded Node (based on RAM)',
'least_loaded_disk' => 'Least Loaded Node (based on disk)',
'least_loaded_cpu' => 'Least Loaded Node (based on CPU)',
])
->default('least_loaded_server')
->helperText('The settings based on CPU, RAM, and disk must be configured in the node settings.')
->required()
->reactive(),
Tabs::make('Tabs')
->persistTabInQueryString()
->columnSpanFull()
->tabs([
Tabs\Tab::make('OS')
->columns(2)
->schema([
Forms\Components\Repeater::make('os')
->relationship('os')
->hiddenLabel()
->disabled(fn (Get $get) => !$get('name'))
->addActionLabel('Add OS')
->schema([
Forms\Components\TextInput::make('name')
->label('Name')
->required()
->maxLength(255)
->placeholder('Enter the name of the OS'),
Forms\Components\TextInput::make('vm_id')
->label('VM ID')
->required()
->numeric()
->unique(ignoreRecord: true, modifyRuleUsing: function (Unique $rule, Get $get, $record) {
return $rule->where('location_id', $get('../../id'));
})
->placeholder('Enter the VM ID'),
Forms\Components\Checkbox::make('is_lxc')
->label('LXC Template')
->default(false)
->helperText('Check if this is an LXC container template (not KVM)'),
])
->cloneable()
->columns(3)
->columnSpanFull(),
]),
]),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('name')->sortable()->searchable(),
Tables\Columns\TextColumn::make('nodes_count')
->label('Nodes')
->sortable()
->searchable()
->counts('nodes')
->formatStateUsing(fn ($state) => $state ?: '0'),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListLocations::route('/'),
'create' => Pages\CreateLocation::route('/create'),
'edit' => Pages\EditLocation::route('/{record}/edit'),
];
}
}