From 59200aad3442bb6e77e168f133e61c4fee552913 Mon Sep 17 00:00:00 2001 From: David Barroso Date: Fri, 11 Mar 2016 11:34:14 +0100 Subject: [PATCH] First working version --- .travis.yml | 22 ++++++++++++++++++ MANIFEST.in | 1 + README.md | 5 ++++ napalm_fortios/__init__.py | 15 ++++++++++++ {napalm => napalm_fortios}/fortios.py | 7 +++--- napalm_fortios/templates/set_hostname.j2 | 3 +++ requirements.txt | 2 ++ setup.py | 29 ++++++++++++++++++++++++ test/unit/TestFortiOSDriver.py | 4 ++-- 9 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 .travis.yml create mode 100644 MANIFEST.in create mode 100644 README.md create mode 100644 napalm_fortios/__init__.py rename {napalm => napalm_fortios}/fortios.py (98%) create mode 100644 napalm_fortios/templates/set_hostname.j2 create mode 100644 requirements.txt create mode 100644 setup.py diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f14df8b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,22 @@ +language: python +python: +- 2.7 +install: +- pip install -r requirements.txt +- pip install . +deploy: + provider: pypi + user: dbarroso + password: + secure: rc45r+LLfen9hE709M0voQ9bfyRbNE++lDVjuPG/qhVQHeYQnFijvT7c/ErFCkFdv+QzdvhM+8XLRYcQL98IJ+FvK7XFJdqZ26zNWKnyylLmT35FfNFOFsj95nitM3XO84es5PpOGZFINxUDg3QVHdN/jstzSJVSr7kHLlkvUFeFLUI5sDW0vlBIrSAs1bfL1ZFypkHnNyZPtvJn+Z4dkUw7Oe4+JfzEDBzKfs/cmxz7PpkSsKqmbYaFaCWTah3Sv7JAKFLEFYIVC19isj+ZGu4y6X1JDpe6OI2XBClpAeQRMO0Ae1RRuQTtmYcjzl55+RdKO3nP+cldSK3FoZbRvx36zv6zV9nD32MX+Jf3HhaHPWkolcLGmb4tiaKUfFuE/eEO3IPMP+5P+JqCn429h6MnP0xcggE9aKcSlcs5WWn69J29fkrvSrNIzuZcvjbGEqnGq8Wh6/RIOZbgE1jNlCjuKFtRLib9rQP0+RiUx7nOoakeul7PM5LpK+G9cPJKUPcATiI5d9VqspKsfsYeYSMpMSYNCRFz96W7b5JjwTKnZllHU2O3049WJPrnOvq9ZR2klbw5QGnfOV3RsdXv3FbV7eveXc3eeEXCok74CWmygAZ+OxHI6B0LRA35QRWRwjnyA4RVGvZjKusiJt+2HvQuyrURCieS58Wvl/81gwE= + on: + tags: true + branch: master +script: +- cd test/unit +- nosetests -v TestFortiOSDriver:TestGetterFortiOSDriver.test_get_bgp_neighbors +- nosetests -v TestFortiOSDriver:TestGetterFortiOSDriver.test_get_environment +- nosetests -v TestFortiOSDriver:TestGetterFortiOSDriver.test_get_facts +- nosetests -v TestFortiOSDriver:TestGetterFortiOSDriver.test_get_interfaces +- nosetests -v TestFortiOSDriver:TestGetterFortiOSDriver.test_get_interfaces_counters +- cd ../.. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..f9bd145 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include requirements.txt diff --git a/README.md b/README.md new file mode 100644 index 0000000..bde95cf --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +[![PyPI](https://img.shields.io/pypi/v/napalm-fortios.svg)](https://pypi.python.org/pypi/napalm-fortios) +[![PyPI](https://img.shields.io/pypi/dm/napalm-fortios.svg)](https://pypi.python.org/pypi/napalm-fortios) +[![Build Status](https://travis-ci.org/napalm-automation/napalm-fortios.svg?branch=master)](https://travis-ci.org/napalm-automation/napalm-fortios) + +# napalm-fortios diff --git a/napalm_fortios/__init__.py b/napalm_fortios/__init__.py new file mode 100644 index 0000000..c23939f --- /dev/null +++ b/napalm_fortios/__init__.py @@ -0,0 +1,15 @@ +# 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_fortios package.""" diff --git a/napalm/fortios.py b/napalm_fortios/fortios.py similarity index 98% rename from napalm/fortios.py rename to napalm_fortios/fortios.py index eebff57..cf47e63 100644 --- a/napalm/fortios.py +++ b/napalm_fortios/fortios.py @@ -14,9 +14,9 @@ import re from pyFG.fortios import FortiOS, FortiConfig, logger from pyFG.exceptions import FailedCommit, CommandExecutionException -from base import NetworkDriver -from exceptions import ReplaceConfigException, MergeConfigException -from napalm.utils.string_parsers import colon_separated_string_to_dict, convert_uptime_string_seconds +from napalm_base.base import NetworkDriver +from napalm_base.exceptions import ReplaceConfigException, MergeConfigException +from napalm_base.utils.string_parsers import colon_separated_string_to_dict, convert_uptime_string_seconds class FortiOSDriver(NetworkDriver): @@ -410,4 +410,3 @@ class FortiOSDriver(NetworkDriver): out['power'] = {t: {'status': True, 'capacity': -1.0, 'output': -1.0} for t in psus} return out - diff --git a/napalm_fortios/templates/set_hostname.j2 b/napalm_fortios/templates/set_hostname.j2 new file mode 100644 index 0000000..3590bf2 --- /dev/null +++ b/napalm_fortios/templates/set_hostname.j2 @@ -0,0 +1,3 @@ +config system global +set hostname "{{hostname}}” +end diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..3b4589b --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +napalm_base +pyFG diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..cbff92d --- /dev/null +++ b/setup.py @@ -0,0 +1,29 @@ +"""setup.py file.""" + +import uuid + +from setuptools import setup, find_packages +from pip.req import parse_requirements + +__author__ = 'David Barroso ' + +install_reqs = parse_requirements('requirements.txt', session=uuid.uuid1()) +reqs = [str(ir.req) for ir in install_reqs] + +setup( + name="napalm-fortios", + version="0.1.0", + packages=find_packages(), + author="David Barroso", + author_email="dbarrosop@dravetech.com", + description="Network Automation and Programmability Abstraction Layer with Multivendor support", + classifiers=[ + 'Topic :: Utilities', + 'Programming Language :: Python', + 'Operating System :: POSIX :: Linux', + 'Operating System :: MacOS', + ], + url="https://github.com/napalm-automation/napalm-fortios", + include_package_data=True, + install_requires=reqs, +) diff --git a/test/unit/TestFortiOSDriver.py b/test/unit/TestFortiOSDriver.py index 526287f..3605f8b 100644 --- a/test/unit/TestFortiOSDriver.py +++ b/test/unit/TestFortiOSDriver.py @@ -14,8 +14,8 @@ import unittest -from napalm.fortios import FortiOSDriver -from base import TestConfigNetworkDriver, TestGettersNetworkDriver +from napalm_fortios.fortios import FortiOSDriver +from napalm_base.test.base import TestConfigNetworkDriver, TestGettersNetworkDriver from pyFG.fortios import FortiConfig