diff --git a/.travis.yml b/.travis.yml index 00110003..748ef28d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,42 +1,34 @@ sudo: required - services: - - docker - +- docker addons: apt_packages: - - pandoc - + - pandoc language: python python: - - 2.7 - - 3.4 - - 3.5 - - 3.6 - +- 2.7 +- 3.4 +- 3.5 +- 3.6 matrix: include: - - python: 3.6 - env: TOXENV=sphinx - - python: 3.6 - env: TOXENV=black - - python: 3.6 - env: TOXENV=pylama - + - python: 3.6 + env: TOXENV=sphinx + - python: 3.6 + env: TOXENV=black + - python: 3.6 + env: TOXENV=pylama install: - - pip install tox tox-travis coveralls - +- pip install tox tox-travis coveralls script: - - tox - +- tox deploy: provider: pypi user: dbarroso password: - secure: N8oS4N3BG8eMTXOxbGvCcZi5c/DSDml4qxux3OVZR2BvFp9X8yiC/9LgpTswp30cDZNgQqrd1cgHnm742hfKUMbcEpRergk65P+5tHcawUwS+jZ47PJJb84KQkne6i63vP5hGFGuN75cPk4U+Lv/q9MfTcWeaVqZfnjmMxwo90o/AqLIvPsduj8wP0wCSbO5DdaR5paTJOmHcTPksVDMyHaxbj5lDYx4kCS04jm4BHWRTBVP6ayyYdmgLDgcHdd54Xphk43EuI3vOMnB0TjU6GmwtsSkXGzsSpws+UNj/gAMZWkUpd5gwPgUThYWOtCiwPSism0DCCYQ9M9GH45210k+o+OgqEIU/HBxVve1rOYaLuApuOGO2gwpwM57WRv0AbnzQbgUVEDbC3XkOFnqxl2sD8ItvdpSTbI24pPj4CY5CdQkAjajorYIqZpmHMo9NVet9yPSTgtNVUqY7NNVIoEhwQzwqr/PtW+1o0f2+EVLyuYxR4Mvtx0B5Nuisrx1fwu0ZaCcpUTItXNkunSXsGmSk1THw06ub+/NgK8AqsKsOtGAwF37Uwgi92JkUmI4LA3UiO28Htu54q3IplhMaaxiMkTUNCj8BVBtykIK956TmDEjp0rJZTX+/64NN+68YYejFwW/Bkjkpra6LOK0AmM1sVoDBm9mNDIHMjiVIyw= + secure: kUJVNxWPy2J1LrB3Mu7uo4iDBLYFuNNZhUCgrueJy1hQJOQc2W7+RE3h2gKV/TmCOEDaXZxE8uN9GVX5TqJqFvycu6F1YUkhsgIg8ocKOtrpNqGWOnA7xCC9HN7V75xiTgtbkUadmlr+ui72FqSfryvO+hwmqgEeSbBK/tP9mHhB906CueGr1SZ8pSeJlvgqeiyqL/nTy3bvCi+sQdAjeXh2+sFvVMwcLgN4cYXcjNu3UD1YNJIZfUogbHvATmDRQtPYctIgDuwWRpzltVDnahhwP1zxIGFVIyW/BVsuQHtb3sNzt9WjdFmqLp927rBxEMJBoYYkK7kwOk94FLdazI/KpQGGLusGzhCSghrDzLcKRAoGv7ZrT65M6E/cmjLD9LcqmcLCqK19OlI66scbg3hn7nl9kLZ3UhqqMQOr51nK6dKBxXe0Fpzsy7V8p4WhLCg9BSTb1Bu6FNZvzNh+qovvC3hA2Gz0SUelEpf3STdeihgcbjlkVm6lz8b5/5ZhNTiF+bE2kNChchOrHg3ki5/yMV6KTmV3Gsd89GCQbAFB9vQwa981ZUnIfpapg5vLkW3uHfafrVadK+AyPYJ9rsWRmQ0MG9dCF4DeersqcVz7Aw8WFipC8kzr6SG91T8F8+okzBM7x8vX4S9/52HCa2aFKADHmyqtLpFvHaRkOsE= on: tags: true branch: master - after_success: - - coveralls +- coveralls diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index a4d9db54..b5454511 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -1,4 +1,4 @@ -How to contribute to Brigade +How to contribute to Nornir ============================ First of all, thank you for conidering to contribute to this project! @@ -8,15 +8,15 @@ Several ways to contribute There are several things you can do to help the project. -- Spread the word about Brigade +- Spread the word about Nornir - Suggest great features - Report bugs - Fix typos - Write documentation - Contribute your plugins -- Improve the Brigade core +- Improve the Nornir core -Spread the word about Brigade +Spread the word about Nornir ----------------------------- Even if you aren't in the position that you can contribute your time to this project, it still helps us if you spread the word about the project. It could be just a short notice in social media or a discussion you have with your friends. As more people become aware of the project there's a better chance that we reach people who are able to contribute. So, even if you can't directly contribute yourself, someone you refer to us might. @@ -24,49 +24,49 @@ Even if you aren't in the position that you can contribute your time to this pro Suggesting new features ----------------------- -It could be that you are aware of something that would be great to have in Brigade and we are always welcoming feature requests. Make sure you explain in what scenario your suggested feature would be useful. +It could be that you are aware of something that would be great to have in Nornir and we are always welcoming feature requests. Make sure you explain in what scenario your suggested feature would be useful. Reporting bugs -------------- -When you are `reporting bugs `_, make sure that you give a explaination about the outcome that you expect and what you are seeing. The bugs which are hardest to fix are the ones which we are unable to reproduce. For this reason it's important that you describe what you did and show us how we can reproduce the bug in another environment. +When you are `reporting bugs `_, make sure that you give a explaination about the outcome that you expect and what you are seeing. The bugs which are hardest to fix are the ones which we are unable to reproduce. For this reason it's important that you describe what you did and show us how we can reproduce the bug in another environment. Fix typos --------- -While we try to take care, getting all the works correct can be.. differcult. Typos are the easiest things to fix and if you find any you can help us from looking silly. You can find more typos to fix by looking in the `Brigade source code `_ or by visiting the `Brigade documentation `_. +While we try to take care, getting all the works correct can be.. differcult. Typos are the easiest things to fix and if you find any you can help us from looking silly. You can find more typos to fix by looking in the `Nornir source code `_ or by visiting the `Nornir documentation `_. Writing documentation --------------------- -Documentation is another great way to help if you don't want to contribute actual code. The documentation of Brigade is divided into different sections. +Documentation is another great way to help if you don't want to contribute actual code. The documentation of Nornir is divided into different sections. -- Tutorials: Aims to help people learn Brigade with a lot of handholding, the user might not end up with something useful after following the tutorial. The goal is for people to learn how to use Brigade. -- How-to guides: This sections goal is to help people solve a specific task with Brigade -- Reference guides: This section describe the Brigade API and plugins. Most of the content in this area is generated from the source code itself. +- Tutorials: Aims to help people learn Nornir with a lot of handholding, the user might not end up with something useful after following the tutorial. The goal is for people to learn how to use Nornir. +- How-to guides: This sections goal is to help people solve a specific task with Nornir +- Reference guides: This section describe the Nornir API and plugins. Most of the content in this area is generated from the source code itself. Contributions to the documentation can be small fixes such as changing scentences to make the text more clear, or it could be new guides. Contributing plugins -------------------- -If you have written your custom plugin for Brigade there's a good chance that it can be useful for others as well. General guidelines when writing plugins are: +If you have written your custom plugin for Nornir there's a good chance that it can be useful for others as well. General guidelines when writing plugins are: - Make them as generic as possible, it doesn't help others if they only work in your environment - Make sure that it's possible to have unit tests which automatically test that the plugins are working -Contributing to the Brigade core +Contributing to the Nornir core -------------------------------- -When you are contributing code to the core of Brigade make sure that the existing tests are passing, and add tests to the code you have added. Having your tests in place ensures that other won't accidentally brake it in the future. +When you are contributing code to the core of Nornir make sure that the existing tests are passing, and add tests to the code you have added. Having your tests in place ensures that other won't accidentally brake it in the future. Before you make any significant code changes to the core it's recommended that you open an issue to discuss your ideas before writing the code. Setting up your environment --------------------------- -In order to run tests locally you need to have `Docker `_ and `Pandoc `_ installed. Docker is used to test the Brigade plugins and Pandoc is required for building the documentation provided by `Sphinx `_. After those are installed you can go ahead and install the needed Python dependencies. +In order to run tests locally you need to have `Docker `_ and `Pandoc `_ installed. Docker is used to test the Nornir plugins and Pandoc is required for building the documentation provided by `Sphinx `_. After those are installed you can go ahead and install the needed Python dependencies. .. code-block:: bash @@ -81,13 +81,13 @@ While the automated tests will be triggered when you submit a new pull request i make tests -The test above will run the tests against the Brigade code and documentation. +The test above will run the tests against the Nornir code and documentation. Coding style ------------ -Brigade uses `Black `_, the the uncompromising Python code formatter. Black makes it easy for you to format your code as you can do so automatically after installing it. Note that Python 3.6 is required to run Black. +Nornir uses `Black `_, the the uncompromising Python code formatter. Black makes it easy for you to format your code as you can do so automatically after installing it. Note that Python 3.6 is required to run Black. .. code-block:: bash diff --git a/MANIFEST.in b/MANIFEST.in index c1ffe8e3..89c3d86b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,2 @@ include requirements* -include README.md \ No newline at end of file +include README.md diff --git a/README.md b/README.md index 5ad6d1df..456ae75e 100644 --- a/README.md +++ b/README.md @@ -1,48 +1,48 @@ -[![Build Status](https://travis-ci.org/brigade-automation/brigade.svg?branch=develop)](https://travis-ci.org/brigade-automation/brigade) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black) [![Coverage Status](https://coveralls.io/repos/github/brigade-automation/brigade/badge.svg?branch=develop)](https://coveralls.io/github/brigade-automation/brigade?branch=develop) +[![Build Status](https://travis-ci.org/nornir-automation/nornir.svg?branch=develop)](https://travis-ci.org/nornir-automation/nornir) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black) [![Coverage Status](https://coveralls.io/repos/github/nornir-automation/nornir/badge.svg?branch=develop)](https://coveralls.io/github/nornir-automation/nornir?branch=develop) -Brigade +Nornir ======= -Brigade is a pure Python automation framework intented to be used directly from Python. While most automation frameworks use their own DSL which you use to describe what you want to have done, Brigade lets you control everything from Python. +Nornir is a pure Python automation framework intented to be used directly from Python. While most automation frameworks use their own DSL which you use to describe what you want to have done, Nornir lets you control everything from Python. One of the benefits we want to highlight with this approach is the ease of troubleshooting, if something goes wrong you can just use your existing debug tools directly from Python (just add a line of `import pdb` & `pdb.set_trace()` and you're good to go). Doing the same using a DSL can be quite time consuming. -What Brigade brings to the table is that it takes care of dealing with your inventory and manages the job of dispatching the tasks you want to run against your nodes and devices. The framework provides a very simple way to write plugins if you aren't happy with the ones we ship. Of course if you have written a plugin you think can be useful to others, please send us your code and test cases as a [pull request](https://github.com/brigade-automation/brigade/pulls). +What Nornir brings to the table is that it takes care of dealing with your inventory and manages the job of dispatching the tasks you want to run against your nodes and devices. The framework provides a very simple way to write plugins if you aren't happy with the ones we ship. Of course if you have written a plugin you think can be useful to others, please send us your code and test cases as a [pull request](https://github.com/nornir-automation/nornir/pulls). Install ======= -While Brigade still supports Python 2.7 the recommended version is 3.6. Install it with pip. +While Nornir still supports Python 2.7 the recommended version is 3.6. Install it with pip. ``` -pip install brigade +pip install nornir ``` Documentation ============= -Read the [Brigade documentation](https://brigade.readthedocs.io/) online or review it's [code here](https://github.com/brigade-automation/brigade/tree/develop/docs) +Read the [Nornir documentation](https://nornir.readthedocs.io/) online or review it's [code here](https://github.com/nornir-automation/nornir/tree/develop/docs) Examples ======== -You can find some examples and already made tools [here](https://github.com/brigade-automation/brg-tools/) +You can find some examples and already made tools [here](https://github.com/nornir-automation/brg-tools/) Bugs & New features =================== -If you think you have bug or would like to request a new feature, please register a GitHub account and [open an issue](https://github.com/brigade-automation/brigade/issues). +If you think you have bug or would like to request a new feature, please register a GitHub account and [open an issue](https://github.com/nornir-automation/nornir/issues). Contact & Support ================= -While we are happy to help, the [GitHub issues]() are intended for bugs and discussions about new features. If are struggling to get something to work but don't believe its due to a bug in Brigade, the place to ask questions is in the #brigade channel in the [networktoCode Slack team](https://networktocode.herokuapp.com/). +While we are happy to help, the [GitHub issues]() are intended for bugs and discussions about new features. If are struggling to get something to work but don't believe its due to a bug in Nornir, the place to ask questions is in the #nornir channel in the [networktoCode Slack team](https://networktocode.herokuapp.com/). -Contributing to Brigade +Contributing to Nornir ======================= -If you want to help the project, the [Contribution Guidelines](https://brigade.readthedocs.io/en/develop/contributing/index.html) is the best place to start. +If you want to help the project, the [Contribution Guidelines](https://nornir.readthedocs.io/en/develop/contributing/index.html) is the best place to start. diff --git a/docs/Makefile b/docs/Makefile index bd0ca526..b7ee3147 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -4,7 +4,7 @@ # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build -SPHINXPROJ = brigade +SPHINXPROJ = nornir SOURCEDIR = . BUILDDIR = _build diff --git a/docs/_data_templates/configuration-parameters.j2 b/docs/_data_templates/configuration-parameters.j2 index 842b919f..cecf3313 100644 --- a/docs/_data_templates/configuration-parameters.j2 +++ b/docs/_data_templates/configuration-parameters.j2 @@ -1,4 +1,4 @@ -The configuration parameters will be set by the :doc:`Brigade.core.configuration.Config ` class. +The configuration parameters will be set by the :doc:`Nornir.core.configuration.Config ` class. {% for k, v in params|dictsort %} ---------- @@ -26,4 +26,4 @@ The configuration parameters will be set by the :doc:`Brigade.core.configuration {{ v['description'] }} -{% endfor %} \ No newline at end of file +{% endfor %} diff --git a/docs/conf.py b/docs/conf.py index b38aa7f3..baf2ddff 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# brigade documentation build configuration file, created by +# nornir documentation build configuration file, created by # sphinx-quickstart on Sun Nov 19 10:41:40 2017. # # This file is execfile()d with the current directory set to its @@ -26,7 +26,7 @@ sys.path.insert(0, os.path.abspath("../")) -from brigade.core.configuration import CONF # noqa +from nornir.core.configuration import CONF # noqa # -- General configuration ------------------------------------------------ BASEPATH = os.path.dirname(__file__) @@ -53,7 +53,7 @@ master_doc = "index" # General information about the project. -project = "brigade" +project = "nornir" copyright = "2017, David Barroso" author = "David Barroso" @@ -120,7 +120,7 @@ # -- Options for HTMLHelp output ------------------------------------------ # Output file base name for HTML help builder. -htmlhelp_basename = "brigadedoc" +htmlhelp_basename = "nornirdoc" # -- Options for LaTeX output --------------------------------------------- @@ -144,7 +144,7 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, "brigade.tex", "brigade Documentation", "David Barroso", "manual") + (master_doc, "nornir.tex", "nornir Documentation", "David Barroso", "manual") ] @@ -152,7 +152,7 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [(master_doc, "brigade", "brigade Documentation", [author], 1)] +man_pages = [(master_doc, "nornir", "nornir Documentation", [author], 1)] # -- Options for Texinfo output ------------------------------------------- @@ -163,10 +163,10 @@ texinfo_documents = [ ( master_doc, - "brigade", - "brigade Documentation", + "nornir", + "nornir Documentation", author, - "brigade", + "nornir", "One line description of project.", "Miscellaneous", ) diff --git a/docs/howto/index.rst b/docs/howto/index.rst index dfadc113..840440bb 100644 --- a/docs/howto/index.rst +++ b/docs/howto/index.rst @@ -1,4 +1,4 @@ -How to use Brigade +How to use Nornir ================== .. toctree:: diff --git a/docs/howto/transforming_inventory_data.rst b/docs/howto/transforming_inventory_data.rst index b6195ffd..fe5cf69e 100644 --- a/docs/howto/transforming_inventory_data.rst +++ b/docs/howto/transforming_inventory_data.rst @@ -10,16 +10,16 @@ Imagine your data looks like:: username: my_user password: my_password -It turns out brigade is going to look for ``brigade_username`` and ``brigade_password`` to use as credentials. You may not want to change the data in your backend and you may not want to write a custom inventory plugin just to accommodate this difference. Fortunately, ``brigade`` has you covered. You can write a function to do all the data manipulations you want and pass it to any inventory plugin. For instance:: +It turns out nornir is going to look for ``nornir_username`` and ``nornir_password`` to use as credentials. You may not want to change the data in your backend and you may not want to write a custom inventory plugin just to accommodate this difference. Fortunately, ``nornir`` has you covered. You can write a function to do all the data manipulations you want and pass it to any inventory plugin. For instance:: def adapt_host_data(host): - host.data["brigade_username"] = host.data["username"] - host.data["brigade_password"] = host.data["password"] + host.data["nornir_username"] = host.data["username"] + host.data["nornir_password"] = host.data["password"] inv = NSOTInventory(transform_function=adapt_host_data) - brigade = Brigade(inventory=inv) + nornir = Nornir(inventory=inv) -What's going to happen is that the inventory is going to create the :obj:`brigade.core.inventory.Host` and :obj:`brigade.core.inventory.Group` objects as usual and then finally the ``transform_function`` is going to be called for each individual host one by one. +What's going to happen is that the inventory is going to create the :obj:`nornir.core.inventory.Host` and :obj:`nornir.core.inventory.Group` objects as usual and then finally the ``transform_function`` is going to be called for each individual host one by one. .. note:: This was a very simple example but the ``transform_function`` can basically do anything you want/need. diff --git a/docs/howto/writing_a_custom_inventory.rst b/docs/howto/writing_a_custom_inventory.rst index 95739348..c24dfdd0 100644 --- a/docs/howto/writing_a_custom_inventory.rst +++ b/docs/howto/writing_a_custom_inventory.rst @@ -5,7 +5,7 @@ If you have your own backend with host information or you don't like the provide from builtins import super - from brigade.core.inventory import Inventory + from nornir.core.inventory import Inventory class MyInventory(Inventory): @@ -40,9 +40,9 @@ So if you want to make it dynamic everything you have to do is get the data your .. note:: it is not mandatory to use groups. Feel free to skip the attribute ``group`` and just pass and empty dict or ``None`` to ``super()``. -Finally, to have brigade use it, you can do:: +Finally, to have nornir use it, you can do:: inv = MyInventory() - brigade = Brigade(inventory=inv) + nornir = Nornir(inventory=inv) And that's it, you now have your own inventory plugin :) diff --git a/docs/index.rst b/docs/index.rst index dd169c56..8fb9f9b9 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,20 +1,20 @@ -.. brigade documentation master file, created by +.. nornir documentation master file, created by sphinx-quickstart on Sun Nov 19 10:41:40 2017. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. -Welcome to brigade's documentation! +Welcome to nornir's documentation! =================================== -Brigade is an automation framework written in python to be used with python. Most automation +Nornir is an automation framework written in python to be used with python. Most automation frameworks hide the language they are written in by using some cumbersome pseudo-language which usually is almost Turing complete but lacks tooling to debug and troubleshoot. Integrating with other systems is also usually quite hard as they usually have complex APIs if any at all. Some of the other common problems of those pseudo-languages is that are usually quite bad at dealing with data and re-usability is limited. -Brigade aims to solve those problems by providing a pure python framework. Just imagine Brigade -as the Flask of automation. Brigade will take care of dealing with the inventory where you +Nornir aims to solve those problems by providing a pure python framework. Just imagine Nornir +as the Flask of automation. Nornir will take care of dealing with the inventory where you have your host information, it will take care of dispatching the tasks to your devices and will provide a common framework to write "plugins". @@ -22,22 +22,22 @@ How the documentation is structured =================================== - The :doc:`Tutorial ` is a great place to start for new users. -- :doc:`How-to guides ` aim to solve a specific use case or answer key problems. These guides can be more advanced than the tutorial and can assume some knowledge about how Brigade and related technologies work. -- :doc:`Reference guides ` contains the API reference for Brigade and describe the core functions and plugins. +- :doc:`How-to guides ` aim to solve a specific use case or answer key problems. These guides can be more advanced than the tutorial and can assume some knowledge about how Nornir and related technologies work. +- :doc:`Reference guides ` contains the API reference for Nornir and describe the core functions and plugins. -Is something missing from the documentation? Please open an issue and `tell us what you are missing `_ or `open a pull request `_ and suggest an improvement. +Is something missing from the documentation? Please open an issue and `tell us what you are missing `_ or `open a pull request `_ and suggest an improvement. A first glance ============== -Here is an example on how to quickly build a runbook leveraging Brigade to retrieve information from the network:: +Here is an example on how to quickly build a runbook leveraging Nornir to retrieve information from the network:: - from brigade.core import InitBrigade - from brigade.plugins.functions.text import print_result - from brigade.plugins.tasks.networking import napalm_get + from nornir.core import InitNornir + from nornir.plugins.functions.text import print_result + from nornir.plugins.tasks.networking import napalm_get - brg = InitBrigade( - config_file="brigade.yaml", dry_run=True, num_workers=20 + brg = InitNornir( + config_file="nornir.yaml", dry_run=True, num_workers=20 ) results = brg.run( @@ -45,7 +45,7 @@ Here is an example on how to quickly build a runbook leveraging Brigade to retri ) print_result(results) -You can find this and other examples `here `_. +You can find this and other examples `here `_. Contents ======== diff --git a/docs/plugins/functions/text.rst b/docs/plugins/functions/text.rst index 6f62d224..94cf53d9 100644 --- a/docs/plugins/functions/text.rst +++ b/docs/plugins/functions/text.rst @@ -1,6 +1,6 @@ Text ==== -.. automodule:: brigade.plugins.functions.text +.. automodule:: nornir.plugins.functions.text :members: :undoc-members: diff --git a/docs/plugins/inventory/ansible.rst b/docs/plugins/inventory/ansible.rst index 1ac77b8b..d6460539 100644 --- a/docs/plugins/inventory/ansible.rst +++ b/docs/plugins/inventory/ansible.rst @@ -1,6 +1,6 @@ Ansible ======= -.. automodule:: brigade.plugins.inventory.ansible +.. automodule:: nornir.plugins.inventory.ansible :members: :undoc-members: diff --git a/docs/plugins/inventory/nsot.rst b/docs/plugins/inventory/nsot.rst index 8663d573..5df87118 100644 --- a/docs/plugins/inventory/nsot.rst +++ b/docs/plugins/inventory/nsot.rst @@ -1,6 +1,6 @@ NSOT ==== -.. automodule:: brigade.plugins.inventory.nsot +.. automodule:: nornir.plugins.inventory.nsot :members: :undoc-members: diff --git a/docs/plugins/inventory/simple.rst b/docs/plugins/inventory/simple.rst index 3a87e8f3..1c8542fd 100644 --- a/docs/plugins/inventory/simple.rst +++ b/docs/plugins/inventory/simple.rst @@ -1,6 +1,6 @@ Simple ====== -.. automodule:: brigade.plugins.inventory.simple +.. automodule:: nornir.plugins.inventory.simple :members: :undoc-members: diff --git a/docs/plugins/tasks/apis.rst b/docs/plugins/tasks/apis.rst index 9aec70f8..7072b1cc 100644 --- a/docs/plugins/tasks/apis.rst +++ b/docs/plugins/tasks/apis.rst @@ -1,6 +1,6 @@ APIs ==== -.. automodule:: brigade.plugins.tasks.apis +.. automodule:: nornir.plugins.tasks.apis :members: :undoc-members: diff --git a/docs/plugins/tasks/commands.rst b/docs/plugins/tasks/commands.rst index 5d1d8e5b..f3466be2 100644 --- a/docs/plugins/tasks/commands.rst +++ b/docs/plugins/tasks/commands.rst @@ -1,6 +1,6 @@ Commands ======== -.. automodule:: brigade.plugins.tasks.commands +.. automodule:: nornir.plugins.tasks.commands :members: :undoc-members: diff --git a/docs/plugins/tasks/connections.rst b/docs/plugins/tasks/connections.rst index efc9de64..77619b07 100644 --- a/docs/plugins/tasks/connections.rst +++ b/docs/plugins/tasks/connections.rst @@ -1,6 +1,6 @@ Connections =========== -.. automodule:: brigade.plugins.tasks.connections +.. automodule:: nornir.plugins.tasks.connections :members: :undoc-members: diff --git a/docs/plugins/tasks/data.rst b/docs/plugins/tasks/data.rst index 12c78f0f..0c93380a 100644 --- a/docs/plugins/tasks/data.rst +++ b/docs/plugins/tasks/data.rst @@ -1,6 +1,6 @@ Data ==== -.. automodule:: brigade.plugins.tasks.data +.. automodule:: nornir.plugins.tasks.data :members: :undoc-members: diff --git a/docs/plugins/tasks/files.rst b/docs/plugins/tasks/files.rst index b429d1c6..1fb152cb 100644 --- a/docs/plugins/tasks/files.rst +++ b/docs/plugins/tasks/files.rst @@ -1,6 +1,6 @@ Files ===== -.. automodule:: brigade.plugins.tasks.files +.. automodule:: nornir.plugins.tasks.files :members: :undoc-members: diff --git a/docs/plugins/tasks/networking.rst b/docs/plugins/tasks/networking.rst index dd8c3b54..9992a7c5 100644 --- a/docs/plugins/tasks/networking.rst +++ b/docs/plugins/tasks/networking.rst @@ -1,6 +1,6 @@ Networking ========== -.. automodule:: brigade.plugins.tasks.networking +.. automodule:: nornir.plugins.tasks.networking :members: :undoc-members: diff --git a/docs/plugins/tasks/text.rst b/docs/plugins/tasks/text.rst index 47971494..3e7edca7 100644 --- a/docs/plugins/tasks/text.rst +++ b/docs/plugins/tasks/text.rst @@ -1,6 +1,6 @@ Text ==== -.. automodule:: brigade.plugins.tasks.text +.. automodule:: nornir.plugins.tasks.text :members: :undoc-members: diff --git a/docs/ref/api/brigade.rst b/docs/ref/api/brigade.rst deleted file mode 100644 index 7e8710bd..00000000 --- a/docs/ref/api/brigade.rst +++ /dev/null @@ -1,18 +0,0 @@ -Data -#### - -.. autoclass:: brigade.core.Data - :members: - :undoc-members: - -Brigade -####### - -.. autoclass:: brigade.core.Brigade - :members: - :undoc-members: - -InitBrigade -########### - -.. automethod:: brigade.core.InitBrigade diff --git a/docs/ref/api/configuration.rst b/docs/ref/api/configuration.rst index d47c5bfd..5bbd3784 100644 --- a/docs/ref/api/configuration.rst +++ b/docs/ref/api/configuration.rst @@ -2,8 +2,8 @@ Configuration ############# -.. autoclass:: brigade.core.configuration.Config +.. autoclass:: nornir.core.configuration.Config :members: :undoc-members: -The attributes for the Config object will be the Brigade configuration parameters. For a list of available parameters see :doc:`Brigade configuration parameters ` +The attributes for the Config object will be the Nornir configuration parameters. For a list of available parameters see :doc:`Nornir configuration parameters ` diff --git a/docs/ref/api/exceptions.rst b/docs/ref/api/exceptions.rst index 95a17b0b..d3f92a9c 100644 --- a/docs/ref/api/exceptions.rst +++ b/docs/ref/api/exceptions.rst @@ -1,7 +1,7 @@ Exceptions ========== -.. automodule:: brigade.core.exceptions +.. automodule:: nornir.core.exceptions :members: :undoc-members: diff --git a/docs/ref/api/index.rst b/docs/ref/api/index.rst index c6175279..d2f5214b 100644 --- a/docs/ref/api/index.rst +++ b/docs/ref/api/index.rst @@ -1,11 +1,11 @@ -Brigade API Reference +Nornir API Reference ===================== .. toctree:: :maxdepth: 1 - :caption: Brigade API + :caption: Nornir API - brigade + nornir configuration inventory task diff --git a/docs/ref/api/inventory.rst b/docs/ref/api/inventory.rst index eda9f42b..df93a6a9 100644 --- a/docs/ref/api/inventory.rst +++ b/docs/ref/api/inventory.rst @@ -4,18 +4,18 @@ Inventory Inventory ========= -.. autoclass:: brigade.core.inventory.Inventory +.. autoclass:: nornir.core.inventory.Inventory :members: :undoc-members: Host ==== -.. autoclass:: brigade.core.inventory.Host +.. autoclass:: nornir.core.inventory.Host :members: :undoc-members: Group ===== -.. autoclass:: brigade.core.inventory.Group +.. autoclass:: nornir.core.inventory.Group diff --git a/docs/ref/api/nornir.rst b/docs/ref/api/nornir.rst new file mode 100644 index 00000000..7af32e14 --- /dev/null +++ b/docs/ref/api/nornir.rst @@ -0,0 +1,18 @@ +Data +#### + +.. autoclass:: nornir.core.Data + :members: + :undoc-members: + +Nornir +####### + +.. autoclass:: nornir.core.Nornir + :members: + :undoc-members: + +InitNornir +########### + +.. automethod:: nornir.core.InitNornir diff --git a/docs/ref/api/task.rst b/docs/ref/api/task.rst index 8ccf2b8e..5a876de7 100644 --- a/docs/ref/api/task.rst +++ b/docs/ref/api/task.rst @@ -1,27 +1,27 @@ Task #### -.. autoclass:: brigade.core.task.Task +.. autoclass:: nornir.core.task.Task :members: :undoc-members: Result ###### -.. autoclass:: brigade.core.task.Result +.. autoclass:: nornir.core.task.Result :members: :undoc-members: AggregatedResult ################ -.. autoclass:: brigade.core.task.AggregatedResult +.. autoclass:: nornir.core.task.AggregatedResult :members: :undoc-members: MultiResult ################ -.. autoclass:: brigade.core.task.MultiResult +.. autoclass:: nornir.core.task.MultiResult :members: :undoc-members: diff --git a/docs/ref/index.rst b/docs/ref/index.rst index d36b6071..966daae9 100644 --- a/docs/ref/index.rst +++ b/docs/ref/index.rst @@ -3,12 +3,12 @@ Reference Guides .. toctree:: :maxdepth: 2 - :caption: Brigade Internals + :caption: Nornir Internals internals/index .. toctree:: :maxdepth: 2 - :caption: Brigade API + :caption: Nornir API API diff --git a/docs/ref/internals/execution_model.rst b/docs/ref/internals/execution_model.rst index 15574e3a..b7ed0118 100644 --- a/docs/ref/internals/execution_model.rst +++ b/docs/ref/internals/execution_model.rst @@ -1,11 +1,11 @@ Execution Model =============== -One of the many advantages of using brigade is that it will be parallelize the execution of tasks for you. The way it works is as follows: +One of the many advantages of using nornir is that it will be parallelize the execution of tasks for you. The way it works is as follows: -1. You trigger the parallelization by running a task via :obj:`brigade.core.Brigade.run` with ``num_workers > 1`` (defaults to ``20``). +1. You trigger the parallelization by running a task via :obj:`nornir.core.Nornir.run` with ``num_workers > 1`` (defaults to ``20``). 2. If ``num_workers == 1`` we run the task over all hosts one after the other in a simple loop. This is useful for troubleshooting/debugging, for writing to disk/database or just for printing on screen. -3. When parallelizing tasks brigade will use a different thread for each host. +3. When parallelizing tasks nornir will use a different thread for each host. Below you can see a simple diagram illustrating how this works: diff --git a/docs/ref/internals/index.rst b/docs/ref/internals/index.rst index 4b87b948..04548245 100644 --- a/docs/ref/internals/index.rst +++ b/docs/ref/internals/index.rst @@ -1,4 +1,4 @@ -Brigade's Internals +Nornir's Internals =================== .. toctree:: diff --git a/docs/tutorials/intro/config.yaml b/docs/tutorials/intro/config.yaml index ed623ada..0b6eab1a 100644 --- a/docs/tutorials/intro/config.yaml +++ b/docs/tutorials/intro/config.yaml @@ -1,6 +1,6 @@ --- num_workers: 100 -inventory: brigade.plugins.inventory.simple.SimpleInventory +inventory: nornir.plugins.inventory.simple.SimpleInventory SimpleInventory: host_file: "inventory/hosts.yaml" group_file: "inventory/groups.yaml" diff --git a/docs/tutorials/intro/executing_tasks.ipynb b/docs/tutorials/intro/executing_tasks.ipynb index a45779d1..415582db 100644 --- a/docs/tutorials/intro/executing_tasks.ipynb +++ b/docs/tutorials/intro/executing_tasks.ipynb @@ -6,8 +6,8 @@ "metadata": {}, "outputs": [], "source": [ - "from brigade.core import InitBrigade\n", - "brg = InitBrigade(config_file=\"config.yaml\")" + "from nornir.core import InitNornir\n", + "brg = InitNornir(config_file=\"config.yaml\")" ] }, { @@ -16,9 +16,9 @@ "source": [ "# Executing tasks\n", "\n", - "Now that you know how to initialize brigade and work with the inventory let's see how we can leverage it to run tasks on groups of hosts.\n", + "Now that you know how to initialize nornir and work with the inventory let's see how we can leverage it to run tasks on groups of hosts.\n", "\n", - "Brigade ships a bunch of tasks you can use directly without having to code them yourself. You can check them out [here](../../plugins/tasks/index.rst).\n", + "Nornir ships a bunch of tasks you can use directly without having to code them yourself. You can check them out [here](../../plugins/tasks/index.rst).\n", "\n", "Let's start by executing the `ls -la /tmp` command on all the device in `cmh` of type `host`:\n" ] @@ -52,8 +52,8 @@ } ], "source": [ - "from brigade.plugins.tasks import commands\n", - "from brigade.plugins.functions.text import print_result\n", + "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", "\n", @@ -67,7 +67,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "So what have we done here? First we have imported the `commands` and `text` modules. Then we have narrowed down brigade to the hosts we want to operate on. Once we have selected the devices we wanted to operate on we have run two tasks:\n", + "So what have we done here? First we have imported the `commands` and `text` modules. Then we have narrowed down nornir to the hosts we want to operate on. Once we have selected the devices we wanted to operate on we have run two tasks:\n", "\n", "1. The task `commands.remote_command` which runs the specified `command` in the remote device.\n", "2. The function `print_result` which just prints on screen the result of an executed task or group of tasks.\n", @@ -136,7 +136,7 @@ } ], "source": [ - "from brigade.plugins.tasks import networking\n", + "from nornir.plugins.tasks import networking\n", "\n", "cmh_spines = brg.filter(site=\"bma\", role=\"spine\")\n", "result = cmh_spines.run(task=networking.napalm_get,\n", @@ -152,7 +152,7 @@ "\n", "## What is a task\n", "\n", - "Let's take a look at what a task is. In it's simplest form a task is a function that takes at least a [Task](../../ref/api/task.rst#brigade.core.task.Task) object as argument. For instance:\n", + "Let's take a look at what a task is. In it's simplest form a task is a function that takes at least a [Task](../../ref/api/task.rst#nornir.core.task.Task) object as argument. For instance:\n", "\n" ] }, @@ -202,7 +202,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The task object has access to `brigade`, `host` and `dry_run` attributes.\n", + "The task object has access to `nornir`, `host` and `dry_run` attributes.\n", "\n", "You can call other tasks from within a task:" ] diff --git a/docs/tutorials/intro/failed_tasks.ipynb b/docs/tutorials/intro/failed_tasks.ipynb index e7a879cd..2e47f9c3 100644 --- a/docs/tutorials/intro/failed_tasks.ipynb +++ b/docs/tutorials/intro/failed_tasks.ipynb @@ -6,7 +6,7 @@ "source": [ "# Failed Tasks\n", "\n", - "Sometimes tasks can fail. Let's see how to deal with failed tasks in brigade.\n", + "Sometimes tasks can fail. Let's see how to deal with failed tasks in nornir.\n", "\n", "Let's start as usual with the needed boilerplate:" ] @@ -17,11 +17,11 @@ "metadata": {}, "outputs": [], "source": [ - "from brigade.core import InitBrigade\n", - "from brigade.plugins.tasks import networking, text\n", - "from brigade.plugins.functions.text import print_result\n", + "from nornir.core import InitNornir\n", + "from nornir.plugins.tasks import networking, text\n", + "from nornir.plugins.functions.text import print_result\n", "\n", - "brg = InitBrigade(config_file=\"config.yaml\")\n", + "brg = InitNornir(config_file=\"config.yaml\")\n", "cmh = brg.filter(site=\"cmh\", type=\"network_device\")" ] }, @@ -147,96 +147,100 @@ "output_type": "stream", "text": [ "\u001b[1m\u001b[36mbasic_configuration*************************************************************\u001b[0m\n", - "\u001b[0m\u001b[1m\u001b[34m* spine00.cmh ** changed : False ***********************************************\u001b[0m\n", - "\u001b[0m\u001b[1m\u001b[32mvvvv basic_configuration ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO\u001b[0m\n", + "\u001b[0m\u001b[1m\u001b[34m* leaf00.cmh ** changed : False ************************************************\u001b[0m\n", + "\u001b[0m\u001b[1m\u001b[31mvvvv basic_configuration ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv ERROR\u001b[0m\n", + "\u001b[0mSubtask: Loading Configuration on the device (failed)\n", + "\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[32m---- Base Configuration ** changed : False ------------------------------------- INFO\u001b[0m\n", "\u001b[0msystem {\n", - " host-name spine00.cmh;\n", + " host-name leaf00.cmh;\n", " domain-name cmh.acme.local;\n", "}\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[31m---- Loading Configuration on the device ** changed : False -------------------- ERROR\u001b[0m\n", "\u001b[0mTraceback (most recent call last):\n", - " File \"/Users/dbarroso/.virtualenvs/brigade/lib/python3.6/site-packages/napalm/eos/eos.py\", line 231, in _load_config\n", + " File \"/Users/dbarroso/.virtualenvs/nornir/lib/python3.6/site-packages/napalm/eos/eos.py\", line 231, in _load_config\n", " self.device.run_commands(commands)\n", - " File \"/Users/dbarroso/.virtualenvs/brigade/lib/python3.6/site-packages/pyeapi/client.py\", line 730, in run_commands\n", + " File \"/Users/dbarroso/.virtualenvs/nornir/lib/python3.6/site-packages/pyeapi/client.py\", line 730, in run_commands\n", " response = self._connection.execute(commands, encoding, **kwargs)\n", - " File \"/Users/dbarroso/.virtualenvs/brigade/lib/python3.6/site-packages/pyeapi/eapilib.py\", line 499, in execute\n", + " File \"/Users/dbarroso/.virtualenvs/nornir/lib/python3.6/site-packages/pyeapi/eapilib.py\", line 499, in execute\n", " response = self.send(request)\n", - " File \"/Users/dbarroso/.virtualenvs/brigade/lib/python3.6/site-packages/pyeapi/eapilib.py\", line 418, in send\n", + " File \"/Users/dbarroso/.virtualenvs/nornir/lib/python3.6/site-packages/pyeapi/eapilib.py\", line 418, in send\n", " raise CommandError(code, msg, command_error=err, output=out)\n", "pyeapi.eapilib.CommandError: Error [1002]: CLI command 3 of 6 'system {' failed: invalid command [Invalid input (at token 1: '{')]\n", "\n", "During handling of the above exception, another exception occurred:\n", "\n", "Traceback (most recent call last):\n", - " File \"/Users/dbarroso/.virtualenvs/brigade/lib/python3.6/site-packages/brigade/core/task.py\", line 61, in start\n", + " File \"/Users/dbarroso/workspace/nornir/nornir/core/task.py\", line 62, in start\n", " r = self.task(self, **self.params)\n", - " File \"/Users/dbarroso/.virtualenvs/brigade/lib/python3.6/site-packages/brigade/plugins/tasks/networking/napalm_configure.py\", line 26, in napalm_configure\n", + " File \"/Users/dbarroso/workspace/nornir/nornir/plugins/tasks/networking/napalm_configure.py\", line 26, in napalm_configure\n", " device.load_merge_candidate(filename=filename, config=configuration)\n", - " File \"/Users/dbarroso/.virtualenvs/brigade/lib/python3.6/site-packages/napalm/eos/eos.py\", line 245, in load_merge_candidate\n", + " File \"/Users/dbarroso/.virtualenvs/nornir/lib/python3.6/site-packages/napalm/eos/eos.py\", line 245, in load_merge_candidate\n", " self._load_config(filename, config, False)\n", - " File \"/Users/dbarroso/.virtualenvs/brigade/lib/python3.6/site-packages/napalm/eos/eos.py\", line 237, in _load_config\n", + " File \"/Users/dbarroso/.virtualenvs/nornir/lib/python3.6/site-packages/napalm/eos/eos.py\", line 237, in _load_config\n", " raise MergeConfigException(e.message)\n", "napalm.base.exceptions.MergeConfigException: Error [1002]: CLI command 3 of 6 'system {' failed: invalid command [Invalid input (at token 1: '{')]\n", "\u001b[0m\n", - "\u001b[0m\u001b[1m\u001b[32m^^^^ END basic_configuration ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n", - "\u001b[0m\u001b[1m\u001b[34m* spine01.cmh ** changed : True ************************************************\u001b[0m\n", + "\u001b[0m\u001b[1m\u001b[31m^^^^ END basic_configuration ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n", + "\u001b[0m\u001b[1m\u001b[34m* leaf01.cmh ** changed : True *************************************************\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[32mvvvv basic_configuration ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[32m---- Base Configuration ** changed : False ------------------------------------- INFO\u001b[0m\n", "\u001b[0msystem {\n", - " host-name spine01.cmh;\n", + " host-name leaf01.cmh;\n", " domain-name cmh.acme.local;\n", "}\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[33m---- Loading Configuration on the device ** changed : True --------------------- INFO\u001b[0m\n", "\u001b[0m[edit system]\n", "- host-name vsrx;\n", - "+ host-name spine01.cmh;\n", + "+ host-name leaf01.cmh;\n", "+ domain-name cmh.acme.local;\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[32m^^^^ END basic_configuration ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n", - "\u001b[0m\u001b[1m\u001b[34m* leaf00.cmh ** changed : False ************************************************\u001b[0m\n", - "\u001b[0m\u001b[1m\u001b[32mvvvv basic_configuration ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO\u001b[0m\n", + "\u001b[0m\u001b[1m\u001b[34m* spine00.cmh ** changed : False ***********************************************\u001b[0m\n", + "\u001b[0m\u001b[1m\u001b[31mvvvv basic_configuration ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv ERROR\u001b[0m\n", + "\u001b[0mSubtask: Loading Configuration on the device (failed)\n", + "\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[32m---- Base Configuration ** changed : False ------------------------------------- INFO\u001b[0m\n", "\u001b[0msystem {\n", - " host-name leaf00.cmh;\n", + " host-name spine00.cmh;\n", " domain-name cmh.acme.local;\n", "}\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[31m---- Loading Configuration on the device ** changed : False -------------------- ERROR\u001b[0m\n", "\u001b[0mTraceback (most recent call last):\n", - " File \"/Users/dbarroso/.virtualenvs/brigade/lib/python3.6/site-packages/napalm/eos/eos.py\", line 231, in _load_config\n", + " File \"/Users/dbarroso/.virtualenvs/nornir/lib/python3.6/site-packages/napalm/eos/eos.py\", line 231, in _load_config\n", " self.device.run_commands(commands)\n", - " File \"/Users/dbarroso/.virtualenvs/brigade/lib/python3.6/site-packages/pyeapi/client.py\", line 730, in run_commands\n", + " File \"/Users/dbarroso/.virtualenvs/nornir/lib/python3.6/site-packages/pyeapi/client.py\", line 730, in run_commands\n", " response = self._connection.execute(commands, encoding, **kwargs)\n", - " File \"/Users/dbarroso/.virtualenvs/brigade/lib/python3.6/site-packages/pyeapi/eapilib.py\", line 499, in execute\n", + " File \"/Users/dbarroso/.virtualenvs/nornir/lib/python3.6/site-packages/pyeapi/eapilib.py\", line 499, in execute\n", " response = self.send(request)\n", - " File \"/Users/dbarroso/.virtualenvs/brigade/lib/python3.6/site-packages/pyeapi/eapilib.py\", line 418, in send\n", + " File \"/Users/dbarroso/.virtualenvs/nornir/lib/python3.6/site-packages/pyeapi/eapilib.py\", line 418, in send\n", " raise CommandError(code, msg, command_error=err, output=out)\n", "pyeapi.eapilib.CommandError: Error [1002]: CLI command 3 of 6 'system {' failed: invalid command [Invalid input (at token 1: '{')]\n", "\n", "During handling of the above exception, another exception occurred:\n", "\n", "Traceback (most recent call last):\n", - " File \"/Users/dbarroso/.virtualenvs/brigade/lib/python3.6/site-packages/brigade/core/task.py\", line 61, in start\n", + " File \"/Users/dbarroso/workspace/nornir/nornir/core/task.py\", line 62, in start\n", " r = self.task(self, **self.params)\n", - " File \"/Users/dbarroso/.virtualenvs/brigade/lib/python3.6/site-packages/brigade/plugins/tasks/networking/napalm_configure.py\", line 26, in napalm_configure\n", + " File \"/Users/dbarroso/workspace/nornir/nornir/plugins/tasks/networking/napalm_configure.py\", line 26, in napalm_configure\n", " device.load_merge_candidate(filename=filename, config=configuration)\n", - " File \"/Users/dbarroso/.virtualenvs/brigade/lib/python3.6/site-packages/napalm/eos/eos.py\", line 245, in load_merge_candidate\n", + " File \"/Users/dbarroso/.virtualenvs/nornir/lib/python3.6/site-packages/napalm/eos/eos.py\", line 245, in load_merge_candidate\n", " self._load_config(filename, config, False)\n", - " File \"/Users/dbarroso/.virtualenvs/brigade/lib/python3.6/site-packages/napalm/eos/eos.py\", line 237, in _load_config\n", + " File \"/Users/dbarroso/.virtualenvs/nornir/lib/python3.6/site-packages/napalm/eos/eos.py\", line 237, in _load_config\n", " raise MergeConfigException(e.message)\n", "napalm.base.exceptions.MergeConfigException: Error [1002]: CLI command 3 of 6 'system {' failed: invalid command [Invalid input (at token 1: '{')]\n", "\u001b[0m\n", - "\u001b[0m\u001b[1m\u001b[32m^^^^ END basic_configuration ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n", - "\u001b[0m\u001b[1m\u001b[34m* leaf01.cmh ** changed : True *************************************************\u001b[0m\n", + "\u001b[0m\u001b[1m\u001b[31m^^^^ END basic_configuration ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n", + "\u001b[0m\u001b[1m\u001b[34m* spine01.cmh ** changed : True ************************************************\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[32mvvvv basic_configuration ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[32m---- Base Configuration ** changed : False ------------------------------------- INFO\u001b[0m\n", "\u001b[0msystem {\n", - " host-name leaf01.cmh;\n", + " host-name spine01.cmh;\n", " domain-name cmh.acme.local;\n", "}\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[33m---- Loading Configuration on the device ** changed : True --------------------- INFO\u001b[0m\n", "\u001b[0m[edit system]\n", "- host-name vsrx;\n", - "+ host-name leaf01.cmh;\n", + "+ host-name spine01.cmh;\n", "+ domain-name cmh.acme.local;\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[32m^^^^ END basic_configuration ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n", "\u001b[0m" @@ -269,10 +273,10 @@ } ], "source": [ - "from brigade.core.exceptions import BrigadeExecutionError\n", + "from nornir.core.exceptions import NornirExecutionError\n", "try:\n", " result.raise_on_error()\n", - "except BrigadeExecutionError:\n", + "except NornirExecutionError:\n", " print(\"ERROR!!!\")" ] }, @@ -282,7 +286,7 @@ "source": [ "## Skipped hosts\n", "\n", - "Brigade will keep track of hosts that failed and won't run future tasks on them:" + "Nornir will keep track of hosts that failed and won't run future tasks on them:" ] }, { @@ -291,7 +295,7 @@ "metadata": {}, "outputs": [], "source": [ - "from brigade.core.task import Result\n", + "from nornir.core.task import Result\n", "\n", "def hi(task):\n", " return Result(host=task.host, result=f\"{task.host.name}: Hi, I am still here!\")\n", @@ -309,14 +313,14 @@ "output_type": "stream", "text": [ "\u001b[1m\u001b[36mhi******************************************************************************\u001b[0m\n", - "\u001b[0m\u001b[1m\u001b[34m* spine01.cmh ** changed : False ***********************************************\u001b[0m\n", - "\u001b[0m\u001b[1m\u001b[32mvvvv hi ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO\u001b[0m\n", - "\u001b[0mspine01.cmh: Hi, I am still here!\u001b[0m\n", - "\u001b[0m\u001b[1m\u001b[32m^^^^ END hi ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[34m* leaf01.cmh ** changed : False ************************************************\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[32mvvvv hi ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO\u001b[0m\n", "\u001b[0mleaf01.cmh: Hi, I am still here!\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[32m^^^^ END hi ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n", + "\u001b[0m\u001b[1m\u001b[34m* spine01.cmh ** changed : False ***********************************************\u001b[0m\n", + "\u001b[0m\u001b[1m\u001b[32mvvvv hi ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO\u001b[0m\n", + "\u001b[0mspine01.cmh: Hi, I am still here!\u001b[0m\n", + "\u001b[0m\u001b[1m\u001b[32m^^^^ END hi ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n", "\u001b[0m" ] } @@ -342,9 +346,9 @@ "output_type": "stream", "text": [ "\u001b[1m\u001b[36mhi******************************************************************************\u001b[0m\n", - "\u001b[0m\u001b[1m\u001b[34m* spine01.cmh ** changed : False ***********************************************\u001b[0m\n", + "\u001b[0m\u001b[1m\u001b[34m* leaf00.cmh ** changed : False ************************************************\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[32mvvvv hi ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO\u001b[0m\n", - "\u001b[0mspine01.cmh: Hi, I am still here!\u001b[0m\n", + "\u001b[0mleaf00.cmh: Hi, I am still here!\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[32m^^^^ END hi ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[34m* leaf01.cmh ** changed : False ************************************************\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[32mvvvv hi ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO\u001b[0m\n", @@ -354,9 +358,9 @@ "\u001b[0m\u001b[1m\u001b[32mvvvv hi ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO\u001b[0m\n", "\u001b[0mspine00.cmh: Hi, I am still here!\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[32m^^^^ END hi ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n", - "\u001b[0m\u001b[1m\u001b[34m* leaf00.cmh ** changed : False ************************************************\u001b[0m\n", + "\u001b[0m\u001b[1m\u001b[34m* spine01.cmh ** changed : False ***********************************************\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[32mvvvv hi ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO\u001b[0m\n", - "\u001b[0mleaf00.cmh: Hi, I am still here!\u001b[0m\n", + "\u001b[0mspine01.cmh: Hi, I am still here!\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[32m^^^^ END hi ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n", "\u001b[0m" ] @@ -384,14 +388,14 @@ "output_type": "stream", "text": [ "\u001b[1m\u001b[36mhi******************************************************************************\u001b[0m\n", - "\u001b[0m\u001b[1m\u001b[34m* spine00.cmh ** changed : False ***********************************************\u001b[0m\n", - "\u001b[0m\u001b[1m\u001b[32mvvvv hi ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO\u001b[0m\n", - "\u001b[0mspine00.cmh: Hi, I am still here!\u001b[0m\n", - "\u001b[0m\u001b[1m\u001b[32m^^^^ END hi ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[34m* leaf00.cmh ** changed : False ************************************************\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[32mvvvv hi ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO\u001b[0m\n", "\u001b[0mleaf00.cmh: Hi, I am still here!\u001b[0m\n", "\u001b[0m\u001b[1m\u001b[32m^^^^ END hi ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n", + "\u001b[0m\u001b[1m\u001b[34m* spine00.cmh ** changed : False ***********************************************\u001b[0m\n", + "\u001b[0m\u001b[1m\u001b[32mvvvv hi ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO\u001b[0m\n", + "\u001b[0mspine00.cmh: Hi, I am still here!\u001b[0m\n", + "\u001b[0m\u001b[1m\u001b[32m^^^^ END hi ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n", "\u001b[0m" ] } @@ -405,7 +409,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "To achieve this `brigade` keeps a list failed hosts in it's shared [data](../../ref/api/brigade.rst#brigade.core.Data) object:" + "To achieve this `nornir` keeps a list failed hosts in it's shared [data](../../ref/api/nornir.rst#nornir.core.Data) object:" ] }, { @@ -432,7 +436,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "If you want to mark some hosts as succeeded and make them back eligible for future tasks you can do it individually per host with the function [recover_host](../../ref/api/brigade.rst#brigade.core.Data.recover_host) or reset the list completely with [reset_failed_hosts](../../ref/api/brigade.rst#brigade.core.Data.reset_failed_hosts):" + "If you want to mark some hosts as succeeded and make them back eligible for future tasks you can do it individually per host with the function [recover_host](../../ref/api/nornir.rst#nornir.core.Data.recover_host) or reset the list completely with [reset_failed_hosts](../../ref/api/nornir.rst#nornir.core.Data.reset_failed_hosts):" ] }, { @@ -462,7 +466,7 @@ "source": [ "## Raise on error automatically\n", "\n", - "Alternatively, you can configure brigade to raise the exception automatically in case of error with the `raise_on_error` configuration option:" + "Alternatively, you can configure nornir to raise the exception automatically in case of error with the `raise_on_error` configuration option:" ] }, { @@ -480,11 +484,11 @@ } ], "source": [ - "brg = InitBrigade(config_file=\"config.yaml\", raise_on_error=True)\n", + "brg = InitNornir(config_file=\"config.yaml\", raise_on_error=True)\n", "cmh = brg.filter(site=\"cmh\", type=\"network_device\")\n", "try:\n", " cmh.run(task=basic_configuration)\n", - "except BrigadeExecutionError:\n", + "except NornirExecutionError:\n", " print(\"ERROR!!!\")" ] }, diff --git a/docs/tutorials/intro/grouping_tasks.ipynb b/docs/tutorials/intro/grouping_tasks.ipynb index 1e3ceb39..db41ad77 100644 --- a/docs/tutorials/intro/grouping_tasks.ipynb +++ b/docs/tutorials/intro/grouping_tasks.ipynb @@ -8,7 +8,7 @@ "\n", "In this section we are going to see how we can group tasks. Grouping tasks might be useful for various reasons, for instance, for reusability purposes (as seen in a previous section) or even just for readability purposes. \n", "\n", - "We will also see very briefly how to use the functions [functions.text.print_title](../../plugins/functions/text.rst#brigade.plugins.functions.text.print_title) and [functions.text.print_result](../../plugins/functions/text.rst#brigade.plugins.functions.text.print_result) to make things look pretty.\n", + "We will also see very briefly how to use the functions [functions.text.print_title](../../plugins/functions/text.rst#nornir.plugins.functions.text.print_title) and [functions.text.print_result](../../plugins/functions/text.rst#nornir.plugins.functions.text.print_result) to make things look pretty.\n", "\n", "As an objective in this tutorial we are going to be configuring the hostname and domain name of our network devices.\n", "\n", @@ -21,11 +21,11 @@ "metadata": {}, "outputs": [], "source": [ - "from brigade.core import InitBrigade\n", - "from brigade.plugins.tasks import networking, text\n", - "from brigade.plugins.functions.text import print_title, print_result\n", + "from nornir.core import InitNornir\n", + "from nornir.plugins.tasks import networking, text\n", + "from nornir.plugins.functions.text import print_title, print_result\n", "\n", - "brg = InitBrigade(config_file=\"config.yaml\", dry_run=True)\n", + "brg = InitNornir(config_file=\"config.yaml\", dry_run=True)\n", "cmh = brg.filter(site=\"cmh\", type=\"network_device\")" ] }, @@ -33,7 +33,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "You may have noticed that `InitBrigade` got a new argument `dry_run=True`. That argument (which defaults to `False`) controls whether to apply the changes to the device or just simulate them. You can control that argument via the configuration as well. Some tasks might even allow you to override this behavior completely at the task level.\n", + "You may have noticed that `InitNornir` got a new argument `dry_run=True`. That argument (which defaults to `False`) controls whether to apply the changes to the device or just simulate them. You can control that argument via the configuration as well. Some tasks might even allow you to override this behavior completely at the task level.\n", "\n", "Now, let's create task that is going to group what we want to do:" ] @@ -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", "
\n", - "**Note:** The `dry_run` value is shared between the main brigade 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 `brg.dry_run = False` and `cmh.dry_run = False` are equivalent.\n", "
" ] }, diff --git a/docs/tutorials/intro/index.rst b/docs/tutorials/intro/index.rst index 384a3971..e7c90839 100644 --- a/docs/tutorials/intro/index.rst +++ b/docs/tutorials/intro/index.rst @@ -1,16 +1,16 @@ -Learning Brigade +Learning Nornir ================ -We're glad you made it here! This is a great place to learn the basics of Brigade. Good luck on your journey. +We're glad you made it here! This is a great place to learn the basics of Nornir. Good luck on your journey. .. toctree:: :maxdepth: 1 - Brigade at a glance + Nornir at a glance 100% Python Installation guide - initializing_brigade.ipynb + initializing_nornir.ipynb inventory.ipynb executing_tasks.ipynb grouping_tasks.ipynb diff --git a/docs/tutorials/intro/initializing_brigade.ipynb b/docs/tutorials/intro/initializing_nornir.ipynb similarity index 90% rename from docs/tutorials/intro/initializing_brigade.ipynb rename to docs/tutorials/intro/initializing_nornir.ipynb index 50325cd3..f1210a2b 100644 --- a/docs/tutorials/intro/initializing_brigade.ipynb +++ b/docs/tutorials/intro/initializing_nornir.ipynb @@ -16,11 +16,11 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Initializing Brigade\n", + "# Initializing Nornir\n", "\n", - "Easiest way of initializing brigade is with the function [InitBrigade](../../ref/api/brigade.rst#initbrigade).\n", + "Easiest way of initializing nornir is with the function [InitNornir](../../ref/api/nornir.rst#initnornir).\n", "\n", - "With `InitBrigade` you can initialize brigade with a configuration file, with code or with a combination of both.\n", + "With `InitNornir` you can initialize nornir with a configuration file, with code or with a combination of both.\n", "\n", "Let's start with [a configuration file](../../configuration/index.rst):" ] @@ -109,7 +109,7 @@ "\n", "
1 ---\n",
        "2 num_workers: 100\n",
-       "3 inventory: brigade.plugins.inventory.simple.SimpleInventory\n",
+       "3 inventory: nornir.plugins.inventory.simple.SimpleInventory\n",
        "4 SimpleInventory:\n",
        "5     host_file: "inventory/hosts.yaml"\n",
        "6     group_file: "inventory/groups.yaml"\n",
@@ -137,7 +137,7 @@
     "**Note:** To pass options to the inventory plugin add a top-level dictionary named after the inventory class name; `SimpleInventory` in this example.\n",
     "
\n", "\n", - "Now to create the [brigade](../../ref/api/brigade.rst#brigade) object:" + "Now to create the [nornir](../../ref/api/nornir.rst#nornir) object:" ] }, { @@ -146,15 +146,15 @@ "metadata": {}, "outputs": [], "source": [ - "from brigade.core import InitBrigade\n", - "brg = InitBrigade(config_file=\"config.yaml\")" + "from nornir.core import InitNornir\n", + "brg = InitNornir(config_file=\"config.yaml\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "You can also initialize brigade programmatically without a configuration file:" + "You can also initialize nornir programmatically without a configuration file:" ] }, { @@ -163,9 +163,9 @@ "metadata": {}, "outputs": [], "source": [ - "from brigade.core import InitBrigade\n", - "brg = InitBrigade(num_workers=100,\n", - " inventory=\"brigade.plugins.inventory.simple.SimpleInventory\",\n", + "from nornir.core import InitNornir\n", + "brg = InitNornir(num_workers=100,\n", + " inventory=\"nornir.plugins.inventory.simple.SimpleInventory\",\n", " SimpleInventory={\"host_file\": \"inventory/hosts.yaml\",\n", " \"group_file\": \"inventory/groups.yaml\"})" ] @@ -183,8 +183,8 @@ "metadata": {}, "outputs": [], "source": [ - "from brigade.core import InitBrigade\n", - "brg = InitBrigade(num_workers=50, config_file=\"config.yaml\")" + "from nornir.core import InitNornir\n", + "brg = InitNornir(num_workers=50, config_file=\"config.yaml\")" ] }, { diff --git a/docs/tutorials/intro/install.rst b/docs/tutorials/intro/install.rst index c2586301..89e2b503 100644 --- a/docs/tutorials/intro/install.rst +++ b/docs/tutorials/intro/install.rst @@ -1,41 +1,41 @@ -Installing Brigade +Installing Nornir ================== -Before you go ahead and install Brigade it's recommended to create your own Python virtualenv. That way you have complete control of your environment and you don't risk overwriting your systems Python environment. +Before you go ahead and install Nornir it's recommended to create your own Python virtualenv. That way you have complete control of your environment and you don't risk overwriting your systems Python environment. .. note:: This tutorial doesn't cover the creation of a Python virtual environment. The Python documentation offers a guide where you can learn more about `virtualenvs `_. We also won't cover the `installation of pip `_, but changes are that you already have pip on your system. -Brigade is published to `PyPI `_ and can be installed like most other Python packages using the pip tool. You can verify that you have pip installed by typing: +Nornir is published to `PyPI `_ and can be installed like most other Python packages using the pip tool. You can verify that you have pip installed by typing: .. code-block:: bash pip --version - pip 9.0.3 from /Users/patrick/brigade/lib/python3.6/site-packages (python 3.6) + pip 9.0.3 from /Users/patrick/nornir/lib/python3.6/site-packages (python 3.6) -It could be that you need to use the pip3 binary instead of pip as pip3 is for Python 3 on some systems. Speaking of Python 3, this tutorial is written with Python 3.6 in mind. This has mostly to do with the use of f-strings, you should however be able to follow along even if you are still at Python 2.7. However, if you are starting something new don't use Python 2.7. If you have to make sure that you're pip is up to date as you might have trouble installing some of the Brigade dependencies if you have a very old pip if you are on version 9.0 or later you should be find. +It could be that you need to use the pip3 binary instead of pip as pip3 is for Python 3 on some systems. Speaking of Python 3, this tutorial is written with Python 3.6 in mind. This has mostly to do with the use of f-strings, you should however be able to follow along even if you are still at Python 2.7. However, if you are starting something new don't use Python 2.7. If you have to make sure that you're pip is up to date as you might have trouble installing some of the Nornir dependencies if you have a very old pip if you are on version 9.0 or later you should be find. As you would assume, the installation is then very easy. .. code-block:: bash - pip install brigade + pip install nornir - Collecting brigade - Collecting colorama (from brigade) + Collecting nornir + Collecting colorama (from nornir) [...] - Successfully installed MarkupSafe-1.0 asn1crypto-0.24.0 bcrypt-3.1.4 brigade-0.0.6 + Successfully installed MarkupSafe-1.0 asn1crypto-0.24.0 bcrypt-3.1.4 nornir-0.0.6 -Please note that the above output has been abbreviated for readability. Your output will be quite a bit longer. You should see that `brigade` is successfully installed. +Please note that the above output has been abbreviated for readability. Your output will be quite a bit longer. You should see that `nornir` is successfully installed. -Now we can verify that Brigade is installed and that you are able to import the package from Python. +Now we can verify that Nornir is installed and that you are able to import the package from Python. .. code-block:: python python - >>>import brigade.core + >>>import nornir.core >>> Great, now you're ready to create an inventory. diff --git a/docs/tutorials/intro/inventory.ipynb b/docs/tutorials/intro/inventory.ipynb index d3d1b665..b1e71a7e 100644 --- a/docs/tutorials/intro/inventory.ipynb +++ b/docs/tutorials/intro/inventory.ipynb @@ -18,9 +18,9 @@ "source": [ "## Inventory\n", "\n", - "The Inventory is arguably the most important piece of brigade. Let's see how it works. To begin with the [inventory](../../ref/api/inventory.rst#brigade.core.inventory.Inventory) is comprised of [hosts](../../ref/api/inventory.rst#brigade.core.inventory.Host) and [groups](../../ref/api/inventory.rst#brigade.core.inventory.Group).\n", + "The Inventory is arguably the most important piece of nornir. Let's see how it works. To begin with the [inventory](../../ref/api/inventory.rst#nornir.core.inventory.Inventory) is comprised of [hosts](../../ref/api/inventory.rst#nornir.core.inventory.Host) and [groups](../../ref/api/inventory.rst#nornir.core.inventory.Group).\n", "\n", - "In this tutorial we are using the [SimpleInventory](../../plugins/inventory/simple.rst#brigade.plugins.inventory.simple.SimpleInventory) plugin. This inventory plugin stores all the relevant data in two files. Let's start by checking them:" + "In this tutorial we are using the [SimpleInventory](../../plugins/inventory/simple.rst#nornir.plugins.inventory.simple.SimpleInventory) plugin. This inventory plugin stores all the relevant data in two files. Let's start by checking them:" ] }, { @@ -107,76 +107,76 @@ "\n", "
  1 ---\n",
        "  2 host1.cmh:\n",
-       "  3     brigade_host: 127.0.0.1\n",
-       "  4     brigade_ssh_port: 2201\n",
-       "  5     brigade_username: vagrant\n",
-       "  6     brigade_password: vagrant\n",
+       "  3     nornir_host: 127.0.0.1\n",
+       "  4     nornir_ssh_port: 2201\n",
+       "  5     nornir_username: vagrant\n",
+       "  6     nornir_password: vagrant\n",
        "  7     site: cmh\n",
        "  8     role: host\n",
        "  9     groups:\n",
        " 10         - cmh\n",
-       " 11     brigade_nos: linux\n",
+       " 11     nornir_nos: linux\n",
        " 12     type: host\n",
        " 13 \n",
        " 14 host2.cmh:\n",
-       " 15     brigade_host: 127.0.0.1\n",
-       " 16     brigade_ssh_port: 2202\n",
-       " 17     brigade_username: vagrant\n",
-       " 18     brigade_password: vagrant\n",
+       " 15     nornir_host: 127.0.0.1\n",
+       " 16     nornir_ssh_port: 2202\n",
+       " 17     nornir_username: vagrant\n",
+       " 18     nornir_password: vagrant\n",
        " 19     site: cmh\n",
        " 20     role: host\n",
        " 21     groups:\n",
        " 22         - cmh\n",
-       " 23     brigade_nos: linux\n",
+       " 23     nornir_nos: linux\n",
        " 24     type: host\n",
        " 25 \n",
        " 26 spine00.cmh:\n",
-       " 27     brigade_host: 127.0.0.1\n",
-       " 28     brigade_username: vagrant\n",
-       " 29     brigade_password: vagrant\n",
-       " 30     brigade_network_api_port: 12444\n",
+       " 27     nornir_host: 127.0.0.1\n",
+       " 28     nornir_username: vagrant\n",
+       " 29     nornir_password: vagrant\n",
+       " 30     nornir_network_api_port: 12444\n",
        " 31     site: cmh\n",
        " 32     role: spine\n",
        " 33     groups:\n",
        " 34         - cmh\n",
-       " 35     brigade_nos: eos\n",
+       " 35     nornir_nos: eos\n",
        " 36     type: network_device\n",
        " 37 \n",
        " 38 spine01.cmh:\n",
-       " 39     brigade_host: 127.0.0.1\n",
-       " 40     brigade_username: vagrant\n",
-       " 41     brigade_password: ""\n",
-       " 42     brigade_network_api_port: 12204\n",
+       " 39     nornir_host: 127.0.0.1\n",
+       " 40     nornir_username: vagrant\n",
+       " 41     nornir_password: ""\n",
+       " 42     nornir_network_api_port: 12204\n",
        " 43     site: cmh\n",
        " 44     role: spine\n",
        " 45     groups:\n",
        " 46         - cmh\n",
-       " 47     brigade_nos: junos\n",
+       " 47     nornir_nos: junos\n",
        " 48     type: network_device\n",
        " 49 \n",
        " 50 leaf00.cmh:\n",
-       " 51     brigade_host: 127.0.0.1\n",
-       " 52     brigade_username: vagrant\n",
-       " 53     brigade_password: vagrant\n",
-       " 54     brigade_network_api_port: 12443\n",
+       " 51     nornir_host: 127.0.0.1\n",
+       " 52     nornir_username: vagrant\n",
+       " 53     nornir_password: vagrant\n",
+       " 54     nornir_network_api_port: 12443\n",
        " 55     site: cmh\n",
        " 56     role: leaf\n",
        " 57     groups:\n",
        " 58         - cmh\n",
-       " 59     brigade_nos: eos\n",
+       " 59     nornir_nos: eos\n",
        " 60     type: network_device\n",
        " 61     asn: 65100\n",
        " 62 \n",
        " 63 leaf01.cmh:\n",
-       " 64     brigade_host: 127.0.0.1\n",
-       " 65     brigade_username: vagrant\n",
-       " 66     brigade_password: ""\n",
-       " 67     brigade_network_api_port: 12203\n",
+       " 64     nornir_host: 127.0.0.1\n",
+       " 65     nornir_username: vagrant\n",
+       " 66     nornir_password: ""\n",
+       " 67     nornir_network_api_port: 12203\n",
        " 68     site: cmh\n",
        " 69     role: leaf\n",
        " 70     groups:\n",
        " 71         - cmh\n",
-       " 72     brigade_nos: junos\n",
+       " 72     nornir_nos: junos\n",
        " 73     type: network_device\n",
        " 74     asn: 65101\n",
        " 75 \n",
@@ -185,7 +185,7 @@
        " 78     role: host\n",
        " 79     groups:\n",
        " 80         - bma\n",
-       " 81     brigade_nos: linux\n",
+       " 81     nornir_nos: linux\n",
        " 82     type: host\n",
        " 83 \n",
        " 84 host2.bma:\n",
@@ -193,55 +193,55 @@
        " 86     role: host\n",
        " 87     groups:\n",
        " 88         - bma\n",
-       " 89     brigade_nos: linux\n",
+       " 89     nornir_nos: linux\n",
        " 90     type: host\n",
        " 91 \n",
        " 92 spine00.bma:\n",
-       " 93     brigade_host: 127.0.0.1\n",
-       " 94     brigade_username: vagrant\n",
-       " 95     brigade_password: vagrant\n",
-       " 96     brigade_network_api_port: 12444\n",
+       " 93     nornir_host: 127.0.0.1\n",
+       " 94     nornir_username: vagrant\n",
+       " 95     nornir_password: vagrant\n",
+       " 96     nornir_network_api_port: 12444\n",
        " 97     site: bma\n",
        " 98     role: spine\n",
        " 99     groups:\n",
        "100         - bma\n",
-       "101     brigade_nos: eos\n",
+       "101     nornir_nos: eos\n",
        "102     type: network_device\n",
        "103 \n",
        "104 spine01.bma:\n",
-       "105     brigade_host: 127.0.0.1\n",
-       "106     brigade_username: vagrant\n",
-       "107     brigade_password: ""\n",
-       "108     brigade_network_api_port: 12204\n",
+       "105     nornir_host: 127.0.0.1\n",
+       "106     nornir_username: vagrant\n",
+       "107     nornir_password: ""\n",
+       "108     nornir_network_api_port: 12204\n",
        "109     site: bma\n",
        "110     role: spine\n",
        "111     groups:\n",
        "112         - bma\n",
-       "113     brigade_nos: junos\n",
+       "113     nornir_nos: junos\n",
        "114     type: network_device\n",
        "115 \n",
        "116 leaf00.bma:\n",
-       "117     brigade_host: 127.0.0.1\n",
-       "118     brigade_username: vagrant\n",
-       "119     brigade_password: vagrant\n",
-       "120     brigade_network_api_port: 12443\n",
+       "117     nornir_host: 127.0.0.1\n",
+       "118     nornir_username: vagrant\n",
+       "119     nornir_password: vagrant\n",
+       "120     nornir_network_api_port: 12443\n",
        "121     site: bma\n",
        "122     role: leaf\n",
        "123     groups:\n",
        "124         - bma\n",
-       "125     brigade_nos: eos\n",
+       "125     nornir_nos: eos\n",
        "126     type: network_device\n",
        "127 \n",
        "128 leaf01.bma:\n",
-       "129     brigade_host: 127.0.0.1\n",
-       "130     brigade_username: vagrant\n",
-       "131     brigade_password: wrong_password\n",
-       "132     brigade_network_api_port: 12203\n",
+       "129     nornir_host: 127.0.0.1\n",
+       "130     nornir_username: vagrant\n",
+       "131     nornir_password: wrong_password\n",
+       "132     nornir_network_api_port: 12203\n",
        "133     site: bma\n",
        "134     role: leaf\n",
        "135     groups:\n",
        "136         - bma\n",
-       "137     brigade_nos: junos\n",
+       "137     nornir_nos: junos\n",
        "138     type: network_device\n",
        "
\n", "\n" @@ -264,7 +264,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The hosts file is basically a map where the outermost key is the hostname and then any arbitrary `` pair you want inside. Usually `brigade_*` keys have special meaning, you can investigate the [hosts](../../ref/api/inventory.rst#brigade.core.inventory.Host) class for details on those. In addition, the `groups` key is a list of groups you can inherite data from. We will inspect soon how the inheritance model works.\n", + "The hosts file is basically a map where the outermost key is the hostname and then any arbitrary `` pair you want inside. Usually `nornir_*` keys have special meaning, you can investigate the [hosts](../../ref/api/inventory.rst#nornir.core.inventory.Host) class for details on those. In addition, the `groups` key is a list of groups you can inherite data from. We will inspect soon how the inheritance model works.\n", "\n", "Now, let's look at the groups file:" ] @@ -397,7 +397,7 @@ "\n", "### Accessing the inventory\n", "\n", - "You can access the [inventory](../../ref/api/inventory.rst#brigade.core.inventory.Inventory) with the `inventory` attribute:" + "You can access the [inventory](../../ref/api/inventory.rst#nornir.core.inventory.Inventory) with the `inventory` attribute:" ] }, { @@ -408,7 +408,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 4, @@ -417,8 +417,8 @@ } ], "source": [ - "from brigade.core import InitBrigade\n", - "brg = InitBrigade(config_file=\"config.yaml\")\n", + "from nornir.core import InitNornir\n", + "brg = InitNornir(config_file=\"config.yaml\")\n", "\n", "brg.inventory" ] @@ -519,7 +519,7 @@ { "data": { "text/plain": [ - "dict_keys(['name', 'groups', 'brigade_host', 'brigade_username', 'brigade_password', 'brigade_network_api_port', 'site', 'role', 'brigade_nos', 'type', 'asn', 'domain'])" + "dict_keys(['name', 'groups', 'nornir_host', 'nornir_username', 'nornir_password', 'nornir_network_api_port', 'site', 'role', 'nornir_nos', 'type', 'asn', 'domain'])" ] }, "execution_count": 8, @@ -765,7 +765,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "If brigade can't resolve the data you should get a KeyError as usual:" + "If nornir can't resolve the data you should get a KeyError as usual:" ] }, { diff --git a/docs/tutorials/intro/inventory/hosts.yaml b/docs/tutorials/intro/inventory/hosts.yaml index d59f8f33..cc253298 100644 --- a/docs/tutorials/intro/inventory/hosts.yaml +++ b/docs/tutorials/intro/inventory/hosts.yaml @@ -1,75 +1,75 @@ --- host1.cmh: - brigade_host: 127.0.0.1 - brigade_ssh_port: 2201 - brigade_username: vagrant - brigade_password: vagrant + nornir_host: 127.0.0.1 + nornir_ssh_port: 2201 + nornir_username: vagrant + nornir_password: vagrant site: cmh role: host groups: - cmh - brigade_nos: linux + nornir_nos: linux type: host host2.cmh: - brigade_host: 127.0.0.1 - brigade_ssh_port: 2202 - brigade_username: vagrant - brigade_password: vagrant + nornir_host: 127.0.0.1 + nornir_ssh_port: 2202 + nornir_username: vagrant + nornir_password: vagrant site: cmh role: host groups: - cmh - brigade_nos: linux + nornir_nos: linux type: host spine00.cmh: - brigade_host: 127.0.0.1 - brigade_username: vagrant - brigade_password: vagrant - brigade_network_api_port: 12444 + nornir_host: 127.0.0.1 + nornir_username: vagrant + nornir_password: vagrant + nornir_network_api_port: 12444 site: cmh role: spine groups: - cmh - brigade_nos: eos + nornir_nos: eos type: network_device spine01.cmh: - brigade_host: 127.0.0.1 - brigade_username: vagrant - brigade_password: "" - brigade_network_api_port: 12204 + nornir_host: 127.0.0.1 + nornir_username: vagrant + nornir_password: "" + nornir_network_api_port: 12204 site: cmh role: spine groups: - cmh - brigade_nos: junos + nornir_nos: junos type: network_device leaf00.cmh: - brigade_host: 127.0.0.1 - brigade_username: vagrant - brigade_password: vagrant - brigade_network_api_port: 12443 + nornir_host: 127.0.0.1 + nornir_username: vagrant + nornir_password: vagrant + nornir_network_api_port: 12443 site: cmh role: leaf groups: - cmh - brigade_nos: eos + nornir_nos: eos type: network_device asn: 65100 leaf01.cmh: - brigade_host: 127.0.0.1 - brigade_username: vagrant - brigade_password: "" - brigade_network_api_port: 12203 + nornir_host: 127.0.0.1 + nornir_username: vagrant + nornir_password: "" + nornir_network_api_port: 12203 site: cmh role: leaf groups: - cmh - brigade_nos: junos + nornir_nos: junos type: network_device asn: 65101 @@ -78,7 +78,7 @@ host1.bma: role: host groups: - bma - brigade_nos: linux + nornir_nos: linux type: host host2.bma: @@ -86,53 +86,53 @@ host2.bma: role: host groups: - bma - brigade_nos: linux + nornir_nos: linux type: host spine00.bma: - brigade_host: 127.0.0.1 - brigade_username: vagrant - brigade_password: vagrant - brigade_network_api_port: 12444 + nornir_host: 127.0.0.1 + nornir_username: vagrant + nornir_password: vagrant + nornir_network_api_port: 12444 site: bma role: spine groups: - bma - brigade_nos: eos + nornir_nos: eos type: network_device spine01.bma: - brigade_host: 127.0.0.1 - brigade_username: vagrant - brigade_password: "" - brigade_network_api_port: 12204 + nornir_host: 127.0.0.1 + nornir_username: vagrant + nornir_password: "" + nornir_network_api_port: 12204 site: bma role: spine groups: - bma - brigade_nos: junos + nornir_nos: junos type: network_device leaf00.bma: - brigade_host: 127.0.0.1 - brigade_username: vagrant - brigade_password: vagrant - brigade_network_api_port: 12443 + nornir_host: 127.0.0.1 + nornir_username: vagrant + nornir_password: vagrant + nornir_network_api_port: 12443 site: bma role: leaf groups: - bma - brigade_nos: eos + nornir_nos: eos type: network_device leaf01.bma: - brigade_host: 127.0.0.1 - brigade_username: vagrant - brigade_password: wrong_password - brigade_network_api_port: 12203 + nornir_host: 127.0.0.1 + nornir_username: vagrant + nornir_password: wrong_password + nornir_network_api_port: 12203 site: bma role: leaf groups: - bma - brigade_nos: junos + nornir_nos: junos type: network_device diff --git a/docs/tutorials/intro/overview.rst b/docs/tutorials/intro/overview.rst index a32a478e..ef9e4fa9 100644 --- a/docs/tutorials/intro/overview.rst +++ b/docs/tutorials/intro/overview.rst @@ -1,20 +1,20 @@ -What is Brigade? +What is Nornir? ================ -Brigade is an automation framework written in Python. These days there exists several automation frameworks. What makes Brigade different is that you write Python code in order to use Brigade. This is to be compared to other frameworks which typically use their own configuration language. +Nornir is an automation framework written in Python. These days there exists several automation frameworks. What makes Nornir different is that you write Python code in order to use Nornir. This is to be compared to other frameworks which typically use their own configuration language. Why does this matter? --------------------- Typically, a specific configuration language is easy to use in a basic way. Though after a while you need to use more advanced features and might have to extend that configuration language with another programming language. While this works it can be very hard to troubleshoot once it's started to grow. -As Brigade allows you to use pure Python code you can troubleshoot and debug it in the same way as you would do with any other Python code. +As Nornir allows you to use pure Python code you can troubleshoot and debug it in the same way as you would do with any other Python code. What does it compare to? ------------------------ -In some ways, you could compare Brigade to `Flask `_, which is a web framework that allows you to create web applications. Flask provides an easy to use interface which lets you build powerful websites without forcing you to work in a particular way. +In some ways, you could compare Nornir to `Flask `_, which is a web framework that allows you to create web applications. Flask provides an easy to use interface which lets you build powerful websites without forcing you to work in a particular way. -Brigade lets you automate your environment by providing you an interface which does a lot of the heavy lifting. +Nornir lets you automate your environment by providing you an interface which does a lot of the heavy lifting. How much Python do you need do know? ------------------------------------ -As you write Python code to control Brigade it's assumed that you are somewhat familiar with Python. But how good do you have to be with Python in order to make use of Brigade? That's actually the topic for the next section *spoiler alert* Not a lot! \ No newline at end of file +As you write Python code to control Nornir it's assumed that you are somewhat familiar with Python. But how good do you have to be with Python in order to make use of Nornir? That's actually the topic for the next section *spoiler alert* Not a lot! diff --git a/docs/tutorials/intro/python.rst b/docs/tutorials/intro/python.rst index 3b7be274..91f45f0f 100644 --- a/docs/tutorials/intro/python.rst +++ b/docs/tutorials/intro/python.rst @@ -1,7 +1,7 @@ The need to know Python ======================= -In order to use Brigade you have to know some Python. This might come as wonderful news to you, or you might find it a bit scary. If you're already a comfortable Python user, just go a head and hit :doc:`next `. +In order to use Nornir you have to know some Python. This might come as wonderful news to you, or you might find it a bit scary. If you're already a comfortable Python user, just go a head and hit :doc:`next `. If you haven't written any code before you might be heading somewhere else now. Before you go however, answer me this: @@ -9,7 +9,7 @@ Do you know Excel? Chances are that you know how to use Excel. It's simple right. You just open a sheet and enter some data. It's used by a lot of finance people and unfortunately it's one of the most used IPAM solutions. Though aside from a simple tool to enter data in a sheet Excel has an insane amount of features. Most people will only use 5% of all the features. How good are you at Excel? Does it matter? -It's the same way with Python, it can take very long time to fully master it. The good part is that you don't have to become a master. As long as you know the very basics you will be able to use Brigade. +It's the same way with Python, it can take very long time to fully master it. The good part is that you don't have to become a master. As long as you know the very basics you will be able to use Nornir. Python skills required ---------------------- diff --git a/docs/tutorials/intro/task_results.ipynb b/docs/tutorials/intro/task_results.ipynb index e9cbd0cb..f15b3bab 100644 --- a/docs/tutorials/intro/task_results.ipynb +++ b/docs/tutorials/intro/task_results.ipynb @@ -17,12 +17,12 @@ "metadata": {}, "outputs": [], "source": [ - "from brigade.core import InitBrigade\n", - "from brigade.plugins.tasks import networking, text\n", - "from brigade.plugins.functions.text import print_title\n", + "from nornir.core import InitNornir\n", + "from nornir.plugins.tasks import networking, text\n", + "from nornir.plugins.functions.text import print_title\n", "import logging\n", "\n", - "brg = InitBrigade(config_file=\"config.yaml\", dry_run=True)\n", + "brg = InitNornir(config_file=\"config.yaml\", dry_run=True)\n", "cmh = brg.filter(site=\"cmh\", type=\"network_device\")\n", "\n", "def basic_configuration(task):\n", @@ -66,7 +66,7 @@ "source": [ "## The easy way\n", "\n", - "Most of the time you will just want to provide some feedback on what's going on. For that you can use [print_result](../../plugins/functions/text.rst#brigade.plugins.functions.text.print_result) function:" + "Most of the time you will just want to provide some feedback on what's going on. For that you can use [print_result](../../plugins/functions/text.rst#nornir.plugins.functions.text.print_result) function:" ] }, { @@ -128,7 +128,7 @@ } ], "source": [ - "from brigade.plugins.functions.text import print_result\n", + "from nornir.plugins.functions.text import print_result\n", "\n", "print_result(result)" ] @@ -298,7 +298,7 @@ "source": [ "## The programmatic way\n", "\n", - "We have hinted already how to deal with result objects already but let's elaborate on that. To begin with, task groups will return an [AggregatedResult](../../ref/api/task.rst#brigade.core.task.AggregatedResult). This object is a dict-like object you can use to iterate over or access directly hosts:" + "We have hinted already how to deal with result objects already but let's elaborate on that. To begin with, task groups will return an [AggregatedResult](../../ref/api/task.rst#nornir.core.task.AggregatedResult). This object is a dict-like object you can use to iterate over or access directly hosts:" ] }, { @@ -365,7 +365,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "You probably noticed that inside each key in [AggregatedResult](../../ref/api/task.rst#brigade.core.task.AggregatedResult) there is a [MultiResult](../../ref/api/task.rst#brigade.core.task.MultiResult) object. This object is a list-like object you can use to iterate over or access any [Result](../../ref/api/task.rst#brigade.core.task.Result) you want:" + "You probably noticed that inside each key in [AggregatedResult](../../ref/api/task.rst#nornir.core.task.AggregatedResult) there is a [MultiResult](../../ref/api/task.rst#nornir.core.task.MultiResult) object. This object is a list-like object you can use to iterate over or access any [Result](../../ref/api/task.rst#nornir.core.task.Result) you want:" ] }, { diff --git a/brigade/__init__.py b/nornir/__init__.py similarity index 60% rename from brigade/__init__.py rename to nornir/__init__.py index 7adb471d..593894db 100644 --- a/brigade/__init__.py +++ b/nornir/__init__.py @@ -1,6 +1,6 @@ import pkg_resources try: - __version__ = pkg_resources.get_distribution("brigade").version + __version__ = pkg_resources.get_distribution("nornir").version except pkg_resources.DistributionNotFound: __version__ = "Not installed" diff --git a/brigade/core/__init__.py b/nornir/core/__init__.py similarity index 83% rename from brigade/core/__init__.py rename to nornir/core/__init__.py index a78de50f..de72d271 100644 --- a/brigade/core/__init__.py +++ b/nornir/core/__init__.py @@ -3,9 +3,9 @@ import sys from multiprocessing.dummy import Pool -from brigade.core.configuration import Config -from brigade.core.task import AggregatedResult, Task -from brigade.plugins.tasks import connections +from nornir.core.configuration import Config +from nornir.core.task import AggregatedResult, Task +from nornir.plugins.tasks import connections if sys.version_info.major == 2: @@ -38,7 +38,7 @@ def _unpickle_method(func_name, obj, cls): class Data(object): """ This class is just a placeholder to share data amongsts different - versions of Brigade after running ``filter`` multiple times. + versions of Nornir after running ``filter`` multiple times. Attributes: failed_hosts (list): Hosts that have failed to run a task properly @@ -56,25 +56,25 @@ def reset_failed_hosts(self): self.failed_hosts = set() -class Brigade(object): +class Nornir(object): """ This is the main object to work with. It contains the inventory and it serves as task dispatcher. Arguments: - inventory (:obj:`brigade.core.inventory.Inventory`): Inventory to work with - data(:obj:`brigade.core.Data`): shared data amongst different iterations of brigade + inventory (:obj:`nornir.core.inventory.Inventory`): Inventory to work with + data(:obj:`nornir.core.Data`): shared data amongst different iterations of nornir dry_run(``bool``): Whether if we are testing the changes or not - config (:obj:`brigade.core.configuration.Config`): Configuration object + config (:obj:`nornir.core.configuration.Config`): Configuration object config_file (``str``): Path to Yaml configuration file available_connections (``dict``): dict of connection types that will be made available. - Defaults to :obj:`brigade.plugins.tasks.connections.available_connections` + Defaults to :obj:`nornir.plugins.tasks.connections.available_connections` Attributes: - inventory (:obj:`brigade.core.inventory.Inventory`): Inventory to work with - data(:obj:`brigade.core.Data`): shared data amongst different iterations of brigade + inventory (:obj:`nornir.core.inventory.Inventory`): Inventory to work with + data(:obj:`nornir.core.Data`): shared data amongst different iterations of nornir dry_run(``bool``): Whether if we are testing the changes or not - config (:obj:`brigade.core.configuration.Config`): Configuration parameters + config (:obj:`nornir.core.configuration.Config`): Configuration parameters available_connections (``dict``): dict of connection types are available """ @@ -88,11 +88,11 @@ def __init__( logger=None, data=None, ): - self.logger = logger or logging.getLogger("brigade") + self.logger = logger or logging.getLogger("nornir") self.data = data or Data() self.inventory = inventory - self.inventory.brigade = self + self.inventory.nornir = self self.data.dry_run = dry_run if config_file: @@ -157,12 +157,12 @@ def configure_logging(self): def filter(self, **kwargs): """ - See :py:meth:`brigade.core.inventory.Inventory.filter` + See :py:meth:`nornir.core.inventory.Inventory.filter` Returns: - :obj:`Brigade`: A new object with same configuration as ``self`` but filtered inventory. + :obj:`Nornir`: A new object with same configuration as ``self`` but filtered inventory. """ - b = Brigade(dry_run=self.dry_run, **self.__dict__) + b = Nornir(dry_run=self.dry_run, **self.__dict__) b.inventory = self.inventory.filter(**kwargs) return b @@ -209,11 +209,11 @@ def run( **kwargs: additional argument to pass to ``task`` when calling it Raises: - :obj:`brigade.core.exceptions.BrigadeExecutionError`: if at least a task fails + :obj:`nornir.core.exceptions.NornirExecutionError`: if at least a task fails and self.config.raise_on_error is set to ``True`` Returns: - :obj:`brigade.core.task.AggregatedResult`: results of each execution + :obj:`nornir.core.task.AggregatedResult`: results of each execution """ num_workers = num_workers or self.config.num_workers @@ -247,16 +247,16 @@ def run( return result -def InitBrigade(config_file="", dry_run=False, **kwargs): +def InitNornir(config_file="", dry_run=False, **kwargs): """ Arguments: config_file(str): Path to the configuration file (optional) dry_run(bool): Whether to simulate changes or not **kwargs: Extra information to pass to the - :obj:`brigade.core.configuration.Config` object + :obj:`nornir.core.configuration.Config` object Returns: - :obj:`brigade.core.Brigade`: fully instantiated and configured + :obj:`nornir.core.Nornir`: fully instantiated and configured """ conf = Config(config_file=config_file, **kwargs) @@ -265,4 +265,4 @@ def InitBrigade(config_file="", dry_run=False, **kwargs): transform_function = conf.transform_function inv = inv_class(transform_function=transform_function, **inv_args) - return Brigade(inventory=inv, dry_run=dry_run, config=conf) + return Nornir(inventory=inv, dry_run=dry_run, config=conf) diff --git a/brigade/core/configuration.py b/nornir/core/configuration.py similarity index 91% rename from brigade/core/configuration.py rename to nornir/core/configuration.py index f296e978..1f1b5509 100644 --- a/brigade/core/configuration.py +++ b/nornir/core/configuration.py @@ -9,13 +9,13 @@ "inventory": { "description": "Path to inventory modules.", "type": "str", - "default": "brigade.plugins.inventory.simple.SimpleInventory", + "default": "nornir.plugins.inventory.simple.SimpleInventory", }, "transform_function": { "description": "Path to transform function. The transform_function you provide " "will run against each host in the inventory. This is useful to manipulate host " "data and make it more consumable. For instance, if your inventory has a 'user' " - "attribute you could use this function to map it to 'brigade_user'", + "attribute you could use this function to map it to 'nornir_user'", "type": "str", "default": {}, }, @@ -25,14 +25,14 @@ "default": {}, }, "num_workers": { - "description": "Number of Brigade worker processes that are run at the same time, " + "description": "Number of Nornir worker processes that are run at the same time, " "configuration can be overridden on individual tasks by using the " - "`num_workers` argument to (:obj:`brigade.core.Brigade.run`)", + "`num_workers` argument to (:obj:`nornir.core.Nornir.run`)", "type": "int", "default": 20, }, "raise_on_error": { - "description": "If set to ``True``, (:obj:`brigade.core.Brigade.run`) method of will raise " + "description": "If set to ``True``, (:obj:`nornir.core.Nornir.run`) method of will raise " "an exception if at least a host failed.", "type": "bool", "default": False, @@ -57,7 +57,7 @@ "logging_file": { "description": "Logging file. Empty string disables logging to file.", "type": "str", - "default": "brigade.log", + "default": "nornir.log", }, "logging_format": { "description": "Logging format", @@ -71,11 +71,11 @@ }, "logging_loggers": { "description": "List of loggers to configure. This allows you to enable logging for " - "multiple loggers. For instance, you could enable logging for both brigade " + "multiple loggers. For instance, you could enable logging for both nornir " "and paramiko or just for paramiko. An empty list will enable logging for " "all loggers.", "type": "list", - "default": ["brigade"], + "default": ["nornir"], }, } @@ -84,7 +84,7 @@ class Config: """ - This object handles the configuration of Brigade. + This object handles the configuration of Nornir. Arguments: config_file(``str``): Yaml configuration file. diff --git a/brigade/core/exceptions.py b/nornir/core/exceptions.py similarity index 69% rename from brigade/core/exceptions.py rename to nornir/core/exceptions.py index af7de6d6..e3a05f5d 100644 --- a/brigade/core/exceptions.py +++ b/nornir/core/exceptions.py @@ -20,15 +20,15 @@ def __init__(self, command, status_code, stdout, stderr): super().__init__(command, status_code, stdout, stderr) -class BrigadeExecutionError(Exception): +class NornirExecutionError(Exception): """ - Raised by brigade when any of the tasks managed by :meth:`brigade.core.Brigade.run` + Raised by nornir when any of the tasks managed by :meth:`nornir.core.Nornir.run` when any of the tasks fail. Arguments: - result (:obj:`brigade.core.task.AggregatedResult`): + result (:obj:`nornir.core.task.AggregatedResult`): Attributes: - result (:obj:`brigade.core.task.AggregatedResult`): + result (:obj:`nornir.core.task.AggregatedResult`): """ def __init__(self, result): @@ -53,17 +53,17 @@ def __str__(self): return text -class BrigadeSubTaskError(Exception): +class NornirSubTaskError(Exception): """ - Raised by brigade when a sub task managed by :meth:`brigade.core.Task.run` + Raised by nornir when a sub task managed by :meth:`nornir.core.Task.run` has failed Arguments: - task (:obj:`brigade.core.task.Task`): The subtask that failed - result (:obj:`brigade.core.task.Result`): The result of the failed task + task (:obj:`nornir.core.task.Task`): The subtask that failed + result (:obj:`nornir.core.task.Result`): The result of the failed task Attributes: - task (:obj:`brigade.core.task.Task`): The subtask that failed - result (:obj:`brigade.core.task.Result`): The result of the failed task + task (:obj:`nornir.core.task.Task`): The subtask that failed + result (:obj:`nornir.core.task.Result`): The result of the failed task """ def __init__(self, task, result): diff --git a/brigade/core/helpers/__init__.py b/nornir/core/helpers/__init__.py similarity index 100% rename from brigade/core/helpers/__init__.py rename to nornir/core/helpers/__init__.py diff --git a/brigade/core/helpers/jinja_helper.py b/nornir/core/helpers/jinja_helper.py similarity index 100% rename from brigade/core/helpers/jinja_helper.py rename to nornir/core/helpers/jinja_helper.py diff --git a/brigade/core/inventory.py b/nornir/core/inventory.py similarity index 81% rename from brigade/core/inventory.py rename to nornir/core/inventory.py index fcfcf227..dcffc607 100644 --- a/brigade/core/inventory.py +++ b/nornir/core/inventory.py @@ -8,7 +8,7 @@ class Host(object): Arguments: name (str): Name of the host group (:obj:`Group`, optional): Group the host belongs to - brigade (:obj:`brigade.core.Brigade`): Reference to the parent brigade object + nornir (:obj:`nornir.core.Nornir`): Reference to the parent nornir object **kwargs: Host data Attributes: @@ -56,8 +56,8 @@ class Host(object): * ``my_host.group.group.data["domain"]`` will return ``acme.com`` """ - def __init__(self, name, groups=None, brigade=None, defaults=None, **kwargs): - self.brigade = brigade + def __init__(self, name, groups=None, nornir=None, defaults=None, **kwargs): + self.nornir = nornir self.name = name self.groups = groups or [] self.data = {} @@ -160,54 +160,54 @@ def get(self, item, default=None): return default @property - def brigade(self): - """Reference to the parent :obj:`brigade.core.Brigade` object""" - return self._brigade + def nornir(self): + """Reference to the parent :obj:`nornir.core.Nornir` object""" + return self._nornir - @brigade.setter - def brigade(self, value): + @nornir.setter + def nornir(self, value): # If it's already set we don't want to set it again # because we may lose valuable information - if not getattr(self, "_brigade", None): - self._brigade = value + if not getattr(self, "_nornir", None): + self._nornir = value @property def host(self): - """String used to connect to the device. Either ``brigade_host`` or ``self.name``""" - return self.get("brigade_host", self.name) + """String used to connect to the device. Either ``nornir_host`` or ``self.name``""" + return self.get("nornir_host", self.name) @property def username(self): - """Either ``brigade_username`` or user running the script.""" - return self.get("brigade_username", getpass.getuser()) + """Either ``nornir_username`` or user running the script.""" + return self.get("nornir_username", getpass.getuser()) @property def password(self): - """Either ``brigade_password`` or empty string.""" - return self.get("brigade_password", "") + """Either ``nornir_password`` or empty string.""" + return self.get("nornir_password", "") @property def ssh_port(self): - """Either ``brigade_ssh_port`` or 22.""" - return self.get("brigade_ssh_port", 22) + """Either ``nornir_ssh_port`` or 22.""" + return self.get("nornir_ssh_port", 22) @property def network_api_port(self): """ For network equipment this is the port where the device's API is listening to. - Either ``brigade_network_api_port`` or ``None``. + Either ``nornir_network_api_port`` or ``None``. """ - return self.get("brigade_network_api_port") + return self.get("nornir_network_api_port") @property def os(self): - """OS the device is running. Defaults to ``brigade_os``.""" - return self.get("brigade_os") + """OS the device is running. Defaults to ``nornir_os``.""" + return self.get("nornir_os") @property def nos(self): - """Network OS the device is running. Defaults to ``brigade_nos``.""" - return self.get("brigade_nos") + """Network OS the device is running. Defaults to ``nornir_nos``.""" + return self.get("nornir_nos") def get_connection(self, connection): """ @@ -230,7 +230,7 @@ def get_connection(self, connection): """ if connection not in self.connections: try: - conn_task = self.brigade.available_connections[connection] + conn_task = self.nornir.available_connections[connection] except KeyError: raise AttributeError( "not sure how to establish a connection for {}".format(connection) @@ -240,7 +240,7 @@ def get_connection(self, connection): # the given host. We also have to set `num_workers=1` because chances are # we are already inside a thread # Task should establish a connection and populate self.connection[connection] - r = self.brigade.filter(name=self.name).run(conn_task, num_workers=1) + r = self.nornir.filter(name=self.name).run(conn_task, num_workers=1) if r[self.name].exception: raise r[self.name].exception @@ -253,7 +253,7 @@ class Group(Host): def children(self): return { n: h - for n, h in self.brigade.inventory.hosts.items() + for n, h in self.nornir.inventory.hosts.items() if h.has_parent_group(self) } @@ -269,7 +269,7 @@ class Inventory(object): representing the group data. transform_function (callable): we will call this function for each host. This is useful to manipulate host data and make it more consumable. For instance, if your inventory - has a "user" attribute you could use this function to map it to "brigade_user" + has a "user" attribute you could use this function to map it to "nornir_user" Attributes: hosts (dict): keys are hostnames and values are :obj:`Host`. @@ -277,16 +277,16 @@ class Inventory(object): """ def __init__( - self, hosts, groups=None, defaults=None, transform_function=None, brigade=None + self, hosts, groups=None, defaults=None, transform_function=None, nornir=None ): - self._brigade = brigade + self._nornir = nornir self.defaults = defaults or {} self.groups = groups or {} for n, g in self.groups.items(): if isinstance(g, dict): - g = Group(name=n, brigade=brigade, **g) + g = Group(name=n, nornir=nornir, **g) self.groups[n] = g for group in self.groups.values(): @@ -295,7 +295,7 @@ def __init__( self.hosts = {} for n, h in hosts.items(): if isinstance(h, dict): - h = Host(name=n, brigade=brigade, defaults=self.defaults, **h) + h = Host(name=n, nornir=nornir, defaults=self.defaults, **h) if transform_function: transform_function(h) @@ -343,23 +343,23 @@ def filter(self, filter_func=None, **kwargs): for n, h in self.hosts.items() if all(h.get(k) == v for k, v in kwargs.items()) } - return Inventory(hosts=filtered, groups=self.groups, brigade=self.brigade) + return Inventory(hosts=filtered, groups=self.groups, nornir=self.nornir) def __len__(self): return self.hosts.__len__() @property - def brigade(self): - """Reference to the parent :obj:`brigade.core.Brigade` object""" - return self._brigade + def nornir(self): + """Reference to the parent :obj:`nornir.core.Nornir` object""" + return self._nornir - @brigade.setter - def brigade(self, value): - if not getattr(self, "_brigade", None): - self._brigade = value + @nornir.setter + def nornir(self, value): + if not getattr(self, "_nornir", None): + self._nornir = value for h in self.hosts.values(): - h.brigade = value + h.nornir = value for g in self.groups.values(): - g.brigade = value + g.nornir = value diff --git a/brigade/core/task.py b/nornir/core/task.py similarity index 79% rename from brigade/core/task.py rename to nornir/core/task.py index 61265ce0..74e49c9e 100644 --- a/brigade/core/task.py +++ b/nornir/core/task.py @@ -2,15 +2,15 @@ import traceback from builtins import super -from brigade.core.exceptions import BrigadeExecutionError -from brigade.core.exceptions import BrigadeSubTaskError +from nornir.core.exceptions import NornirExecutionError +from nornir.core.exceptions import NornirSubTaskError class Task(object): """ A task is basically a wrapper around a function that has to be run against multiple devices. You won't probably have to deal with this class yourself as - :meth:`brigade.core.Brigade.run` will create it automatically. + :meth:`nornir.core.Nornir.run` will create it automatically. Arguments: task (callable): function or callable we will be calling @@ -22,10 +22,10 @@ class Task(object): task (callable): function or callable we will be calling name (``string``): name of task, defaults to ``task.__name__`` params: Parameters that will be passed to the ``task``. - self.results (:obj:`brigade.core.task.MultiResult`): Intermediate results - host (:obj:`brigade.core.inventory.Host`): Host we are operating with. Populated right + self.results (:obj:`nornir.core.task.MultiResult`): Intermediate results + host (:obj:`nornir.core.inventory.Host`): Host we are operating with. Populated right before calling the ``task`` - brigade(:obj:`brigade.core.Brigade`): Populated right before calling + nornir(:obj:`nornir.core.Nornir`): Populated right before calling the ``task`` severity_level (logging.LEVEL): Severity level associated to the task """ @@ -40,30 +40,30 @@ def __init__(self, task, name=None, severity_level=logging.INFO, **kwargs): def __repr__(self): return self.name - def start(self, host, brigade): + def start(self, host, nornir): """ Run the task for the given host. Arguments: - host (:obj:`brigade.core.inventory.Host`): Host we are operating with. Populated right + host (:obj:`nornir.core.inventory.Host`): Host we are operating with. Populated right before calling the ``task`` - brigade(:obj:`brigade.core.Brigade`): Populated right before calling + nornir(:obj:`nornir.core.Nornir`): Populated right before calling the ``task`` Returns: - host (:obj:`brigade.core.task.MultiResult`): Results of the task and its subtasks + host (:obj:`nornir.core.task.MultiResult`): Results of the task and its subtasks """ self.host = host - self.brigade = brigade + self.nornir = nornir - logger = logging.getLogger("brigade") + logger = logging.getLogger("nornir") try: logger.info("{}: {}: running task".format(self.host.name, self.name)) r = self.task(self, **self.params) if not isinstance(r, Result): r = Result(host=host, result=r) - except BrigadeSubTaskError as e: + except NornirSubTaskError as e: tb = traceback.format_exc() logger.error("{}: {}".format(self.host, tb)) r = Result(host, exception=e, result=str(e), failed=True) @@ -87,13 +87,13 @@ def grouped_tasks(task): task.run(my_first_task) task.run(my_second_task) - brigade.run(grouped_tasks) + nornir.run(grouped_tasks) This method will ensure the subtask is run only for the host in the current thread. """ - if not self.host or not self.brigade: + if not self.host or not self.nornir: msg = ( - "You have to call this after setting host and brigade attributes. ", + "You have to call this after setting host and nornir attributes. ", "You probably called this from outside a nested task", ) raise Exception(msg) @@ -101,12 +101,12 @@ def grouped_tasks(task): if "severity_level" not in kwargs: kwargs["severity_level"] = self.severity_level task = Task(task, **kwargs) - r = task.start(self.host, self.brigade) + r = task.start(self.host, self.nornir) self.results.append(r[0] if len(r) == 1 else r) if r.failed: # Without this we will keep running the grouped task - raise BrigadeSubTaskError(task=task, result=r) + raise NornirSubTaskError(task=task, result=r) return r @@ -117,7 +117,7 @@ def is_dry_run(self, override=None): Arguments: override (bool): Override for current task """ - return override if override is not None else self.brigade.dry_run + return override if override is not None else self.nornir.dry_run class Result(object): @@ -128,7 +128,7 @@ class Result(object): changed (bool): ``True`` if the task is changing the system diff (obj): Diff between state of the system before/after running this task result (obj): Result of the task execution, see task's documentation for details - host (:obj:`brigade.core.inventory.Host`): Reference to the host that lead ot this result + host (:obj:`nornir.core.inventory.Host`): Reference to the host that lead ot this result failed (bool): Whether the execution failed or not severity_level (logging.LEVEL): Severity level associated to the result of the excecution exception (Exception): uncaught exception thrown during the exection of the task (if any) @@ -137,7 +137,7 @@ class Result(object): changed (bool): ``True`` if the task is changing the system diff (obj): Diff between state of the system before/after running this task result (obj): Result of the task execution, see task's documentation for details - host (:obj:`brigade.core.inventory.Host`): Reference to the host that lead ot this result + host (:obj:`nornir.core.inventory.Host`): Reference to the host that lead ot this result failed (bool): Whether the execution failed or not severity_level (logging.LEVEL): Severity level associated to the result of the excecution exception (Exception): uncaught exception thrown during the exection of the task (if any) @@ -205,10 +205,10 @@ def failed_hosts(self): def raise_on_error(self): """ Raises: - :obj:`brigade.core.exceptions.BrigadeExecutionError`: When at least a task failed + :obj:`nornir.core.exceptions.NornirExecutionError`: When at least a task failed """ if self.failed: - raise BrigadeExecutionError(self) + raise NornirExecutionError(self) class MultiResult(list): @@ -239,7 +239,7 @@ def changed(self): def raise_on_error(self): """ Raises: - :obj:`brigade.core.exceptions.BrigadeExecutionError`: When at least a task failed + :obj:`nornir.core.exceptions.NornirExecutionError`: When at least a task failed """ if self.failed: - raise BrigadeExecutionError(self) + raise NornirExecutionError(self) diff --git a/brigade/plugins/__init__.py b/nornir/plugins/__init__.py similarity index 100% rename from brigade/plugins/__init__.py rename to nornir/plugins/__init__.py diff --git a/brigade/plugins/functions/__init__.py b/nornir/plugins/functions/__init__.py similarity index 100% rename from brigade/plugins/functions/__init__.py rename to nornir/plugins/functions/__init__.py diff --git a/brigade/plugins/functions/text/__init__.py b/nornir/plugins/functions/text/__init__.py similarity index 91% rename from brigade/plugins/functions/text/__init__.py rename to nornir/plugins/functions/text/__init__.py index e5635c7c..6f63994d 100644 --- a/brigade/plugins/functions/text/__init__.py +++ b/nornir/plugins/functions/text/__init__.py @@ -1,7 +1,7 @@ import logging import pprint -from brigade.core.task import AggregatedResult, MultiResult, Result +from nornir.core.task import AggregatedResult, MultiResult, Result from colorama import Fore, Style, init @@ -57,16 +57,16 @@ def print_result( result, host=None, vars=None, failed=None, severity_level=logging.INFO ): """ - Prints the :obj:`brigade.core.task.Result` from a previous task to screen + Prints the :obj:`nornir.core.task.Result` from a previous task to screen Arguments: - result (:obj:`brigade.core.task.Result`): from a previous task + result (:obj:`nornir.core.task.Result`): from a previous task vars (list of str): Which attributes you want to print failed (``bool``): if ``True`` assume the task failed severity_level (int): Print only errors with this severity level or higher Returns: - :obj:`brigade.core.task.Result`: + :obj:`nornir.core.task.Result`: """ vars = vars or ["diff", "result", "stdout"] diff --git a/brigade/plugins/inventory/__init__.py b/nornir/plugins/inventory/__init__.py similarity index 100% rename from brigade/plugins/inventory/__init__.py rename to nornir/plugins/inventory/__init__.py diff --git a/brigade/plugins/inventory/ansible.py b/nornir/plugins/inventory/ansible.py similarity index 92% rename from brigade/plugins/inventory/ansible.py rename to nornir/plugins/inventory/ansible.py index 8859c9b8..cc16ba17 100644 --- a/brigade/plugins/inventory/ansible.py +++ b/nornir/plugins/inventory/ansible.py @@ -6,12 +6,12 @@ import os from builtins import super -from brigade.core.inventory import Inventory +from nornir.core.inventory import Inventory import ruamel.yaml -logger = logging.getLogger("brigade") +logger = logging.getLogger("nornir") class AnsibleParser(object): @@ -38,7 +38,7 @@ def parse_group(self, group, data, parent=None): self.groups[group].update(data.get("vars", {})) self.groups[group].update(self.read_vars_file(group_file, self.path, False)) - self.groups[group] = self.map_brigade_vars(self.groups[group]) + self.groups[group] = self.map_nornir_vars(self.groups[group]) self.parse_hosts(data.get("hosts", {}), parent=group) @@ -57,7 +57,7 @@ def parse_hosts(self, hosts, parent=None): self.hosts[host]["groups"].append(parent) self.hosts[host].update(data) self.hosts[host].update(self.read_vars_file(host, self.path, True)) - self.hosts[host] = self.map_brigade_vars(self.hosts[host]) + self.hosts[host] = self.map_nornir_vars(self.hosts[host]) def sort_groups(self): for host in self.hosts.values(): @@ -84,12 +84,12 @@ def read_vars_file(self, element, path, is_host=True): yml = ruamel.yaml.YAML(typ="rt", pure=True) return yml.load(f) - def map_brigade_vars(self, obj): + def map_nornir_vars(self, obj): mappings = { - "ansible_host": "brigade_host", - "ansible_port": "brigade_ssh_port", - "ansible_user": "brigade_username", - "ansible_password": "brigade_password", + "ansible_host": "nornir_host", + "ansible_port": "nornir_ssh_port", + "ansible_user": "nornir_username", + "ansible_password": "nornir_password", } result = {} for k, v in obj.items(): diff --git a/brigade/plugins/inventory/nsot.py b/nornir/plugins/inventory/nsot.py similarity index 98% rename from brigade/plugins/inventory/nsot.py rename to nornir/plugins/inventory/nsot.py index 54429bb0..569c7e31 100644 --- a/brigade/plugins/inventory/nsot.py +++ b/nornir/plugins/inventory/nsot.py @@ -1,7 +1,7 @@ import os from builtins import super -from brigade.core.inventory import Inventory +from nornir.core.inventory import Inventory import requests diff --git a/brigade/plugins/inventory/simple.py b/nornir/plugins/inventory/simple.py similarity index 84% rename from brigade/plugins/inventory/simple.py rename to nornir/plugins/inventory/simple.py index 762914c3..cf77c98a 100644 --- a/brigade/plugins/inventory/simple.py +++ b/nornir/plugins/inventory/simple.py @@ -2,7 +2,7 @@ import os from builtins import super -from brigade.core.inventory import Inventory +from nornir.core.inventory import Inventory import yaml @@ -30,9 +30,9 @@ class SimpleInventory(Inventory): nos: linux switch00.cmh: - brigade_ip: 127.0.0.1 - brigade_username: vagrant - brigade_password: vagrant + nornir_ip: 127.0.0.1 + nornir_username: vagrant + nornir_password: vagrant napalm_port: 12443 site: cmh role: leaf @@ -41,9 +41,9 @@ class SimpleInventory(Inventory): nos: eos switch01.cmh: - brigade_ip: 127.0.0.1 - brigade_username: vagrant - brigade_password: "" + nornir_ip: 127.0.0.1 + nornir_username: vagrant + nornir_password: "" napalm_port: 12203 site: cmh role: leaf @@ -66,9 +66,9 @@ class SimpleInventory(Inventory): nos: linux switch00.bma: - brigade_ip: 127.0.0.1 - brigade_username: vagrant - brigade_password: vagrant + nornir_ip: 127.0.0.1 + nornir_username: vagrant + nornir_password: vagrant napalm_port: 12443 site: bma role: leaf @@ -77,9 +77,9 @@ class SimpleInventory(Inventory): nos: eos switch01.bma: - brigade_ip: 127.0.0.1 - brigade_username: vagrant - brigade_password: "" + nornir_ip: 127.0.0.1 + nornir_username: vagrant + nornir_password: "" napalm_port: 12203 site: bma role: leaf diff --git a/brigade/plugins/tasks/__init__.py b/nornir/plugins/tasks/__init__.py similarity index 100% rename from brigade/plugins/tasks/__init__.py rename to nornir/plugins/tasks/__init__.py diff --git a/brigade/plugins/tasks/apis/__init__.py b/nornir/plugins/tasks/apis/__init__.py similarity index 100% rename from brigade/plugins/tasks/apis/__init__.py rename to nornir/plugins/tasks/apis/__init__.py diff --git a/brigade/plugins/tasks/apis/http_method.py b/nornir/plugins/tasks/apis/http_method.py similarity index 94% rename from brigade/plugins/tasks/apis/http_method.py rename to nornir/plugins/tasks/apis/http_method.py index 55e9fd3e..e4c50292 100644 --- a/brigade/plugins/tasks/apis/http_method.py +++ b/nornir/plugins/tasks/apis/http_method.py @@ -1,4 +1,4 @@ -from brigade.core.task import Result +from nornir.core.task import Result import requests @@ -20,7 +20,7 @@ def http_method(task=None, method="get", url="", raise_for_status=True, **kwargs method Returns: - :obj:`brigade.core.task.Result`: + :obj:`nornir.core.task.Result`: * result (``string/dict``): Body of the response. Either text or a dict if the response was a json object * reponse (object): Original `Response diff --git a/brigade/plugins/tasks/commands/__init__.py b/nornir/plugins/tasks/commands/__init__.py similarity index 100% rename from brigade/plugins/tasks/commands/__init__.py rename to nornir/plugins/tasks/commands/__init__.py diff --git a/brigade/plugins/tasks/commands/command.py b/nornir/plugins/tasks/commands/command.py similarity index 78% rename from brigade/plugins/tasks/commands/command.py rename to nornir/plugins/tasks/commands/command.py index 101b6981..f97ace74 100644 --- a/brigade/plugins/tasks/commands/command.py +++ b/nornir/plugins/tasks/commands/command.py @@ -2,8 +2,8 @@ import subprocess -from brigade.core.exceptions import CommandError -from brigade.core.task import Result +from nornir.core.exceptions import CommandError +from nornir.core.task import Result def command(task, command): @@ -14,12 +14,12 @@ def command(task, command): command (``str``): command to execute Returns: - :obj:`brigade.core.task.Result`: + :obj:`nornir.core.task.Result`: * result (``str``): stderr or stdout * stdout (``str``): stdout * stderr (``srr``): stderr Raises: - :obj:`brigade.core.exceptions.CommandError`: when there is a command error + :obj:`nornir.core.exceptions.CommandError`: when there is a command error """ cmd = subprocess.Popen( shlex.split(command), diff --git a/brigade/plugins/tasks/commands/remote_command.py b/nornir/plugins/tasks/commands/remote_command.py similarity index 79% rename from brigade/plugins/tasks/commands/remote_command.py rename to nornir/plugins/tasks/commands/remote_command.py index 3d5070f9..5772a979 100644 --- a/brigade/plugins/tasks/commands/remote_command.py +++ b/nornir/plugins/tasks/commands/remote_command.py @@ -1,5 +1,5 @@ -from brigade.core.exceptions import CommandError -from brigade.core.task import Result +from nornir.core.exceptions import CommandError +from nornir.core.task import Result def remote_command(task, command): @@ -10,13 +10,13 @@ def remote_command(task, command): command (``str``): command to execute Returns: - :obj:`brigade.core.task.Result`: + :obj:`nornir.core.task.Result`: * result (``str``): stderr or stdout * stdout (``str``): stdout * stderr (``srr``): stderr Raises: - :obj:`brigade.core.exceptions.CommandError`: when there is a command error + :obj:`nornir.core.exceptions.CommandError`: when there is a command error """ client = task.host.get_connection("paramiko") diff --git a/brigade/plugins/tasks/connections/__init__.py b/nornir/plugins/tasks/connections/__init__.py similarity index 100% rename from brigade/plugins/tasks/connections/__init__.py rename to nornir/plugins/tasks/connections/__init__.py diff --git a/brigade/plugins/tasks/connections/napalm_connection.py b/nornir/plugins/tasks/connections/napalm_connection.py similarity index 89% rename from brigade/plugins/tasks/connections/napalm_connection.py rename to nornir/plugins/tasks/connections/napalm_connection.py index 607f5533..d1d4482b 100644 --- a/brigade/plugins/tasks/connections/napalm_connection.py +++ b/nornir/plugins/tasks/connections/napalm_connection.py @@ -25,6 +25,8 @@ def napalm_connection(task=None, timeout=60, optional_args=None): } if "port" not in parameters["optional_args"] and host.network_api_port: parameters["optional_args"]["port"] = host.network_api_port + elif "port" not in parameters["optional_args"] and host.ssh_port: + parameters["optional_args"]["port"] = host.ssh_port network_driver = get_network_driver(host.nos) host.connections["napalm"] = network_driver(**parameters) diff --git a/brigade/plugins/tasks/connections/netmiko_connection.py b/nornir/plugins/tasks/connections/netmiko_connection.py similarity index 100% rename from brigade/plugins/tasks/connections/netmiko_connection.py rename to nornir/plugins/tasks/connections/netmiko_connection.py diff --git a/brigade/plugins/tasks/connections/paramiko_connection.py b/nornir/plugins/tasks/connections/paramiko_connection.py similarity index 95% rename from brigade/plugins/tasks/connections/paramiko_connection.py rename to nornir/plugins/tasks/connections/paramiko_connection.py index 2fcf40b2..8197be50 100644 --- a/brigade/plugins/tasks/connections/paramiko_connection.py +++ b/nornir/plugins/tasks/connections/paramiko_connection.py @@ -15,7 +15,7 @@ def paramiko_connection(task=None): client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh_config = paramiko.SSHConfig() - ssh_config_file = task.brigade.config.ssh_config_file + ssh_config_file = task.nornir.config.ssh_config_file if os.path.exists(ssh_config_file): with open(ssh_config_file) as f: ssh_config.parse(f) diff --git a/brigade/plugins/tasks/data/__init__.py b/nornir/plugins/tasks/data/__init__.py similarity index 100% rename from brigade/plugins/tasks/data/__init__.py rename to nornir/plugins/tasks/data/__init__.py diff --git a/brigade/plugins/tasks/data/load_json.py b/nornir/plugins/tasks/data/load_json.py similarity index 82% rename from brigade/plugins/tasks/data/load_json.py rename to nornir/plugins/tasks/data/load_json.py index dfc6fc12..06782000 100644 --- a/brigade/plugins/tasks/data/load_json.py +++ b/nornir/plugins/tasks/data/load_json.py @@ -1,6 +1,6 @@ import json -from brigade.core.task import Result +from nornir.core.task import Result def load_json(task, file): @@ -11,7 +11,7 @@ def load_json(task, file): file (str): path to the file containing the json file to load Returns: - :obj:`brigade.core.task.Result`: + :obj:`nornir.core.task.Result`: * result (``dict``): dictionary with the contents of the file """ with open(file, "r") as f: diff --git a/brigade/plugins/tasks/data/load_yaml.py b/nornir/plugins/tasks/data/load_yaml.py similarity index 82% rename from brigade/plugins/tasks/data/load_yaml.py rename to nornir/plugins/tasks/data/load_yaml.py index 058a18c5..2e989097 100644 --- a/brigade/plugins/tasks/data/load_yaml.py +++ b/nornir/plugins/tasks/data/load_yaml.py @@ -1,4 +1,4 @@ -from brigade.core.task import Result +from nornir.core.task import Result import yaml @@ -12,7 +12,7 @@ def load_yaml(task, file): file (str): path to the file containing the yaml file to load Returns: - :obj:`brigade.core.task.Result`: + :obj:`nornir.core.task.Result`: * result (``dict``): dictionary with the contents of the file """ with open(file, "r") as f: diff --git a/brigade/plugins/tasks/files/__init__.py b/nornir/plugins/tasks/files/__init__.py similarity index 100% rename from brigade/plugins/tasks/files/__init__.py rename to nornir/plugins/tasks/files/__init__.py diff --git a/brigade/plugins/tasks/files/sftp.py b/nornir/plugins/tasks/files/sftp.py similarity index 94% rename from brigade/plugins/tasks/files/sftp.py rename to nornir/plugins/tasks/files/sftp.py index 42d67276..3eb97435 100644 --- a/brigade/plugins/tasks/files/sftp.py +++ b/nornir/plugins/tasks/files/sftp.py @@ -2,9 +2,9 @@ import os import stat -from brigade.core.exceptions import CommandError -from brigade.core.task import Result -from brigade.plugins.tasks import commands +from nornir.core.exceptions import CommandError +from nornir.core.task import Result +from nornir.plugins.tasks import commands import paramiko @@ -107,7 +107,7 @@ def sftp(task, src, dst, action, dry_run=None): Example:: - brigade.run(files.sftp, + nornir.run(files.sftp, action="put", src="README.md", dst="/tmp/README.md") @@ -119,7 +119,7 @@ def sftp(task, src, dst, action, dry_run=None): action (``str``): ``put``, ``get``. Returns: - :obj:`brigade.core.task.Result`: + :obj:`nornir.core.task.Result`: * changed (``bool``): * files_changed (``list``): list of files that changed """ diff --git a/brigade/plugins/tasks/files/write_file.py b/nornir/plugins/tasks/files/write_file.py similarity index 97% rename from brigade/plugins/tasks/files/write_file.py rename to nornir/plugins/tasks/files/write_file.py index c88646eb..a1f2a6b2 100644 --- a/brigade/plugins/tasks/files/write_file.py +++ b/nornir/plugins/tasks/files/write_file.py @@ -1,7 +1,7 @@ import difflib import os -from brigade.core.task import Result +from nornir.core.task import Result def _read_file(file): diff --git a/brigade/plugins/tasks/networking/__init__.py b/nornir/plugins/tasks/networking/__init__.py similarity index 100% rename from brigade/plugins/tasks/networking/__init__.py rename to nornir/plugins/tasks/networking/__init__.py diff --git a/brigade/plugins/tasks/networking/napalm_cli.py b/nornir/plugins/tasks/networking/napalm_cli.py similarity index 83% rename from brigade/plugins/tasks/networking/napalm_cli.py rename to nornir/plugins/tasks/networking/napalm_cli.py index 94187858..a1d75921 100644 --- a/brigade/plugins/tasks/networking/napalm_cli.py +++ b/nornir/plugins/tasks/networking/napalm_cli.py @@ -1,4 +1,4 @@ -from brigade.core.task import Result +from nornir.core.task import Result def napalm_cli(task, commands): @@ -9,7 +9,7 @@ def napalm_cli(task, commands): commands (``list``): List of commands to execute Returns: - :obj:`brigade.core.task.Result`: + :obj:`nornir.core.task.Result`: * result (``dict``): dictionary with the result of the commands """ device = task.host.get_connection("napalm") diff --git a/brigade/plugins/tasks/networking/napalm_configure.py b/nornir/plugins/tasks/networking/napalm_configure.py similarity index 93% rename from brigade/plugins/tasks/networking/napalm_configure.py rename to nornir/plugins/tasks/networking/napalm_configure.py index eae41e0f..88ede18c 100644 --- a/brigade/plugins/tasks/networking/napalm_configure.py +++ b/nornir/plugins/tasks/networking/napalm_configure.py @@ -1,4 +1,4 @@ -from brigade.core.task import Result +from nornir.core.task import Result def napalm_configure( @@ -14,7 +14,7 @@ def napalm_configure( replace (bool): whether to replace or merge the configuration Returns: - :obj:`brigade.core.task.Result`: + :obj:`nornir.core.task.Result`: * changed (``bool``): whether if the task is changing the system or not * diff (``string``): change in the system """ diff --git a/brigade/plugins/tasks/networking/napalm_get.py b/nornir/plugins/tasks/networking/napalm_get.py similarity index 88% rename from brigade/plugins/tasks/networking/napalm_get.py rename to nornir/plugins/tasks/networking/napalm_get.py index f90564d9..8ea9411c 100644 --- a/brigade/plugins/tasks/networking/napalm_get.py +++ b/nornir/plugins/tasks/networking/napalm_get.py @@ -1,4 +1,4 @@ -from brigade.core.task import Result +from nornir.core.task import Result def napalm_get(task, getters): @@ -10,7 +10,7 @@ def napalm_get(task, getters): Returns: - :obj:`brigade.core.task.Result`: + :obj:`nornir.core.task.Result`: * result (``dict``): dictionary with the result of the getter """ device = task.host.get_connection("napalm") diff --git a/brigade/plugins/tasks/networking/napalm_validate.py b/nornir/plugins/tasks/networking/napalm_validate.py similarity index 90% rename from brigade/plugins/tasks/networking/napalm_validate.py rename to nornir/plugins/tasks/networking/napalm_validate.py index 3e9f4db6..1149e1a5 100644 --- a/brigade/plugins/tasks/networking/napalm_validate.py +++ b/nornir/plugins/tasks/networking/napalm_validate.py @@ -1,4 +1,4 @@ -from brigade.core.task import Result +from nornir.core.task import Result def napalm_validate(task, src=None, validation_source=None): @@ -12,7 +12,7 @@ def napalm_validate(task, src=None, validation_source=None): validation_source (list): instead of a file data needed to validate device's state Returns: - :obj:`brigade.core.task.Result`: + :obj:`nornir.core.task.Result`: * result (``dict``): dictionary with the result of the validation * complies (``bool``): Whether the device complies or not """ diff --git a/brigade/plugins/tasks/networking/netmiko_file_transfer.py b/nornir/plugins/tasks/networking/netmiko_file_transfer.py similarity index 92% rename from brigade/plugins/tasks/networking/netmiko_file_transfer.py rename to nornir/plugins/tasks/networking/netmiko_file_transfer.py index 0561e7d1..05bffed2 100644 --- a/brigade/plugins/tasks/networking/netmiko_file_transfer.py +++ b/nornir/plugins/tasks/networking/netmiko_file_transfer.py @@ -1,4 +1,4 @@ -from brigade.core.task import Result +from nornir.core.task import Result from netmiko import file_transfer @@ -13,7 +13,7 @@ def netmiko_file_transfer(task, source_file, dest_file, **kwargs): kwargs (dict, optional): Additional arguments to pass to file_transfer Returns: - :obj:`brigade.core.task.Result`: + :obj:`nornir.core.task.Result`: * result (``bool``): file exists and MD5 is valid * changed (``bool``): the destination file was changed diff --git a/brigade/plugins/tasks/networking/netmiko_send_command.py b/nornir/plugins/tasks/networking/netmiko_send_command.py similarity index 91% rename from brigade/plugins/tasks/networking/netmiko_send_command.py rename to nornir/plugins/tasks/networking/netmiko_send_command.py index ebd5c915..3097812b 100644 --- a/brigade/plugins/tasks/networking/netmiko_send_command.py +++ b/nornir/plugins/tasks/networking/netmiko_send_command.py @@ -1,4 +1,4 @@ -from brigade.core.task import Result +from nornir.core.task import Result def netmiko_send_command(task, command_string, use_timing=False, **kwargs): @@ -11,7 +11,7 @@ def netmiko_send_command(task, command_string, use_timing=False, **kwargs): kwargs (dict, optional): Additional arguments to pass to send_command method. Returns: - :obj:`brigade.core.task.Result`: + :obj:`nornir.core.task.Result`: * result (``dict``): dictionary with the result of the show command. """ net_connect = task.host.get_connection("netmiko") diff --git a/brigade/plugins/tasks/networking/netmiko_send_config.py b/nornir/plugins/tasks/networking/netmiko_send_config.py similarity index 92% rename from brigade/plugins/tasks/networking/netmiko_send_config.py rename to nornir/plugins/tasks/networking/netmiko_send_config.py index 63c9366a..e200067e 100644 --- a/brigade/plugins/tasks/networking/netmiko_send_config.py +++ b/nornir/plugins/tasks/networking/netmiko_send_config.py @@ -1,6 +1,6 @@ from __future__ import unicode_literals -from brigade.core.task import Result +from nornir.core.task import Result def netmiko_send_config(task, config_commands=None, config_file=None, **kwargs): @@ -12,7 +12,7 @@ def netmiko_send_config(task, config_commands=None, config_file=None, **kwargs): kwargs (dict, optional): Additional arguments to pass to method. Returns: - :obj:`brigade.core.task.Result`: + :obj:`nornir.core.task.Result`: * result (``dict``): dictionary showing the CLI from the configuration changes. """ net_connect = task.host.get_connection("netmiko") diff --git a/brigade/plugins/tasks/networking/tcp_ping.py b/nornir/plugins/tasks/networking/tcp_ping.py similarity index 89% rename from brigade/plugins/tasks/networking/tcp_ping.py rename to nornir/plugins/tasks/networking/tcp_ping.py index 4f4d47aa..0d7fda15 100644 --- a/brigade/plugins/tasks/networking/tcp_ping.py +++ b/nornir/plugins/tasks/networking/tcp_ping.py @@ -1,7 +1,7 @@ import socket -from brigade.core.task import Result +from nornir.core.task import Result def tcp_ping(task, ports, timeout=2, host=None): @@ -12,11 +12,11 @@ def tcp_ping(task, ports, timeout=2, host=None): Arguments: ports (list of int): tcp port to ping timeout (int, optional): defaults to 0.5 - host (string, optional): defaults to ``brigade_ip`` + host (string, optional): defaults to ``nornir_ip`` Returns: - :obj:`brigade.core.task.Result`: + :obj:`nornir.core.task.Result`: * result (``dict``): Contains port numbers as keys with True/False as values """ diff --git a/brigade/plugins/tasks/text/__init__.py b/nornir/plugins/tasks/text/__init__.py similarity index 100% rename from brigade/plugins/tasks/text/__init__.py rename to nornir/plugins/tasks/text/__init__.py diff --git a/brigade/plugins/tasks/text/template_file.py b/nornir/plugins/tasks/text/template_file.py similarity index 74% rename from brigade/plugins/tasks/text/template_file.py rename to nornir/plugins/tasks/text/template_file.py index 5e5b4112..38b70054 100644 --- a/brigade/plugins/tasks/text/template_file.py +++ b/nornir/plugins/tasks/text/template_file.py @@ -1,5 +1,5 @@ -from brigade.core.helpers import jinja_helper, merge_two_dicts -from brigade.core.task import Result +from nornir.core.helpers import jinja_helper, merge_two_dicts +from nornir.core.task import Result def template_file(task, template, path, jinja_filters=None, **kwargs): @@ -9,14 +9,14 @@ def template_file(task, template, path, jinja_filters=None, **kwargs): Arguments: template (string): filename path (string): path to dir with templates - jinja_filters (dict): jinja filters to enable. Defaults to brigade.config.jinja_filters + jinja_filters (dict): jinja filters to enable. Defaults to nornir.config.jinja_filters **kwargs: additional data to pass to the template Returns: - :obj:`brigade.core.task.Result`: + :obj:`nornir.core.task.Result`: * result (``string``): rendered string """ - jinja_filters = jinja_filters or {} or task.brigade.config.jinja_filters + jinja_filters = jinja_filters or {} or task.nornir.config.jinja_filters merged = merge_two_dicts(task.host, kwargs) text = jinja_helper.render_from_file( template=template, diff --git a/brigade/plugins/tasks/text/template_string.py b/nornir/plugins/tasks/text/template_string.py similarity index 71% rename from brigade/plugins/tasks/text/template_string.py rename to nornir/plugins/tasks/text/template_string.py index 80d3f83b..6da51ecd 100644 --- a/brigade/plugins/tasks/text/template_string.py +++ b/nornir/plugins/tasks/text/template_string.py @@ -1,5 +1,5 @@ -from brigade.core.helpers import jinja_helper, merge_two_dicts -from brigade.core.task import Result +from nornir.core.helpers import jinja_helper, merge_two_dicts +from nornir.core.task import Result def template_string(task, template, jinja_filters=None, **kwargs): @@ -8,14 +8,14 @@ def template_string(task, template, jinja_filters=None, **kwargs): Arguments: template (string): template string - jinja_filters (dict): jinja filters to enable. Defaults to brigade.config.jinja_filters + jinja_filters (dict): jinja filters to enable. Defaults to nornir.config.jinja_filters **kwargs: additional data to pass to the template Returns: - :obj:`brigade.core.task.Result`: + :obj:`nornir.core.task.Result`: * result (``string``): rendered string """ - jinja_filters = jinja_filters or {} or task.brigade.config.jinja_filters + jinja_filters = jinja_filters or {} or task.nornir.config.jinja_filters merged = merge_two_dicts(task.host, kwargs) text = jinja_helper.render_from_string( template=template, host=task.host, jinja_filters=jinja_filters, **merged diff --git a/setup.cfg b/setup.cfg index 579d83f4..91cd4633 100644 --- a/setup.cfg +++ b/setup.cfg @@ -18,5 +18,5 @@ skip = .tox/* max_line_length = 100 [tool:pytest] -addopts = --cov=brigade --cov-report=term-missing -vs +addopts = --cov=nornir --cov-report=term-missing -vs python_paths = ./ diff --git a/setup.py b/setup.py index 7a76b253..44c7b2ec 100644 --- a/setup.py +++ b/setup.py @@ -10,16 +10,16 @@ __author__ = "dbarrosop@dravetech.com" __license__ = "Apache License, version 2" -__version__ = "1.0.0" +__version__ = "1.0.1" setup( - name="brigade", + name="nornir", version=__version__, description="Fighting fire with fire", long_description=long_description, long_description_content_type="text/markdown", author=__author__, - url="https://github.com/brigade-automation/brigade", + url="https://github.com/nornir-automation/nornir", include_package_data=True, install_requires=reqs, packages=find_packages(exclude=("test*",)), diff --git a/tests/conftest.py b/tests/conftest.py index f47fade2..5ba15678 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,8 +2,8 @@ import os import subprocess -from brigade.core import Brigade -from brigade.plugins.inventory.simple import SimpleInventory +from nornir.core import Nornir +from nornir.plugins.inventory.simple import SimpleInventory import pytest @@ -41,15 +41,15 @@ def fin(): @pytest.fixture(scope="session", autouse=True) -def brigade(request): - """Initializes brigade""" +def nornir(request): + """Initializes nornir""" dir_path = os.path.dirname(os.path.realpath(__file__)) - brigade = Brigade( + nornir = Nornir( inventory=SimpleInventory( "{}/inventory_data/hosts.yaml".format(dir_path), "{}/inventory_data/groups.yaml".format(dir_path), ), dry_run=True, ) - return brigade + return nornir diff --git a/tests/core/test_InitBrigade.py b/tests/core/test_InitNornir.py similarity index 67% rename from tests/core/test_InitBrigade.py rename to tests/core/test_InitNornir.py index d6a3d9fc..6344fe2c 100644 --- a/tests/core/test_InitBrigade.py +++ b/tests/core/test_InitNornir.py @@ -2,11 +2,11 @@ from builtins import super -from brigade.core import InitBrigade -from brigade.core.inventory import Inventory +from nornir.core import InitNornir +from nornir.core.inventory import Inventory -dir_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "test_InitBrigade") +dir_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "test_InitNornir") def transform_func(host): @@ -22,10 +22,10 @@ def __init__(self, *args, **kwargs): class Test(object): - def test_InitBrigade_defaults(self): + def test_InitNornir_defaults(self): os.chdir("tests/inventory_data/") try: - brg = InitBrigade() + brg = InitNornir() finally: os.chdir("../../") assert not brg.dry_run @@ -33,17 +33,17 @@ def test_InitBrigade_defaults(self): assert len(brg.inventory.hosts) assert len(brg.inventory.groups) - def test_InitBrigade_file(self): - brg = InitBrigade(config_file=os.path.join(dir_path, "a_config.yaml")) + def test_InitNornir_file(self): + brg = InitNornir(config_file=os.path.join(dir_path, "a_config.yaml")) assert not brg.dry_run assert brg.config.num_workers == 100 assert len(brg.inventory.hosts) assert len(brg.inventory.groups) - def test_InitBrigade_programmatically(self): - brg = InitBrigade( + def test_InitNornir_programmatically(self): + brg = InitNornir( num_workers=100, - inventory="brigade.plugins.inventory.simple.SimpleInventory", + inventory="nornir.plugins.inventory.simple.SimpleInventory", SimpleInventory={ "host_file": "tests/inventory_data/hosts.yaml", "group_file": "tests/inventory_data/groups.yaml", @@ -54,8 +54,8 @@ def test_InitBrigade_programmatically(self): assert len(brg.inventory.hosts) assert len(brg.inventory.groups) - def test_InitBrigade_combined(self): - brg = InitBrigade( + def test_InitNornir_combined(self): + brg = InitNornir( config_file=os.path.join(dir_path, "a_config.yaml"), num_workers=200 ) assert not brg.dry_run @@ -63,30 +63,30 @@ def test_InitBrigade_combined(self): assert len(brg.inventory.hosts) assert len(brg.inventory.groups) - def test_InitBrigade_different_inventory_by_string(self): - brg = InitBrigade( + def test_InitNornir_different_inventory_by_string(self): + brg = InitNornir( config_file=os.path.join(dir_path, "a_config.yaml"), - inventory="tests.core.test_InitBrigade.StringInventory", + inventory="tests.core.test_InitNornir.StringInventory", ) assert isinstance(brg.inventory, StringInventory) - def test_InitBrigade_different_inventory_imported(self): - brg = InitBrigade( + def test_InitNornir_different_inventory_imported(self): + brg = InitNornir( config_file=os.path.join(dir_path, "a_config.yaml"), inventory=StringInventory, ) assert isinstance(brg.inventory, StringInventory) - def test_InitBrigade_different_transform_function_by_string(self): - brg = InitBrigade( + def test_InitNornir_different_transform_function_by_string(self): + brg = InitNornir( config_file=os.path.join(dir_path, "a_config.yaml"), - transform_function="tests.core.test_InitBrigade.transform_func", + transform_function="tests.core.test_InitNornir.transform_func", ) for value in brg.inventory.hosts.values(): assert value.processed_by_transform_function - def test_InitBrigade_different_transform_function_imported(self): - brg = InitBrigade( + def test_InitNornir_different_transform_function_imported(self): + brg = InitNornir( config_file=os.path.join(dir_path, "a_config.yaml"), transform_function=transform_func, ) diff --git a/tests/core/test_InitBrigade/a_config.yaml b/tests/core/test_InitNornir/a_config.yaml similarity index 69% rename from tests/core/test_InitBrigade/a_config.yaml rename to tests/core/test_InitNornir/a_config.yaml index 9047b4a9..a0fddd4f 100644 --- a/tests/core/test_InitBrigade/a_config.yaml +++ b/tests/core/test_InitNornir/a_config.yaml @@ -1,6 +1,6 @@ --- num_workers: 100 -inventory: brigade.plugins.inventory.simple.SimpleInventory +inventory: nornir.plugins.inventory.simple.SimpleInventory SimpleInventory: host_file: "tests/inventory_data/hosts.yaml" group_file: "tests/inventory_data/groups.yaml" diff --git a/tests/core/test_configuration.py b/tests/core/test_configuration.py index d65f50c9..1bc27399 100644 --- a/tests/core/test_configuration.py +++ b/tests/core/test_configuration.py @@ -1,6 +1,6 @@ import os -from brigade.core.configuration import Config +from nornir.core.configuration import Config # import pytest diff --git a/tests/core/test_inventory.py b/tests/core/test_inventory.py index 62a7a02b..a741bf31 100644 --- a/tests/core/test_inventory.py +++ b/tests/core/test_inventory.py @@ -1,7 +1,7 @@ import os -from brigade.core.inventory import Group, Host -from brigade.plugins.inventory.simple import SimpleInventory +from nornir.core.inventory import Group, Host +from nornir.plugins.inventory.simple import SimpleInventory import pytest diff --git a/tests/core/test_multithreading.py b/tests/core/test_multithreading.py index 2c9f1bcf..ad0915dc 100644 --- a/tests/core/test_multithreading.py +++ b/tests/core/test_multithreading.py @@ -1,8 +1,8 @@ import datetime import time -from brigade.core.exceptions import BrigadeExecutionError, CommandError -from brigade.plugins.tasks import commands +from nornir.core.exceptions import NornirExecutionError, CommandError +from nornir.plugins.tasks import commands import pytest @@ -32,69 +32,69 @@ def verify_data_change(task): class Test(object): - def test_blocking_task_single_thread(self, brigade): + def test_blocking_task_single_thread(self, nornir): t1 = datetime.datetime.now() - brigade.run(blocking_task, wait=0.5, num_workers=1) + nornir.run(blocking_task, wait=0.5, num_workers=1) t2 = datetime.datetime.now() delta = t2 - t1 assert delta.seconds == 2, delta - def test_blocking_task_multithreading(self, brigade): + def test_blocking_task_multithreading(self, nornir): t1 = datetime.datetime.now() - brigade.run(blocking_task, wait=2, num_workers=NUM_WORKERS) + nornir.run(blocking_task, wait=2, num_workers=NUM_WORKERS) t2 = datetime.datetime.now() delta = t2 - t1 assert delta.seconds == 2, delta - def test_failing_task_simple_singlethread(self, brigade): - result = brigade.run(failing_task_simple, num_workers=1) + def test_failing_task_simple_singlethread(self, nornir): + result = nornir.run(failing_task_simple, num_workers=1) processed = False for k, v in result.items(): processed = True assert isinstance(k, str), k assert isinstance(v.exception, Exception), v assert processed - brigade.data.reset_failed_hosts() + nornir.data.reset_failed_hosts() - def test_failing_task_simple_multithread(self, brigade): - result = brigade.run(failing_task_simple, num_workers=NUM_WORKERS) + def test_failing_task_simple_multithread(self, nornir): + result = nornir.run(failing_task_simple, num_workers=NUM_WORKERS) processed = False for k, v in result.items(): processed = True assert isinstance(k, str), k assert isinstance(v.exception, Exception), v assert processed - brigade.data.reset_failed_hosts() + nornir.data.reset_failed_hosts() - def test_failing_task_complex_singlethread(self, brigade): - result = brigade.run(failing_task_complex, num_workers=1) + def test_failing_task_complex_singlethread(self, nornir): + result = nornir.run(failing_task_complex, num_workers=1) processed = False for k, v in result.items(): processed = True assert isinstance(k, str), k assert isinstance(v.exception, CommandError), v assert processed - brigade.data.reset_failed_hosts() + nornir.data.reset_failed_hosts() - def test_failing_task_complex_multithread(self, brigade): - result = brigade.run(failing_task_complex, num_workers=NUM_WORKERS) + def test_failing_task_complex_multithread(self, nornir): + result = nornir.run(failing_task_complex, num_workers=NUM_WORKERS) processed = False for k, v in result.items(): processed = True assert isinstance(k, str), k assert isinstance(v.exception, CommandError), v assert processed - brigade.data.reset_failed_hosts() + nornir.data.reset_failed_hosts() - def test_failing_task_complex_multithread_raise_on_error(self, brigade): - with pytest.raises(BrigadeExecutionError) as e: - brigade.run( + def test_failing_task_complex_multithread_raise_on_error(self, nornir): + with pytest.raises(NornirExecutionError) as e: + nornir.run( failing_task_complex, num_workers=NUM_WORKERS, raise_on_error=True ) for k, v in e.value.result.items(): assert isinstance(k, str), k assert isinstance(v.exception, CommandError), v - def test_change_data_in_thread(self, brigade): - brigade.run(change_data, num_workers=NUM_WORKERS) - brigade.run(verify_data_change, num_workers=NUM_WORKERS) + def test_change_data_in_thread(self, nornir): + nornir.run(change_data, num_workers=NUM_WORKERS) + nornir.run(verify_data_change, num_workers=NUM_WORKERS) diff --git a/tests/core/test_tasks.py b/tests/core/test_tasks.py index 7aa06065..bf4001de 100644 --- a/tests/core/test_tasks.py +++ b/tests/core/test_tasks.py @@ -1,6 +1,6 @@ import logging -from brigade.plugins.tasks import commands +from nornir.plugins.tasks import commands def task_fails_for_some(task): @@ -21,22 +21,22 @@ def sub_task(task): class Test(object): - def test_task(self, brigade): - result = brigade.run(commands.command, command="echo hi") + def test_task(self, nornir): + result = nornir.run(commands.command, command="echo hi") assert result for h, r in result.items(): assert r.stdout.strip() == "hi" - def test_sub_task(self, brigade): - result = brigade.run(sub_task) + def test_sub_task(self, nornir): + result = nornir.run(sub_task) assert result for h, r in result.items(): assert r[0].name == "sub_task" assert r[1].name == "command" assert h == r[1].stdout.strip() - def test_skip_failed_host(self, brigade): - result = brigade.run(task_fails_for_some) + def test_skip_failed_host(self, nornir): + result = nornir.run(task_fails_for_some) assert result.failed assert "dev3.group_2" in result @@ -47,52 +47,52 @@ def test_skip_failed_host(self, brigade): assert not r.failed assert h == r[1].stdout.strip() - result = brigade.run(task_fails_for_some) + result = nornir.run(task_fails_for_some) assert not result.failed assert "dev3.group_2" not in result - brigade.data.reset_failed_hosts() + nornir.data.reset_failed_hosts() - def test_run_on(self, brigade): - result = brigade.run(task_fails_for_some) + def test_run_on(self, nornir): + result = nornir.run(task_fails_for_some) assert result.failed assert "dev3.group_2" in result assert "dev1.group_1" in result - result = brigade.run(task_fails_for_some, on_failed=True) + result = nornir.run(task_fails_for_some, on_failed=True) assert result.failed assert "dev3.group_2" in result assert "dev1.group_1" in result - result = brigade.run(task_fails_for_some, on_failed=True, on_good=False) + result = nornir.run(task_fails_for_some, on_failed=True, on_good=False) assert result.failed assert "dev3.group_2" in result assert "dev1.group_1" not in result - result = brigade.run(task_fails_for_some, on_failed=False, on_good=True) + result = nornir.run(task_fails_for_some, on_failed=False, on_good=True) assert not result.failed assert "dev3.group_2" not in result assert "dev1.group_1" in result - brigade.data.reset_failed_hosts() + nornir.data.reset_failed_hosts() - def test_severity(self, brigade): - r = brigade.run(commands.command, command="echo blah") + def test_severity(self, nornir): + r = nornir.run(commands.command, command="echo blah") for host, result in r.items(): assert result[0].severity_level == logging.INFO - r = brigade.run( + r = nornir.run( commands.command, command="echo blah", severity_level=logging.WARN ) for host, result in r.items(): assert result[0].severity_level == logging.WARN - r = brigade.run(sub_task, severity_level=logging.WARN) + r = nornir.run(sub_task, severity_level=logging.WARN) for host, result in r.items(): for sr in result: assert sr.severity_level == logging.WARN - r = brigade.run(task_fails_for_some, severity_level=logging.WARN, num_workers=1) + r = nornir.run(task_fails_for_some, severity_level=logging.WARN, num_workers=1) for host, result in r.items(): if host == "dev3.group_2": assert result[0].severity_level == logging.ERROR @@ -100,4 +100,4 @@ def test_severity(self, brigade): assert result[0].severity_level == logging.WARN assert result[1].severity_level == logging.DEBUG - brigade.data.reset_failed_hosts() + nornir.data.reset_failed_hosts() diff --git a/tests/inventory_data/external_hosts.yaml b/tests/inventory_data/external_hosts.yaml index d3d5db56..03b6f6dc 100644 --- a/tests/inventory_data/external_hosts.yaml +++ b/tests/inventory_data/external_hosts.yaml @@ -1,6 +1,6 @@ --- www.github.com: - brigade_ip: www.github.com + nornir_ip: www.github.com dummy: - brigade_ip: 1.1.1.1 \ No newline at end of file + nornir_ip: 1.1.1.1 diff --git a/tests/inventory_data/groups.yaml b/tests/inventory_data/groups.yaml index f10df87a..81ecaa51 100644 --- a/tests/inventory_data/groups.yaml +++ b/tests/inventory_data/groups.yaml @@ -1,10 +1,10 @@ --- defaults: my_var: comes_from_defaults - brigade_host: 127.0.0.1 - brigade_username: root - brigade_password: docker - brigade_os: linux + nornir_host: 127.0.0.1 + nornir_username: root + nornir_password: docker + nornir_os: linux group_1: my_var: comes_from_group_1 diff --git a/tests/inventory_data/hosts.yaml b/tests/inventory_data/hosts.yaml index 76126566..86078f08 100644 --- a/tests/inventory_data/hosts.yaml +++ b/tests/inventory_data/hosts.yaml @@ -5,33 +5,33 @@ dev1.group_1: my_var: comes_from_dev1.group_1 www_server: nginx role: www - brigade_ssh_port: 65001 - brigade_nos: eos + nornir_ssh_port: 65001 + nornir_nos: eos dev2.group_1: groups: - group_1 role: db - brigade_ssh_port: 65002 - brigade_nos: junos + nornir_ssh_port: 65002 + nornir_nos: junos dev3.group_2: groups: - group_2 www_server: apache role: www - brigade_ssh_port: 65003 - brigade_network_api_port: 12443 - brigade_os: linux - brigade_nos: mock - # brigade_username: vagrant - # brigade_password: vagrant + nornir_ssh_port: 65003 + nornir_network_api_port: 12443 + nornir_os: linux + nornir_nos: mock + # nornir_username: vagrant + # nornir_password: vagrant dev4.group_2: groups: - group_2 my_var: comes_from_dev4.group_2 role: db - brigade_ssh_port: 65004 - brigade_network_api_port: 65004 - brigade_nos: linux + nornir_ssh_port: 65004 + nornir_network_api_port: 65004 + nornir_nos: linux diff --git a/tests/plugins/functions/text/output_data/basic_inventory.stdout b/tests/plugins/functions/text/output_data/basic_inventory.stdout index 400491f8..e53e05bf 100644 --- a/tests/plugins/functions/text/output_data/basic_inventory.stdout +++ b/tests/plugins/functions/text/output_data/basic_inventory.stdout @@ -1,17 +1,17 @@ echo_task*********************************************************************** * dev1.group_1 ** changed : False ********************************************** vvvv echo_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO -Hello from Brigade +Hello from Nornir ^^^^ END echo_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * dev2.group_1 ** changed : False ********************************************** vvvv echo_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO -Hello from Brigade +Hello from Nornir ^^^^ END echo_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * dev3.group_2 ** changed : False ********************************************** vvvv echo_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO -Hello from Brigade +Hello from Nornir ^^^^ END echo_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * dev4.group_2 ** changed : False ********************************************** vvvv echo_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO -Hello from Brigade +Hello from Nornir ^^^^ END echo_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/plugins/functions/text/output_data/basic_inventory_one_host.stdout b/tests/plugins/functions/text/output_data/basic_inventory_one_host.stdout index ba300d7a..c409e09b 100644 --- a/tests/plugins/functions/text/output_data/basic_inventory_one_host.stdout +++ b/tests/plugins/functions/text/output_data/basic_inventory_one_host.stdout @@ -1,6 +1,6 @@ vvvv data_with_greeting ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO ---- echo_task ** changed : False ---------------------------------------------- INFO -Hello from Brigade +Hello from Nornir ---- load_data ** changed : False ---------------------------------------------- INFO {'os': 'Linux', 'services': ['http', 'smtp', 'dns']} ^^^^ END data_with_greeting ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/plugins/functions/text/output_data/basic_inventory_one_host_python27.stdout b/tests/plugins/functions/text/output_data/basic_inventory_one_host_python27.stdout index 424afece..94bdebb1 100644 --- a/tests/plugins/functions/text/output_data/basic_inventory_one_host_python27.stdout +++ b/tests/plugins/functions/text/output_data/basic_inventory_one_host_python27.stdout @@ -1,6 +1,6 @@ vvvv data_with_greeting ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO ---- echo_task ** changed : False ---------------------------------------------- INFO -Hello from Brigade +Hello from Nornir ---- load_data ** changed : False ---------------------------------------------- INFO { 'os': 'Linux', 'services': ['http', 'smtp', 'dns']} ^^^^ END data_with_greeting ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/plugins/functions/text/output_data/basic_inventory_one_task.stdout b/tests/plugins/functions/text/output_data/basic_inventory_one_task.stdout index 5700ec74..be49c4a9 100644 --- a/tests/plugins/functions/text/output_data/basic_inventory_one_task.stdout +++ b/tests/plugins/functions/text/output_data/basic_inventory_one_task.stdout @@ -1,2 +1,2 @@ ---- echo_task ** changed : False ---------------------------------------------- INFO -Hello from Brigade +Hello from Nornir diff --git a/tests/plugins/functions/text/output_data/basic_inventory_one_task_python27.stdout b/tests/plugins/functions/text/output_data/basic_inventory_one_task_python27.stdout index 5700ec74..be49c4a9 100644 --- a/tests/plugins/functions/text/output_data/basic_inventory_one_task_python27.stdout +++ b/tests/plugins/functions/text/output_data/basic_inventory_one_task_python27.stdout @@ -1,2 +1,2 @@ ---- echo_task ** changed : False ---------------------------------------------- INFO -Hello from Brigade +Hello from Nornir diff --git a/tests/plugins/functions/text/output_data/basic_inventory_python27.stdout b/tests/plugins/functions/text/output_data/basic_inventory_python27.stdout index 400491f8..e53e05bf 100644 --- a/tests/plugins/functions/text/output_data/basic_inventory_python27.stdout +++ b/tests/plugins/functions/text/output_data/basic_inventory_python27.stdout @@ -1,17 +1,17 @@ echo_task*********************************************************************** * dev1.group_1 ** changed : False ********************************************** vvvv echo_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO -Hello from Brigade +Hello from Nornir ^^^^ END echo_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * dev2.group_1 ** changed : False ********************************************** vvvv echo_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO -Hello from Brigade +Hello from Nornir ^^^^ END echo_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * dev3.group_2 ** changed : False ********************************************** vvvv echo_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO -Hello from Brigade +Hello from Nornir ^^^^ END echo_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * dev4.group_2 ** changed : False ********************************************** vvvv echo_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO -Hello from Brigade +Hello from Nornir ^^^^ END echo_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/plugins/functions/text/output_data/basic_single.stdout b/tests/plugins/functions/text/output_data/basic_single.stdout index 842de17d..8cbbe534 100644 --- a/tests/plugins/functions/text/output_data/basic_single.stdout +++ b/tests/plugins/functions/text/output_data/basic_single.stdout @@ -1,5 +1,5 @@ echo_task*********************************************************************** * dev1.group_1 ** changed : False ********************************************** vvvv echo_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO -Hello from Brigade +Hello from Nornir ^^^^ END echo_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/plugins/functions/text/output_data/basic_single_python27.stdout b/tests/plugins/functions/text/output_data/basic_single_python27.stdout index 842de17d..8cbbe534 100644 --- a/tests/plugins/functions/text/output_data/basic_single_python27.stdout +++ b/tests/plugins/functions/text/output_data/basic_single_python27.stdout @@ -1,5 +1,5 @@ echo_task*********************************************************************** * dev1.group_1 ** changed : False ********************************************** vvvv echo_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO -Hello from Brigade +Hello from Nornir ^^^^ END echo_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/plugins/functions/text/output_data/failed_with_severity.stdout b/tests/plugins/functions/text/output_data/failed_with_severity.stdout index c6fcf161..a80685c3 100644 --- a/tests/plugins/functions/text/output_data/failed_with_severity.stdout +++ b/tests/plugins/functions/text/output_data/failed_with_severity.stdout @@ -13,7 +13,7 @@ Hello from CRITICAL ^^^^ END read_data ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * dev4.group_2 ** changed : False ********************************************** vvvv read_data ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv ERROR -BrigadeSubTaskError() +NornirSubTaskError() ---- echo_task ** changed : False ---------------------------------------------- CRITICAL Hello from CRITICAL ---- parse_data ** changed : False --------------------------------------------- ERROR diff --git a/tests/plugins/functions/text/output_data/failed_with_severity_python27.stdout b/tests/plugins/functions/text/output_data/failed_with_severity_python27.stdout index c6fcf161..a80685c3 100644 --- a/tests/plugins/functions/text/output_data/failed_with_severity_python27.stdout +++ b/tests/plugins/functions/text/output_data/failed_with_severity_python27.stdout @@ -13,7 +13,7 @@ Hello from CRITICAL ^^^^ END read_data ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * dev4.group_2 ** changed : False ********************************************** vvvv read_data ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv ERROR -BrigadeSubTaskError() +NornirSubTaskError() ---- echo_task ** changed : False ---------------------------------------------- CRITICAL Hello from CRITICAL ---- parse_data ** changed : False --------------------------------------------- ERROR diff --git a/tests/plugins/functions/text/output_data/multiple_tasks.stdout b/tests/plugins/functions/text/output_data/multiple_tasks.stdout index 0a6892a6..f75e1843 100644 --- a/tests/plugins/functions/text/output_data/multiple_tasks.stdout +++ b/tests/plugins/functions/text/output_data/multiple_tasks.stdout @@ -3,28 +3,28 @@ * dev1.group_1 ** changed : False ********************************************** vvvv data_with_greeting ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO ---- echo_task ** changed : False ---------------------------------------------- INFO -Hello from Brigade +Hello from Nornir ---- load_data ** changed : False ---------------------------------------------- INFO {'os': 'Linux', 'services': ['http', 'smtp', 'dns']} ^^^^ END data_with_greeting ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * dev2.group_1 ** changed : False ********************************************** vvvv data_with_greeting ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO ---- echo_task ** changed : False ---------------------------------------------- INFO -Hello from Brigade +Hello from Nornir ---- load_data ** changed : False ---------------------------------------------- INFO {'os': 'Linux', 'services': ['http', 'smtp', 'dns']} ^^^^ END data_with_greeting ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * dev3.group_2 ** changed : False ********************************************** vvvv data_with_greeting ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO ---- echo_task ** changed : False ---------------------------------------------- INFO -Hello from Brigade +Hello from Nornir ---- load_data ** changed : False ---------------------------------------------- INFO {'os': 'Linux', 'services': ['http', 'smtp', 'dns']} ^^^^ END data_with_greeting ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * dev4.group_2 ** changed : False ********************************************** vvvv data_with_greeting ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO ---- echo_task ** changed : False ---------------------------------------------- INFO -Hello from Brigade +Hello from Nornir ---- load_data ** changed : False ---------------------------------------------- INFO {'os': 'Linux', 'services': ['http', 'smtp', 'dns']} ^^^^ END data_with_greeting ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/plugins/functions/text/output_data/multiple_tasks_python27.stdout b/tests/plugins/functions/text/output_data/multiple_tasks_python27.stdout index 2ee93878..5c1105d5 100644 --- a/tests/plugins/functions/text/output_data/multiple_tasks_python27.stdout +++ b/tests/plugins/functions/text/output_data/multiple_tasks_python27.stdout @@ -3,28 +3,28 @@ * dev1.group_1 ** changed : False ********************************************** vvvv data_with_greeting ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO ---- echo_task ** changed : False ---------------------------------------------- INFO -Hello from Brigade +Hello from Nornir ---- load_data ** changed : False ---------------------------------------------- INFO { 'os': 'Linux', 'services': ['http', 'smtp', 'dns']} ^^^^ END data_with_greeting ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * dev2.group_1 ** changed : False ********************************************** vvvv data_with_greeting ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO ---- echo_task ** changed : False ---------------------------------------------- INFO -Hello from Brigade +Hello from Nornir ---- load_data ** changed : False ---------------------------------------------- INFO { 'os': 'Linux', 'services': ['http', 'smtp', 'dns']} ^^^^ END data_with_greeting ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * dev3.group_2 ** changed : False ********************************************** vvvv data_with_greeting ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO ---- echo_task ** changed : False ---------------------------------------------- INFO -Hello from Brigade +Hello from Nornir ---- load_data ** changed : False ---------------------------------------------- INFO { 'os': 'Linux', 'services': ['http', 'smtp', 'dns']} ^^^^ END data_with_greeting ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * dev4.group_2 ** changed : False ********************************************** vvvv data_with_greeting ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO ---- echo_task ** changed : False ---------------------------------------------- INFO -Hello from Brigade +Hello from Nornir ---- load_data ** changed : False ---------------------------------------------- INFO { 'os': 'Linux', 'services': ['http', 'smtp', 'dns']} ^^^^ END data_with_greeting ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/plugins/functions/text/test_print_result.py b/tests/plugins/functions/text/test_print_result.py index c7f690fd..9d6f6ffc 100644 --- a/tests/plugins/functions/text/test_print_result.py +++ b/tests/plugins/functions/text/test_print_result.py @@ -1,15 +1,15 @@ import os import logging -from brigade.plugins.functions.text import print_result -from brigade.plugins.functions.text import print_title -from brigade.core.task import Result +from nornir.plugins.functions.text import print_result +from nornir.plugins.functions.text import print_title +from nornir.core.task import Result from tests.wrapper import wrap_cli_test output_dir = "{}/output_data".format(os.path.dirname(os.path.realpath(__file__))) -def echo_task(task, msg="Brigade"): +def echo_task(task, msg="Nornir"): return Result( host=task.host, result="Hello from {}".format(msg), @@ -63,39 +63,39 @@ def read_data(task): class Test(object): @wrap_cli_test(output="{}/basic_single".format(output_dir)) - def test_print_basic(self, brigade): - filter = brigade.filter(name="dev1.group_1") + def test_print_basic(self, nornir): + filter = nornir.filter(name="dev1.group_1") result = filter.run(echo_task) print_result(result, vars="result") @wrap_cli_test(output="{}/basic_inventory".format(output_dir)) - def test_print_basic_inventory(self, brigade): - result = brigade.run(echo_task) + def test_print_basic_inventory(self, nornir): + result = nornir.run(echo_task) print_result(result) @wrap_cli_test(output="{}/basic_inventory_one_host".format(output_dir)) - def test_print_basic_inventory_one_host(self, brigade): - result = brigade.run(data_with_greeting) + def test_print_basic_inventory_one_host(self, nornir): + result = nornir.run(data_with_greeting) print_result(result["dev2.group_1"]) @wrap_cli_test(output="{}/basic_inventory_one_task".format(output_dir)) - def test_print_basic_inventory_one_task(self, brigade): - result = brigade.run(data_with_greeting) + def test_print_basic_inventory_one_task(self, nornir): + result = nornir.run(data_with_greeting) print_result(result["dev2.group_1"][1]) @wrap_cli_test(output="{}/multiple_tasks".format(output_dir)) - def test_print_multiple_tasks(self, brigade): - result = brigade.run(data_with_greeting) + def test_print_multiple_tasks(self, nornir): + result = nornir.run(data_with_greeting) print_title("Behold the data!") print_result(result) @wrap_cli_test(output="{}/changed_host".format(output_dir)) - def test_print_changed_host(self, brigade): - filter = brigade.filter(site="site1") + def test_print_changed_host(self, nornir): + filter = nornir.filter(site="site1") result = filter.run(read_data, severity_level=logging.WARN) print_result(result) @wrap_cli_test(output="{}/failed_with_severity".format(output_dir)) - def test_print_failed_with_severity(self, brigade): - result = brigade.run(read_data) + def test_print_failed_with_severity(self, nornir): + result = nornir.run(read_data) print_result(result, vars=["exception", "output"], severity_level=logging.ERROR) diff --git a/tests/plugins/inventory/ansible/ini/expected/hosts.yaml b/tests/plugins/inventory/ansible/ini/expected/hosts.yaml index cf9682ef..c8e69867 100644 --- a/tests/plugins/inventory/ansible/ini/expected/hosts.yaml +++ b/tests/plugins/inventory/ansible/ini/expected/hosts.yaml @@ -10,8 +10,8 @@ one.example.com: - dbservers my_var: from_one.example.com three.example.com: - brigade_host: 192.0.2.50 - brigade_ssh_port: 5555 + nornir_host: 192.0.2.50 + nornir_ssh_port: 5555 groups: - dbservers two.example.com: diff --git a/tests/plugins/inventory/ansible/yaml/expected/hosts.yaml b/tests/plugins/inventory/ansible/yaml/expected/hosts.yaml index cf9682ef..c8e69867 100644 --- a/tests/plugins/inventory/ansible/yaml/expected/hosts.yaml +++ b/tests/plugins/inventory/ansible/yaml/expected/hosts.yaml @@ -10,8 +10,8 @@ one.example.com: - dbservers my_var: from_one.example.com three.example.com: - brigade_host: 192.0.2.50 - brigade_ssh_port: 5555 + nornir_host: 192.0.2.50 + nornir_ssh_port: 5555 groups: - dbservers two.example.com: diff --git a/tests/plugins/inventory/ansible/yaml2/expected/hosts.yaml b/tests/plugins/inventory/ansible/yaml2/expected/hosts.yaml index 5e746bb5..f516beff 100644 --- a/tests/plugins/inventory/ansible/yaml2/expected/hosts.yaml +++ b/tests/plugins/inventory/ansible/yaml2/expected/hosts.yaml @@ -1,8 +1,8 @@ one.example.com: groups: [] three.example.com: - brigade_host: 192.0.2.50 - brigade_ssh_port: 5555 + nornir_host: 192.0.2.50 + nornir_ssh_port: 5555 groups: [] two.example.com: groups: [] diff --git a/tests/plugins/inventory/test_ansible.py b/tests/plugins/inventory/test_ansible.py index 78ed75dc..4d1cfe01 100644 --- a/tests/plugins/inventory/test_ansible.py +++ b/tests/plugins/inventory/test_ansible.py @@ -1,6 +1,6 @@ import os -from brigade.plugins.inventory import ansible +from nornir.plugins.inventory import ansible import pytest diff --git a/tests/plugins/inventory/test_nsot.py b/tests/plugins/inventory/test_nsot.py index ce1740e0..b57389f7 100644 --- a/tests/plugins/inventory/test_nsot.py +++ b/tests/plugins/inventory/test_nsot.py @@ -2,7 +2,7 @@ import subprocess import time -from brigade.plugins.inventory import nsot +from nornir.plugins.inventory import nsot import pytest @@ -11,7 +11,7 @@ def transform_function(host): attrs = ["user", "password"] for a in attrs: if a in host.data: - host["brigade_{}".format(a)] = host.data[a] + host["nornir_{}".format(a)] = host.data[a] @pytest.fixture(scope="module") @@ -46,5 +46,5 @@ def test_inventory(self, inv): def test_transform_function(self, inv): for host in inv.hosts.values(): - assert host["user"] == host["brigade_user"] - assert host["password"] == host["brigade_password"] + assert host["user"] == host["nornir_user"] + assert host["password"] == host["nornir_password"] diff --git a/tests/plugins/tasks/apis/test_http_method.py b/tests/plugins/tasks/apis/test_http_method.py index a2c5ceaa..6cc3b2b8 100644 --- a/tests/plugins/tasks/apis/test_http_method.py +++ b/tests/plugins/tasks/apis/test_http_method.py @@ -1,6 +1,6 @@ import json -from brigade.plugins.tasks.apis import http_method +from nornir.plugins.tasks.apis import http_method import pytest @@ -60,11 +60,11 @@ def test_raise_for_status(self): result = http_method(method="post", url=url, raise_for_status=False) assert result.response.status_code - def test_with_brigade(self, brigade): + def test_with_nornir(self, nornir): url = "{}/get".format(BASE_URL) params = {"my_param": "my_value"} - r = brigade.run(http_method, method="get", url=url, params=params) + r = nornir.run(http_method, method="get", url=url, params=params) processed = False for host, result in r.items(): diff --git a/tests/plugins/tasks/commands/test_command.py b/tests/plugins/tasks/commands/test_command.py index 215d7d91..a5766664 100644 --- a/tests/plugins/tasks/commands/test_command.py +++ b/tests/plugins/tasks/commands/test_command.py @@ -1,5 +1,5 @@ -from brigade.core.exceptions import CommandError -from brigade.plugins.tasks import commands +from nornir.core.exceptions import CommandError +from nornir.plugins.tasks import commands def echo_hostname(task): @@ -9,26 +9,26 @@ def echo_hostname(task): class Test(object): - def test_command(self, brigade): - result = brigade.run(echo_hostname) + def test_command(self, nornir): + result = nornir.run(echo_hostname) assert result for h, r in result.items(): assert h == r[1].stdout.strip() - def test_command_error(self, brigade): - result = brigade.run(commands.command, command="ech") + def test_command_error(self, nornir): + result = nornir.run(commands.command, command="ech") processed = False for r in result.values(): processed = True assert isinstance(r.exception, OSError) assert processed - brigade.data.reset_failed_hosts() + nornir.data.reset_failed_hosts() - def test_command_error_generic(self, brigade): - result = brigade.run(commands.command, command="ls /asdadsd") + def test_command_error_generic(self, nornir): + result = nornir.run(commands.command, command="ls /asdadsd") processed = False for r in result.values(): processed = True assert isinstance(r.exception, CommandError) assert processed - brigade.data.reset_failed_hosts() + nornir.data.reset_failed_hosts() diff --git a/tests/plugins/tasks/commands/test_remote_command.py b/tests/plugins/tasks/commands/test_remote_command.py index 7f2b89d8..945af852 100644 --- a/tests/plugins/tasks/commands/test_remote_command.py +++ b/tests/plugins/tasks/commands/test_remote_command.py @@ -1,20 +1,20 @@ -from brigade.core.exceptions import CommandError -from brigade.plugins.tasks import commands +from nornir.core.exceptions import CommandError +from nornir.plugins.tasks import commands class Test(object): - def test_remote_command(self, brigade): - result = brigade.run(commands.remote_command, command="hostname") + def test_remote_command(self, nornir): + result = nornir.run(commands.remote_command, command="hostname") assert result for h, r in result.items(): assert h == r.stdout.strip() - def test_remote_command_error_generic(self, brigade): - result = brigade.run(commands.remote_command, command="ls /asdadsd") + def test_remote_command_error_generic(self, nornir): + result = nornir.run(commands.remote_command, command="ls /asdadsd") processed = False for r in result.values(): processed = True assert isinstance(r.exception, CommandError) assert processed - brigade.data.reset_failed_hosts() + nornir.data.reset_failed_hosts() diff --git a/tests/plugins/tasks/data/test_data/broken.json b/tests/plugins/tasks/data/test_data/broken.json index 3809a603..fda45b38 100644 --- a/tests/plugins/tasks/data/test_data/broken.json +++ b/tests/plugins/tasks/data/test_data/broken.json @@ -5,4 +5,4 @@ "dns", "Broken file ] -} \ No newline at end of file +} diff --git a/tests/plugins/tasks/data/test_load_json.py b/tests/plugins/tasks/data/test_load_json.py index a381f25e..686952fd 100644 --- a/tests/plugins/tasks/data/test_load_json.py +++ b/tests/plugins/tasks/data/test_load_json.py @@ -1,7 +1,7 @@ import os import sys -from brigade.plugins.tasks import data +from nornir.plugins.tasks import data data_dir = "{}/test_data".format(os.path.dirname(os.path.realpath(__file__))) @@ -9,36 +9,36 @@ class Test(object): - def test_load_json(self, brigade): + def test_load_json(self, nornir): test_file = "{}/simple.json".format(data_dir) - result = brigade.run(data.load_json, file=test_file) + result = nornir.run(data.load_json, file=test_file) for h, r in result.items(): d = r.result assert d["env"] == "test" assert d["services"] == ["dhcp", "dns"] - def test_load_json_error_broken_file(self, brigade): + def test_load_json_error_broken_file(self, nornir): test_file = "{}/broken.json".format(data_dir) - results = brigade.run(data.load_json, file=test_file) + results = nornir.run(data.load_json, file=test_file) processed = False for result in results.values(): processed = True assert isinstance(result.exception, ValueError) assert processed - brigade.data.reset_failed_hosts() + nornir.data.reset_failed_hosts() - def test_load_json_error_missing_file(self, brigade): + def test_load_json_error_missing_file(self, nornir): test_file = "{}/missing.json".format(data_dir) if sys.version_info.major == 2: not_found = IOError else: not_found = FileNotFoundError # noqa - results = brigade.run(data.load_json, file=test_file) + results = nornir.run(data.load_json, file=test_file) processed = False for result in results.values(): processed = True assert isinstance(result.exception, not_found) assert processed - brigade.data.reset_failed_hosts() + nornir.data.reset_failed_hosts() diff --git a/tests/plugins/tasks/data/test_load_yaml.py b/tests/plugins/tasks/data/test_load_yaml.py index d6c931d6..de9eba05 100644 --- a/tests/plugins/tasks/data/test_load_yaml.py +++ b/tests/plugins/tasks/data/test_load_yaml.py @@ -2,7 +2,7 @@ import sys -from brigade.plugins.tasks import data +from nornir.plugins.tasks import data from yaml.scanner import ScannerError @@ -13,26 +13,26 @@ class Test(object): - def test_load_yaml(self, brigade): + def test_load_yaml(self, nornir): test_file = "{}/simple.yaml".format(data_dir) - result = brigade.run(data.load_yaml, file=test_file) + result = nornir.run(data.load_yaml, file=test_file) for h, r in result.items(): d = r.result assert d["env"] == "test" assert d["services"] == ["dhcp", "dns"] - def test_load_yaml_error_broken_file(self, brigade): + def test_load_yaml_error_broken_file(self, nornir): test_file = "{}/broken.yaml".format(data_dir) - results = brigade.run(data.load_yaml, file=test_file) + results = nornir.run(data.load_yaml, file=test_file) processed = False for result in results.values(): processed = True assert isinstance(result.exception, ScannerError) assert processed - brigade.data.reset_failed_hosts() + nornir.data.reset_failed_hosts() - def test_load_yaml_error_missing_file(self, brigade): + def test_load_yaml_error_missing_file(self, nornir): test_file = "{}/missing.yaml".format(data_dir) if sys.version_info.major == 2: @@ -40,10 +40,10 @@ def test_load_yaml_error_missing_file(self, brigade): else: not_found = FileNotFoundError # noqa - results = brigade.run(data.load_yaml, file=test_file) + results = nornir.run(data.load_yaml, file=test_file) processed = False for result in results.values(): processed = True assert isinstance(result.exception, not_found) assert processed - brigade.data.reset_failed_hosts() + nornir.data.reset_failed_hosts() diff --git a/tests/plugins/tasks/files/test_sftp.py b/tests/plugins/tasks/files/test_sftp.py index b1677fc4..feef3730 100644 --- a/tests/plugins/tasks/files/test_sftp.py +++ b/tests/plugins/tasks/files/test_sftp.py @@ -1,7 +1,7 @@ import uuid -# from brigade.core.exceptions import BrigadeExecutionError, CommandError -from brigade.plugins.tasks import files +# from nornir.core.exceptions import NornirExecutionError, CommandError +from nornir.plugins.tasks import files # import pytest @@ -50,8 +50,8 @@ def get_directory(task): class Test(object): - def test_sftp_put(self, brigade): - result = brigade.run( + def test_sftp_put(self, nornir): + result = nornir.run( files.sftp, dry_run=True, action="put", @@ -63,7 +63,7 @@ def test_sftp_put(self, brigade): for h, r in result.items(): assert r.changed, r.files_changed - result = brigade.run( + result = nornir.run( files.sftp, dry_run=False, action="put", @@ -75,7 +75,7 @@ def test_sftp_put(self, brigade): for h, r in result.items(): assert r.changed, r.files_changed - result = brigade.run( + result = nornir.run( files.sftp, dry_run=True, action="put", @@ -87,35 +87,35 @@ def test_sftp_put(self, brigade): for h, r in result.items(): assert not r.changed - def test_sftp_get(self, brigade): - result = brigade.run(get_file) + def test_sftp_get(self, nornir): + result = nornir.run(get_file) assert not result.failed - def test_sftp_put_directory(self, brigade): - result = brigade.run( - files.sftp, dry_run=True, action="put", src="./brigade", dst="/tmp/asd" + def test_sftp_put_directory(self, nornir): + result = nornir.run( + files.sftp, dry_run=True, action="put", src="./nornir", dst="/tmp/asd" ) assert result for h, r in result.items(): assert r.changed, r.files_changed - result = brigade.run( - files.sftp, dry_run=False, action="put", src="./brigade", dst="/tmp/asd" + result = nornir.run( + files.sftp, dry_run=False, action="put", src="./nornir", dst="/tmp/asd" ) assert result for h, r in result.items(): assert r.changed, r.files_changed - result = brigade.run( - files.sftp, dry_run=True, action="put", src="./brigade", dst="/tmp/asd" + result = nornir.run( + files.sftp, dry_run=True, action="put", src="./nornir", dst="/tmp/asd" ) assert result for h, r in result.items(): assert not r.changed - def test_sftp_get_directory(self, brigade): - result = brigade.run(get_directory) + def test_sftp_get_directory(self, nornir): + result = nornir.run(get_directory) assert not result.failed diff --git a/tests/plugins/tasks/files/test_write_file.py b/tests/plugins/tasks/files/test_write_file.py index b2251cf8..6a2d0a28 100644 --- a/tests/plugins/tasks/files/test_write_file.py +++ b/tests/plugins/tasks/files/test_write_file.py @@ -1,7 +1,7 @@ import os import uuid -from brigade.plugins.tasks import files +from nornir.plugins.tasks import files content_a = """ @@ -20,7 +20,7 @@ """ -diff_new = """--- /tmp/brigade-write_file/dev3.group_2-f66d9331-3eeb-4912-98b9-37f55ac48deb +diff_new = """--- /tmp/nornir-write_file/dev3.group_2-f66d9331-3eeb-4912-98b9-37f55ac48deb +++ new @@ -33,7 +33,7 @@ +BLOH +BLUH""" -diff_overwrite_file = """--- /tmp/brigade-write_file/dev4.group_2-e63969eb-2261-4200-8913-196a12f4d791 +diff_overwrite_file = """--- /tmp/nornir-write_file/dev4.group_2-e63969eb-2261-4200-8913-196a12f4d791 +++ new @@ -49,7 +49,7 @@ -BLUH""" # noqa -diff_append = """--- /tmp/brigade-write_file/dev4.group_2-36ea350d-6623-4098-a961-fc143504eb42 +diff_append = """--- /tmp/nornir-write_file/dev4.group_2-36ea350d-6623-4098-a961-fc143504eb42 +++ new @@ -65,7 +65,7 @@ +BLIH""" # noqa -BASEPATH = "/tmp/brigade-write_file" +BASEPATH = "/tmp/nornir-write_file" if not os.path.exists(BASEPATH): os.makedirs(BASEPATH) @@ -129,11 +129,11 @@ def _test_append(task): class Test(object): - def test_write_file(self, brigade): - brigade.run(_test_write_file) + def test_write_file(self, nornir): + nornir.run(_test_write_file) - def test_overwrite_file(self, brigade): - brigade.run(_test_overwrite_file) + def test_overwrite_file(self, nornir): + nornir.run(_test_overwrite_file) - def test_append(self, brigade): - brigade.run(_test_append) + def test_append(self, nornir): + nornir.run(_test_append) diff --git a/tests/plugins/tasks/networking/data/test_file.txt b/tests/plugins/tasks/networking/data/test_file.txt index 6fbcd24f..9869b4d8 100644 --- a/tests/plugins/tasks/networking/data/test_file.txt +++ b/tests/plugins/tasks/networking/data/test_file.txt @@ -1 +1 @@ -Testing secure copy file for brigade +Testing secure copy file for nornir diff --git a/tests/plugins/tasks/networking/test_napalm_cli.py b/tests/plugins/tasks/networking/test_napalm_cli.py index 98a28128..70507541 100644 --- a/tests/plugins/tasks/networking/test_napalm_cli.py +++ b/tests/plugins/tasks/networking/test_napalm_cli.py @@ -1,7 +1,7 @@ import os -# from brigade.core.exceptions import BrigadeExecutionError -from brigade.plugins.tasks import connections, networking +# from nornir.core.exceptions import NornirExecutionError +from nornir.plugins.tasks import connections, networking # from napalm.base import exceptions @@ -13,9 +13,9 @@ class Test(object): - def test_napalm_cli(self, brigade): + def test_napalm_cli(self, nornir): opt = {"path": THIS_DIR + "/test_napalm_cli"} - d = brigade.filter(name="dev3.group_2") + d = nornir.filter(name="dev3.group_2") d.run(connections.napalm_connection, optional_args=opt) result = d.run( networking.napalm_cli, commands=["show version", "show interfaces"] @@ -26,10 +26,10 @@ def test_napalm_cli(self, brigade): assert r.result["show interfaces"] -# def test_napalm_cli_error(self, brigade): +# def test_napalm_cli_error(self, nornir): # opt = {"path": THIS_DIR + "/test_napalm_cli_error"} -# with pytest.raises(BrigadeExecutionError) as e: -# brigade.filter(name="dev3.group_2").run(networking.napalm_cli, +# with pytest.raises(NornirExecutionError) as e: +# nornir.filter(name="dev3.group_2").run(networking.napalm_cli, # num_workers=1, # commands=["show version", # "show interfacesa"], diff --git a/tests/plugins/tasks/networking/test_napalm_configure.py b/tests/plugins/tasks/networking/test_napalm_configure.py index 8ab1bc75..a699c1d7 100644 --- a/tests/plugins/tasks/networking/test_napalm_configure.py +++ b/tests/plugins/tasks/networking/test_napalm_configure.py @@ -1,6 +1,6 @@ import os -from brigade.plugins.tasks import connections, networking +from nornir.plugins.tasks import connections, networking from napalm.base import exceptions @@ -10,10 +10,10 @@ class Test(object): - def test_napalm_configure_change_dry_run(self, brigade): + def test_napalm_configure_change_dry_run(self, nornir): opt = {"path": THIS_DIR + "/test_napalm_configure_change_dry_run"} configuration = "hostname changed-hostname" - d = brigade.filter(name="dev3.group_2") + d = nornir.filter(name="dev3.group_2") d.run(connections.napalm_connection, optional_args=opt) result = d.run(networking.napalm_configure, configuration=configuration) assert result @@ -21,10 +21,10 @@ def test_napalm_configure_change_dry_run(self, brigade): assert "+hostname changed-hostname" in r.diff assert r.changed - def test_napalm_configure_change_commit(self, brigade): + def test_napalm_configure_change_commit(self, nornir): opt = {"path": THIS_DIR + "/test_napalm_configure_change_commit/step1"} configuration = "hostname changed-hostname" - d = brigade.filter(name="dev3.group_2") + d = nornir.filter(name="dev3.group_2") d.run(connections.napalm_connection, optional_args=opt) result = d.run( networking.napalm_configure, dry_run=False, configuration=configuration @@ -43,11 +43,11 @@ def test_napalm_configure_change_commit(self, brigade): assert "+hostname changed-hostname" not in r.diff assert not r.changed - def test_napalm_configure_change_error(self, brigade): + def test_napalm_configure_change_error(self, nornir): opt = {"path": THIS_DIR + "/test_napalm_configure_change_error"} configuration = "hostname changed_hostname" - d = brigade.filter(name="dev3.group_2") + d = nornir.filter(name="dev3.group_2") d.run(connections.napalm_connection, optional_args=opt) results = d.run(networking.napalm_configure, configuration=configuration) processed = False @@ -55,4 +55,4 @@ def test_napalm_configure_change_error(self, brigade): processed = True assert isinstance(result.exception, exceptions.MergeConfigException) assert processed - brigade.data.reset_failed_hosts() + nornir.data.reset_failed_hosts() diff --git a/tests/plugins/tasks/networking/test_napalm_get.py b/tests/plugins/tasks/networking/test_napalm_get.py index e8dea302..9712a731 100644 --- a/tests/plugins/tasks/networking/test_napalm_get.py +++ b/tests/plugins/tasks/networking/test_napalm_get.py @@ -1,6 +1,6 @@ import os -from brigade.plugins.tasks import connections, networking +from nornir.plugins.tasks import connections, networking THIS_DIR = os.path.dirname(os.path.realpath(__file__)) + "/mocked/napalm_get" @@ -8,9 +8,9 @@ class Test(object): - def test_napalm_getters(self, brigade): + def test_napalm_getters(self, nornir): opt = {"path": THIS_DIR + "/test_napalm_getters"} - d = brigade.filter(name="dev3.group_2") + d = nornir.filter(name="dev3.group_2") d.run(connections.napalm_connection, optional_args=opt) result = d.run(networking.napalm_get, getters=["facts", "interfaces"]) assert result @@ -18,9 +18,9 @@ def test_napalm_getters(self, brigade): assert r.result["facts"] assert r.result["interfaces"] - def test_napalm_getters_error(self, brigade): + def test_napalm_getters_error(self, nornir): opt = {"path": THIS_DIR + "/test_napalm_getters_error"} - d = brigade.filter(name="dev3.group_2") + d = nornir.filter(name="dev3.group_2") d.run(connections.napalm_connection, optional_args=opt) results = d.run(networking.napalm_get, getters=["facts", "interfaces"]) @@ -29,4 +29,4 @@ def test_napalm_getters_error(self, brigade): processed = True assert isinstance(result.exception, KeyError) assert processed - brigade.data.reset_failed_hosts() + nornir.data.reset_failed_hosts() diff --git a/tests/plugins/tasks/networking/test_napalm_validate.py b/tests/plugins/tasks/networking/test_napalm_validate.py index e85953a3..213d18a3 100644 --- a/tests/plugins/tasks/networking/test_napalm_validate.py +++ b/tests/plugins/tasks/networking/test_napalm_validate.py @@ -1,6 +1,6 @@ import os -from brigade.plugins.tasks import connections, networking +from nornir.plugins.tasks import connections, networking THIS_DIR = os.path.dirname(os.path.realpath(__file__)) @@ -8,9 +8,9 @@ class Test(object): - def test_napalm_validate_src_ok(self, brigade): + def test_napalm_validate_src_ok(self, nornir): opt = {"path": THIS_DIR + "/mocked/napalm_get/test_napalm_getters"} - d = brigade.filter(name="dev3.group_2") + d = nornir.filter(name="dev3.group_2") d.run(connections.napalm_connection, optional_args=opt) result = d.run( networking.napalm_validate, src=THIS_DIR + "/data/validate_ok.yaml" @@ -19,9 +19,9 @@ def test_napalm_validate_src_ok(self, brigade): for h, r in result.items(): assert not r.failed - def test_napalm_validate_src_error(self, brigade): + def test_napalm_validate_src_error(self, nornir): opt = {"path": THIS_DIR + "/mocked/napalm_get/test_napalm_getters"} - d = brigade.filter(name="dev3.group_2") + d = nornir.filter(name="dev3.group_2") d.run(connections.napalm_connection, optional_args=opt) result = d.run( @@ -32,9 +32,9 @@ def test_napalm_validate_src_error(self, brigade): assert not r.failed assert not r.result["complies"] - def test_napalm_validate_src_validate_source(self, brigade): + def test_napalm_validate_src_validate_source(self, nornir): opt = {"path": THIS_DIR + "/mocked/napalm_get/test_napalm_getters"} - d = brigade.filter(name="dev3.group_2") + d = nornir.filter(name="dev3.group_2") d.run(connections.napalm_connection, optional_args=opt) validation_dict = [{"get_interfaces": {"Ethernet1": {"description": ""}}}] diff --git a/tests/plugins/tasks/networking/test_netmiko_file_transfer.py b/tests/plugins/tasks/networking/test_netmiko_file_transfer.py index ef67c407..f70c3014 100644 --- a/tests/plugins/tasks/networking/test_netmiko_file_transfer.py +++ b/tests/plugins/tasks/networking/test_netmiko_file_transfer.py @@ -1,16 +1,16 @@ import os -from brigade.plugins.tasks import networking +from nornir.plugins.tasks import networking THIS_DIR = os.path.dirname(os.path.realpath(__file__)) class Test(object): - def test_netmiko_file_transfer(self, brigade): + def test_netmiko_file_transfer(self, nornir): source_file = os.path.join(THIS_DIR, "data", "test_file.txt") dest_file = "test_file.txt" - result = brigade.filter(name="dev4.group_2").run( + result = nornir.filter(name="dev4.group_2").run( networking.netmiko_file_transfer, source_file=source_file, dest_file=dest_file, diff --git a/tests/plugins/tasks/networking/test_netmiko_send_command.py b/tests/plugins/tasks/networking/test_netmiko_send_command.py index 8c0021ae..254d73d6 100644 --- a/tests/plugins/tasks/networking/test_netmiko_send_command.py +++ b/tests/plugins/tasks/networking/test_netmiko_send_command.py @@ -1,26 +1,26 @@ -from brigade.plugins.tasks import connections, networking +from nornir.plugins.tasks import connections, networking class Test(object): - def test_explicit_netmiko_connection(self, brigade): - brigade.filter(name="dev4.group_2").run(task=connections.netmiko_connection) - result = brigade.filter(name="dev4.group_2").run( + def test_explicit_netmiko_connection(self, nornir): + nornir.filter(name="dev4.group_2").run(task=connections.netmiko_connection) + result = nornir.filter(name="dev4.group_2").run( networking.netmiko_send_command, command_string="hostname" ) assert result for h, r in result.items(): assert h == r.result.strip() - def test_netmiko_send_command(self, brigade): - result = brigade.filter(name="dev4.group_2").run( + def test_netmiko_send_command(self, nornir): + result = nornir.filter(name="dev4.group_2").run( networking.netmiko_send_command, command_string="hostname" ) assert result for h, r in result.items(): assert h == r.result.strip() - result = brigade.filter(name="dev4.group_2").run( + result = nornir.filter(name="dev4.group_2").run( networking.netmiko_send_command, command_string="hostname", use_timing=True ) assert result diff --git a/tests/plugins/tasks/networking/test_netmiko_send_config.py b/tests/plugins/tasks/networking/test_netmiko_send_config.py index 42be8e53..edbf4bcc 100644 --- a/tests/plugins/tasks/networking/test_netmiko_send_config.py +++ b/tests/plugins/tasks/networking/test_netmiko_send_config.py @@ -1,19 +1,19 @@ -from brigade.plugins.tasks import connections, networking +from nornir.plugins.tasks import connections, networking class Test(object): - def test_explicit_netmiko_connection(self, brigade): - brigade.filter(name="dev4.group_2").run(task=connections.netmiko_connection) - result = brigade.filter(name="dev4.group_2").run( + def test_explicit_netmiko_connection(self, nornir): + nornir.filter(name="dev4.group_2").run(task=connections.netmiko_connection) + result = nornir.filter(name="dev4.group_2").run( networking.netmiko_send_config, config_commands="hostname" ) assert result for h, r in result.items(): assert h in r.result.strip() - def test_netmiko_send_command(self, brigade): - result = brigade.filter(name="dev4.group_2").run( + def test_netmiko_send_command(self, nornir): + result = nornir.filter(name="dev4.group_2").run( networking.netmiko_send_config, config_commands="hostname" ) assert result diff --git a/tests/plugins/tasks/networking/test_tcp_ping.py b/tests/plugins/tasks/networking/test_tcp_ping.py index 26e9ea42..920e2296 100644 --- a/tests/plugins/tasks/networking/test_tcp_ping.py +++ b/tests/plugins/tasks/networking/test_tcp_ping.py @@ -1,9 +1,9 @@ import os -from brigade.core import Brigade -from brigade.plugins.inventory.simple import SimpleInventory -from brigade.plugins.tasks import networking +from nornir.core import Nornir +from nornir.plugins.inventory.simple import SimpleInventory +from nornir.plugins.tasks import networking cur_dir = os.path.dirname(os.path.realpath(__file__)) @@ -12,16 +12,16 @@ class Test(object): - def test_tcp_ping_port(self, brigade): - filter = brigade.filter(name="dev4.group_2") + def test_tcp_ping_port(self, nornir): + filter = nornir.filter(name="dev4.group_2") result = filter.run(networking.tcp_ping, ports=65004) assert result for h, r in result.items(): assert r.result[65004] - def test_tcp_ping_ports(self, brigade): - filter = brigade.filter(name="dev4.group_2") + def test_tcp_ping_ports(self, nornir): + filter = nornir.filter(name="dev4.group_2") result = filter.run(networking.tcp_ping, ports=[35004, 65004]) assert result @@ -29,27 +29,27 @@ def test_tcp_ping_ports(self, brigade): assert r.result[35004] is False assert r.result[65004] - def test_tcp_ping_invalid_port(self, brigade): - results = brigade.run(networking.tcp_ping, ports="web") + def test_tcp_ping_invalid_port(self, nornir): + results = nornir.run(networking.tcp_ping, ports="web") processed = False for result in results.values(): processed = True assert isinstance(result.exception, ValueError) assert processed - brigade.data.reset_failed_hosts() + nornir.data.reset_failed_hosts() - def test_tcp_ping_invalid_ports(self, brigade): - results = brigade.run(networking.tcp_ping, ports=[22, "web", 443]) + def test_tcp_ping_invalid_ports(self, nornir): + results = nornir.run(networking.tcp_ping, ports=[22, "web", 443]) processed = False for result in results.values(): processed = True assert isinstance(result.exception, ValueError) assert processed - brigade.data.reset_failed_hosts() + nornir.data.reset_failed_hosts() def test_tcp_ping_external_hosts(): - external = Brigade(inventory=SimpleInventory(ext_inv_file, ""), dry_run=True) + external = Nornir(inventory=SimpleInventory(ext_inv_file, ""), dry_run=True) result = external.run(networking.tcp_ping, ports=[23, 443]) assert result diff --git a/tests/plugins/tasks/text/test_data/broken.j2 b/tests/plugins/tasks/text/test_data/broken.j2 index 0f4344c7..dd0cdb2e 100644 --- a/tests/plugins/tasks/text/test_data/broken.j2 +++ b/tests/plugins/tasks/text/test_data/broken.j2 @@ -2,4 +2,4 @@ host-name {{ host -my_var: {{ my_var}} \ No newline at end of file +my_var: {{ my_var}} diff --git a/tests/plugins/tasks/text/test_data/simple.j2 b/tests/plugins/tasks/text/test_data/simple.j2 index b1e1a580..1ce1ad87 100644 --- a/tests/plugins/tasks/text/test_data/simple.j2 +++ b/tests/plugins/tasks/text/test_data/simple.j2 @@ -1,4 +1,4 @@ host-name {{ host }} -my_var: {{ my_var}} \ No newline at end of file +my_var: {{ my_var}} diff --git a/tests/plugins/tasks/text/test_template_file.py b/tests/plugins/tasks/text/test_template_file.py index 83384ddf..6f1c7efc 100644 --- a/tests/plugins/tasks/text/test_template_file.py +++ b/tests/plugins/tasks/text/test_template_file.py @@ -1,7 +1,7 @@ import os -from brigade.plugins.tasks import text +from nornir.plugins.tasks import text from jinja2 import TemplateSyntaxError @@ -11,8 +11,8 @@ class Test(object): - def test_template_file(self, brigade): - result = brigade.run(text.template_file, template="simple.j2", path=data_dir) + def test_template_file(self, nornir): + result = nornir.run(text.template_file, template="simple.j2", path=data_dir) assert result for h, r in result.items(): @@ -22,11 +22,11 @@ def test_template_file(self, brigade): if h == "host4.group_2": assert "my_var: comes_from_host4.group_2" in r.result - def test_template_file_error_broken_file(self, brigade): - results = brigade.run(text.template_file, template="broken.j2", path=data_dir) + def test_template_file_error_broken_file(self, nornir): + results = nornir.run(text.template_file, template="broken.j2", path=data_dir) processed = False for result in results.values(): processed = True assert isinstance(result.exception, TemplateSyntaxError) assert processed - brigade.data.reset_failed_hosts() + nornir.data.reset_failed_hosts() diff --git a/tests/plugins/tasks/text/test_template_string.py b/tests/plugins/tasks/text/test_template_string.py index 9716d7ef..c02dbd28 100644 --- a/tests/plugins/tasks/text/test_template_string.py +++ b/tests/plugins/tasks/text/test_template_string.py @@ -1,6 +1,6 @@ import os -from brigade.plugins.tasks import text +from nornir.plugins.tasks import text from jinja2 import TemplateSyntaxError @@ -26,9 +26,9 @@ class Test(object): - def test_template_string(self, brigade): + def test_template_string(self, nornir): - result = brigade.run(text.template_string, template=simple_j2) + result = nornir.run(text.template_string, template=simple_j2) assert result for h, r in result.items(): @@ -38,11 +38,11 @@ def test_template_string(self, brigade): if h == "host2.group_1": assert "my_var: comes_from_group_1" in r.result - def test_template_string_error_broken_string(self, brigade): - results = brigade.run(text.template_string, template=broken_j2) + def test_template_string_error_broken_string(self, nornir): + results = nornir.run(text.template_string, template=broken_j2) processed = False for result in results.values(): processed = True assert isinstance(result.exception, TemplateSyntaxError) assert processed - brigade.data.reset_failed_hosts() + nornir.data.reset_failed_hosts()