[Python-modules-commits] [napalm-eos] 01/03: Import napalm-eos_0.5.1.orig.tar.gz

Vincent Bernat bernat at moszumanska.debian.org
Sun Jan 8 17:16:13 UTC 2017


This is an automated email from the git hooks/post-receive script.

bernat pushed a commit to branch master
in repository napalm-eos.

commit 249ebfe015c994ea41cd6ad3cb0e02710a5a3cab
Author: Vincent Bernat <bernat at debian.org>
Date:   Sun Jan 8 18:14:49 2017 +0100

    Import napalm-eos_0.5.1.orig.tar.gz
---
 PKG-INFO                                   |  2 +-
 napalm_eos.egg-info/PKG-INFO               |  2 +-
 napalm_eos.egg-info/SOURCES.txt            |  6 ++--
 napalm_eos/eos.py                          | 46 +++++++++++++++++++++---------
 napalm_eos/templates/delete_ntp_peers.j2   |  3 --
 napalm_eos/templates/delete_ntp_servers.j2 |  3 ++
 napalm_eos/templates/delete_snmp_config.j2 | 14 +++++++++
 napalm_eos/templates/set_ntp_peers.j2      |  3 --
 napalm_eos/templates/set_ntp_servers.j2    |  3 ++
 napalm_eos/templates/snmp_config.j2        | 22 ++++++++++++++
 setup.cfg                                  |  3 +-
 setup.py                                   |  2 +-
 12 files changed, 83 insertions(+), 26 deletions(-)

diff --git a/PKG-INFO b/PKG-INFO
index de91264..2a12cec 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: napalm-eos
-Version: 0.5.0
+Version: 0.5.1
 Summary: Network Automation and Programmability Abstraction Layer with Multivendor support
 Home-page: https://github.com/napalm-automation/napalm-eos
 Author: David Barroso, Mircea Ulinic
diff --git a/napalm_eos.egg-info/PKG-INFO b/napalm_eos.egg-info/PKG-INFO
index de91264..2a12cec 100644
--- a/napalm_eos.egg-info/PKG-INFO
+++ b/napalm_eos.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: napalm-eos
-Version: 0.5.0
+Version: 0.5.1
 Summary: Network Automation and Programmability Abstraction Layer with Multivendor support
 Home-page: https://github.com/napalm-automation/napalm-eos
 Author: David Barroso, Mircea Ulinic
diff --git a/napalm_eos.egg-info/SOURCES.txt b/napalm_eos.egg-info/SOURCES.txt
index cdd05dd..1d55617 100644
--- a/napalm_eos.egg-info/SOURCES.txt
+++ b/napalm_eos.egg-info/SOURCES.txt
@@ -9,8 +9,10 @@ napalm_eos.egg-info/SOURCES.txt
 napalm_eos.egg-info/dependency_links.txt
 napalm_eos.egg-info/requires.txt
 napalm_eos.egg-info/top_level.txt
-napalm_eos/templates/delete_ntp_peers.j2
-napalm_eos/templates/set_ntp_peers.j2
+napalm_eos/templates/delete_ntp_servers.j2
+napalm_eos/templates/delete_snmp_config.j2
+napalm_eos/templates/set_ntp_servers.j2
+napalm_eos/templates/snmp_config.j2
 napalm_eos/utils/__init__.py
 napalm_eos/utils/textfsm_templates/bgp_detail.tpl
 napalm_eos/utils/textfsm_templates/ntp_peers.tpl
diff --git a/napalm_eos/eos.py b/napalm_eos/eos.py
index a0c1c43..e7accf0 100644
--- a/napalm_eos/eos.py
+++ b/napalm_eos/eos.py
@@ -43,6 +43,7 @@ from napalm_base.utils import py23_compat
 from napalm_base.exceptions import ConnectionException, MergeConfigException, \
                         ReplaceConfigException, SessionLockedException, CommandErrorException
 
+import napalm_base.constants as c
 # local modules
 # here add local imports
 # e.g. import napalm_eos.helpers etc.
@@ -427,7 +428,7 @@ class EOSDriver(NetworkDriver):
     def get_environment(self):
         def extract_temperature_data(data):
             for s in data:
-                temp = s['currentTemperature']
+                temp = s['currentTemperature'] if 'currentTemperature' in s else 0.0
                 name = s['name']
                 values = {
                    'temperature': temp,
@@ -483,7 +484,7 @@ class EOSDriver(NetworkDriver):
         # Matches either of
         # Mem:   3844356k total,  3763184k used,    81172k free,    16732k buffers ( 4.16 > )
         # KiB Mem:  32472080 total,  5697604 used, 26774476 free,   372052 buffers ( 4.16 < )
-        mem_regex = '.*total,\s+ (?P<used>\d+)[k\s]+used,\s+(?P<free>\d+)[k\s]+free,.*'
+        mem_regex = '.*total,\s+(?P<used>\d+)[k\s]+used,\s+(?P<free>\d+)[k\s]+free,.*'
         m = re.match(mem_regex, cpu_lines[3])
         environment_counters['memory'] = {
             'available_ram': int(m.group('free')),
@@ -540,7 +541,7 @@ class EOSDriver(NetworkDriver):
                 )
         return lldp_neighbors_out
 
-    def cli(self, commands=None):
+    def cli(self, commands):
         cli_output = dict()
 
         if type(commands) is not list:
@@ -985,6 +986,9 @@ class EOSDriver(NetworkDriver):
     def get_route_to(self, destination='', protocol=''):
         routes = dict()
 
+        if protocol.lower() == 'direct':
+            protocol = 'connected'
+
         try:
             ipv = ''
             if IPNetwork(destination).version == 6:
@@ -992,9 +996,10 @@ class EOSDriver(NetworkDriver):
         except AddrFormatError:
             return 'Please specify a valid destination!'
 
-        command = 'show ip{ipv} route {destination} detail'.format(
+        command = 'show ip{ipv} route {destination} {protocol} detail'.format(
             ipv=ipv,
-            destination=destination
+            destination=destination,
+            protocol=protocol,
         )
 
         command_output = self.device.run_commands([command])[0]
@@ -1008,7 +1013,7 @@ class EOSDriver(NetworkDriver):
             if prefix not in routes.keys():
                 routes[prefix] = list()
             route_protocol = route_details.get('routeType').upper()
-            preference = route_details.get('preference')
+            preference = route_details.get('preference', 0)
 
             route = {
                 'current_active': False,
@@ -1066,12 +1071,20 @@ class EOSDriver(NetworkDriver):
             else:
                 for next_hop in route_details.get('vias'):
                     route_next_hop = route.copy()
-                    route_next_hop.update(
-                        {
-                            'next_hop': napalm_base.helpers.ip(next_hop.get('nexthopAddr')),
-                            'outgoing_interface': next_hop.get('interface')
-                        }
-                    )
+                    if next_hop.get('nexthopAddr') is None:
+                        route_next_hop.update(
+                            {
+                                'next_hop': '',
+                                'outgoing_interface': next_hop.get('interface')
+                            }
+                        )
+                    else:
+                        route_next_hop.update(
+                            {
+                                'next_hop': napalm_base.helpers.ip(next_hop.get('nexthopAddr')),
+                                'outgoing_interface': next_hop.get('interface')
+                            }
+                        )
                     routes[prefix].append(route_next_hop)
 
         return routes
@@ -1134,7 +1147,11 @@ class EOSDriver(NetworkDriver):
 
         return users
 
-    def traceroute(self, destination, source='', ttl=0, timeout=0):
+    def traceroute(self,
+                   destination,
+                   source=c.TRACEROUTE_SOURCE,
+                   ttl=c.TRACEROUTE_TTL,
+                   timeout=c.TRACEROUTE_TIMEOUT):
 
         _HOP_ENTRY_PROBE = [
             '\s+',
@@ -1541,7 +1558,8 @@ class EOSDriver(NetworkDriver):
         else:
             return vrfs
 
-    def ping(self, destination, source='', ttl=255, timeout=2, size=100, count=5):
+    def ping(self, destination, source=c.PING_SOURCE, ttl=c.PING_TTL, timeout=c.PING_TIMEOUT,
+             size=c.PING_SIZE, count=c.PING_COUNT):
         """
         Execute ping on the device and returns a dictionary with the result.
         Output dictionary has one of following keys:
diff --git a/napalm_eos/templates/delete_ntp_peers.j2 b/napalm_eos/templates/delete_ntp_peers.j2
deleted file mode 100644
index 159c33d..0000000
--- a/napalm_eos/templates/delete_ntp_peers.j2
+++ /dev/null
@@ -1,3 +0,0 @@
-{% for peer in template_vars %}
-no ntp server {{peer}}
-{% endfor %}
diff --git a/napalm_eos/templates/delete_ntp_servers.j2 b/napalm_eos/templates/delete_ntp_servers.j2
new file mode 100644
index 0000000..38accdf
--- /dev/null
+++ b/napalm_eos/templates/delete_ntp_servers.j2
@@ -0,0 +1,3 @@
+{% for server in servers %}
+no ntp server {{server}}
+{% endfor %}
diff --git a/napalm_eos/templates/delete_snmp_config.j2 b/napalm_eos/templates/delete_snmp_config.j2
new file mode 100644
index 0000000..0543dfe
--- /dev/null
+++ b/napalm_eos/templates/delete_snmp_config.j2
@@ -0,0 +1,14 @@
+{% if (location is defined) and location %}
+no snmp-server location "{{location}}"
+{% endif %}
+{% if (contact is defined) and contact %}
+no snmp-server contact "{{contact}}"
+{% endif %}
+{% if (chassis_id is defined) and chassis_id %}
+no snmp-server chassis-id "{{chassis_id}}"
+{% endif %}
+{% if (community is defined) and community %}
+{% for comm_name, comm_details in community.iteritems() %}
+no community {{comm_name}}
+{% endfor %}
+{% endif %}
diff --git a/napalm_eos/templates/set_ntp_peers.j2 b/napalm_eos/templates/set_ntp_peers.j2
deleted file mode 100644
index c5e8423..0000000
--- a/napalm_eos/templates/set_ntp_peers.j2
+++ /dev/null
@@ -1,3 +0,0 @@
-{% for peer in template_vars %}
-ntp server {{peer}}
-{% endfor %}
diff --git a/napalm_eos/templates/set_ntp_servers.j2 b/napalm_eos/templates/set_ntp_servers.j2
new file mode 100644
index 0000000..1cebc15
--- /dev/null
+++ b/napalm_eos/templates/set_ntp_servers.j2
@@ -0,0 +1,3 @@
+{% for server in servers %}
+ntp server {{server}}
+{% endfor %}
diff --git a/napalm_eos/templates/snmp_config.j2 b/napalm_eos/templates/snmp_config.j2
new file mode 100644
index 0000000..4e98e56
--- /dev/null
+++ b/napalm_eos/templates/snmp_config.j2
@@ -0,0 +1,22 @@
+{% if (location is defined) and location %}
+snmp-server location "{{location}}"
+{% endif %}
+{% if (contact is defined) and contact %}
+snmp-server contact "{{contact}}"
+{% endif %}
+{% if (chassis_id is defined) and chassis_id %}
+snmp-server chassis-id "{{chassis_id}}"
+{% endif %}
+{% if (community is defined) and community %}
+{% for comm_name, comm_details in community.iteritems() %}
+{% if (comm_details is defined) and comm_details %}
+{% if (comm_details.get('mode') is defined) and comm_details.get('mode') == 'rw' %}
+community {{comm_name}} rw
+{% else %}
+community {{comm_name}} ro
+{% endif %}
+{% else %}
+community {{comm_name}} ro
+{% endif %}
+{% endfor %}
+{% endif %}
diff --git a/setup.cfg b/setup.cfg
index b0920df..f32cbb1 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,12 +1,13 @@
 [pylama]
 linters = mccabe,pep8,pyflakes
 ignore = D203,C901
+skip = .tox/*
 
 [pylama:pep8]
 max_line_length = 100
 
 [pytest]
-addopts = --cov=./ -vs
+addopts = --cov=napalm_eos --cov-report term-missing -vs --pylama
 json_report = report.json
 jsonapi = true
 
diff --git a/setup.py b/setup.py
index f40af5d..b14324a 100644
--- a/setup.py
+++ b/setup.py
@@ -12,7 +12,7 @@ reqs = [str(ir.req) for ir in install_reqs]
 
 setup(
     name="napalm-eos",
-    version="0.5.0",
+    version="0.5.1",
     packages=find_packages(),
     author="David Barroso, Mircea Ulinic",
     author_email="dbarrosop at dravetech.com, mircea at cloudflare.com",

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/napalm-eos.git



More information about the Python-modules-commits mailing list