Skip to content

Commit

Permalink
newdevice: Added Coriant support (#6026)
Browse files Browse the repository at this point in the history
* Added Coriant TNMS MIB and MEF (Metro Ethernet Forum) MIB

* Coriant Logo

* Added Basic Librenms Support and MEF support

* Forgot snmpsim

* Better like this

* Spaces !

* Renamed sql file

* Space

* Fix spaces

* svgo optimized logo

* Removed modules that are by default to 0

* Added sysDescr as requested

* Fix conflict file

* Setting right severity id in the discovery log_event()

* Since MEF-EVC can be used on other devices than Coriant's one, lets this be used by the poller/discovery itself

* Fixed spaces

* Rename 173.sql to 174.sql

* Moved logo from os/  to logos/
Addd Icon

* Fix name

* minimize file

* Change l/w to viewbox and minify

* Renamed mef-evc to mef on request from @laf

* Rename 174.sql to 175.sql
  • Loading branch information
xbeaudouin authored and murrant committed Mar 11, 2017
1 parent 872eb22 commit fa29839
Show file tree
Hide file tree
Showing 16 changed files with 20,313 additions and 0 deletions.
1 change: 1 addition & 0 deletions html/images/logos/coriant.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions html/images/os/coriant.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions html/includes/print-mef.inc.php
@@ -0,0 +1,23 @@
<?php
echo '<tr class="list">';
echo '<td class="list">';
echo $mef['mefIdent'];

echo '</td>';
echo '<td class="list">'. $mef['mefType'] . '</td>';
echo '<td class="list">'. $mef['mefMTU'] . '</td>';

echo '<td class="list">';
if ($mef['mefAdmState'] == 'unlocked') {
echo '<i class="fa fa-unlock fa-lg icon-theme" aria-hidden="true" style="color:green"></i>';
} else {
echo '<i class="fa fa-lock fa-lg icon-theme" aria-hidden="true" style="color:red"></i>';
}
echo '</td>';
if ($mef['mefRowState'] == 'active') {
echo '<td class="list"><span style="min-width:40px; display:inline-block;" class="label label-success">active</span></td>';
} else {
echo '<td class="list"><span style="min-width:40px; display:inline-block;" class="label label-default">'.$mef['mefRowState'].'</span></td>';
}

echo '</tr>';
8 changes: 8 additions & 0 deletions html/pages/device.inc.php
Expand Up @@ -164,6 +164,14 @@
</a>
</li>';
}

if (@dbFetchCell("SELECT COUNT(id) FROM mefinfo WHERE device_id = '".$device['device_id']."'") > '0') {
echo '<li class="'.$select['mef'].'">
<a href="'.generate_device_url($device, array('tab' => 'mef')).'">
<i class="fa fa-link fa-lg icon-theme" aria-hidden="true"></i> Metro Ethernet
</a>
</li>';
}

// $loadbalancer_tabs is used in device/loadbalancer/ to build the submenu. we do it here to save queries
if ($device['os'] == 'netscaler') {
Expand Down
11 changes: 11 additions & 0 deletions html/pages/device/mef.inc.php
@@ -0,0 +1,11 @@
<?php
$pagetitle[] = 'Metro Ethernet';
echo '<table border="0" cellspacing="0" cellpadding="5" width="100%" class="table table-condensed"><tr class="tablehead"><th>Link</th><th>Type</th><th>MTU</th><th>Admin State</th><th>Row State</th></tr>';
$i = '1';

foreach (dbFetchRows('SELECT `mefIdent`,`mefType`,`mefMTU`,`mefAdmState`,`mefRowState` FROM `mefinfo` WHERE `device_id` = ? ORDER BY `mefID`', array($device['device_id'])) as $mef) {
include 'includes/print-mef.inc.php';
$i++;
}

echo '</table>';
2 changes: 2 additions & 0 deletions includes/defaults.inc.php
Expand Up @@ -712,6 +712,7 @@
$config['poller_modules']['ntp'] = 1;
$config['poller_modules']['services'] = 1;
$config['poller_modules']['loadbalancers'] = 0;
$config['poller_modules']['mef'] = 0;

// List of discovery modules. Need to be in this array to be
// considered for execution.
Expand Down Expand Up @@ -749,6 +750,7 @@
$config['discovery_modules']['stp'] = 1;
$config['discovery_modules']['ntp'] = 1;
$config['discovery_modules']['loadbalancers'] = 0;
$config['discovery_modules']['mef'] = 0;

$config['modules_compat']['rfc1628']['liebert'] = 1;
$config['modules_compat']['rfc1628']['netmanplus'] = 1;
Expand Down
39 changes: 39 additions & 0 deletions includes/definitions/coriant.yaml
@@ -0,0 +1,39 @@
os: coriant
text: 'Coriant TNMS'
type: network
icon: coriant
discovery_modules:
ntp: 0
ospf: 0
stp: 0
ucd-diskio: 0
ucd-mib: 0
ipmi: 0
bgp-peers: 0
services: 0
vlans: 0
arp-table: 0
mef-evc: 1
cisco-vrf-lite: 0
storage: 0
poller_modules:
ntp: 0
ospf: 0
stp: 0
ucd-diskio: 0
ucd-mib: 0
ipmi: 0
bgp-peers: 0
services: 0
libvirt-vminfo: 0
vmware-vminfo: 0
vlans: 0
arp-table: 0
mef-evc: 1
cisco-vrf-lite: 0
storage: 0
discovery:
- sysObjectId:
- .1.3.6.1.4.1.42229.6.22
register_mibs:
mefServiceEvcCfgTable: MEF-UNI-EVC-MIB
70 changes: 70 additions & 0 deletions includes/discovery/mef.inc.php
@@ -0,0 +1,70 @@
<?php

/*
* Try to discover any MEF Links
*/

/*
* Variable to hold the discovered MEF Links.
*/

$mef_list = array();

/*
* Fetch information about MEF Links.
*/

$oids = snmpwalk_cache_multi_oid($device, 'MefServiceEvcCfgEntry', $oids, 'MEF-UNI-EVC-MIB');

echo "MEF : ";
foreach ($oids as $index => $entry) {
$mefIdent = $entry['mefServiceEvcCfgIdentifier'];
$mefType = $entry['mefServiceEvcCfgServiceType'];
$mefMtu = $entry['mefServiceEvcCfgMtuSize'];
$mefAdmState = $entry['mefServiceEvcCfgAdminState'];
$mefRowState = $entry['mefServiceEvcCfgRowStatus'];

/*
* Coriant MEF-EVC is quite strange, MTU is sometime set to 0 setting it to "strange" default value
* According to Coriant this should be fixed in Nov 2017.
*/
if (($mefMtu == 0) && ($device['os'] == 'coriant')) {
$mefMtu = 1600;
}

/*
* Check if the MEF is already known for this host
*/
if (dbFetchCell("SELECT COUNT(id) FROM `mefinfo` WHERE `device_id` = ? AND `mefID` = ?", array($device['device_id'], $index)) == 0) {
$mefid = dbInsert(array('device_id' => $device['device_id'], 'mefID' => $index, 'mefType' => mres($mefType), 'mefIdent' => mres($mefIdent), 'mefMTU' => mres($mefMtu), 'mefAdmState' => mres($mefAdmState), 'mefRowState' => mres($mefRowState)), 'mefinfo');
log_event("MEF link: ". mres($mefIdent) . " (" . $index . ") Discovered", $device, 'system', 2);
echo '+';
} else {
echo '.';
}
/*
* Save the discovered MEF Link
*/
$mef_list[] = $index;
}

/*
* Get a list of all the known MEF Links for this host
*/

$sql = "SELECT id, mefID, mefIdent FROM mefinfo WHERE device_id = '".$device['device_id']."'";
foreach (dbFetchRows($sql) as $db_mef) {
/*
* Delete the MEF Link that are removed from the host.
*/
if (!in_array($db_mef['mefID'], $mef_list)) {
dbDelete('mefinfo', '`id` = ?', array($db_mef['id']));
log_event("MEF link: ".mres($db_mef['mefIdent']).' Removed', $device, 'system', 3);
echo '-';
}
}
/*
* Finished MEF information
*/
unset($mef_list, $oids, $db_mef);
echo PHP_EOL;
51 changes: 51 additions & 0 deletions includes/polling/mef.inc.php
@@ -0,0 +1,51 @@
<?php

echo 'MEF Links: ';

/*
* Get a list of all the known MEF Links for this host.
*/

$db_info_list = dbFetchRows('SELECT id, mefID, mefType, mefIdent, mefMTU, mefAdmState, mefRowState FROM mefinfo WHERE device_id = ?', array($device['device_id']));
$current_mefinfo = snmpwalk_cache_multi_oid($device, 'MefServiceEvcCfgEntry', array(), 'MEF-UNI-EVC-MIB');

foreach ($db_info_list as $db_info) {
$mef_info = array();

$mef_info['mefType'] = $current_mefinfo[$db_info['mefID']]['mefServiceEvcCfgServiceType'];
$mef_info['mefIdent'] = $current_mefinfo[$db_info['mefID']]['mefServiceEvcCfgIdentifier'];
$mef_info['mefMTU'] = $current_mefinfo[$db_info['mefID']]['mefServiceEvcCfgMtuSize'];
$mef_info['mefAdmState'] = $current_mefinfo[$db_info['mefID']]['mefServiceEvcCfgAdminState'];
$mef_info['mefRowState'] = $current_mefinfo[$db_info['mefID']]['mefServiceEvcCfgRowStatus'];

/*
* Coriant MEF-EVC is quite strange, MTU is sometime set to 0 so we can set it into 1600 instead
* According to Coriant this should be fixed in Nov 2017
*/
if (($mef_info['mefMTU'] == 0) && ($device['os'] == 'coriant')) {
$mef_info['mefMTU'] = 1600;
}

/*
* Process all the MEF properties.
*/
foreach ($mef_info as $property => $value) {
/*
* Check the property for any modifications.
*/
if ($mef_info[$property] != $db_info[$property]) {
// FIXME - this should loop building a query and then run the query after the loop (bad geert!)
dbUpdate(array($property => mres($mef_info[$property])), 'mefinfo', '`id` = ?', array($db_info['id']));
if ($db_info['mefIdent'] != null) {
log_event("MEF Link : ".mres($db_info['mefIdent']) . ' (' . preg_replace('/^mef/', '', mres($db_info[$property])) . ') -> ' . $mef_info[$property], $device);
}
}
}
}//end foreach

/*
* Finished discovering MEF Links information.
*/

unset($db_info_list,$current_mefinfo);
echo PHP_EOL;

0 comments on commit fa29839

Please sign in to comment.