diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..27285ba --- /dev/null +++ b/.travis.yml @@ -0,0 +1,34 @@ +language: python + +python: + - 2.7 + +install: + - pip install -r requirements.txt + - pip install . + +deploy: + provider: pypi + user: dbarroso + password: + secure: FWTA4L2e08mMpD8BbCNWTZN1XFCQKSlYUfPqT0aXDz/GgEK2KfZqbzj1V8Xwx4pXuBHSy8JunlpLGdc18dqtfMKpryz7elWbIsvyPNvcVFxYatG1RdDZB3qiN0MWTCVOCTUyOeglbOsaahKlV66RGBRbQpx107woZ/I+hg43jeNdi6fUer5Ip2DXLMFkR7yb5vbI+tc9KM1Z3/isSzmpkYWQm1MUGxnFonye46r6MoSOANTDpzNIAQKOKwUvGwdovZCAhdqn8JQp8EsKB9Tl0QK56k2//TWmOlglvwL3vVHOeP0V12fc8viKvYRGXKSCwzcz+bi5RSGo0Afurc7lVrmHgJbJIfXxilucE0OBOn58487wynn3k+30D39V9PnddYJ6iNU1ji7/qYpCbyE9ydSKFu4rFgwDbFTU1kJ+JlmNmoJYET/rZITQNUjtFC9grtjSdpouurzNS4eSg7CD8EfzVV6i3IS+1p9n4xosUxdCRl8/jhm9pNMW2OaM00r4GwW2Xt4kDP9J8OWDhlErDLE5lR4EjuGPCLmCYTWcl3DtvUlDCqBs5JZutHV+6raHBw7qFUcI2MxacjQys/3etjIUb9UilbBP1cnqec5Q/FfcTvD0QXCT56f1eM87eh4ysxmHFIDrW+ZwaDW/DicOExfeq264bYOge01poQEkdGM= + on: + tags: true + branch: master + +script: + - cd test/unit + - nosetests -v TestIOSDriver:TestGetterIOSDriver.test_get_arp_table + - nosetests -v TestIOSDriver:TestGetterIOSDriver.test_get_bgp_neighbors + - nosetests -v TestIOSDriver:TestGetterIOSDriver.test_get_environment + - nosetests -v TestIOSDriver:TestGetterIOSDriver.test_get_facts + - nosetests -v TestIOSDriver:TestGetterIOSDriver.test_get_interfaces + - nosetests -v TestIOSDriver:TestGetterIOSDriver.test_get_interfaces_counters + - nosetests -v TestIOSDriver:TestGetterIOSDriver.test_get_interfaces_ip + - nosetests -v TestIOSDriver:TestGetterIOSDriver.test_get_lldp_neighbors + - nosetests -v TestIOSDriver:TestGetterIOSDriver.test_get_lldp_neighbors_detail + - nosetests -v TestIOSDriver:TestGetterIOSDriver.test_get_mac_address_table + - nosetests -v TestIOSDriver:TestGetterIOSDriver.test_get_ntp_peers + - nosetests -v TestIOSDriver:TestGetterIOSDriver.test_get_snmp_information + - nosetests -v TestIOSDriver:TestGetterIOSDriver.test_ios_only_bgp_time_conversion #IOS only test + - cd ../.. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..cd663b8 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +include requirements.txt +include napalm_ios/templates/*.j2 diff --git a/napalm_ios/__init__.py b/napalm_ios/__init__.py new file mode 100644 index 0000000..5a2b850 --- /dev/null +++ b/napalm_ios/__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_ios package.""" diff --git a/napalm/ios.py b/napalm_ios/ios.py similarity index 99% rename from napalm/ios.py rename to napalm_ios/ios.py index 458a638..f8a8fa7 100644 --- a/napalm/ios.py +++ b/napalm_ios/ios.py @@ -20,8 +20,8 @@ from datetime import datetime from netmiko import ConnectHandler, FileTransfer -from napalm.base import NetworkDriver -from napalm.exceptions import ReplaceConfigException, MergeConfigException +from napalm_base.base import NetworkDriver +from napalm_base.exceptions import ReplaceConfigException, MergeConfigException # Easier to store these as constants HOUR_SECONDS = 3600 @@ -1321,4 +1321,4 @@ def get_snmp_information(self): else: raise ValueError("Unexpected Response from the device") - return snmp_dict \ No newline at end of file + return snmp_dict diff --git a/napalm_ios/templates/delete_ntp_peers.j2 b/napalm_ios/templates/delete_ntp_peers.j2 new file mode 100644 index 0000000..159c33d --- /dev/null +++ b/napalm_ios/templates/delete_ntp_peers.j2 @@ -0,0 +1,3 @@ +{% for peer in template_vars %} +no ntp server {{peer}} +{% endfor %} diff --git a/napalm_ios/templates/set_hostname.j2 b/napalm_ios/templates/set_hostname.j2 new file mode 100644 index 0000000..5425366 --- /dev/null +++ b/napalm_ios/templates/set_hostname.j2 @@ -0,0 +1 @@ +hostname {{hostname}} diff --git a/napalm_ios/templates/set_ntp_peers.j2 b/napalm_ios/templates/set_ntp_peers.j2 new file mode 100644 index 0000000..c5e8423 --- /dev/null +++ b/napalm_ios/templates/set_ntp_peers.j2 @@ -0,0 +1,3 @@ +{% for peer in template_vars %} +ntp server {{peer}} +{% endfor %} diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..6ffada5 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +napalm-base +netmiko diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..4692f4f --- /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-ios", + 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-ios", + include_package_data=True, + install_requires=reqs, +) diff --git a/test/unit/TestIOSDriver.py b/test/unit/TestIOSDriver.py index 913ac57..cd72741 100644 --- a/test/unit/TestIOSDriver.py +++ b/test/unit/TestIOSDriver.py @@ -15,8 +15,8 @@ """Tests for IOSDriver.""" import unittest -from napalm import get_network_driver -from base import TestConfigNetworkDriver, TestGettersNetworkDriver +from napalm_ios import ios +from napalm_base.test.base import TestConfigNetworkDriver, TestGettersNetworkDriver import re @@ -52,10 +52,9 @@ def setUpClass(cls): username = 'vagrant' password = 'vagrant' cls.vendor = 'ios' - driver = get_network_driver(cls.vendor) optional_args = {'port': 12204, 'dest_file_system': 'bootflash:'} - cls.device = driver(ip_addr, username, password, optional_args=optional_args) + cls.device = ios.IOSDriver(ip_addr, username, password, optional_args=optional_args) cls.device.open() # Setup initial state @@ -134,11 +133,10 @@ def setUpClass(cls): ip_addr = '192.168.0.234' password = 'vagrant' cls.vendor = 'ios' - driver = get_network_driver(cls.vendor) optional_args = {} optional_args['dest_file_system'] = 'flash:' - cls.device = driver(ip_addr, username, password, optional_args=optional_args) + cls.device = ios.IOSDriver(ip_addr, username, password, optional_args=optional_args) if cls.mock: cls.device.device = FakeIOSDevice()