Fixed Junos port/vlan relationships for els and non-els based software (#10321)

* Fixed Junos port/vlan relationships for els and non-els based software

* fixed tabs

* Add test data

* Updated test data

* Update module_tables.yaml

* Update junos_qfx5100.json

* Update junos_qfx5100.json

* Update junos_qfx5100.json
This commit is contained in:
Serazio
2019-08-28 14:14:26 +02:00
committed by Tony Murray
parent 78112270c6
commit 142a1abbfd
4 changed files with 15709 additions and 10 deletions

View File

@@ -10,19 +10,58 @@ if ($vlanversion == 'version1' || $vlanversion == '2') {
$vlans = snmpwalk_cache_oid($device, 'jnxExVlanName', array(), 'JUNIPER-VLAN-MIB');
if (empty($vlans)) {
$vlans = snmpwalk_cache_oid($device, 'jnxL2aldVlanName', array(), 'JUNIPER-L2ALD-MIB');
$tagoruntag = snmpwalk_cache_oid($device, 'jnxL2aldVlanTag', array(), 'JUNIPER-L2ALD-MIB', null, ['-OQUs', '--hexOutputLength=0']);
$vlan_tag = snmpwalk_cache_oid($device, 'jnxL2aldVlanTag', array(), 'JUNIPER-L2ALD-MIB', null, ['-OQUs', '--hexOutputLength=0']);
$untag = snmpwalk_cache_oid($device, 'jnxExVlanPortTagness', array(), 'JUNIPER-VLAN-MIB', null, ['-OQeUs', '--hexOutputLength=0']);
$tmp_tag = 'jnxL2aldVlanTag';
$tmp_name = 'jnxL2aldVlanName';
} else {
$tagoruntag = snmpwalk_cache_oid($device, 'jnxExVlanTag', array(), 'JUNIPER-VLAN-MIB', null, ['-OQUs', '--hexOutputLength=0']);
$vlan_tag = snmpwalk_cache_oid($device, 'jnxExVlanTag', array(), 'JUNIPER-VLAN-MIB', null, ['-OQUs', '--hexOutputLength=0']);
$untag = snmpwalk_cache_oid($device, 'jnxExVlanPortTagness', array(), 'JUNIPER-VLAN-MIB', null, ['-OQeUs', '--hexOutputLength=0']);
$tmp_tag = 'jnxExVlanTag';
$tmp_name = 'jnxExVlanName';
}
foreach ($vlans as $vlan_id => $vlan) {
$vlan_id = $tagoruntag[$vlan_id][$tmp_tag];
if (empty($untag)) {
# If $untag is empty, device is based on Junipers ELS software
$untag = snmpwalk_cache_oid($device, 'dot1qVlanStaticUntaggedPorts', array(), 'Q-BRIDGE-MIB', null, ['-OQUs', '--hexOutputLength=0']);
$taganduntag = snmpwalk_cache_oid($device, 'dot1qVlanStaticEgressPorts', array(), 'Q-BRIDGE-MIB', null, ['-OQUs', '--hexOutputLength=0']);
$vlan_tag = snmpwalk_cache_oid($device, 'jnxL2aldVlanTag', array(), 'JUNIPER-L2ALD-MIB', null, ['-OQUs', '--hexOutputLength=0']);
$tmp_tag = 'jnxL2aldVlanTag';
$tmp_name = 'jnxL2aldVlanName';
$temp_vlan = array();
foreach ($vlan_tag as $key => $value) {
$temp_vlan[$key] = $value['jnxL2aldVlanTag'];
}
#set all port vlan relationships to be tagged
foreach ($taganduntag as $key => $taganduntag) {
$vlan_index = array_search($key, $temp_vlan);
$port_on_vlan = explode(',', $taganduntag['dot1qVlanStaticEgressPorts']);
foreach ($port_on_vlan as $port) {
$tagness_by_vlan_index[$vlan_index][$base_to_index[$port]]['tag'] = 0;
unset($tagness_by_vlan_index[$vlan_index]['']);
}
}
# correct all untagged ports to be untagged
foreach ($untag as $key => $untag) {
$vlan_index = array_search($key, $temp_vlan);
$port_on_vlan = explode(',', $untag['dot1qVlanStaticUntaggedPorts']);
foreach ($port_on_vlan as $port) {
$tagness_by_vlan_index[$vlan_index][$base_to_index[$port]]['tag'] = 1;
unset($tagness_by_vlan_index[$vlan_index]['']);
}
}
} else {
foreach ($untag as $key => $tagness) {
$key = explode('.', $key);
if ($tagness['jnxExVlanPortTagness'] == 2) {
$tagness_by_vlan_index[$key[0]][$base_to_index[$key[1]]]['tag'] = 1;
} else {
$tagness_by_vlan_index[$key[0]][$base_to_index[$key[1]]]['tag'] = 0;
}
}
}
foreach ($vlans as $vlan_index => $vlan) {
$vlan_id = $vlan_tag[$vlan_index][$tmp_tag];
d_echo(" $vlan_id");
if (is_array($vlans_db[$vtpdomain_id][$vlan_id])) {
$vlan_data = $vlans_db[$vtpdomain_id][$vlan_id];
@@ -44,13 +83,9 @@ if ($vlanversion == 'version1' || $vlanversion == '2') {
), 'vlans');
echo '+';
}
$device['vlans'][$vtpdomain_id][$vlan_id] = $vlan_id;
$egress_ids = $tagoruntag[$vlan_id][$tmp_tag];
foreach ($egress_ids as $port_id) {
$ifIndex = $base_to_index[$port_id];
$per_vlan_data[$vlan_id][$ifIndex]['untagged'] = $untagged_ids;
foreach ($tagness_by_vlan_index[$vlan_index] as $ifIndex => $tag) {
$per_vlan_data[$vlan_id][$ifIndex]['untagged'] = $tag['tag'];
}
}
}

12327
tests/data/junos_qfx5100.json Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -92,6 +92,7 @@ sensors:
storage:
storage:
excluded_fields: [device_id, storage_id]
order_by: storage_index
toner:
toner:
excluded_fields: [device_id, toner_id]

File diff suppressed because it is too large Load Diff