Skip to content

Commit

Permalink
Merge pull request #141 from nornir-automation/rename_abbreviations
Browse files Browse the repository at this point in the history
rename abbreviations
  • Loading branch information
dbarrosop committed May 16, 2018
2 parents f01a4c7 + 5c74d0e commit 439a0fd
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 69 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Read the [Nornir documentation](https://nornir.readthedocs.io/) online or review
Examples
========

You can find some examples and already made tools [here](https://github.com/nornir-automation/brg-tools/)
You can find some examples and already made tools [here](https://github.com/nornir-automation/nornir-tools/)


Bugs & New features
Expand Down
6 changes: 3 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ Here is an example on how to quickly build a runbook leveraging Nornir to retrie
from nornir.plugins.functions.text import print_result
from nornir.plugins.tasks.networking import napalm_get

brg = InitNornir(
nr = InitNornir(
config_file="nornir.yaml", dry_run=True, num_workers=20
)

results = brg.run(
results = nr.run(
task=napalm_get, getters=["facts", "interfaces"]
)
print_result(results)

You can find this and other examples `here <https://github.com/nornir-automation/brg-tools/>`_.
You can find this and other examples `here <https://github.com/nornir-automation/nornir-tools/>`_.

Contents
========
Expand Down
8 changes: 4 additions & 4 deletions docs/tutorials/intro/executing_tasks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"outputs": [],
"source": [
"from nornir.core import InitNornir\n",
"brg = InitNornir(config_file=\"config.yaml\")"
"nr = InitNornir(config_file=\"config.yaml\")"
]
},
{
Expand Down Expand Up @@ -55,7 +55,7 @@
"from nornir.plugins.tasks import commands\n",
"from nornir.plugins.functions.text import print_result\n",
"\n",
"cmh_hosts = brg.filter(site=\"cmh\", role=\"host\")\n",
"cmh_hosts = nr.filter(site=\"cmh\", role=\"host\")\n",
"\n",
"result = cmh_hosts.run(task=commands.remote_command,\n",
" command=\"ls -la /tmp\")\n",
Expand Down Expand Up @@ -138,7 +138,7 @@
"source": [
"from nornir.plugins.tasks import networking\n",
"\n",
"cmh_spines = brg.filter(site=\"bma\", role=\"spine\")\n",
"cmh_spines = nr.filter(site=\"bma\", role=\"spine\")\n",
"result = cmh_spines.run(task=networking.napalm_get,\n",
" getters=[\"facts\"]) \n",
"print_result(result)"
Expand Down Expand Up @@ -195,7 +195,7 @@
"def hi(task):\n",
" print(f\"hi! My name is {task.host.name} and I live in {task.host['site']}\")\n",
" \n",
"brg.run(task=hi, num_workers=1)"
"nr.run(task=hi, num_workers=1)"
]
},
{
Expand Down
14 changes: 7 additions & 7 deletions docs/tutorials/intro/failed_tasks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"from nornir.plugins.tasks import networking, text\n",
"from nornir.plugins.functions.text import print_result\n",
"\n",
"brg = InitNornir(config_file=\"config.yaml\")\n",
"cmh = brg.filter(site=\"cmh\", type=\"network_device\")"
"nr = InitNornir(config_file=\"config.yaml\")\n",
"cmh = nr.filter(site=\"cmh\", type=\"network_device\")"
]
},
{
Expand Down Expand Up @@ -429,7 +429,7 @@
}
],
"source": [
"brg.data.failed_hosts"
"nr.data.failed_hosts"
]
},
{
Expand All @@ -456,8 +456,8 @@
}
],
"source": [
"brg.data.reset_failed_hosts()\n",
"brg.data.failed_hosts"
"nr.data.reset_failed_hosts()\n",
"nr.data.failed_hosts"
]
},
{
Expand All @@ -484,8 +484,8 @@
}
],
"source": [
"brg = InitNornir(config_file=\"config.yaml\", raise_on_error=True)\n",
"cmh = brg.filter(site=\"cmh\", type=\"network_device\")\n",
"nr = InitNornir(config_file=\"config.yaml\", raise_on_error=True)\n",
"cmh = nr.filter(site=\"cmh\", type=\"network_device\")\n",
"try:\n",
" cmh.run(task=basic_configuration)\n",
"except NornirExecutionError:\n",
Expand Down
8 changes: 4 additions & 4 deletions docs/tutorials/intro/grouping_tasks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"from nornir.plugins.tasks import networking, text\n",
"from nornir.plugins.functions.text import print_title, print_result\n",
"\n",
"brg = InitNornir(config_file=\"config.yaml\", dry_run=True)\n",
"cmh = brg.filter(site=\"cmh\", type=\"network_device\")"
"nr = InitNornir(config_file=\"config.yaml\", dry_run=True)\n",
"cmh = nr.filter(site=\"cmh\", type=\"network_device\")"
]
},
{
Expand Down Expand Up @@ -210,7 +210,7 @@
"However, this was a `dry_run`. Let's set the `dry_run` variable to `False` so changes are commited and then run the code again:\n",
"\n",
"<div class=\"alert alert-info\">\n",
"**Note:** The `dry_run` value is shared between the main nornir objects and its childs so in the snippet below `brg.dry_run = False` and `cmh.dry_run = False` are equivalent.\n",
"**Note:** The `dry_run` value is shared between the main nornir objects and its childs so in the snippet below `nr.dry_run = False` and `cmh.dry_run = False` are equivalent.\n",
"</div>"
]
},
Expand Down Expand Up @@ -290,7 +290,7 @@
}
],
"source": [
"brg.dry_run = False\n",
"nr.dry_run = False\n",
"print_title(\"Playbook to configure the network\")\n",
"result = cmh.run(task=basic_configuration)\n",
"print_result(result)"
Expand Down
8 changes: 4 additions & 4 deletions docs/tutorials/intro/initializing_nornir.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
"outputs": [],
"source": [
"from nornir.core import InitNornir\n",
"brg = InitNornir(config_file=\"config.yaml\")"
"nr = InitNornir(config_file=\"config.yaml\")"
]
},
{
Expand All @@ -164,7 +164,7 @@
"outputs": [],
"source": [
"from nornir.core import InitNornir\n",
"brg = InitNornir(num_workers=100,\n",
"nr = InitNornir(num_workers=100,\n",
" inventory=\"nornir.plugins.inventory.simple.SimpleInventory\",\n",
" SimpleInventory={\"host_file\": \"inventory/hosts.yaml\",\n",
" \"group_file\": \"inventory/groups.yaml\"})"
Expand All @@ -184,7 +184,7 @@
"outputs": [],
"source": [
"from nornir.core import InitNornir\n",
"brg = InitNornir(num_workers=50, config_file=\"config.yaml\")"
"nr = InitNornir(num_workers=50, config_file=\"config.yaml\")"
]
},
{
Expand All @@ -204,7 +204,7 @@
}
],
"source": [
"brg.config.num_workers"
"nr.config.num_workers"
]
}
],
Expand Down
32 changes: 16 additions & 16 deletions docs/tutorials/intro/inventory.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,9 @@
],
"source": [
"from nornir.core import InitNornir\n",
"brg = InitNornir(config_file=\"config.yaml\")\n",
"nr = InitNornir(config_file=\"config.yaml\")\n",
"\n",
"brg.inventory"
"nr.inventory"
]
},
{
Expand Down Expand Up @@ -458,7 +458,7 @@
}
],
"source": [
"brg.inventory.hosts"
"nr.inventory.hosts"
]
},
{
Expand All @@ -481,7 +481,7 @@
}
],
"source": [
"brg.inventory.groups"
"nr.inventory.groups"
]
},
{
Expand All @@ -501,7 +501,7 @@
}
],
"source": [
"brg.inventory.hosts[\"leaf01.bma\"]"
"nr.inventory.hosts[\"leaf01.bma\"]"
]
},
{
Expand All @@ -528,7 +528,7 @@
}
],
"source": [
"host = brg.inventory.hosts[\"leaf01.bma\"]\n",
"host = nr.inventory.hosts[\"leaf01.bma\"]\n",
"host.keys()"
]
},
Expand Down Expand Up @@ -709,7 +709,7 @@
}
],
"source": [
"leaf01_bma = brg.inventory.hosts[\"leaf01.bma\"]\n",
"leaf01_bma = nr.inventory.hosts[\"leaf01.bma\"]\n",
"leaf01_bma[\"domain\"] # comes from the group `global`"
]
},
Expand Down Expand Up @@ -757,7 +757,7 @@
}
],
"source": [
"leaf01_cmh = brg.inventory.hosts[\"leaf01.cmh\"]\n",
"leaf01_cmh = nr.inventory.hosts[\"leaf01.cmh\"]\n",
"leaf01_cmh[\"domain\"] # comes from defaults"
]
},
Expand Down Expand Up @@ -821,7 +821,7 @@
"source": [
"### Filtering the inventory\n",
"\n",
"So far we have seen that `brg.inventory.hosts` and `brg.inventory.groups` are dict-like objects that we can use to iterate over all the hosts and groups or to access any particular one directly. Now we are going to see how we can do some fancy filtering that will enable us to operate on groups of hosts based on their properties.\n",
"So far we have seen that `nr.inventory.hosts` and `nr.inventory.groups` are dict-like objects that we can use to iterate over all the hosts and groups or to access any particular one directly. Now we are going to see how we can do some fancy filtering that will enable us to operate on groups of hosts based on their properties.\n",
"\n",
"The simpler way of filtering hosts is by `<key, value>` pairs. For instance:"
]
Expand All @@ -843,7 +843,7 @@
}
],
"source": [
"brg.filter(site=\"cmh\").inventory.hosts.keys()"
"nr.filter(site=\"cmh\").inventory.hosts.keys()"
]
},
{
Expand All @@ -870,7 +870,7 @@
}
],
"source": [
"brg.filter(site=\"cmh\", role=\"spine\").inventory.hosts.keys()"
"nr.filter(site=\"cmh\", role=\"spine\").inventory.hosts.keys()"
]
},
{
Expand All @@ -897,7 +897,7 @@
}
],
"source": [
"brg.filter(site=\"cmh\").filter(role=\"spine\").inventory.hosts.keys()"
"nr.filter(site=\"cmh\").filter(role=\"spine\").inventory.hosts.keys()"
]
},
{
Expand All @@ -924,7 +924,7 @@
}
],
"source": [
"cmh = brg.filter(site=\"cmh\")\n",
"cmh = nr.filter(site=\"cmh\")\n",
"cmh.filter(role=\"spine\").inventory.hosts.keys()"
]
},
Expand Down Expand Up @@ -977,7 +977,7 @@
}
],
"source": [
"brg.inventory.groups[\"eu\"].children()"
"nr.inventory.groups[\"eu\"].children()"
]
},
{
Expand Down Expand Up @@ -1009,7 +1009,7 @@
"def has_long_name(host):\n",
" return len(host.name) == 11\n",
"\n",
"brg.filter(filter_func=has_long_name).inventory.hosts.keys()"
"nr.filter(filter_func=has_long_name).inventory.hosts.keys()"
]
},
{
Expand All @@ -1030,7 +1030,7 @@
],
"source": [
"# Or a lambda function\n",
"brg.filter(filter_func=lambda h: len(h.name) == 9).inventory.hosts.keys()"
"nr.filter(filter_func=lambda h: len(h.name) == 9).inventory.hosts.keys()"
]
}
],
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/intro/task_results.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"from nornir.plugins.functions.text import print_title\n",
"import logging\n",
"\n",
"brg = InitNornir(config_file=\"config.yaml\", dry_run=True)\n",
"cmh = brg.filter(site=\"cmh\", type=\"network_device\")\n",
"nr = InitNornir(config_file=\"config.yaml\", dry_run=True)\n",
"cmh = nr.filter(site=\"cmh\", type=\"network_device\")\n",
"\n",
"def basic_configuration(task):\n",
" # Transform inventory data to configuration via a template file\n",
Expand Down

0 comments on commit 439a0fd

Please sign in to comment.