-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial skeleton from napalm cookiecutter
- Loading branch information
Showing
24 changed files
with
254 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Senthil Kumar Ganesan <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Please, read http://napalm.readthedocs.io/en/latest/contributing/index.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include requirements.txt | ||
include napalm_dellos10/templates/*.j2 | ||
include napalm_dellos10/utils/textfsm_templates/*.tpl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright 2016 Dravetech AB. All rights reserved. | ||
# | ||
# The contents of this file are licensed under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with the | ||
# License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations under | ||
# the License. | ||
|
||
"""napalm-dellos10 package.""" | ||
from dellos10 import Dellos10Driver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Copyright 2016 Dravetech AB. All rights reserved. | ||
# | ||
# The contents of this file are licensed under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with the | ||
# License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations under | ||
# the License. | ||
|
||
""" | ||
Napalm driver for Dellos10. | ||
Read https://napalm.readthedocs.io for more information. | ||
""" | ||
|
||
from napalm_base.base import NetworkDriver | ||
from napalm_base.exceptions import ( | ||
ConnectionException, | ||
SessionLockedException, | ||
MergeConfigException, | ||
ReplaceConfigException, | ||
CommandErrorException, | ||
) | ||
|
||
|
||
class Dellos10Driver(NetworkDriver): | ||
"""Napalm driver for Dellos10.""" | ||
|
||
def __init__(self, hostname, username, password, timeout=60, optional_args=None): | ||
"""Constructor.""" | ||
self.device = None | ||
self.hostname = hostname | ||
self.username = username | ||
self.password = password | ||
self.timeout = timeout | ||
|
||
if optional_args is None: | ||
optional_args = {} | ||
|
||
def open(self): | ||
"""Implementation of NAPALM method open.""" | ||
pass | ||
|
||
def close(self): | ||
"""Implementation of NAPALM method close.""" | ||
pass |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""napalm.utils package.""" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
future >= 0.13.1, <1 | ||
pytest | ||
pytest-cov | ||
pytest-json | ||
pytest-pythonpath | ||
pylama | ||
flake8-import-order | ||
-r requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
napalm_base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[pylama] | ||
linters = mccabe,pep257,pep8,pyflakes,import_order | ||
ignore = D203 | ||
|
||
[pylama:pep8] | ||
max_line_length = 100 | ||
|
||
[pytest] | ||
addopts = --cov=napalm_dellos10 --cov-report term-missing -vs --pylama | ||
json_report = report.json | ||
jsonapi = true | ||
|
||
[coverage:run] | ||
include = | ||
napalm_skeleton/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""setup.py file.""" | ||
|
||
import uuid | ||
|
||
from setuptools import setup, find_packages | ||
from pip.req import parse_requirements | ||
|
||
__author__ = 'Senthil Kumar Ganesan <[email protected]>' | ||
|
||
install_reqs = parse_requirements('requirements.txt', session=uuid.uuid1()) | ||
reqs = [str(ir.req) for ir in install_reqs] | ||
|
||
setup( | ||
name="napalm-dellos10", | ||
version="0.1.0", | ||
packages=find_packages(), | ||
author="Senthil Kumar Ganesan", | ||
author_email="[email protected]", | ||
description="NAPALM driver for Dell EMC Networking OS10 Operating System.", | ||
classifiers=[ | ||
'Topic :: Utilities', | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 2', | ||
'Programming Language :: Python :: 2.7', | ||
'Operating System :: POSIX :: Linux', | ||
'Operating System :: MacOS', | ||
], | ||
url="https://github.com/skg-net/napalm-dellos10", | ||
include_package_data=True, | ||
install_requires=reqs, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright 2016 Dravetech AB. All rights reserved. | ||
# | ||
# The contents of this file are licensed under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with the | ||
# License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations under | ||
# the License. | ||
|
||
"""Tests.""" | ||
|
||
import unittest | ||
|
||
from napalm_dellos10 import dellos10 | ||
from napalm_base.test.base import TestConfigNetworkDriver | ||
|
||
|
||
class TestConfigDellos10Driver(unittest.TestCase, TestConfigNetworkDriver): | ||
"""Group of tests that test Configuration related methods.""" | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
"""Run before starting the tests.""" | ||
hostname = '127.0.0.1' | ||
username = 'vagrant' | ||
password = 'vagrant' | ||
cls.vendor = 'dellos10' | ||
|
||
optional_args = {'port': 12443, } | ||
cls.device = dellos10.Dellos10Driver(hostname, username, password, timeout=60, | ||
optional_args=optional_args) | ||
cls.device.open() | ||
|
||
cls.device.load_replace_candidate(filename='%s/initial.conf' % cls.vendor) | ||
cls.device.commit_config() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
"""Test fixtures.""" | ||
from builtins import super | ||
|
||
import pytest | ||
from napalm_base.test import conftest as parent_conftest | ||
|
||
from napalm_base.test.double import BaseTestDouble | ||
|
||
from napalm_dellos10 import dellos10 | ||
|
||
|
||
@pytest.fixture(scope='class') | ||
def set_device_parameters(request): | ||
"""Set up the class.""" | ||
def fin(): | ||
request.cls.device.close() | ||
request.addfinalizer(fin) | ||
|
||
request.cls.driver = dellos10.Dellos10Driver | ||
request.cls.patched_driver = PatchedDellos10Driver | ||
request.cls.vendor = 'dellos10' | ||
parent_conftest.set_device_parameters(request) | ||
|
||
|
||
def pytest_generate_tests(metafunc): | ||
"""Generate test cases dynamically.""" | ||
parent_conftest.pytest_generate_tests(metafunc, __file__) | ||
|
||
|
||
class PatchedDellos10Driver(dellos10.Dellos10Driver): | ||
"""Patched Dellos10 Driver.""" | ||
|
||
def __init__(self, hostname, username, password, timeout=60, optional_args=None): | ||
"""Patched Dellos10 Driver constructor.""" | ||
super().__init__(hostname, username, password, timeout, optional_args) | ||
|
||
self.patched_attrs = ['device'] | ||
self.device = FakeDellos10Device() | ||
|
||
|
||
class FakeDellos10Device(BaseTestDouble): | ||
"""Dellos10 device test double.""" | ||
|
||
def run_commands(self, command_list, encoding='json'): | ||
"""Fake run_commands.""" | ||
result = list() | ||
|
||
for command in command_list: | ||
filename = '{}.{}'.format(self.sanitize_text(command), encoding) | ||
full_path = self.find_file(filename) | ||
|
||
if encoding == 'json': | ||
result.append(self.read_json_file(full_path)) | ||
else: | ||
result.append({'output': self.read_txt_file(full_path)}) | ||
|
||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Initial configuration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Some changes that will be merged while testing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The diff when merging `merged_good.conf` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Some changes that will be merge while testing. Should contain a typo or something that triggers | ||
an error during the load/commmit phase |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
A full new configuration. It will be used to test the replace operation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
A diff between `initial.conf` and `new_good.conf` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
A full new configuration. However, it should contain a typo or something that triggers an error | ||
during commit/load phase. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"""Tests for getters.""" | ||
|
||
from napalm_base.test.getters import BaseTestGetters | ||
|
||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.usefixtures("set_device_parameters") | ||
class TestGetter(BaseTestGetters): | ||
"""Test get_* methods.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[tox] | ||
envlist = py27,py34,py35 | ||
|
||
[testenv] | ||
deps = | ||
-rrequirements-dev.txt | ||
|
||
commands= | ||
py.test |