Skip to content

Commit

Permalink
Merge pull request #22 from napalm-automation/develop
Browse files Browse the repository at this point in the history
Release 0.2.0
  • Loading branch information
mirceaulinic committed Oct 25, 2016
2 parents 1183cc6 + 18d374a commit ad4bc37
Show file tree
Hide file tree
Showing 16 changed files with 726 additions and 23 deletions.
32 changes: 32 additions & 0 deletions .github/ISSUE_TEMPLATE
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
### Description of Issue/Question


### Did you follow the steps from https://github.com/napalm-automation/napalm#faq
- [ ] Yes
- [ ] No


### Setup

### napalm-panos version
(Paste verbatim output from `pip freeze | grep napalm-panos` between quotes below)

```

```

### PanOS version
(Paste verbatim output from `show system info` between quotes below)

```

```

### Steps to Reproduce the Issue

### Error Traceback
(Paste the complete traceback of the exception between quotes below)

```

```
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- Make sure you have read http://napalm.readthedocs.io/en/latest/contributing/index.html --!>
19 changes: 12 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
language: python

python:
- 2.7

install:
- pip install -r requirements.txt
- pip install -r requirements-dev.txt
- pip install .
- git clone https://github.com/napalm-automation/napalm-base.git napalm-automation/napalm-base
- cd napalm-automation/napalm-base
- python setup.py install
- cd ../..
- pip install coveralls

deploy:
provider: pypi
user: dbarroso
Expand All @@ -16,8 +16,13 @@ deploy:
on:
tags: true
branch: master

script:
- pylama .
- cd test/unit
- nosetests -v TestDriver:TestGetterDriver.test_get_facts
- nosetests -v TestDriver:TestGetterDriver.test_get_interfaces
- nosetests --with-coverage --cover-package napalm_panos -v TestDriver:TestGetterDriver.test_get_facts
- nosetests --with-coverage --cover-package napalm_panos -v TestDriver:TestGetterDriver.test_get_interfaces
- cd ../..
- coverage combine test/unit/.coverage

after_success: coveralls
1 change: 1 addition & 0 deletions CONTRIBUTING
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Please, read http://napalm.readthedocs.io/en/latest/contributing/index.html
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include requirements.txt
include include napalm_panos/templates/*.j2
include napalm_panos/templates/*.j2
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[![PyPI](https://img.shields.io/pypi/v/napalm-panos.svg)](https://pypi.python.org/pypi/napalm-panos)
[![PyPI](https://img.shields.io/pypi/dm/napalm-panos.svg)](https://pypi.python.org/pypi/napalm-panos)
[![Build Status](https://travis-ci.org/napalm-automation/napalm-panos.svg?branch=master)](https://travis-ci.org/napalm-automation/napalm-panos)
[![Coverage Status](https://coveralls.io/repos/github/napalm-automation/napalm-panos/badge.svg?branch=develop)](https://coveralls.io/github/napalm-automation/napalm-panos?branch=develop)

# napalm-panos
# napalm-panos
14 changes: 13 additions & 1 deletion napalm_panos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,16 @@
# the License.

"""napalm_panos package."""
from panos import PANOSDriver

# Import stdlib
import pkg_resources

# Import local modules
from napalm_panos.panos import PANOSDriver

try:
__version__ = pkg_resources.get_distribution('napalm-panos').version
except pkg_resources.DistributionNotFound:
__version__ = "Not installed"

__all__ = ('PANOSDriver',)
36 changes: 33 additions & 3 deletions napalm_panos/panos.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import time

# local modules
import napalm_base.exceptions
import napalm_base.helpers
from napalm_base.utils.string_parsers import convert_uptime_string_seconds
from napalm_base.exceptions import ConnectionException, ReplaceConfigException,\
MergeConfigException
Expand Down Expand Up @@ -127,7 +125,8 @@ def load_replace_candidate(self, filename=None, config=None):

path = self._import_file(filename)
if path is False:
raise ReplaceConfigException("Error while trying to move the config file to the device.")
msg = "Error while trying to move the config file to the device."
raise ReplaceConfigException(msg)

# Let's load the config.
cmd = '<load><config><from>{0}</from></config></load>'.format(path)
Expand Down Expand Up @@ -174,6 +173,37 @@ def _send_merge_commands(self, config, file_config):
self.loaded = True
self.merge_config = True

def _get_candidate(self):
candidate_command = '<show><config><candidate></candidate></config></show>'
self.device.op(cmd=candidate_command)
candidate = str(self.device.xml_root())
return candidate

def _get_running(self):
self.device.show()
running = str(self.device.xml_root())
return running

def get_config(self, retrieve='all'):
configs = {}
running = ''
candidate = ''
startup = ''

if retrieve == 'all':
running = self._get_running()
candidate = self._get_candidate()
elif retrieve == 'running':
running = self._get_running()
elif retrieve == 'candidate':
candidate = self._get_candidate()

configs['running'] = running
configs['candidate'] = candidate
configs['startup'] = startup

return configs

def load_merge_candidate(self, filename=None, config=None):
if filename:
file_config = True
Expand Down
6 changes: 0 additions & 6 deletions pylama.ini

This file was deleted.

8 changes: 8 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
coveralls
pytest
pytest-cov
pytest-json
pytest-pythonpath
pylama
flake8-import-order
-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
napalm-base==0.17.0
pan-python
netmiko>=0.5.0
requests-toolbelt
Expand Down
6 changes: 6 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[pylama]
linters = mccabe,pep8,pyflakes
ignore = D203,C901

[pylama:pep8]
max_line_length = 100
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.1.0",
version="0.2.0",
packages=find_packages(),
author="Gabriele Gerbino",
author_email="gabriele@networktocode.com",
Expand Down
9 changes: 7 additions & 2 deletions test/unit/TestDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from napalm_panos import panos
from napalm_base.test.base import TestConfigNetworkDriver, TestGettersNetworkDriver
from napalm_base import exceptions


class TestConfigDriver(unittest.TestCase, TestConfigNetworkDriver):
"""Group of tests that test Configuration related methods."""
Expand Down Expand Up @@ -67,11 +67,16 @@ def read_txt_file(filename):
return data_file.read()

def xml_root(self):
filename = self.cmd.replace('<', '_').replace('>', '_').replace('/', '_').replace('\n', '').replace(' ', '')
tmp_str = self.cmd.replace('<', '_').replace('>', '_')
filename = tmp_str.replace('/', '_').replace('\n', '').replace(' ', '')
xml_string = self.read_txt_file(
'panos/mock_data/{filename}.txt'.format(filename=filename[0:150]))
return xml_string

def op(self, cmd=''):
self.cmd = cmd
return True

def show(self, cmd=''):
self.cmd = 'running_config'
return True
Loading

0 comments on commit ad4bc37

Please sign in to comment.