Skip to content
This repository has been archived by the owner on Sep 17, 2019. It is now read-only.

Commit

Permalink
Merge pull request #93 from napalm-automation/develop
Browse files Browse the repository at this point in the history
Release 0.5.3
  • Loading branch information
mirceaulinic committed Jun 26, 2017
2 parents 740bdeb + 63c2d19 commit f3b0e9c
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 19 deletions.
23 changes: 19 additions & 4 deletions napalm_nxos/nxos.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ def _compute_timestamp(stupid_cisco_output):
if not stupid_cisco_output or stupid_cisco_output == 'never':
return -1.0

if '(s)' in stupid_cisco_output:
pass
elif ':' in stupid_cisco_output:
stupid_cisco_output = stupid_cisco_output.replace(':', 'hour(s) ', 1)
stupid_cisco_output = stupid_cisco_output.replace(':', 'minute(s) ', 1)
stupid_cisco_output += 'second(s)'
else:
stupid_cisco_output = stupid_cisco_output.replace('d', 'day(s) ')
stupid_cisco_output = stupid_cisco_output.replace('h', 'hour(s)')

things = {
'second(s)': {
'weight': 1
Expand Down Expand Up @@ -226,6 +236,9 @@ def _send_file(self, filename, dest):
if not self.fc.remote_file_exists():
self.fc.send()
elif not self.fc.file_already_exists():
commands = ['terminal dont-ask',
'delete {0}'.format(self.fc.dst)]
self.device.config_list(commands)
self.fc.send()
except NXOSFileTransferError as fte:
raise ReplaceConfigException(fte.message)
Expand Down Expand Up @@ -329,9 +342,10 @@ def commit_config(self):
raise ReplaceConfigException('No config loaded.')

def _delete_file(self, filename):
self.device.show('terminal dont-ask', raw_text=True)
self.device.show('delete {}'.format(filename), raw_text=True)
self.device.show('no terminal dont-ask', raw_text=True)
commands = ['terminal dont-ask',
'delete {}'.format(filename),
'no terminal dont-ask']
self.device.show_list(commands, raw_text=True)

def discard_config(self):
if self.loaded:
Expand Down Expand Up @@ -439,10 +453,11 @@ def get_bgp_neighbors(self):

for neighbor_dict in neighbors_list:
neighborid = napalm_base.helpers.ip(neighbor_dict['neighbor-id'])
remoteas = napalm_base.helpers.as_number(neighbor_dict['remoteas'])

result_peer_dict = {
'local_as': int(vrf_dict['local-as']),
'remote_as': int(neighbor_dict['remoteas']),
'remote_as': remoteas,
'remote_id': neighborid,
'is_enabled': True,
'uptime': -1,
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ pytest-json
pytest-pythonpath
pylama
flake8-import-order
mock
-r requirements.txt

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
napalm-base>=0.18.0
napalm-base>=0.24.0
pynxos
netaddr
future
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

setup(
name="napalm-nxos",
version="0.5.2",
packages=find_packages(),
version="0.5.3",
packages=find_packages(exclude=["test", "test.*"]),
author="David Barroso",
author_email="dbarrosop@dravetech.com",
description="Network Automation and Programmability Abstraction Layer with Multivendor support",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,26 @@
}
}
}
},
"red": {
"router_id": "10.1.100.20",
"peers": {
"10.1.100.21": {
"is_enabled": true,
"uptime": -1,
"remote_as": 4261806180,
"description": "",
"remote_id": "10.1.100.21",
"local_as": 65535,
"is_up": true,
"address_family": {
"ipv4": {
"sent_prefixes": -1,
"accepted_prefixes": -1,
"received_prefixes": -1
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,26 @@
"state": "1"
}
}
}, {
"vrf-name-out": "red",
"local-as": "65535",
"vrfpeers": "1",
"vrfestablishedpeers": "0",
"router-id": "10.1.100.20",
"TABLE_neighbor": {
"ROW_neighbor": {
"neighbor-id": "10.1.100.21",
"remoteas": "65030.100",
"connectionsdropped": "7",
"localport": "0/0",
"notificationssent": "6",
"notificationsreceived": "0",
"lastflap": "P1M6DT17H23M26S",
"lastread": "PT0S",
"lastwrite": "PT0S",
"state": "1"
}
}
}]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@
"Ethernet2/1": {
"is_enabled": true,
"description": "",
"last_flapped": -1.0,
"last_flapped": 1498617600,
"is_up": true,
"mac_address": "2C:C2:60:4F:FE:B2",
"speed": 1000
Expand Down Expand Up @@ -810,15 +810,15 @@
"Ethernet2/3": {
"is_enabled": true,
"description": "",
"last_flapped": -1.0,
"last_flapped": 1499978034,
"is_up": true,
"mac_address": "2C:C2:60:4F:FE:B2",
"speed": 1000
},
"Ethernet2/2": {
"is_enabled": true,
"description": "",
"last_flapped": -1.0,
"last_flapped": 1499539200,
"is_up": true,
"mac_address": "2C:C2:60:4F:FE:B2",
"speed": 1000
Expand Down Expand Up @@ -1167,4 +1167,4 @@
"mac_address": "00:0C:29:D1:D5:6B",
"speed": 1000
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"eth_swt_monitor": "off",
"eth_ethertype": "0x8100",
"eth_eee_state": "n/a",
"eth_link_flapped": "never",
"eth_link_flapped": "2week(s) 2day(s)",
"eth_clear_counters": "never",
"eth_reset_cntr": 1,
"eth_load_interval1_rx": 0,
Expand Down Expand Up @@ -153,7 +153,7 @@
"eth_swt_monitor": "off",
"eth_ethertype": "0x8100",
"eth_eee_state": "n/a",
"eth_link_flapped": "never",
"eth_link_flapped": "5d08h",
"eth_clear_counters": "never",
"eth_reset_cntr": 1,
"eth_load_interval1_rx": 0,
Expand Down Expand Up @@ -241,7 +241,7 @@
"eth_swt_monitor": "off",
"eth_ethertype": "0x8100",
"eth_eee_state": "n/a",
"eth_link_flapped": "never",
"eth_link_flapped": "06:06:06",
"eth_clear_counters": "never",
"eth_reset_cntr": 1,
"eth_load_interval1_rx": 0,
Expand Down Expand Up @@ -12885,4 +12885,4 @@
}
]
}
}
}
21 changes: 19 additions & 2 deletions test/unit/test_getters.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
"""Tests for getters."""

from napalm_base.test.getters import BaseTestGetters

from napalm_base.test.getters import BaseTestGetters, wrap_test_cases
from napalm_base.test import helpers
from napalm_base.test import models

import pytest
from mock import patch


def mock_time():
return 1500000000.000000


@pytest.mark.usefixtures("set_device_parameters")
class TestGetter(BaseTestGetters):
"""Test get_* methods."""
@patch('time.time', mock_time)
@wrap_test_cases
def test_get_interfaces(self, test_case):
"""Test get_interfaces."""
get_interfaces = self.device.get_interfaces()
assert len(get_interfaces) > 0

for interface, interface_data in get_interfaces.items():
assert helpers.test_model(models.interface, interface_data)

return get_interfaces

0 comments on commit f3b0e9c

Please sign in to comment.