Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve #1293 #1382

Merged
merged 7 commits into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions napalm/junos/junos.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,18 @@ def get_interfaces_counters(self):
"""Return interfaces counters."""
query = junos_views.junos_iface_counter_table(self.device)
query.get()
query_logical = junos_views.junos_logical_iface_counter_table(self.device)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should make a separate request just for this: the logical interfaces are already present in the junos_iface_counter_table, we just need to extract them. For this we can use the nested tables junos-eznc offers, see an example here where a view is able to reference a sub-table. In the same way, we can have the logical interfaces nested under a sub-table, and avoid an additional RPC request.

query_logical.get()
interface_counters = {}
for interface, counters in query.items():
interface_counters[interface] = {
k: v if v is not None else -1 for k, v in counters
}
for interface, counters in query_logical.items():
interface_counters[interface] = {
k: v if v is not None else -1 for k, v in counters
}

return interface_counters

def get_environment(self):
Expand Down
39 changes: 39 additions & 0 deletions napalm/junos/utils/junos_views.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,45 @@ junos_environment_table:
key: name
view: junos_environment_view

junos_logical_iface_counter_table:
rpc: get-interface-information
args:
extensive: True
interface_name: '[vmfgxe][mlet]*'
args_key: interface_name
item: physical-interface/logical-interface
view: junos_logical_iface_counter_view

junos_logical_iface_counter_view:
groups:
ts: traffic-statistics
rxerrs: input-error-list
txerrs: output-error-list
ethernet_traffic_types: ethernet-mac-statistics


# fields that are part of groups are called
# "fields_<group-name>"
fields_ethernet_traffic_types:
rx_broadcast_packets: { input-broadcasts: int }
tx_broadcast_packets: { output-broadcasts: int }
rx_unicast_packets: { input-unicasts: int }
tx_unicast_packets: { output-unicasts: int }
rx_multicast_packets: { input-multicasts: int }
tx_multicast_packets: { output-multicasts: int }

fields_ts:
rx_octets: { input-bytes: int }
tx_octets: { output-bytes: int }

fields_rxerrs:
rx_errors: { input-errors: int }
rx_discards: { input-discards: int }

fields_txerrs:
tx_errors: { output-errors: int }
tx_discards: { output-drops: int }

junos_environment_table_srx_cluster:
rpc: get-environment-information
args:
Expand Down
Loading