mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
tests: Added testing for Arista EOS BGP (#7984)
* tests: Added testing fro Arista EOS BGP * fixing tests * small updates * last one * more updates * Account for no space after = in snmp data always load_os() when a new device is freshly loaded by device_by_id_cache() * don't be fatal in load_os() * Update json to correct data
This commit is contained in:
@@ -241,9 +241,10 @@ class ModuleTestHelper
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str_contains($line, ' = ')) {
|
if (str_contains($line, ' =')) {
|
||||||
list($oid, $raw_data) = explode(' = ', $line, 2);
|
list($oid, $raw_data) = explode(' =', $line, 2);
|
||||||
$oid = ltrim($oid, '.');
|
$oid = ltrim($oid, '.');
|
||||||
|
$raw_data = trim($raw_data);
|
||||||
|
|
||||||
if (empty($raw_data)) {
|
if (empty($raw_data)) {
|
||||||
$result[] = "$oid|4|"; // empty data, we don't know type, put string
|
$result[] = "$oid|4|"; // empty data, we don't know type, put string
|
||||||
|
@@ -360,6 +360,7 @@ function device_by_id_cache($device_id, $refresh = false)
|
|||||||
$device = $cache['devices']['id'][$device_id];
|
$device = $cache['devices']['id'][$device_id];
|
||||||
} else {
|
} else {
|
||||||
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device_id));
|
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device_id));
|
||||||
|
load_os($device);
|
||||||
|
|
||||||
//order vrf_lite_cisco with context, this will help to get the vrf_name and instance_name all the time
|
//order vrf_lite_cisco with context, this will help to get the vrf_name and instance_name all the time
|
||||||
$vrfs_lite_cisco = dbFetchRows("SELECT * FROM `vrf_lite_cisco` WHERE `device_id` = ?", array($device_id));
|
$vrfs_lite_cisco = dbFetchRows("SELECT * FROM `vrf_lite_cisco` WHERE `device_id` = ?", array($device_id));
|
||||||
@@ -1559,14 +1560,16 @@ function display($value, $purifier_config = array())
|
|||||||
* $device['os'] must be set
|
* $device['os'] must be set
|
||||||
*
|
*
|
||||||
* @param array $device
|
* @param array $device
|
||||||
* @throws Exception No OS to load
|
|
||||||
*/
|
*/
|
||||||
function load_os(&$device)
|
function load_os(&$device)
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if (!isset($device['os'])) {
|
if (!isset($device['os'])) {
|
||||||
throw new Exception('No OS to load');
|
d_echo('No OS to load');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tmp_os = Symfony\Component\Yaml\Yaml::parse(
|
$tmp_os = Symfony\Component\Yaml\Yaml::parse(
|
||||||
file_get_contents($config['install_dir'] . '/includes/definitions/' . $device['os'] . '.yaml')
|
file_get_contents($config['install_dir'] . '/includes/definitions/' . $device['os'] . '.yaml')
|
||||||
);
|
);
|
||||||
|
186
tests/data/arista_eos.json
Normal file
186
tests/data/arista_eos.json
Normal file
@@ -0,0 +1,186 @@
|
|||||||
|
{
|
||||||
|
"bgp-peers": {
|
||||||
|
"discovery": {
|
||||||
|
"devices": [
|
||||||
|
{
|
||||||
|
"bgpLocalAs": "65000"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"bgpPeers": [
|
||||||
|
{
|
||||||
|
"astext": "",
|
||||||
|
"bgpPeerIdentifier": "192.168.0.2",
|
||||||
|
"bgpPeerRemoteAs": "65000",
|
||||||
|
"bgpPeerState": "idle",
|
||||||
|
"bgpPeerAdminStatus": "stop",
|
||||||
|
"bgpLocalAddr": "0.0.0.0",
|
||||||
|
"bgpPeerRemoteAddr": "0.0.0.0",
|
||||||
|
"bgpPeerInUpdates": "0",
|
||||||
|
"bgpPeerOutUpdates": "0",
|
||||||
|
"bgpPeerInTotalMessages": "0",
|
||||||
|
"bgpPeerOutTotalMessages": "0",
|
||||||
|
"bgpPeerFsmEstablishedTime": "0",
|
||||||
|
"bgpPeerInUpdateElapsedTime": "0",
|
||||||
|
"context_name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"astext": "",
|
||||||
|
"bgpPeerIdentifier": "2001:0550:0002:002f:0000:0000:0033:0001",
|
||||||
|
"bgpPeerRemoteAs": "65001",
|
||||||
|
"bgpPeerState": "idle",
|
||||||
|
"bgpPeerAdminStatus": "stop",
|
||||||
|
"bgpLocalAddr": "0.0.0.0",
|
||||||
|
"bgpPeerRemoteAddr": "0.0.0.0",
|
||||||
|
"bgpPeerInUpdates": "0",
|
||||||
|
"bgpPeerOutUpdates": "0",
|
||||||
|
"bgpPeerInTotalMessages": "0",
|
||||||
|
"bgpPeerOutTotalMessages": "0",
|
||||||
|
"bgpPeerFsmEstablishedTime": "0",
|
||||||
|
"bgpPeerInUpdateElapsedTime": "0",
|
||||||
|
"context_name": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"bgpPeers_cbgp": [
|
||||||
|
{
|
||||||
|
"bgpPeerIdentifier": "192.168.0.2",
|
||||||
|
"afi": "ipv4",
|
||||||
|
"safi": "unicast",
|
||||||
|
"AcceptedPrefixes": "0",
|
||||||
|
"DeniedPrefixes": "0",
|
||||||
|
"PrefixAdminLimit": "0",
|
||||||
|
"PrefixThreshold": "0",
|
||||||
|
"PrefixClearThreshold": "0",
|
||||||
|
"AdvertisedPrefixes": "0",
|
||||||
|
"SuppressedPrefixes": "0",
|
||||||
|
"WithdrawnPrefixes": "0",
|
||||||
|
"AcceptedPrefixes_delta": "0",
|
||||||
|
"AcceptedPrefixes_prev": "0",
|
||||||
|
"DeniedPrefixes_delta": "0",
|
||||||
|
"DeniedPrefixes_prev": "0",
|
||||||
|
"AdvertisedPrefixes_delta": "0",
|
||||||
|
"AdvertisedPrefixes_prev": "0",
|
||||||
|
"SuppressedPrefixes_delta": "0",
|
||||||
|
"SuppressedPrefixes_prev": "0",
|
||||||
|
"WithdrawnPrefixes_delta": "0",
|
||||||
|
"WithdrawnPrefixes_prev": "0",
|
||||||
|
"context_name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bgpPeerIdentifier": "2001:0550:0002:002f:0000:0000:0033:0001",
|
||||||
|
"afi": "ipv6",
|
||||||
|
"safi": "unicast",
|
||||||
|
"AcceptedPrefixes": "0",
|
||||||
|
"DeniedPrefixes": "0",
|
||||||
|
"PrefixAdminLimit": "0",
|
||||||
|
"PrefixThreshold": "0",
|
||||||
|
"PrefixClearThreshold": "0",
|
||||||
|
"AdvertisedPrefixes": "0",
|
||||||
|
"SuppressedPrefixes": "0",
|
||||||
|
"WithdrawnPrefixes": "0",
|
||||||
|
"AcceptedPrefixes_delta": "0",
|
||||||
|
"AcceptedPrefixes_prev": "0",
|
||||||
|
"DeniedPrefixes_delta": "0",
|
||||||
|
"DeniedPrefixes_prev": "0",
|
||||||
|
"AdvertisedPrefixes_delta": "0",
|
||||||
|
"AdvertisedPrefixes_prev": "0",
|
||||||
|
"SuppressedPrefixes_delta": "0",
|
||||||
|
"SuppressedPrefixes_prev": "0",
|
||||||
|
"WithdrawnPrefixes_delta": "0",
|
||||||
|
"WithdrawnPrefixes_prev": "0",
|
||||||
|
"context_name": ""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"poller": {
|
||||||
|
"devices": [
|
||||||
|
{
|
||||||
|
"bgpLocalAs": "65000"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"bgpPeers": [
|
||||||
|
{
|
||||||
|
"astext": "",
|
||||||
|
"bgpPeerIdentifier": "192.168.0.2",
|
||||||
|
"bgpPeerRemoteAs": "65000",
|
||||||
|
"bgpPeerState": "established",
|
||||||
|
"bgpPeerAdminStatus": "running",
|
||||||
|
"bgpLocalAddr": "",
|
||||||
|
"bgpPeerRemoteAddr": "0.0.0.0",
|
||||||
|
"bgpPeerInUpdates": "13362513",
|
||||||
|
"bgpPeerOutUpdates": "13579799",
|
||||||
|
"bgpPeerInTotalMessages": "0",
|
||||||
|
"bgpPeerOutTotalMessages": "0",
|
||||||
|
"bgpPeerFsmEstablishedTime": "4",
|
||||||
|
"bgpPeerInUpdateElapsedTime": "0",
|
||||||
|
"context_name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"astext": "",
|
||||||
|
"bgpPeerIdentifier": "2001:0550:0002:002f:0000:0000:0033:0001",
|
||||||
|
"bgpPeerRemoteAs": "65001",
|
||||||
|
"bgpPeerState": "established",
|
||||||
|
"bgpPeerAdminStatus": "running",
|
||||||
|
"bgpLocalAddr": "2001:0550:0002:002f:0000:0000:0033:0002",
|
||||||
|
"bgpPeerRemoteAddr": "0.0.0.0",
|
||||||
|
"bgpPeerInUpdates": "12658044",
|
||||||
|
"bgpPeerOutUpdates": "118",
|
||||||
|
"bgpPeerInTotalMessages": "0",
|
||||||
|
"bgpPeerOutTotalMessages": "0",
|
||||||
|
"bgpPeerFsmEstablishedTime": "1551697",
|
||||||
|
"bgpPeerInUpdateElapsedTime": "0",
|
||||||
|
"context_name": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"bgpPeers_cbgp": [
|
||||||
|
{
|
||||||
|
"bgpPeerIdentifier": "192.168.0.2",
|
||||||
|
"afi": "ipv4",
|
||||||
|
"safi": "unicast",
|
||||||
|
"AcceptedPrefixes": "540339",
|
||||||
|
"DeniedPrefixes": "0",
|
||||||
|
"PrefixAdminLimit": "0",
|
||||||
|
"PrefixThreshold": "0",
|
||||||
|
"PrefixClearThreshold": "0",
|
||||||
|
"AdvertisedPrefixes": "0",
|
||||||
|
"SuppressedPrefixes": "0",
|
||||||
|
"WithdrawnPrefixes": "0",
|
||||||
|
"AcceptedPrefixes_delta": "540339",
|
||||||
|
"AcceptedPrefixes_prev": "0",
|
||||||
|
"DeniedPrefixes_delta": "0",
|
||||||
|
"DeniedPrefixes_prev": "0",
|
||||||
|
"AdvertisedPrefixes_delta": "0",
|
||||||
|
"AdvertisedPrefixes_prev": "0",
|
||||||
|
"SuppressedPrefixes_delta": "0",
|
||||||
|
"SuppressedPrefixes_prev": "0",
|
||||||
|
"WithdrawnPrefixes_delta": "0",
|
||||||
|
"WithdrawnPrefixes_prev": "0",
|
||||||
|
"context_name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bgpPeerIdentifier": "2001:0550:0002:002f:0000:0000:0033:0001",
|
||||||
|
"afi": "ipv6",
|
||||||
|
"safi": "unicast",
|
||||||
|
"AcceptedPrefixes": "40633",
|
||||||
|
"DeniedPrefixes": "0",
|
||||||
|
"PrefixAdminLimit": "0",
|
||||||
|
"PrefixThreshold": "0",
|
||||||
|
"PrefixClearThreshold": "0",
|
||||||
|
"AdvertisedPrefixes": "0",
|
||||||
|
"SuppressedPrefixes": "0",
|
||||||
|
"WithdrawnPrefixes": "0",
|
||||||
|
"AcceptedPrefixes_delta": "40633",
|
||||||
|
"AcceptedPrefixes_prev": "0",
|
||||||
|
"DeniedPrefixes_delta": "0",
|
||||||
|
"DeniedPrefixes_prev": "0",
|
||||||
|
"AdvertisedPrefixes_delta": "0",
|
||||||
|
"AdvertisedPrefixes_prev": "0",
|
||||||
|
"SuppressedPrefixes_delta": "0",
|
||||||
|
"SuppressedPrefixes_prev": "0",
|
||||||
|
"WithdrawnPrefixes_delta": "0",
|
||||||
|
"WithdrawnPrefixes_prev": "0",
|
||||||
|
"context_name": ""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,2 +1,32 @@
|
|||||||
1.3.6.1.2.1.1.1.0|4|Arista Networks EOS version 4.15.3F running on an Arista Networks DCS-7050TX-128
|
1.3.6.1.2.1.1.1.0|4|Arista Networks EOS version 4.15.3F running on an Arista Networks DCS-7050TX-128
|
||||||
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1..30065.1.3011.7050.1958.128
|
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.30065.1.3011.7050.1958.128
|
||||||
|
1.3.6.1.2.1.1.3.0|67|2793316199
|
||||||
|
1.3.6.1.2.1.1.5.0|4|<private>
|
||||||
|
1.3.6.1.2.1.1.6.0|4|<private>
|
||||||
|
1.3.6.1.2.1.15.2.0|2|65000
|
||||||
|
1.3.6.1.2.1.25.1.1.0|67|2793326600
|
||||||
|
1.3.6.1.4.1.30065.4.1.1.2.1.3.1.1.4.192.168.0.2|4x|17AA8001
|
||||||
|
1.3.6.1.4.1.30065.4.1.1.2.1.3.1.2.16.32.1.5.80.0.2.0.47.0.0.0.0.0.51.0.1|4x|200105500002002F0000000000330002
|
||||||
|
1.3.6.1.4.1.30065.4.1.1.2.1.10.1.1.4.192.168.0.2|66|65000
|
||||||
|
1.3.6.1.4.1.30065.4.1.1.2.1.10.1.2.16.32.1.5.80.0.2.0.47.0.0.0.0.0.51.0.1|66|65001
|
||||||
|
1.3.6.1.4.1.30065.4.1.1.2.1.12.1.1.4.192.168.0.2|2|2
|
||||||
|
1.3.6.1.4.1.30065.4.1.1.2.1.12.1.2.16.32.1.5.80.0.2.0.47.0.0.0.0.0.51.0.1|2|2
|
||||||
|
1.3.6.1.4.1.30065.4.1.1.2.1.13.1.1.4.192.168.0.2|2|6
|
||||||
|
1.3.6.1.4.1.30065.4.1.1.2.1.13.1.2.16.32.1.5.80.0.2.0.47.0.0.0.0.0.51.0.1|2|6
|
||||||
|
1.3.6.1.4.1.30065.4.1.1.4.1.1.1.1.4.192.168.0.2|66|13090321
|
||||||
|
1.3.6.1.4.1.30065.4.1.1.4.1.1.1.2.16.32.1.5.80.0.2.0.47.0.0.0.0.0.51.0.1|66|1551697
|
||||||
|
1.3.6.1.4.1.30065.4.1.1.4.1.2.1.1.4.192.168.0.2|66|4
|
||||||
|
1.3.6.1.4.1.30065.4.1.1.4.1.2.1.2.16.32.1.5.80.0.2.0.47.0.0.0.0.0.51.0.1|66|17
|
||||||
|
1.3.6.1.4.1.30065.4.1.1.7.1.1.1.1.4.192.168.0.2|65|13362513
|
||||||
|
1.3.6.1.4.1.30065.4.1.1.7.1.1.1.2.16.32.1.5.80.0.2.0.47.0.0.0.0.0.51.0.1|65|12658044
|
||||||
|
1.3.6.1.4.1.30065.4.1.1.7.1.2.1.1.4.192.168.0.2|65|6500126734
|
||||||
|
1.3.6.1.4.1.30065.4.1.1.7.1.2.1.2.16.32.1.5.80.0.2.0.47.0.0.0.0.0.51.0.1|65|118
|
||||||
|
1.3.6.1.4.1.30065.4.1.1.7.1.3.1.1.4.192.168.0.2|65|13579799
|
||||||
|
1.3.6.1.4.1.30065.4.1.1.7.1.3.1.2.16.32.1.5.80.0.2.0.47.0.0.0.0.0.51.0.1|65|12658183
|
||||||
|
1.3.6.1.4.1.30065.4.1.1.7.1.4.1.1.4.192.168.0.2|65|17644316
|
||||||
|
1.3.6.1.4.1.30065.4.1.1.7.1.4.1.2.16.32.1.5.80.0.2.0.47.0.0.0.0.0.51.0.1|65|447455
|
||||||
|
1.3.6.1.4.1.30065.4.1.1.8.1.3.1.1.4.192.168.0.2.1.1|66|540336
|
||||||
|
1.3.6.1.4.1.30065.4.1.1.8.1.3.1.2.16.32.1.5.80.0.2.0.47.0.0.0.0.0.51.0.1.2.1|66|41030
|
||||||
|
1.3.6.1.4.1.30065.4.1.1.8.1.4.1.1.4.192.168.0.2.1.1|66|540339
|
||||||
|
1.3.6.1.4.1.30065.4.1.1.8.1.4.1.2.16.32.1.5.80.0.2.0.47.0.0.0.0.0.51.0.1.2.1|66|40633
|
||||||
|
1.3.6.1.6.3.10.2.1.3.0|2|26373899
|
||||||
|
Reference in New Issue
Block a user