63 lines
2.0 KiB
PHP
63 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\Host;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
|
class DatabaseSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Seed the application's database.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
// Never create a known-credential account outside local/testing.
|
|
if (! app()->environment('local', 'testing')) {
|
|
return;
|
|
}
|
|
|
|
User::updateOrCreate(
|
|
['email' => env('SEED_ADMIN_EMAIL', 'admin@clupilot.local')],
|
|
[
|
|
'name' => 'Admin',
|
|
'password' => Hash::make(env('SEED_ADMIN_PASSWORD', 'password')),
|
|
'is_admin' => true,
|
|
],
|
|
);
|
|
|
|
// A plain customer to exercise the portal (and prove the admin gate).
|
|
User::updateOrCreate(
|
|
['email' => 'kunde@clupilot.local'],
|
|
[
|
|
'name' => 'Dr. S. Berger',
|
|
'password' => Hash::make(env('SEED_ADMIN_PASSWORD', 'password')),
|
|
'is_admin' => false,
|
|
],
|
|
);
|
|
|
|
// Demo fleet so the operator console hosts view has content locally.
|
|
$fleet = [
|
|
['name' => 'pve-fsn-1', 'datacenter' => 'fsn', 'public_ip' => '203.0.113.11', 'wg_ip' => '10.66.0.2'],
|
|
['name' => 'pve-hel-1', 'datacenter' => 'hel', 'public_ip' => '203.0.113.21', 'wg_ip' => '10.66.0.3'],
|
|
];
|
|
foreach ($fleet as $host) {
|
|
Host::updateOrCreate(['name' => $host['name']], [
|
|
'datacenter' => $host['datacenter'],
|
|
'public_ip' => $host['public_ip'],
|
|
'wg_ip' => $host['wg_ip'],
|
|
'status' => 'active',
|
|
'total_gb' => 2000,
|
|
'total_ram_mb' => 131072,
|
|
'cpu_cores' => 32,
|
|
'cpu_weight' => 32,
|
|
'reserve_pct' => 15,
|
|
'pve_version' => 'pve-manager/8.2.2',
|
|
'last_seen_at' => now(),
|
|
]);
|
|
}
|
|
}
|
|
}
|