mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Laravel 8.x Shift (#12235)
* Shift HTTP kernel and middleware * Shift service providers * Shift console routes * Shift to class based factories * Namespace seeders * Shift PSR-4 autoloading * Default config files In an effort to make upgrading the constantly changing config files easier, Shift defaulted them. This allows you to review the commit diff for once for customizations when you are done Shifting. Moving forward, consider using ENV variables or create a separate config file to allow the core config files to remain as default as possible. * Shift Laravel dependencies * Shift return type of base TestCase methods From the [PHPUnit 8 release notes][1], the `TestCase` methods below now declare a `void` return type: - `setUpBeforeClass()` - `setUp()` - `assertPreConditions()` - `assertPostConditions()` - `tearDown()` - `tearDownAfterClass()` - `onNotSuccessfulTest()` [1]: https://phpunit.de/announcements/phpunit-8.html * Shift cleanup * console routes * composer update * factories * phpunit * bootstrap pagination * model factory * wip * Apply fixes from StyleCI (#12236) * wip * Apply fixes from StyleCI (#12238) * wip * wip * wip * wip * Apply fixes from StyleCI (#12240) * wip * Apply fixes from StyleCI (#12242) * composer update * Bump to PHP 7.3 minimum Co-authored-by: Laravel Shift <shift@laravelshift.com>
This commit is contained in:
39
database/factories/AlertScheduleFactory.php
Normal file
39
database/factories/AlertScheduleFactory.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\AlertSchedule;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class AlertScheduleFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = AlertSchedule::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'title' => $this->faker->name,
|
||||
'notes' => $this->faker->text,
|
||||
'recurring' => 0,
|
||||
];
|
||||
}
|
||||
|
||||
public function recurring()
|
||||
{
|
||||
return $this->state(function () {
|
||||
return [
|
||||
'recurring' => 1,
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
40
database/factories/BgpPeerFactory.php
Normal file
40
database/factories/BgpPeerFactory.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\BgpPeer;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class BgpPeerFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = BgpPeer::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'bgpPeerIdentifier' => $this->faker->ipv4,
|
||||
'bgpLocalAddr' => $this->faker->ipv4,
|
||||
'bgpPeerRemoteAddr' => $this->faker->ipv4,
|
||||
'bgpPeerRemoteAs' => $this->faker->numberBetween(1, 65535),
|
||||
'bgpPeerState' => $this->faker->randomElement(['established', 'idle']),
|
||||
'astext' => $this->faker->sentence(),
|
||||
'bgpPeerAdminStatus' => $this->faker->randomElement(['start', 'stop']),
|
||||
'bgpPeerInUpdates' => $this->faker->randomDigit,
|
||||
'bgpPeerOutUpdates' => $this->faker->randomDigit,
|
||||
'bgpPeerInTotalMessages' => $this->faker->randomDigit,
|
||||
'bgpPeerOutTotalMessages' => $this->faker->randomDigit,
|
||||
'bgpPeerFsmEstablishedTime' => $this->faker->unixTime,
|
||||
'bgpPeerInUpdateElapsedTime' => $this->faker->unixTime,
|
||||
];
|
||||
}
|
||||
}
|
28
database/factories/BillFactory.php
Normal file
28
database/factories/BillFactory.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Bill;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class BillFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Bill::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'bill_name' => $this->faker->text,
|
||||
];
|
||||
}
|
||||
}
|
29
database/factories/ComponentFactory.php
Normal file
29
database/factories/ComponentFactory.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Component;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class ComponentFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Component::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'device_id' => $this->faker->randomDigit,
|
||||
'type' => $this->faker->regexify('[A-Za-z0-9]{4,20}'),
|
||||
];
|
||||
}
|
||||
}
|
51
database/factories/DeviceFactory.php
Normal file
51
database/factories/DeviceFactory.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Device;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class DeviceFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Device::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'hostname' => $this->faker->domainWord . '-' . $this->faker->domainWord . '-' . $this->faker->domainWord . '.' . $this->faker->domainName,
|
||||
'ip' => $this->faker->randomElement([$this->faker->ipv4, $this->faker->ipv6]),
|
||||
'type' => $this->faker->randomElement([
|
||||
'appliance',
|
||||
'camera',
|
||||
'collaboration',
|
||||
'encoder',
|
||||
'environment',
|
||||
'firewall',
|
||||
'loadbalancer',
|
||||
'management',
|
||||
'network',
|
||||
'power',
|
||||
'printer',
|
||||
'proxy',
|
||||
'sensor',
|
||||
'server',
|
||||
'storage',
|
||||
'timing',
|
||||
'wireless',
|
||||
'workstation',
|
||||
]),
|
||||
'status' => $status = random_int(0, 1),
|
||||
'status_reason' => $status == 0 ? $this->faker->randomElement(['snmp', 'icmp']) : '', // allow invalid states?
|
||||
];
|
||||
}
|
||||
}
|
30
database/factories/DeviceGroupFactory.php
Normal file
30
database/factories/DeviceGroupFactory.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\DeviceGroup;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class DeviceGroupFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = DeviceGroup::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->domainWord,
|
||||
'desc' => $this->faker->text(255),
|
||||
'type' =>'static',
|
||||
];
|
||||
}
|
||||
}
|
39
database/factories/Ipv4AddressFactory.php
Normal file
39
database/factories/Ipv4AddressFactory.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Ipv4Address;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use LibreNMS\Util\IPv4;
|
||||
|
||||
class Ipv4AddressFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Ipv4Address::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$prefix = $this->faker->numberBetween(0, 32);
|
||||
$ip = new IPv4($this->faker->ipv4 . '/' . $prefix);
|
||||
|
||||
return [
|
||||
'ipv4_address' => $ip->uncompressed(),
|
||||
'ipv4_prefixlen' => $prefix,
|
||||
'port_id' => function () {
|
||||
return \App\Models\Port::factory()->create()->port_id;
|
||||
},
|
||||
'ipv4_network_id' => function () use ($ip) {
|
||||
return \App\Models\Ipv4Network::factory()->create(['ipv4_network' => $ip->getNetworkAddress() . '/' . $ip->cidr])->ipv4_network_id;
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
28
database/factories/Ipv4NetworkFactory.php
Normal file
28
database/factories/Ipv4NetworkFactory.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Ipv4Network;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class Ipv4NetworkFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Ipv4Network::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'ipv4_network' => $this->faker->ipv4 . '/' . $this->faker->numberBetween(0, 32),
|
||||
];
|
||||
}
|
||||
}
|
@@ -1,218 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Model Factories
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define all of your model factories. Model factories give
|
||||
| you a convenient way to create models for testing and seeding your
|
||||
| database. Just tell the factory how a default model should look.
|
||||
|
|
||||
*/
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Carbon\Carbon;
|
||||
use LibreNMS\Util\IPv4;
|
||||
|
||||
$factory->define(App\Models\User::class, function (Faker\Generator $faker) {
|
||||
static $password;
|
||||
|
||||
return [
|
||||
'auth_type' => 'mysql',
|
||||
'username' => $faker->unique()->userName,
|
||||
'realname' => $faker->name,
|
||||
'email' => $faker->safeEmail,
|
||||
'password' => $password ?: $password = bcrypt('secret'),
|
||||
'level' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\User::class, 'admin', function ($faker) {
|
||||
return [
|
||||
'level' => '10',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\User::class, 'read', function ($faker) {
|
||||
return [
|
||||
'level' => '5',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\App\Models\Bill::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'bill_name' => $faker->text,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\App\Models\Device::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'hostname' => $faker->domainWord . '-' . $faker->domainWord . '-' . $faker->domainWord . '.' . $faker->domainName,
|
||||
'ip' => $faker->randomElement([$faker->ipv4, $faker->ipv6]),
|
||||
'type' => $faker->randomElement([
|
||||
'appliance',
|
||||
'camera',
|
||||
'collaboration',
|
||||
'encoder',
|
||||
'environment',
|
||||
'firewall',
|
||||
'loadbalancer',
|
||||
'management',
|
||||
'network',
|
||||
'power',
|
||||
'printer',
|
||||
'proxy',
|
||||
'sensor',
|
||||
'server',
|
||||
'storage',
|
||||
'timing',
|
||||
'wireless',
|
||||
'workstation',
|
||||
]),
|
||||
'status' => $status = random_int(0, 1),
|
||||
'status_reason' => $status == 0 ? $faker->randomElement(['snmp', 'icmp']) : '', // allow invalid states?
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\App\Models\DeviceGroup::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->domainWord,
|
||||
'desc' => $faker->text(255),
|
||||
'type' =>'static',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\App\Models\Port::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'ifIndex' => $faker->unique()->numberBetween(),
|
||||
'ifName' => $faker->text(20),
|
||||
'ifDescr' => $faker->text(255),
|
||||
'ifLastChange' => $faker->unixTime(),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\App\Models\BgpPeer::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'bgpPeerIdentifier' => $faker->ipv4,
|
||||
'bgpLocalAddr' => $faker->ipv4,
|
||||
'bgpPeerRemoteAddr' => $faker->ipv4,
|
||||
'bgpPeerRemoteAs' => $faker->numberBetween(1, 65535),
|
||||
'bgpPeerState' => $faker->randomElement(['established', 'idle']),
|
||||
'astext' => $faker->sentence(),
|
||||
'bgpPeerAdminStatus' => $faker->randomElement(['start', 'stop']),
|
||||
'bgpPeerInUpdates' => $faker->randomDigit,
|
||||
'bgpPeerOutUpdates' => $faker->randomDigit,
|
||||
'bgpPeerInTotalMessages' => $faker->randomDigit,
|
||||
'bgpPeerOutTotalMessages' => $faker->randomDigit,
|
||||
'bgpPeerFsmEstablishedTime' => $faker->unixTime,
|
||||
'bgpPeerInUpdateElapsedTime' => $faker->unixTime,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\App\Models\Ipv4Address::class, function (Faker\Generator $faker) {
|
||||
$prefix = $faker->numberBetween(0, 32);
|
||||
$ip = new IPv4($faker->ipv4 . '/' . $prefix);
|
||||
|
||||
return [
|
||||
'ipv4_address' => $ip->uncompressed(),
|
||||
'ipv4_prefixlen' => $prefix,
|
||||
'port_id' => function () {
|
||||
return factory(\App\Models\Port::class)->create()->port_id;
|
||||
},
|
||||
'ipv4_network_id' => function () use ($ip) {
|
||||
return factory(\App\Models\Ipv4Network::class)->create(['ipv4_network' => $ip->getNetworkAddress() . '/' . $ip->cidr])->ipv4_network_id;
|
||||
},
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\App\Models\Ipv4Network::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'ipv4_network' => $faker->ipv4 . '/' . $faker->numberBetween(0, 32),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\App\Models\Syslog::class, function (Faker\Generator $faker) {
|
||||
$facilities = ['kern', 'user', 'mail', 'daemon', 'auth', 'syslog', 'lpr', 'news', 'uucp', 'cron', 'authpriv', 'ftp', 'ntp', 'security', 'console', 'solaris-cron', 'local0', 'local1', 'local2', 'local3', 'local4', 'local5', 'local6', 'local7'];
|
||||
$levels = ['emerg', 'alert', 'crit', 'err', 'warning', 'notice', 'info', 'debug'];
|
||||
|
||||
return [
|
||||
'facility' => $faker->randomElement($facilities),
|
||||
'priority' => $faker->randomElement($levels),
|
||||
'level' => $faker->randomElement($levels),
|
||||
'tag' => $faker->asciify(str_repeat('*', $faker->numberBetween(0, 10))),
|
||||
'timestamp' => Carbon::now(),
|
||||
'program' => $faker->asciify(str_repeat('*', $faker->numberBetween(0, 32))),
|
||||
'msg' => $faker->text(),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\App\Models\Vminfo::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'vm_type' => $faker->text(16),
|
||||
'vmwVmVMID' => $faker->randomDigit,
|
||||
'vmwVmDisplayName' => $faker->domainWord . '.' . $faker->domainName,
|
||||
'vmwVmGuestOS' => $faker->text(128),
|
||||
'vmwVmMemSize' => $faker->randomDigit,
|
||||
'vmwVmCpus' => $faker->randomDigit,
|
||||
'vmwVmState' => $faker->randomElement(['powered on', 'powered off', 'suspended']),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\App\Models\OspfNbr::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'id' => $faker->randomDigit,
|
||||
'ospfNbrIpAddr' => $faker->ipv4,
|
||||
'ospfNbrAddressLessIndex' => $faker->randomDigit,
|
||||
'ospfNbrRtrId' => $faker->ipv4,
|
||||
'ospfNbrOptions' => 0,
|
||||
'ospfNbrPriority' => 1,
|
||||
'ospfNbrEvents' => $faker->randomDigit,
|
||||
'ospfNbrLsRetransQLen' => 0,
|
||||
'ospfNbmaNbrStatus' => 'active',
|
||||
'ospfNbmaNbrPermanence' => 'dynamic',
|
||||
'ospfNbrHelloSuppressed' => 'false',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\App\Models\OspfPort::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'id' => $faker->randomDigit,
|
||||
'ospf_port_id' => $faker->randomDigit,
|
||||
'ospfIfIpAddress' => $faker->ipv4,
|
||||
'ospfAddressLessIf' => $faker->randomDigit,
|
||||
'ospfIfAreaId' => '0.0.0.0',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\App\Models\Component::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'device_id' => $faker->randomDigit,
|
||||
'type' => $faker->regexify('[A-Za-z0-9]{4,20}'),
|
||||
];
|
||||
});
|
||||
$factory->define(\App\Models\Sensor::class, function (Faker\Generator $faker) {
|
||||
$sensor_class = ['airflow', 'ber', 'charge', 'chromatic_dispersion', 'cooling', 'count', 'current', 'dbm', 'delay', 'eer', 'fanspeed', 'frequency', 'humidity', 'load', 'loss', 'power', 'power_consumed', 'power_factor', 'pressure', 'quality_factor', 'runtime', 'signal', 'snr', 'state', 'temperature', 'voltage', 'waterflow'];
|
||||
$sensor_oid = '.1.3.6.1.4.1.4115.1.4.3.3.' . $faker->numberBetween(0, 10) . '.' . $faker->numberBetween(0, 10) . '.' . $faker->numberBetween(0, 10);
|
||||
|
||||
return [
|
||||
'sensor_index' => $faker->randomDigit,
|
||||
'sensor_class' => $faker->randomElement($sensor_class),
|
||||
'sensor_current' => $faker->randomDigit,
|
||||
'sensor_oid' => $sensor_oid,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\App\Models\AlertSchedule::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'title' => $faker->name,
|
||||
'notes' => $faker->text,
|
||||
'recurring' => 0,
|
||||
];
|
||||
});
|
||||
$factory->state(\App\Models\AlertSchedule::class, 'recurring', function ($faker) {
|
||||
return [
|
||||
'recurring' => 1,
|
||||
];
|
||||
});
|
38
database/factories/OspfNbrFactory.php
Normal file
38
database/factories/OspfNbrFactory.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\OspfNbr;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class OspfNbrFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = OspfNbr::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'id' => $this->faker->randomDigit,
|
||||
'ospfNbrIpAddr' => $this->faker->ipv4,
|
||||
'ospfNbrAddressLessIndex' => $this->faker->randomDigit,
|
||||
'ospfNbrRtrId' => $this->faker->ipv4,
|
||||
'ospfNbrOptions' => 0,
|
||||
'ospfNbrPriority' => 1,
|
||||
'ospfNbrEvents' => $this->faker->randomDigit,
|
||||
'ospfNbrLsRetransQLen' => 0,
|
||||
'ospfNbmaNbrStatus' => 'active',
|
||||
'ospfNbmaNbrPermanence' => 'dynamic',
|
||||
'ospfNbrHelloSuppressed' => 'false',
|
||||
];
|
||||
}
|
||||
}
|
32
database/factories/OspfPortFactory.php
Normal file
32
database/factories/OspfPortFactory.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\OspfPort;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class OspfPortFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = OspfPort::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'id' => $this->faker->randomDigit,
|
||||
'ospf_port_id' => $this->faker->randomDigit,
|
||||
'ospfIfIpAddress' => $this->faker->ipv4,
|
||||
'ospfAddressLessIf' => $this->faker->randomDigit,
|
||||
'ospfIfAreaId' => '0.0.0.0',
|
||||
];
|
||||
}
|
||||
}
|
31
database/factories/PortFactory.php
Normal file
31
database/factories/PortFactory.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Port;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class PortFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Port::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'ifIndex' => $this->faker->unique()->numberBetween(),
|
||||
'ifName' => $this->faker->text(20),
|
||||
'ifDescr' => $this->faker->text(255),
|
||||
'ifLastChange' => $this->faker->unixTime(),
|
||||
];
|
||||
}
|
||||
}
|
34
database/factories/SensorFactory.php
Normal file
34
database/factories/SensorFactory.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Sensor;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class SensorFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Sensor::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$sensor_class = ['airflow', 'ber', 'charge', 'chromatic_dispersion', 'cooling', 'count', 'current', 'dbm', 'delay', 'eer', 'fanspeed', 'frequency', 'humidity', 'load', 'loss', 'power', 'power_consumed', 'power_factor', 'pressure', 'quality_factor', 'runtime', 'signal', 'snr', 'state', 'temperature', 'voltage', 'waterflow'];
|
||||
$sensor_oid = '.1.3.6.1.4.1.4115.1.4.3.3.' . $this->faker->numberBetween(0, 10) . '.' . $this->faker->numberBetween(0, 10) . '.' . $this->faker->numberBetween(0, 10);
|
||||
|
||||
return [
|
||||
'sensor_index' => $this->faker->randomDigit,
|
||||
'sensor_class' => $this->faker->randomElement($sensor_class),
|
||||
'sensor_current' => $this->faker->randomDigit,
|
||||
'sensor_oid' => $sensor_oid,
|
||||
];
|
||||
}
|
||||
}
|
38
database/factories/SyslogFactory.php
Normal file
38
database/factories/SyslogFactory.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Syslog;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class SyslogFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Syslog::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$facilities = ['kern', 'user', 'mail', 'daemon', 'auth', 'syslog', 'lpr', 'news', 'uucp', 'cron', 'authpriv', 'ftp', 'ntp', 'security', 'console', 'solaris-cron', 'local0', 'local1', 'local2', 'local3', 'local4', 'local5', 'local6', 'local7'];
|
||||
$levels = ['emerg', 'alert', 'crit', 'err', 'warning', 'notice', 'info', 'debug'];
|
||||
|
||||
return [
|
||||
'facility' => $this->faker->randomElement($facilities),
|
||||
'priority' => $this->faker->randomElement($levels),
|
||||
'level' => $this->faker->randomElement($levels),
|
||||
'tag' => $this->faker->asciify(str_repeat('*', $this->faker->numberBetween(0, 10))),
|
||||
'timestamp' => Carbon::now(),
|
||||
'program' => $this->faker->asciify(str_repeat('*', $this->faker->numberBetween(0, 32))),
|
||||
'msg' => $this->faker->text(),
|
||||
];
|
||||
}
|
||||
}
|
53
database/factories/UserFactory.php
Normal file
53
database/factories/UserFactory.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = User::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
static $password;
|
||||
|
||||
return [
|
||||
'auth_type' => 'mysql',
|
||||
'username' => $this->faker->unique()->userName,
|
||||
'realname' => $this->faker->name,
|
||||
'email' => $this->faker->safeEmail,
|
||||
'password' => $password ?: $password = bcrypt('secret'),
|
||||
'level' => 1,
|
||||
];
|
||||
}
|
||||
|
||||
public function admin()
|
||||
{
|
||||
return $this->state(function () {
|
||||
return [
|
||||
'level' => '10',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
public function read()
|
||||
{
|
||||
return $this->state(function () {
|
||||
return [
|
||||
'level' => '5',
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
34
database/factories/VminfoFactory.php
Normal file
34
database/factories/VminfoFactory.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Vminfo;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class VminfoFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Vminfo::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'vm_type' => $this->faker->text(16),
|
||||
'vmwVmVMID' => $this->faker->randomDigit,
|
||||
'vmwVmDisplayName' => $this->faker->domainWord . '.' . $this->faker->domainName,
|
||||
'vmwVmGuestOS' => $this->faker->text(128),
|
||||
'vmwVmMemSize' => $this->faker->randomDigit,
|
||||
'vmwVmCpus' => $this->faker->randomDigit,
|
||||
'vmwVmState' => $this->faker->randomElement(['powered on', 'powered off', 'suspended']),
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user