Skip to content

Commit d594cd3

Browse files
committed
[NF] IRRDB summary / status explorer - ref #877
1 parent 90dd4f2 commit d594cd3

File tree

11 files changed

+226
-22
lines changed

11 files changed

+226
-22
lines changed

Diff for: .idea/IXP-Manager.iml

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: app/Http/Controllers/IrrdbConfigController.php renamed to app/Http/Controllers/Irrdb/IrrdbConfigController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace IXP\Http\Controllers;
3+
namespace IXP\Http\Controllers\Irrdb;
44

55
/*
66
* Copyright (C) 2009 - 2021 Internet Neutral Exchange Association Company Limited By Guarantee.

Diff for: app/Http/Controllers/IrrdbController.php renamed to app/Http/Controllers/Irrdb/IrrdbController.php

+37-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace IXP\Http\Controllers;
3+
namespace IXP\Http\Controllers\Irrdb;
44

55
/*
66
* Copyright (C) 2009 - 2021 Internet Neutral Exchange Association Company Limited By Guarantee.
@@ -26,13 +26,15 @@
2626
use Auth, Cache;
2727

2828
use Illuminate\Http\RedirectResponse;
29+
use Illuminate\Http\Request;
2930
use Illuminate\View\View;
3031

32+
use IXP\Http\Controllers\Controller;
3133
use IXP\Jobs\UpdateIrrdb;
3234

3335
use IXP\Http\Requests\Irrdb as IrrdbRequest;
3436

35-
use IXP\Models\{Aggregators\IrrdbAggregator, Customer, User};
37+
use IXP\Models\{Aggregators\IrrdbAggregator, Customer, User, VirtualInterface, VlanInterface};
3638

3739
/**
3840
* Irrdb Controller
@@ -46,6 +48,39 @@
4648
*/
4749
class IrrdbController extends Controller
4850
{
51+
52+
/**
53+
* Display a table of all members IRRDB status
54+
*
55+
* Protected via route in web-auth-superuser.php
56+
*
57+
* @param Request $r
58+
* @return View
59+
*/
60+
public function summary( Request $r ) : View
61+
{
62+
// find all customers who use the route servers and are IRRDB filtered:
63+
$custids = VirtualInterface::select('custid')
64+
->join('vlaninterface', 'vlaninterface.virtualinterfaceid', '=', 'virtualinterface.id')
65+
->where('vlaninterface.rsclient', 1 )
66+
->where('vlaninterface.irrdbfilter', 1 )
67+
->groupBy('custid')
68+
->orderBy('custid')
69+
->pluck('custid');
70+
71+
72+
// using the above, get these customers details and update log for the table:
73+
$customers_logs = Customer::whereIn('id', $custids)
74+
->select('id', 'name', 'autsys', 'abbreviatedName')
75+
->with('irrdbUpdateLog')
76+
->get();
77+
78+
return view( 'irrdb/summary', [
79+
'customers_logs' => $customers_logs,
80+
] );
81+
82+
}
83+
4984
/**
5085
* Display the list of IRRDB (ASN/Prefix), (IPv4/IPv6) for a customer
5186
*

Diff for: app/Models/Customer.php

+10
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,16 @@ public function virtualInterfaces(): HasMany
367367
return $this->hasMany(VirtualInterface::class, 'custid');
368368
}
369369

370+
/**
371+
* Get the virtual interfaces for the customer
372+
*/
373+
public function irrdbUpdateLog(): Hasone
374+
{
375+
return $this->hasOne(IrrdbUpdateLog::class, 'cust_id');
376+
}
377+
378+
379+
370380
/**
371381
* Get the peers for the customer
372382
*/

Diff for: composer.lock

+13-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: resources/views/irrdb/js/summary.foil.php

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<script>
2+
3+
4+
let tableList = $( '#ixpDataTable' );
5+
6+
tableList.dataTable({
7+
stateSave: true,
8+
stateDuration : DATATABLE_STATE_DURATION,
9+
10+
"aLengthMenu": [[20, 50, 100, 500, -1], [20, 50, 100, 500, "All"]],
11+
12+
"bAutoWidth": false,
13+
14+
"aaSorting": [[0, 'asc']],
15+
"iDisplayLength": 100,
16+
});
17+
18+
$(document).ready(function() {
19+
tableList.show();
20+
});
21+
22+
</script>

Diff for: resources/views/irrdb/summary.foil.php

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<?php
2+
/** @var Foil\Template\Template $t */
3+
$this->layout( 'layouts/ixpv4' )
4+
?>
5+
6+
<?php $this->section( 'page-header-preamble' ) ?>
7+
IRRDB Summary
8+
<?php $this->append() ?>
9+
10+
<?php $this->section( 'page-header-postamble' ) ?>
11+
<div class="btn-group btn-group-sm ml-auto" role="group">
12+
<a target="_blank" class="btn btn-white" href="https://docs.ixpmanager.org/latest/features/irrdb/">
13+
Documentation
14+
</a>
15+
</div>
16+
<?php $this->append() ?>
17+
18+
<?php $this->section( 'content' ) ?>
19+
20+
<div class="alert alert-info mt-4 mb-4" role="alert">
21+
This page shows the last update times of each <?= config( 'ixp_fe.lang.customer.many' ) ?> IRRDB entries.
22+
Entries are considered stale if they have not been updated in the last 24 hours.
23+
</div>
24+
25+
26+
<div class="row">
27+
<div class="col-sm-12">
28+
<?= $t->alerts() ?>
29+
30+
<table id="ixpDataTable" class="table table-striped table-bordered collapse" style="width:100%">
31+
<thead class="thead-dark">
32+
<tr>
33+
<th><?= ucfirst( config( 'ixp_fe.lang.customer.one' ) ) ?></th>
34+
<th class="tw-text-center">V4 Prefixes</th>
35+
<th class="tw-text-center">V6 Prefixes</th>
36+
<th class="tw-text-center">V4 ASNs</th>
37+
<th class="tw-text-center">V6 ASNs</th>
38+
</tr>
39+
</thead>
40+
<tbody>
41+
42+
<?php foreach( $t->customers_logs as $c ): ?>
43+
<tr>
44+
<td data-sort="<?= $c->abbreviatedName ?>">
45+
<a href="<?= route( 'customer@overview', [ 'cust' => $c->id ] ) ?>">
46+
<?= $c->abbreviatedName ?> (AS<?= $c->autsys ?>)
47+
</a>
48+
</td>
49+
50+
<?php foreach( [ 'prefix_v4', 'prefix_v6', 'asn_v4', 'asn_v6' ] as $type ): ?>
51+
52+
<td class="tw-text-center"
53+
data-sort="<?= !$c->isIPvXEnabled( substr( $type, -1 ) ) ? -1000 : $c?->irrdbUpdateLog?->$type?->timestamp ?? 0 ?>">
54+
55+
<?php if( !$c->isIPvXEnabled( substr( $type, -1 ) ) ): ?>
56+
57+
<a class="badge badge-secondary">n/a</a>
58+
59+
<?php else: ?>
60+
61+
<?php if( $c->irrdbUpdateLog === null || $c->irrdbUpdateLog->$type === null ): ?>
62+
63+
<a class="badge badge-danger"
64+
href="<?= route( 'irrdb@list', [
65+
'cust' => $c,
66+
'type' => str_starts_with( $type, 'prefix' ) ? 'prefix' : 'asn',
67+
'protocol' => str_ends_with( $type, '4' ) ? '4' : '6',
68+
] ) ?>"
69+
>NEVER</a>
70+
71+
<?php else: ?>
72+
73+
<span class="tw-tabular-nums" title="<?= $c->irrdbUpdateLog->$type->format('Y-m-d H:i') ?>">
74+
<?= $c->irrdbUpdateLog->$type->diffForHumans() ?>
75+
</span>
76+
77+
<?php if( $c->irrdbUpdateLog->$type->isBefore( now()->subDay() ) ): ?>
78+
79+
<a class="badge badge-warning"
80+
href="<?= route( 'irrdb@list', [
81+
'cust' => $c,
82+
'type' => str_starts_with( $type, 'prefix' ) ? 'prefix' : 'asn',
83+
'protocol' => str_ends_with( $type, '4' ) ? '4' : '6',
84+
] ) ?>"
85+
>STALE</a>
86+
87+
<?php else: ?>
88+
89+
<a href="<?= route( 'irrdb@list', [
90+
'cust' => $c,
91+
'type' => str_starts_with( $type, 'prefix' ) ? 'prefix' : 'asn',
92+
'protocol' => str_ends_with( $type, '4' ) ? '4' : '6',
93+
] ) ?>" <i class="ml-2 fa fa-arrow-circle-o-right"></i></a>
94+
95+
<?php endif; ?>
96+
97+
<?php endif; ?>
98+
99+
<?php endif; ?>
100+
101+
</td>
102+
103+
<?php endforeach; ?>
104+
105+
</tr>
106+
<?php endforeach; ?>
107+
</tbody>
108+
</table>
109+
110+
</div>
111+
</div>
112+
<?php $this->append() ?>
113+
114+
<?php $this->section( 'scripts' ) ?>
115+
<?= $t->insert( 'irrdb/js/summary' ); ?>
116+
<?php $this->append() ?>

Diff for: resources/views/layouts/menu.foil.php

+16-3
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,25 @@
235235
</ul>
236236
<?php endif; ?>
237237

238-
<li class=" <?= !request()->is( 'irrdb-config/*' ) ?: 'active' ?>">
239-
<a href="<?= route( 'irrdb-config@list' ) ?>" class="nav-link">
240-
IRRDB Configuration
238+
239+
<li>
240+
<a href="<?= route( 'irrdb@summary' ) ?>" class="nav-link">
241+
IRRDB Summary
241242
</a>
242243
</li>
243244

245+
<?php if( request()->is( 'irrdb-config*' ) ): ?>
246+
<ul>
247+
<li class="nav-sub-menu-item <?= !request()->is( 'irrdb-config/*' ) ?: 'active' ?>">
248+
<a href="<?= route( 'irrdb-config@list' ) ?>">
249+
IRRDB Configuration
250+
</a>
251+
</li>
252+
</ul>
253+
<?php endif; ?>
254+
255+
256+
244257
<li>
245258
<a href="<?= route( 'layer2-address@list' ) ?>" class="nav-link">
246259
MAC Addresses

Diff for: routes/web-auth-superuser.php

+9
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,15 @@
333333
Route::get( 'rs-filters/list-customers', 'RsFilterController@listCustomers' )->name( 'rs-filters@list-customers' );
334334

335335

336+
/////////////////////////////////////////////////////////////////////////////////////////////////
337+
/////////////////////////////////////////////////////////////////////////////////////////////////
338+
///
339+
/// IRRDB
340+
///
341+
342+
Route::get( 'irrdb/summary', 'Irrdb\IrrdbController@summary' )->name( 'irrdb@summary' );
343+
344+
336345

337346

338347

Diff for: routes/web-auth.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
///
166166
/// IRRDB
167167
///
168-
Route::group( [ 'prefix' => 'irrdb' ], function() {
168+
Route::group( [ 'namespace' => 'Irrdb', 'prefix' => 'irrdb' ], function() {
169169
Route::get( 'customer/{cust}/{type}/{protocol}', 'IrrdbController@list' )->name( 'irrdb@list' );
170170
Route::get( 'update/{cust}/{type}/{protocol}', 'IrrdbController@update' )->name( 'irrdb@update' );
171171
});

Diff for: routes/web-eloquent2frontend.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
IXP\Http\Controllers\CustKitController::routes();
3838
IXP\Http\Controllers\Customer\CustomerTagController::routes();
3939
IXP\Http\Controllers\InfrastructureController::routes();
40-
IXP\Http\Controllers\IrrdbConfigController::routes();
40+
IXP\Http\Controllers\Irrdb\IrrdbConfigController::routes();
4141
IXP\Http\Controllers\Layer2AddressController::routes();
4242
IXP\Http\Controllers\LocationController::routes();
4343
IXP\Http\Controllers\LoginHistoryController::routes();

0 commit comments

Comments
 (0)