Skip to content
This repository has been archived by the owner on Mar 7, 2018. It is now read-only.

Commit

Permalink
Merge pull request #83 from napalm-automation/develop
Browse files Browse the repository at this point in the history
Release 0.4.3
  • Loading branch information
dbarrosop committed Nov 7, 2016
2 parents 6d3ae82 + 62535b0 commit 47f0eda
Show file tree
Hide file tree
Showing 6 changed files with 180 additions and 103 deletions.
54 changes: 24 additions & 30 deletions napalm_eos/eos.py
Expand Up @@ -23,7 +23,7 @@
import time

from datetime import datetime

from collections import defaultdict
from netaddr import IPAddress
from netaddr import IPNetwork

Expand Down Expand Up @@ -66,7 +66,7 @@ def __init__(self, hostname, username, password, timeout=60, optional_args=None)

if self.transport == 'https':
self.port = optional_args.get('port', 443)
elif self.transrpot == 'http':
elif self.transport == 'http':
self.port = optional_args.get('port', 80)

self.enablepwd = optional_args.get('enable_password', '')
Expand All @@ -76,7 +76,7 @@ def open(self):
try:
if self.transport in ('http', 'https'):
connection = pyeapi.client.connect(
transport='https',
transport=self.transport,
host=self.hostname,
username=self.username,
password=self.password,
Expand Down Expand Up @@ -270,34 +270,28 @@ def get_lldp_neighbors(self):
return lldp

def get_interfaces_counters(self):
commands = list()

commands.append('show interfaces counters')
commands.append('show interfaces counters errors')

commands = ['show interfaces']
output = self.device.run_commands(commands)

interface_counters = dict()

for interface, counters in output[0]['interfaces'].iteritems():
interface_counters[interface] = dict()

interface_counters[interface]['tx_octets'] = counters['outOctets']
interface_counters[interface]['rx_octets'] = counters['inOctets']
interface_counters[interface]['tx_unicast_packets'] = counters['outUcastPkts']
interface_counters[interface]['rx_unicast_packets'] = counters['inUcastPkts']
interface_counters[interface]['tx_multicast_packets'] = counters['outMulticastPkts']
interface_counters[interface]['rx_multicast_packets'] = counters['inMulticastPkts']
interface_counters[interface]['tx_broadcast_packets'] = counters['outBroadcastPkts']
interface_counters[interface]['rx_broadcast_packets'] = counters['inBroadcastPkts']
interface_counters[interface]['tx_discards'] = counters['outDiscards']
interface_counters[interface]['rx_discards'] = counters['inDiscards']

# Errors come from a different command
errors = output[1]['interfaceErrorCounters'][interface]
interface_counters[interface]['tx_errors'] = errors['outErrors']
interface_counters[interface]['rx_errors'] = errors['inErrors']

interface_counters = defaultdict(dict)
for interface, data in output[0]['interfaces'].iteritems():
if data['hardware'] == 'subinterface':
# Subinterfaces will never have counters so no point in parsing them at all
continue
counters = data.get('interfaceCounters', {})
interface_counters[interface].update(
tx_octets=counters.get('outOctets', -1),
rx_octets=counters.get('inOctets', -1),
tx_unicast_packets=counters.get('outUcastPkts', -1),
rx_unicast_packets=counters.get('inUcastPkts', -1),
tx_multicast_packets=counters.get('outMulticastPkts', -1),
rx_multicast_packets=counters.get('inMulticastPkts', -1),
tx_broadcast_packets=counters.get('outBroadcastPkts', -1),
rx_broadcast_packets=counters.get('inBroadcastPkts', -1),
tx_discards=counters.get('outDiscards', -1),
rx_discards=counters.get('inDiscards', -1),
tx_errors=counters.get('totalOutErrors', -1),
rx_errors=counters.get('totalInErrors', -1)
)
return interface_counters

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -12,7 +12,7 @@

setup(
name="napalm-eos",
version="0.4.2",
version="0.4.3",
packages=find_packages(),
author="David Barroso",
author_email="dbarrosop@dravetech.com",
Expand Down
@@ -1 +1,30 @@
{"Ethernet2": {"tx_multicast_packets": 6745, "tx_discards": 0, "tx_octets": 852151, "tx_errors": 0, "rx_octets": 74942, "tx_unicast_packets": 0, "rx_errors": 0, "tx_broadcast_packets": 0, "rx_multicast_packets": 371, "rx_broadcast_packets": 0, "rx_discards": 0, "rx_unicast_packets": 0}, "Management1": {"tx_multicast_packets": 0, "tx_discards": 0, "tx_octets": 275633, "tx_errors": 0, "rx_octets": 387875, "tx_unicast_packets": 2118, "rx_errors": 0, "tx_broadcast_packets": 0, "rx_multicast_packets": 0, "rx_broadcast_packets": 1179, "rx_discards": 0, "rx_unicast_packets": 0}, "Ethernet1": {"tx_multicast_packets": 6745, "tx_discards": 0, "tx_octets": 852151, "tx_errors": 0, "rx_octets": 74942, "tx_unicast_packets": 0, "rx_errors": 0, "tx_broadcast_packets": 0, "rx_multicast_packets": 371, "rx_broadcast_packets": 0, "rx_discards": 0, "rx_unicast_packets": 0}}
{
"Ethernet1": {
"tx_multicast_packets": 0,
"tx_discards": 0,
"tx_octets": 0,
"tx_errors": 0,
"rx_octets": 0,
"tx_unicast_packets": 0,
"rx_errors": 0,
"tx_broadcast_packets": 0,
"rx_multicast_packets": 0,
"rx_broadcast_packets": 0,
"rx_discards": 0,
"rx_unicast_packets": 0
},
"Port-Channel1": {
"tx_multicast_packets": 0,
"tx_discards": 0,
"tx_octets": 0,
"tx_errors": 0,
"rx_octets": 0,
"tx_unicast_packets": 0,
"rx_errors": 0,
"tx_broadcast_packets": 0,
"rx_multicast_packets": 0,
"rx_broadcast_packets": 0,
"rx_discards": 0,
"rx_unicast_packets": 0
}
}
@@ -0,0 +1,125 @@
{
"interfaces": {
"Ethernet1": {
"lastStatusChangeTimestamp": 1475664667.431372,
"name": "Ethernet1",
"interfaceStatus": "notconnect",
"autoNegotiate": "off",
"burnedInAddress": "44:4c:a8:cd:33:7e",
"loopbackMode": "loopbackNone",
"interfaceStatistics": {
"inBitsRate": 0.0,
"inPktsRate": 0.0,
"outBitsRate": 0.0,
"updateInterval": 300.0,
"outPktsRate": 0.0
},
"mtu": 9214,
"hardware": "ethernet",
"duplex": "duplexFull",
"bandwidth": 10000000000,
"forwardingModel": "dataLink",
"lineProtocolStatus": "down",
"interfaceCounters": {
"outBroadcastPkts": 0,
"linkStatusChanges": 2,
"totalOutErrors": 0,
"inMulticastPkts": 0,
"counterRefreshTime": 1478085320.927135,
"inBroadcastPkts": 0,
"outputErrorsDetail": {
"deferredTransmissions": 0,
"txPause": 0,
"collisions": 0,
"lateCollisions": 0
},
"inOctets": 0,
"outDiscards": 0,
"outOctets": 0,
"inUcastPkts": 0,
"inputErrorsDetail": {
"runtFrames": 0,
"rxPause": 0,
"fcsErrors": 0,
"alignmentErrors": 0,
"giantFrames": 0,
"symbolErrors": 0
},
"outUcastPkts": 0,
"outMulticastPkts": 0,
"totalInErrors": 0,
"inDiscards": 0
},
"interfaceMembership": "Member of Port-Channel1",
"interfaceAddress": [],
"physicalAddress": "44:4c:a8:cd:33:7e",
"description": "not available"
},
"Port-Channel1": {
"lastStatusChangeTimestamp": 1475664568.7738712,
"name": "Port-Channel1",
"interfaceStatus": "notconnect",
"memberInterfaces": {},
"interfaceStatistics": {
"inBitsRate": 0.0,
"inPktsRate": 0.0,
"outBitsRate": 0.0,
"updateInterval": 300.0,
"outPktsRate": 0.0
},
"mtu": 1500,
"hardware": "portChannel",
"bandwidth": 0,
"forwardingModel": "routed",
"fallbackEnabled": false,
"lineProtocolStatus": "lowerLayerDown",
"interfaceCounters": {
"outBroadcastPkts": 0,
"linkStatusChanges": 1,
"totalOutErrors": 0,
"inMulticastPkts": 0,
"counterRefreshTime": 1478085363.701278,
"inBroadcastPkts": 0,
"inOctets": 0,
"outDiscards": 0,
"outOctets": 0,
"inUcastPkts": 0,
"outUcastPkts": 0,
"outMulticastPkts": 0,
"totalInErrors": 0,
"inDiscards": 0
},
"fallbackEnabledType": "fallbackNone",
"interfaceAddress": [],
"physicalAddress": "44:4c:a8:cd:33:7d",
"description": "description not available"
},
"Port-Channel1.20": {
"lastStatusChangeTimestamp": 1475664578.738529,
"name": "Port-Channel2.20",
"interfaceStatus": "notconnect",
"mtu": 1500,
"hardware": "subinterface",
"bandwidth": 0,
"forwardingModel": "routed",
"lineProtocolStatus": "lowerLayerDown",
"interfaceAddress": [
{
"secondaryIpsOrderedList": [],
"broadcastAddress": "255.255.255.255",
"secondaryIps": {},
"primaryIp": {
"maskLen": 31,
"address": "1.1.1.1"
},
"virtualIp": {
"maskLen": 0,
"address": "0.0.0.0"
}
}
],
"physicalAddress": "44:4c:a8:cd:33:7d",
"description": "Not available"
}
}
}

This file was deleted.

This file was deleted.

0 comments on commit 47f0eda

Please sign in to comment.