Skip to content

Commit

Permalink
Merge pull request napalm-automation-community#56 from napalm-automat…
Browse files Browse the repository at this point in the history
…ion-community/develop

Merge to master
  • Loading branch information
itdependsnetworks authored Jan 28, 2018
2 parents 1cd80d5 + 3ea56ce commit ebf731f
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 15 deletions.
30 changes: 21 additions & 9 deletions napalm_panos/panos.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,21 @@
import time

# local modules
from napalm_base.utils.string_parsers import convert_uptime_string_seconds
from napalm_base.exceptions import ConnectionException, ReplaceConfigException,\
MergeConfigException
try:
from napalm.base.utils.string_parsers import convert_uptime_string_seconds
from napalm.base.exceptions import ConnectionException
from napalm.base.exceptions import ReplaceConfigException
from napalm.base.exceptions import MergeConfigException
from napalm.base import NetworkDriver
from napalm.base.utils import py23_compat
except ImportError:
from napalm_base.utils.string_parsers import convert_uptime_string_seconds
from napalm_base.exceptions import ConnectionException
from napalm_base.exceptions import ReplaceConfigException
from napalm_base.exceptions import MergeConfigException
from napalm_base.base import NetworkDriver
from napalm_base.utils import py23_compat

from napalm_base.base import NetworkDriver

from napalm_base.utils import py23_compat

from netmiko import ConnectHandler
from netmiko import __version__ as netmiko_version
Expand Down Expand Up @@ -372,9 +380,13 @@ def get_facts(self):

for element in interfaces:
for entry in interfaces[element]:
for intf in interfaces[element][entry]:
if intf['name'] not in facts['interface_list']:
facts['interface_list'].append(intf['name'])
if isinstance(interfaces[element][entry], list):
for intf in interfaces[element][entry]:
if intf['name'] not in facts['interface_list']:
facts['interface_list'].append(intf['name'])
else:
if interfaces[element][entry]['name'] not in facts['interface_list']:
facts['interface_list'].append(interfaces[element][entry]['name'])
facts['interface_list'].sort()
return facts

Expand Down
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>=2.3.0
pan-python
netmiko>=1.0.0
requests-toolbelt
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name="napalm-panos",
version="0.4.1",
version="0.5.1",
packages=find_packages(),
author="Gabriele Gerbino",
author_email="[email protected]",
Expand Down
2 changes: 1 addition & 1 deletion test/unit/TestDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import unittest

from napalm_panos import panos
from napalm_base.test.base import TestConfigNetworkDriver
from napalm.base.test.base import TestConfigNetworkDriver


class TestConfigDriver(unittest.TestCase, TestConfigNetworkDriver):
Expand Down
4 changes: 2 additions & 2 deletions test/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from builtins import super

import pytest
from napalm_base.test import conftest as parent_conftest
from napalm_base.test.double import BaseTestDouble
from napalm.base.test import conftest as parent_conftest
from napalm.base.test.double import BaseTestDouble

from napalm_panos import PANOSDriver as OriginalDriver

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<response status="success"><result>
<ifnet>
<entry>
<name>ethernet1/1</name>
<zone/>
<fwd>N/A</fwd>
<vsys>1</vsys>
<dyn-addr/>
<addr6/>
<tag>0</tag>
<ip>N/A</ip>
<id>16</id>
<addr/>
</entry>
<entry>
<name>ethernet1/1.135</name>
<zone>Untrust</zone>
<fwd>vr:default</fwd>
<vsys>1</vsys>
<dyn-addr/>
<addr6/>
<tag>135</tag>
<ip>10.20.30.40/29</ip>
<id>256</id>
<addr/>
</entry>
</ifnet>
<hw>
<entry>
<name>ethernet1/1</name>
<duplex>full</duplex>
<type>0</type>
<state>up</state>
<st>10000/full/up</st>
<mac>00:ca:fe:be:ef:00</mac>
<mode>(autoneg)</mode>
<speed>10000</speed>
<id>16</id>
</entry>
</hw>
</result></response>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<response status="success">
<result>
<system>
<hostname>pa1</hostname>
<ip-address>10.0.0.90</ip-address>
<netmask>255.255.255.0</netmask>
<default-gateway>10.0.0.2</default-gateway>
<ipv6-address>unknown</ipv6-address>
<ipv6-link-local-address>fe80::20c:29ff:fe6d:c67e/64</ipv6-link-local-address>
<ipv6-default-gateway></ipv6-default-gateway>
<mac-address>00:0c:29:6d:c6:7e</mac-address>
<time>Sun May 8 02:03:23 2016</time>
<uptime>11 days, 22:09:01</uptime>
<devicename>pa1</devicename>
<family>vm</family>
<model>PA-VM</model>
<serial>unknown</serial>
<vm-mac-base>BA:DB:EE:FB:AD:00</vm-mac-base>
<vm-mac-count>255</vm-mac-count>
<vm-uuid>564D8B6D-7BDB-75AF-400F-B062016DC67E</vm-uuid>
<vm-cpuid>FB060000FDFB8B07</vm-cpuid>
<vm-license>none</vm-license>
<vm-mode>VMWare ESXi</vm-mode>
<sw-version>7.0.1</sw-version>
<global-protect-client-package-version>0.0.0</global-protect-client-package-version>
<app-version>497-2688</app-version>
<app-release-date>unknown</app-release-date>
<av-version>0</av-version>
<av-release-date>unknown</av-release-date>
<threat-version>0</threat-version>
<threat-release-date>unknown</threat-release-date>
<wf-private-version>0</wf-private-version>
<wf-private-release-date>unknown</wf-private-release-date>
<url-db>paloaltonetworks</url-db>
<wildfire-version>0</wildfire-version>
<wildfire-release-date>unknown</wildfire-release-date>
<url-filtering-version>0000.00.00.000</url-filtering-version>
<global-protect-datafile-version>0</global-protect-datafile-version>
<global-protect-datafile-release-date>unknown</global-protect-datafile-release-date><logdb-version>7.0.9</logdb-version>
<platform-family>vm</platform-family>
<vpn-disable-mode>off</vpn-disable-mode>
<multi-vsys>off</multi-vsys>
<operational-mode>normal</operational-mode>
</system>
</result>
</response>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"uptime": 1030141, "vendor": "Palo Alto Networks", "hostname": "pa1", "fqdn": "N/A", "os_version": "7.0.1", "serial_number": "unknown", "model": "PA-VM", "interface_list": ["ethernet1/1", "ethernet1/1.135"]}
2 changes: 1 addition & 1 deletion test/unit/test_getters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Tests for getters."""

from napalm_base.test.getters import BaseTestGetters
from napalm.base.test.getters import BaseTestGetters


import pytest
Expand Down

0 comments on commit ebf731f

Please sign in to comment.