Pseudowires refresh (#14882)

* refresh the pseudowires

* linting
This commit is contained in:
Stef 2023-03-13 16:19:23 +01:00 committed by GitHub
parent d3f02e6bb7
commit 0e322ae5d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 50 additions and 21 deletions

View File

@ -34,7 +34,8 @@ if ($vars['view'] == 'minigraphs') {
print_optionbar_end();
echo '<table cellpadding=5 cellspacing=0 class=devicetable width=100%>';
echo '<table class="table">';
echo '<tr><th>PW ID</th><th>Local PW Name</th><th>Local Port</th><td></th><th>Remote Device/PW Name</th><th>Remote Port</th></tr>';
$linkdone = [];
$bg = '';
@ -44,35 +45,63 @@ foreach (dbFetchRows('SELECT * FROM pseudowires AS P, ports AS I WHERE P.port_id
if (in_array($pw_a['device_id'] . $pw_a['port_id'], $linkdone)) {
continue;
}
$pw_b = dbFetchRow(
'SELECT * from `devices` AS D, `ports` AS I, `pseudowires` AS P WHERE D.device_id = ? AND D.device_id = I.device_id
AND P.cpwVcID = ? AND P.port_id = I.port_id',
[$pw_a['peer_device_id'], $pw_a['cpwVcID']]
);
$pw_b = cleanPort($pw_b);
if (! port_permitted($pw_a['port_id'])) {
continue;
}
if (! port_permitted($pw_b['port_id'])) {
continue;
}
if ($bg == 'ffffff') {
$bg = 'e5e5e5';
// if the remote device is valid, resolve their pw & port details
if ($pw_a['peer_device_id'] != 0) {
$pw_b = dbFetchRow(
'SELECT * from `devices` AS D, `ports` AS I, `pseudowires` AS P WHERE D.device_id = ? AND D.device_id = I.device_id
AND P.cpwVcID = ? AND P.port_id = I.port_id',
[$pw_a['peer_device_id'], $pw_a['cpwVcID']]
);
$pw_b = cleanPort($pw_b);
if (! port_permitted($pw_b['port_id'])) {
continue;
}
} else {
$bg = 'ffffff';
unset($pw_b);
}
echo "<tr style=\"background-color: #$bg;\"><td rowspan=2 style='font-size:18px; padding:4px;'>" . $pw_a['cpwVcID'] . '</td><td>' . generate_port_link($pw_a) . "</td>
<td rowspan=2> <i class='fa fa-arrows-alt fa-lg icon-theme' aria-hidden='true'></i> </td>
<td>" . generate_device_link($pw_b) . '</td><td>' . generate_port_link($pw_b) . '</td></tr>';
echo "<tr style=\"background-color: #$bg;\"><td colspan=2>" . $pw_a['ifAlias'] . '</td><td>' . $pw_b['ifAlias'] . '</td></tr>';
if ($bg == '255,255,255') {
$bg = '238, 238, 238';
} else {
$bg = '255,255,255';
}
echo '<tr style="background-color: rgb(' . $bg . ')">
<td style="font-size:18px; padding:4px;vertical-align: middle;">' . $pw_a['cpwVcID'] . '</td>
<td>' . $pw_a['pw_descr'] . '<br/><span class="box-desc">' . $pw_a['pw_type'] . ' ' . $pw_a['pw_psntype'] . '</span></td>
<td>' . generate_port_link($pw_a) . ' <i class="fa fa-arrow-' . $pw_a['ifOperStatus'] . ' report-' . $pw_a['ifOperStatus'] . '" aria-hidden="true"></i><br/><span class="interface-desc">' . $pw_a['ifAlias'] . '</span>';
if ($pw_a['pw_local_mtu'] != 0) {
echo '<br/><span class="box-desc">MTU ' . $pw_a['ifMtu'] . '</span>';
echo '<br/><span class="box-desc">PW MTU ' . $pw_a['pw_local_mtu'] . '</span>';
} else {
echo '<br/><span class="box-desc">MTU ' . $pw_a['ifMtu'] . '</span>';
}
echo '</td>
<td style="vertical-align: middle;"> <i class="fa fa-times" aria-hidden="true" style="font-size:2em;"></i></span> </td>';
//Only if b-endpoint was found
if ($pw_b) {
echo '<td>' . generate_device_link($pw_b) . '<br/><span class="box-desc"> ' . $pw_b['pw_descr'] . '</span></td>
<td>' . generate_port_link($pw_b) . ' <i class="fa fa-arrow-' . $pw_b['ifOperStatus'] . ' report-' . $pw_b['ifOperStatus'] . '" aria-hidden="true"></i><br/><span class="interface-desc">' . $pw_b['ifAlias'] . '</span>';
if ($pw_b['pw_local_mtu'] != 0) {
echo '<br/><span class="box-desc">MTU ' . $pw_b['ifMtu'] . '</span>';
echo '<br/><span class="box-desc">PW MTU ' . $pw_b['pw_local_mtu'] . '</span>';
} else {
echo '<br/><span class="box-desc">MTU ' . $pw_b['ifMtu'] . '</span>';
}
} else {
echo '<td style="font-style: italic; vertical-align: middle;">unresolved remote device</td><td></td>';
}
echo '</tr>';
if ($vars['view'] == 'minigraphs') {
echo "<tr style=\"background-color: #$bg;\"><td></td><td colspan=2>";
echo '<tr style="background-color: rgb(' . $bg . ')"><td></td><td colspan=2>';
if ($pw_a) {
$pw_a['width'] = '150';