diff --git a/.github/workflows/python36.yml b/.github/workflows/python36.yml new file mode 100644 index 0000000..d699210 --- /dev/null +++ b/.github/workflows/python36.yml @@ -0,0 +1,28 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python3.6 + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.6 + uses: actions/setup-python@v2 + with: + python-version: 3.6 + - name: Install dependencies + run: | + python setup.py install + - name: Run tests + run: | + python setup.py test diff --git a/.github/workflows/python37.yml b/.github/workflows/python37.yml new file mode 100644 index 0000000..85b5f3a --- /dev/null +++ b/.github/workflows/python37.yml @@ -0,0 +1,28 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python3.7 + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Install dependencies + run: | + python setup.py install + - name: Run tests + run: | + python setup.py test diff --git a/.github/workflows/python38.yml b/.github/workflows/python38.yml new file mode 100644 index 0000000..5c2f24a --- /dev/null +++ b/.github/workflows/python38.yml @@ -0,0 +1,28 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python3.8 + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install dependencies + run: | + python setup.py install + - name: Run tests + run: | + python setup.py test diff --git a/.travis.yml b/.travis.yml index 197185d..384e270 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,6 @@ language: python python: -- "3.6" -- "3.7" - "3.8" install: @@ -30,4 +28,3 @@ deploy: local-dir: "docs" on: branch: master - condition: $TRAVIS_PYTHON_VERSION = "3.6" diff --git a/netnir/__init__.py b/netnir/__init__.py index 6bee679..2c42bd6 100644 --- a/netnir/__init__.py +++ b/netnir/__init__.py @@ -3,4 +3,4 @@ netnir will create the default config and folders. """ -__version__ = "0.0.9" +__version__ = "0.0.10" diff --git a/netnir/core/inventory.py b/netnir/core/inventory.py index 2707715..10a06de 100644 --- a/netnir/core/inventory.py +++ b/netnir/core/inventory.py @@ -1,19 +1,9 @@ -from netnir.constants import ( - HOSTVARS, - GROUPVARS, - TEMPLATES, - DOMAIN, - NETNIR_USER, - NETNIR_PASS, -) -from netnir.helpers import device_mapper from nornir.core.deserializer.inventory import Inventory import os import yaml -"""dynamic inventory builder class -""" +"""dynamic inventory builder class""" class NornirInventory(Inventory): @@ -31,7 +21,13 @@ def __init__(self, **kwargs): ) def nhosts(self): + from netnir.helpers import device_mapper from netnir.core.credentials import Credentials + from netnir.constants import ( + HOSTVARS, + TEMPLATES, + DOMAIN, + ) """ load devices from host_vars and load them into the nornir inventory schema @@ -48,8 +44,8 @@ def nhosts(self): ) data[host] = { "hostname": f"{host}.{domain}" if domain else host, - "username": os.environ.get(NETNIR_USER, creds["username"]), - "password": os.environ.get(NETNIR_PASS, creds["password"]), + "username": creds["username"], + "password": creds["password"], "port": host_vars.get("port", 22), "platform": device_mapper(host_vars["os"]), "groups": host_vars.get("groups", list()), @@ -68,8 +64,8 @@ def nhosts(self): "connection_options": { "netconf": { "hostname": f"{host}.{domain}" if domain else host, - "username": os.environ.get(NETNIR_USER, creds["username"]), - "password": os.environ.get(NETNIR_PASS, creds["password"]), + "username": creds["username"], + "password": creds["password"], "platform": host_vars.get("os"), "port": host_vars.get("port", 830), "extras": {"hostkey_verify": False}, @@ -83,6 +79,8 @@ def ngroups(self): """ load groups from group_vars and load them into the nornir inventory schema """ + from netnir.constants import GROUPVARS + data = dict() groups = os.listdir(os.path.expanduser(GROUPVARS)) if "all" in groups: @@ -101,6 +99,8 @@ def ndefaults(self): """ load the defaults from group_vars/all and load them into the nornir inventory schema """ + from netnir.constants import GROUPVARS + if os.path.isfile(os.path.expanduser(GROUPVARS) + "/all"): default_vars = yaml.load( open(os.path.expanduser(GROUPVARS) + "/all"), Loader=yaml.SafeLoader,