Skip to content

Commit

Permalink
move to ruamel.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarrosop committed Jun 18, 2018
1 parent bca9720 commit c153b7d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions nornir/core/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os


import yaml
import ruamel.yaml


CONF = {
Expand Down Expand Up @@ -93,7 +93,7 @@ class Config(object):
def __init__(self, config_file=None, **kwargs):
if config_file:
with open(config_file, "r") as f:
data = yaml.load(f.read()) or {}
data = ruamel.yaml.safe_load(f.read()) or {}
else:
data = {}

Expand Down
6 changes: 3 additions & 3 deletions nornir/plugins/inventory/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from nornir.core.inventory import Inventory

import yaml
import ruamel.yaml


class SimpleInventory(Inventory):
Expand Down Expand Up @@ -118,12 +118,12 @@ class SimpleInventory(Inventory):

def __init__(self, host_file="hosts.yaml", group_file="groups.yaml", **kwargs):
with open(host_file, "r") as f:
hosts = yaml.load(f.read())
hosts = ruamel.yaml.safe_load(f.read())

if group_file:
if os.path.exists(group_file):
with open(group_file, "r") as f:
groups = yaml.load(f.read())
groups = ruamel.yaml.safe_load(f.read())
else:
logging.warning("{}: doesn't exist".format(group_file))
groups = {}
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
colorama
pyyaml
jinja2
napalm>=2.3.0
netmiko>=2.1.1
Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_configuration/config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
num_workers: 10
raise_on_error: no
raise_on_error: false
user_defined: "asdasd"
my_root:
user_defined: "i am nested"

0 comments on commit c153b7d

Please sign in to comment.