Skip to content
This repository was archived by the owner on Nov 15, 2024. It is now read-only.

Commit bde89e0

Browse files
authored
Merge pull request #12 from netdevops/credential-bugs
bug fixes in credentials
2 parents 302c4eb + 9fdcb28 commit bde89e0

6 files changed

Lines changed: 100 additions & 19 deletions

File tree

.github/workflows/python36.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Python3.6
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Set up Python 3.6
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: 3.6
23+
- name: Install dependencies
24+
run: |
25+
python setup.py install
26+
- name: Run tests
27+
run: |
28+
python setup.py test

.github/workflows/python37.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Python3.7
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Set up Python 3.7
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: 3.7
23+
- name: Install dependencies
24+
run: |
25+
python setup.py install
26+
- name: Run tests
27+
run: |
28+
python setup.py test

.github/workflows/python38.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Python3.8
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Set up Python 3.8
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: 3.8
23+
- name: Install dependencies
24+
run: |
25+
python setup.py install
26+
- name: Run tests
27+
run: |
28+
python setup.py test

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
language: python
22

33
python:
4-
- "3.6"
5-
- "3.7"
64
- "3.8"
75

86
install:
@@ -30,4 +28,3 @@ deploy:
3028
local-dir: "docs"
3129
on:
3230
branch: master
33-
condition: $TRAVIS_PYTHON_VERSION = "3.6"

netnir/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
netnir will create the default config and folders.
44
"""
55

6-
__version__ = "0.0.9"
6+
__version__ = "0.0.10"

netnir/core/inventory.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
1-
from netnir.constants import (
2-
HOSTVARS,
3-
GROUPVARS,
4-
TEMPLATES,
5-
DOMAIN,
6-
NETNIR_USER,
7-
NETNIR_PASS,
8-
)
9-
from netnir.helpers import device_mapper
101
from nornir.core.deserializer.inventory import Inventory
112
import os
123
import yaml
134

145

15-
"""dynamic inventory builder class
16-
"""
6+
"""dynamic inventory builder class"""
177

188

199
class NornirInventory(Inventory):
@@ -31,7 +21,13 @@ def __init__(self, **kwargs):
3121
)
3222

3323
def nhosts(self):
24+
from netnir.helpers import device_mapper
3425
from netnir.core.credentials import Credentials
26+
from netnir.constants import (
27+
HOSTVARS,
28+
TEMPLATES,
29+
DOMAIN,
30+
)
3531

3632
"""
3733
load devices from host_vars and load them into the nornir inventory schema
@@ -48,8 +44,8 @@ def nhosts(self):
4844
)
4945
data[host] = {
5046
"hostname": f"{host}.{domain}" if domain else host,
51-
"username": os.environ.get(NETNIR_USER, creds["username"]),
52-
"password": os.environ.get(NETNIR_PASS, creds["password"]),
47+
"username": creds["username"],
48+
"password": creds["password"],
5349
"port": host_vars.get("port", 22),
5450
"platform": device_mapper(host_vars["os"]),
5551
"groups": host_vars.get("groups", list()),
@@ -68,8 +64,8 @@ def nhosts(self):
6864
"connection_options": {
6965
"netconf": {
7066
"hostname": f"{host}.{domain}" if domain else host,
71-
"username": os.environ.get(NETNIR_USER, creds["username"]),
72-
"password": os.environ.get(NETNIR_PASS, creds["password"]),
67+
"username": creds["username"],
68+
"password": creds["password"],
7369
"platform": host_vars.get("os"),
7470
"port": host_vars.get("port", 830),
7571
"extras": {"hostkey_verify": False},
@@ -83,6 +79,8 @@ def ngroups(self):
8379
"""
8480
load groups from group_vars and load them into the nornir inventory schema
8581
"""
82+
from netnir.constants import GROUPVARS
83+
8684
data = dict()
8785
groups = os.listdir(os.path.expanduser(GROUPVARS))
8886
if "all" in groups:
@@ -101,6 +99,8 @@ def ndefaults(self):
10199
"""
102100
load the defaults from group_vars/all and load them into the nornir inventory schema
103101
"""
102+
from netnir.constants import GROUPVARS
103+
104104
if os.path.isfile(os.path.expanduser(GROUPVARS) + "/all"):
105105
default_vars = yaml.load(
106106
open(os.path.expanduser(GROUPVARS) + "/all"), Loader=yaml.SafeLoader,

0 commit comments

Comments
 (0)