diff --git a/.env.docker b/.env.docker index b68d138f1..8ceb675ff 100644 --- a/.env.docker +++ b/.env.docker @@ -30,10 +30,10 @@ APP_LOG_LEVEL=debug # MySQL Connection Details DB_CONNECTION="mysql" -DB_HOST="127.0.0.1" -DB_DATABASE="inex" -DB_USERNAME="inex" -DB_PASSWORD="inex" +DB_HOST="ixpmanager-mysql" +DB_DATABASE="ixpmanager" +DB_USERNAME="ixpmanager" +DB_PASSWORD="ixpmanager" ####################################################################################### # Identity. Used throughout IXP Manager in various ways. # This has grown organically and we intend to clean this up in a coming release and @@ -90,7 +90,7 @@ MAIL_PORT=1025 ### Graphing - see https://ixp-manager.readthedocs.org/en/latest/features/grapher.html # For Docker MRTG testing, change this to: "mrtg|dummy". -GRAPHER_BACKENDS="smokeping|mrtg|sflow|dummy" +GRAPHER_BACKENDS="dummy" diff --git a/app/Providers/GrapherServiceProvider.php b/app/Providers/GrapherServiceProvider.php index 261d82353..b47a421e0 100644 --- a/app/Providers/GrapherServiceProvider.php +++ b/app/Providers/GrapherServiceProvider.php @@ -26,6 +26,7 @@ use Illuminate\Support\ServiceProvider; use IXP\Exceptions\Services\Grapher\ConfigurationException; +use IXP\Services\Grapher; use IXP\Services\Grapher\Renderer\Extensions\Grapher as GrapherRendererExtension; use Entities\User as UserEntity; @@ -91,7 +92,7 @@ public function boot() /** * Register the application services. * - * @return void|\IXP\Services\Grapher + * @return void|Grapher * @throws */ public function register() @@ -105,7 +106,7 @@ public function register() $this->app->singleton( 'IXP\Services\Grapher', function() { - return new \IXP\Services\Grapher; + return new Grapher; }); $this->commands( $this->commands ); diff --git a/app/Services/Grapher/Backend/Dummy.php b/app/Services/Grapher/Backend/Dummy.php index 407184cc9..d596a636b 100644 --- a/app/Services/Grapher/Backend/Dummy.php +++ b/app/Services/Grapher/Backend/Dummy.php @@ -32,7 +32,7 @@ use Entities\IXP; /** - * Grapher Backend -> Mrtg + * Grapher Backend -> Dummy * * @author Barry O'Donovan * @category Grapher @@ -194,7 +194,10 @@ public function data( Graph $graph ): array { * {inheritDoc} * * @param Graph $graph + * * @return string + * + * @throws */ public function png( Graph $graph ): string { return @file_get_contents( $this->resolveFilePath( $graph, 'png' ) ); diff --git a/app/Services/Grapher/Backend/Mrtg.php b/app/Services/Grapher/Backend/Mrtg.php index 99d13465d..9e27225fc 100644 --- a/app/Services/Grapher/Backend/Mrtg.php +++ b/app/Services/Grapher/Backend/Mrtg.php @@ -322,7 +322,9 @@ public static function supports(): array { * {inheritDoc} * * @param Graph $graph + * * @return array + * * @throws */ public function data( Graph $graph ): array { @@ -346,7 +348,9 @@ public function data( Graph $graph ): array { * {inheritDoc} * * @param Graph $graph + * * @return string + * * @throws */ public function png( Graph $graph ): string { @@ -375,7 +379,9 @@ public function png( Graph $graph ): string { * {inheritDoc} * * @param Graph $graph + * * @return string + * * @throws */ public function rrd( Graph $graph ): string { @@ -393,7 +399,9 @@ public function rrd( Graph $graph ): string { /** * For larger IXPs, allow sharding of directories over 16 possible base directories + * * @param int $id The customer entity id + * * @return string shared path -> e.g. 18 -> 18 % 16 = 2 / 00016 -> 2/00016 */ private function shardMemberDir( int $id ): string { @@ -406,7 +414,9 @@ private function shardMemberDir( int $id ): string { * * @param Graph $graph * @param string $type + * * @return string + * * @throws */ public function resolveFilePath( Graph $graph, string $type ): string { @@ -470,7 +480,4 @@ public function resolveFilePath( Graph $graph, string $type ): string { throw new CannotHandleRequestException("Backend asserted it could process but cannot handle graph of type: {$graph->type()}" ); } } - - - } diff --git a/app/Services/Grapher/Backend/Sflow.php b/app/Services/Grapher/Backend/Sflow.php index 101c188a2..bacc3bf9d 100644 --- a/app/Services/Grapher/Backend/Sflow.php +++ b/app/Services/Grapher/Backend/Sflow.php @@ -22,6 +22,7 @@ */ use IXP\Contracts\Grapher\Backend as GrapherBackendContract; +use IXP\Exceptions\Services\Grapher\CannotHandleRequestException; use IXP\Services\Grapher\Backend as GrapherBackend; use IXP\Services\Grapher\Graph; @@ -37,7 +38,7 @@ use Log; /** - * Grapher Backend -> Mrtg + * Grapher Backend -> Sflow * * @author Barry O'Donovan * @category Grapher @@ -92,7 +93,7 @@ public function isMultiFileConfigurationSupported(): bool { * * {inheritDoc} * - * @param int $config_type The type of configuration to generate + * @param int $type The type of configuration to generate * @return array */ public function generateConfiguration( int $type = self::GENERATED_CONFIG_TYPE_MONOLITHIC ): array @@ -140,7 +141,10 @@ public static function supports(): array { * {inheritDoc} * * @param \IXP\Services\Grapher\Graph $graph + * * @return array + * + * @throws */ public function data( Graph $graph ): array { try { @@ -158,7 +162,10 @@ public function data( Graph $graph ): array { * {inheritDoc} * * @param Graph $graph + * * @return string + * + * @throws */ public function png( Graph $graph ): string { try { @@ -176,7 +183,10 @@ public function png( Graph $graph ): string { * {inheritDoc} * * @param Graph $graph + * * @return string + * + * @throws */ public function rrd( Graph $graph ): string { try { @@ -206,26 +216,31 @@ private function translateCategory( $c ): string { * For a given graph, return the filename where the appropriate data * will be found. * - * @param Graph $graph + * @param Graph $graph + * @param string $type + * * @return string + * + * @throws */ private function resolveFileName( Graph $graph, $type ): string { - $config = config('grapher.backends.sflow'); - switch( $graph->classType() ) { case 'Vlan': + /** @var Graph\Vlan $graph */ return sprintf( "aggregate.%s.%s.vlan%05d.%s", $graph->protocol(), $this->translateCategory( $graph->category() ), $graph->vlan()->getNumber(), $type ); break; case 'VlanInterface': + /** @var Graph\VlanInterface $graph */ return sprintf( "individual.%s.%s.src-%05d.%s", $graph->protocol(), $this->translateCategory( $graph->category() ), $graph->vlanInterface()->getId(), $type ); break; case 'P2p': + /** @var Graph\P2p $graph */ return sprintf( "p2p.%s.%s.src-%05d.dst-%05d.%s", $graph->protocol(), $this->translateCategory( $graph->category() ), $graph->svli()->getId(), $graph->dvli()->getId(), $type ); @@ -241,25 +256,31 @@ private function resolveFileName( Graph $graph, $type ): string { * will be found. * * @param Graph $graph + * * @return string + * + * @throws */ private function resolveFilePath( Graph $graph, $type ): string { $config = config('grapher.backends.sflow'); switch( $graph->classType() ) { case 'Vlan': + /** @var Graph\Vlan $graph */ return sprintf( "%s/%s/%s/aggregate/%s", $config['root'], $graph->protocol(), $this->translateCategory( $graph->category() ), $this->resolveFileName( $graph, $type ) ); break; case 'VlanInterface': + /** @var Graph\VlanInterface $graph */ return sprintf( "%s/%s/%s/individual/%s", $config['root'], $graph->protocol(), $this->translateCategory( $graph->category() ), $this->resolveFileName( $graph, $type ) ); break; case 'P2p': + /** @var Graph\P2p $graph */ return sprintf( "%s/%s/%s/p2p/src-%05d/%s", $config['root'], $graph->protocol(), $this->translateCategory( $graph->category() ), $graph->svli()->getId(), $this->resolveFileName( $graph, $type ) ); diff --git a/app/Services/Grapher/Backend/Smokeping.php b/app/Services/Grapher/Backend/Smokeping.php index 061eb93db..570e7a779 100644 --- a/app/Services/Grapher/Backend/Smokeping.php +++ b/app/Services/Grapher/Backend/Smokeping.php @@ -137,7 +137,10 @@ public function data( Graph $graph ): array { * {inheritDoc} * * @param Graph $graph + * * @return string + * + * @throws */ public function png( Graph $graph ): string { return @file_get_contents( $this->resolveFilePath( $graph ) ); @@ -149,6 +152,7 @@ public function png( Graph $graph ): string { * {inheritDoc} * * @param Graph $graph + * * @return string */ public function rrd( Graph $graph ): string { @@ -161,7 +165,9 @@ public function rrd( Graph $graph ): string { * will be found. * * @param Graph $graph + * * @return string + * * @throws */ private function resolveFilePath( Graph $graph ): string { diff --git a/app/Services/Grapher/Graph/Latency.php b/app/Services/Grapher/Graph/Latency.php index 1486e5efc..ddf5ee657 100644 --- a/app/Services/Grapher/Graph/Latency.php +++ b/app/Services/Grapher/Graph/Latency.php @@ -85,7 +85,6 @@ class Latency extends Graph { */ const PERIOD_DEFAULT = self::PERIOD_3HOURS; - /** * Array of valid periods for drill down graphs */ @@ -96,7 +95,6 @@ class Latency extends Graph { self::PERIOD_1YEAR => "1year" ]; - /** * Default protocol for graphs */ @@ -146,7 +144,6 @@ public static function resolvePeriod( $period = null ): string { return self::PERIODS[ $period ] ?? 'Unknown'; } - /** * Get the vlan interface we're meant to graph for latency * @return VlanInterfaceEntity @@ -232,14 +229,16 @@ public function getParamsAsArray(): array { * * Does a abort(404) if invalid * - * @param int $vliid The user input value - * @return VlanInterfaceEntity $vli VlanInterface object + * @param int $vliid The user input value + * + * @return VlanInterfaceEntity */ public static function processParameterVlanInterface( int $vliid ): VlanInterfaceEntity { - /** @var $vli VlanInterfaceEntity */ + /** @var VlanInterfaceEntity $vli */ if( !$vliid || !( $vli = D2EM::getRepository( VlanInterfaceEntity::class )->find( $vliid ) ) ) { abort(404); } + return $vli; } } diff --git a/library/IXP/Form/Switch.php b/library/IXP/Form/Switch.php index 42ac6dc56..913fb24ee 100644 --- a/library/IXP/Form/Switch.php +++ b/library/IXP/Form/Switch.php @@ -153,7 +153,7 @@ public function init() ->setAttrib( 'class', 'span3' ) ->addFilter( 'StringTrim' ) ->addFilter( 'StringToLower' ) - ->addFilter( new Zend_Filter_PregReplace( [ 'match' => '/[^0-9a-f]*/', 'reaplce' => '' ] ) ); + ->addFilter( new Zend_Filter_PregReplace( [ 'match' => '/[^0-9a-f]*/', 'replace' => '' ] ) ); $this->addElement( $mgmt_mac_address );