Skip to content

Commit

Permalink
Merge pull request #231 from napalm-automation/develop
Browse files Browse the repository at this point in the history
Merge develop into master, preparing release 0.5.0
  • Loading branch information
mirceaulinic committed May 8, 2018
2 parents dbdd16d + d7a56a0 commit 514c7eb
Show file tree
Hide file tree
Showing 29 changed files with 525 additions and 7 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.0b5
0.5.0
6 changes: 3 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ FROM alpine:3.6
ARG requirements=""
ARG version=""

WORKDIR /tmp/napalm-logs
COPY config.txt .
RUN mkdir /etc/napalm
COPY config.txt /etc/napalm/logs

# Install napalm-logs and pre-requisites
RUN apk add --no-cache \
Expand All @@ -21,4 +21,4 @@ RUN for req in $requirements; do \
pip install $req; \
done

CMD napalm-logs --config-file config.txt
CMD napalm-logs --config-file /etc/napalm/logs
35 changes: 35 additions & 0 deletions docs/releases/0.5.0.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.. _release-0.5.0:

==================================
Release 0.5.0 - Codename Drawknife
==================================

Cisco IOS Support
-----------------

Initial support for Cisco IOS has been added thanks to Nico Vinzens
(@nvinzens), providing notifications for :ref:`INTERFACE_DOWN`,
:ref:`OSPF_NEIGHBOR_UP`, and :ref:`OSPF_NEIGHBOR_DOWN`. We welcome your Pull
Requests to extend this list!

``napalm-logs`` Docker Image
----------------------------

The initial public version has been provided by Nathan Catania
(@nathancatania). Starting with this release, whenever we publish a new
``napalm-logs`` version, there will also be a new Docker image pushed to the
Docker hub. The image can be pulled from `<https://hub.docker.com/r/mirceaulinic/napalm-logs/>`_,
e.g., ``docker pull mirceaulinic/napalm-logs:0.5.0``.

New Structured Messages
-----------------------

- :ref:`INTERFACE_DUPLEX_MODE`, currently available only for ``nxos``.

The following messages were already defined, now extending the list of
supported platforms:

- :ref:`INTERFACE_DOWN` added for ``ios`` and ``nxos``.
- :ref:`INTERFACE_UP` added for ``nxos``.
- :ref:`OSPF_NEIGHBOR_UP` and :ref:`OSPF_NEIGHBOR_DOWN` added for ``ios``.
- :ref:`ISIS_NEIGHBOR_DOWN` and :ref:`ISIS_NEIGHBOR_UP` defined for ``junos``.
3 changes: 2 additions & 1 deletion docs/releases/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ Release Notes
Latest Release
^^^^^^^^^^^^^^

- :ref:`release-0.4.2`
- :ref:`release-0.5.0`

Previous Releases
^^^^^^^^^^^^^^^^^

- :ref:`release-0.4.2`
- :ref:`release-0.4.1`
- :ref:`release-0.4.0`
- :ref:`release-0.3.0`
Expand Down
11 changes: 11 additions & 0 deletions napalm_logs/config/eos/INTERFACE_UP.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
messages:
# 'error' should be unique and vendor agnostic. Currently we are using the JUNOS syslog message name as the canonical name.
# This may change if we are able to find a more well defined naming system.
- error: INTERFACE_UP
tag: LINEPROTO-5-UPDOWN
values:
interface: (\w+[\.\-\d\/\w]+)
description: (.*)
line: 'Line protocol on Interface {interface} ({description}), changed state to up'
model: openconfig-interfaces
mapping:
variables: {}
static:
interfaces//interface//{interface}//state//oper_status: UP
- error: INTERFACE_UP
tag: LINEPROTO-5-UPDOWN
values:
Expand Down
14 changes: 14 additions & 0 deletions napalm_logs/config/ios/INTERFACE_DOWN.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Interface GigabitEthernet2, changed state to administratively down

messages:
- error: INTERFACE_DOWN
tag: LINK-5-CHANGED
values:
interface: (\w+[\.\-\d\/\w+]+)
adminStatus|upper: (\w+)
line: 'Interface {interface}, changed state to administratively {adminStatus}'
model: openconfig-interfaces
mapping:
variables:
interfaces//interface//{interface}//state//admin_status: adminStatus
static: {}
18 changes: 18 additions & 0 deletions napalm_logs/config/ios/OSPF_NEIGHBOR_DOWN.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#<189>521: router1: *Mar 15 10:05:53.044: %OSPF-5-ADJCHG: Process 1, Nbr 172.16.46.4 on GigabitEthernet2.45 from INIT to DOWN, Neighbor Down: Dead timer expired

messages:
- error: OSPF_NEIGHBOR_DOWN
tag: OSPF-5-ADJCHG
values:
neighborIP: ([\w\d:\.]+)
interface: ([\w\d\.]+)
adjacencyStateChangeReasonMessage: ([\w+\s?]+)
initStatus: (\w+)
line: 'Nbr {neighborIP} on {interface} from {initStatus} to DOWN, Neighbor Down: {adjacencyStateChangeReasonMessage}'
model: openconfig-ospf
mapping:
variables:
network-instances//network-instance//global//protocols//protocol//ospf//ospfv2//areas//area//area//interfaces//interface//{interface}//neighbors//neighbor//{neighborIP}//state//adjacency-state-change-reason-message: adjacencyStateChangeReasonMessage
static:
network-instances//network-instance//global//protocols//protocol//ospf//ospfv2//areas//area//area//interfaces//interface//{interface}//neighbors//neighbor//{neighborIP}//state//adjacency-state: DOWN
network-instances//network-instance//global//protocols//protocol//ospf//ospfv2//areas//area//area//interfaces//interface//{interface}//neighbors//neighbor//{neighborIP}//state//adjacency-state-change-reason: INACTIVE_TIMER
15 changes: 15 additions & 0 deletions napalm_logs/config/ios/OSPF_NEIGHBOR_UP.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#<190>521: router1: *Mar 15 10:05:53.044: %OSPF-5-ADJCHG: Process 1, Nbr 172.16.46.4 on GigabitEthernet2.45 from LOADING to FULL, Loading Done

messages:
- error: OSPF_NEIGHBOR_UP
tag: OSPF-5-ADJCHG
values:
neighbor: ([\w\d:\.]+)
interface: ([\w\d\.]+)
initStatus: (\w+)
line: 'Nbr {neighbor} on {interface} from {initStatus} to FULL, Loading Done'
model: openconfig-ospf
mapping:
variables: {}
static:
network-instances//network-instance//global//protocols//protocol//ospf//ospfv2//areas//area//area//interfaces//interface//{interface}//neighbors//neighbor//{neighbor}//state//adjacency-state: UP
24 changes: 24 additions & 0 deletions napalm_logs/config/ios/init.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

#<189>521: router1: *Nov 14 08:30:56.699: %LINK-5-CHANGED: Interface GigabitEthernet2, changed state to administratively down
# host logging-id needs to be enabled (highly recommended) on the ios-device for the profiles to work
prefixes:
- time_format: "%b %d %H:%M:%S"
values:
messageId: (\d+)
host: ([^ ]+)
date: (\w+\s?\d+)
time: (\d\d:\d\d:\d\d)
milliseconds: (\d\d\d)
tag: ([\w-]+)
# some messages contain a process number (eg. OSPF related messages)
processId: (\d+)
line: '{messageId}: {host}: *{date} {time}.{milliseconds}: %{tag}: Process {processId}, '
- time_format: "%b %d %H:%M:%S"
values:
messageId: (\d+)
host: ([^ ]+)
date: (\w+\s?\d+)
time: (\d\d:\d\d:\d\d)
milliseconds: (\d+)
tag: ([\w-]+)
line: '{messageId}: {host}: *{date} {time}.{milliseconds}: %{tag}: '
25 changes: 25 additions & 0 deletions napalm_logs/config/nxos/INTERFACE_DOWN.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Interface Ethernet1/33 is down (Link failure)

messages:
- error: INTERFACE_DOWN
tag: ETHPORT-5-IF_DOWN_LINK_FAILURE
values:
interface: (\w+[\.\-\d\/\w+]+)
reason: (.*)
line: 'Interface {interface} is down ({reason})'
model: openconfig-interfaces
mapping:
variables:
interfaces//interface//{interface}//state//change_reason: reason
static:
interfaces//interface//{interface}//state//admin_status: DOWN
- error: INTERFACE_DOWN
tag: ETH_PORT_CHANNEL-5-PORT_INDIVIDUAL_DOWN
values:
interface: (\w+[\.\-\d\/\w+]+)
line: 'individual port {interface} is down'
model: openconfig-interfaces
mapping:
variables: {}
static:
interfaces//interface//{interface}//state//admin_status: DOWN
19 changes: 19 additions & 0 deletions napalm_logs/config/nxos/INTERFACE_DUPLEX_MODE.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This message type is received when there's a notification that the interface
# changed the duplex mode, e.g.,
#
# .. code-block:: text
#
# Interface Ethernet1/33, operational duplex mode changed to Full

messages:
- error: INTERFACE_DUPLEX_MODE
tag: ETHPORT-5-IF_DUPLEX
values:
interface: (\w+[\.\-\d\/\w+]+)
mode|upper: (\w+)
line: 'Interface {interface}, operational duplex mode changed to {mode}'
model: openconfig-interfaces
mapping:
variables:
interfaces//interface//{interface}//ethernet//state//duplex_mode: mode
static: {}
15 changes: 15 additions & 0 deletions napalm_logs/config/nxos/INTERFACE_UP.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Interface Ethernet1/33 is up in mode trunk

messages:
- error: INTERFACE_UP
tag: ETHPORT-5-IF_UP
values:
interface: (\w+[\.\-\d\/\w+]+)
mode|upper: (\w+)
line: 'Interface {interface} is up in mode {mode}'
model: openconfig-interfaces
mapping:
variables:
interfaces//interface//{interface}//ethernet//switched_vlan//state//interface_mode: mode
static:
interfaces//interface//{interface}//state//admin_status: UP
16 changes: 14 additions & 2 deletions napalm_logs/config/nxos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,23 @@
('message', r'(.*)')
]
_RGX_PARTS = OrderedDict(_RGX_PARTS)

_RGX = r'\<{0[pri]}\>{0[host]}: {0[date]} {0[time]} {0[timeZone]}: %{0[tag]}: {0[message]}'.format(_RGX_PARTS)

_ALT_RGX_PARTS = [
('pri', r'(\d+)'),
('date', r'(\d+ \w+ +\d+)'),
('time', r'(\d\d:\d\d:\d\d)'),
('host', r'([^ ]+)'),
('tag', r'([\w\d-]+)'),
('message', r'(.*)')
]
_ALT_RGX_PARTS = OrderedDict(_ALT_RGX_PARTS)
_ALT_RGX = r'\<{0[pri]}\>{0[date]} {0[time]} {0[host]} %{0[tag]}: {0[message]}'.format(_ALT_RGX_PARTS)

_TIME_FORMAT = ('{date} {time} {timeZone}', '%Y %b %d %H:%M:%S %Z')
_ALT_TIME_FORMAT = ('{date} {time}', '%Y %b %d %H:%M:%S')


def extract(msg):
return napalm_logs.utils.extract(_RGX, msg, _RGX_PARTS, _TIME_FORMAT)
return napalm_logs.utils.extract(_RGX, msg, _RGX_PARTS, _TIME_FORMAT) or\
napalm_logs.utils.extract(_ALT_RGX, msg, _ALT_RGX_PARTS, _ALT_TIME_FORMAT)
1 change: 1 addition & 0 deletions tests/config/eos/INTERFACE_UP/consistency_ftw/syslog.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<165>Feb 6 08:27:14 veos01 Ebra: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet28 (added description in EOS 4.19.6M), changed state to up
32 changes: 32 additions & 0 deletions tests/config/eos/INTERFACE_UP/consistency_ftw/yang.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"yang_message": {
"interfaces": {
"interface": {
"Ethernet28": {
"state": {
"oper_status": "UP"
}
}
}
}
},
"message_details": {
"severity": 5,
"facility": 20,
"pri": "165",
"processName": "Ebra",
"host": "veos01",
"tag": "LINEPROTO-5-UPDOWN",
"time": "08:27:14",
"date": "Feb 6",
"message": ": Line protocol on Interface Ethernet28 (added description in EOS 4.19.6M), changed state to up"
},
"facility": 20,
"ip": "127.0.0.1",
"error": "INTERFACE_UP",
"host": "veos01",
"yang_model": "openconfig-interfaces",
"timestamp": 1517905634,
"os": "eos",
"severity": 5
}
1 change: 1 addition & 0 deletions tests/config/ios/INTERFACE_DOWN/default/syslog.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<189>521: router1: *Nov 14 08:30:56.699: %LINK-5-CHANGED: Interface GigabitEthernet2, changed state to administratively down
33 changes: 33 additions & 0 deletions tests/config/ios/INTERFACE_DOWN/default/yang.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"yang_message": {
"interfaces": {
"interface": {
"GigabitEthernet2": {
"state": {
"admin_status": "DOWN"
}
}
}
}
},
"message_details": {
"severity": 5,
"facility": 23,
"pri": "189",
"host": "router1",
"tag": "LINK-5-CHANGED",
"time": "08:30:56",
"date": "Nov 14",
"messageId": "521",
"milliseconds": "699",
"message": "Interface GigabitEthernet2, changed state to administratively down"
},
"timestamp": 1507969856,
"facility": 23,
"ip": "127.0.0.1",
"host": "router1",
"yang_model": "openconfig-interfaces",
"error": "INTERFACE_DOWN",
"os": "ios",
"severity": 5
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<189>521: router1: *Mar 15 10:05:53.044: %OSPF-5-ADJCHG: Process 1, Nbr 172.16.46.4 on GigabitEthernet2.45 from INIT to DOWN, Neighbor Down: Dead timer expired
62 changes: 62 additions & 0 deletions tests/config/ios/OSPF_NEIGHBOR_DOWN/init_to_down/yang.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"yang_message": {
"network-instances": {
"network-instance": {
"global": {
"protocols": {
"protocol": {
"ospf": {
"ospfv2": {
"areas": {
"area": {
"area": {
"interfaces": {
"interface": {
"GigabitEthernet2.45": {
"neighbors": {
"neighbor": {
"172.16.46.4": {
"state": {
"adjacency-state-change-reason-message": "Dead timer expired",
"adjacency-state": "DOWN",
"adjacency-state-change-reason": "INACTIVE_TIMER"
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
},
"message_details": {
"date": "Mar 15",
"time": "10:05:53",
"host": "router1",
"processId": "1",
"tag": "OSPF-5-ADJCHG",
"pri": "189",
"messageId": "521",
"milliseconds": "044",
"message": "Nbr 172.16.46.4 on GigabitEthernet2.45 from INIT to DOWN, Neighbor Down: Dead timer expired",
"facility": 23,
"severity": 5
},
"yang_model": "openconfig-ospf",
"os": "ios",
"facility": 23,
"severity": 5,
"error": "OSPF_NEIGHBOR_DOWN",
"host": "router1",
"ip": "127.0.0.1",
"timestamp": 1521108353
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<190>521: router1: *Mar 15 10:05:53.044: %OSPF-5-ADJCHG: Process 1, Nbr 172.16.46.4 on GigabitEthernet2.45 from LOADING to FULL, Loading Done

0 comments on commit 514c7eb

Please sign in to comment.