Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mikrotik RouterOS API support #79

Merged
merged 27 commits into from
Jun 6, 2023

Conversation

pato23arg
Copy link
Contributor

@pato23arg pato23arg commented Apr 25, 2023

Nornir Driver that provides functionality to handle Mikrotik RouterOS API interactions with v6.x and v7.x(to be tested):

  • Generate Config backups in JSON format of selected features.
  • Features selected in platforms_settings/api_schema.
  • Future Platforms that require API interactions can use the same pattern.
  • Intended Config in JSON format via Jinja templates.

Maintainers:

  • Config Compliance logic placement to be defined - this draft attempts to handle at the Nornir driver level with DeepDiff, this is an OPEN discussion.

Options:

  1. Custom JSON field on the Platform object stores the schema
  2. Config Context on the Device object
  3. ComplianceRule - to be discussed
for any job of Type(Golden Config Backup):
   execute_children_jobs_of_subtype()

☝️ @ maintainers we need Your input on the one above. We have to store a set of API endpoints (schema.py file.)

pato23arg and others added 5 commits April 24, 2023 11:40
	new file:   /dispatcher/platform_settings/__init__.py
	new file:   dispatcher/platform_settings/api_schemas.py
	modified:   /tasks/dispatcher/platform_settings/api_schemas.py
	deleted:    /tasks/dispatcher/schema.py
@jvanderaa

This comment was marked as outdated.

@pato23arg

This comment was marked as outdated.

@mzbroch

This comment was marked as outdated.

	modified:   nornir_nautobot/plugins/tasks/dispatcher/mikrotik_routeros_api.py
	deleted:    nornir_nautobot/plugins/tasks/dispatcher/platform_settings/__init__.py
	deleted:    nornir_nautobot/plugins/tasks/dispatcher/platform_settings/api_schemas.py
@pato23arg

This comment was marked as outdated.

@pato23arg pato23arg marked this pull request as ready for review May 9, 2023 10:30
@pato23arg

This comment was marked as outdated.

@jvanderaa

This comment was marked as outdated.

@jvanderaa

This comment was marked as outdated.

@pato23arg

This comment was marked as outdated.

@itdependsnetworks

This comment was marked as outdated.

	modified:   nornir_nautobot/plugins/tasks/dispatcher/mikrotik_routeros_api.py
	new file:   nornir_nautobot/plugins/tasks/dispatcher/platform_settings/__init__.py
	new file:   nornir_nautobot/plugins/tasks/dispatcher/platform_settings/configuration.py
@pato23arg

This comment was marked as outdated.

pato23arg and others added 3 commits May 15, 2023 11:49
	modified:   nornir_nautobot/plugins/tasks/dispatcher/cisco_asa.py
	modified:   nornir_nautobot/plugins/tasks/dispatcher/cisco_ios.py
	modified:   nornir_nautobot/plugins/tasks/dispatcher/cisco_ios_xr.py
	modified:   nornir_nautobot/plugins/tasks/dispatcher/cisco_nxos.py
	modified:   nornir_nautobot/plugins/tasks/dispatcher/default.py
	modified:   nornir_nautobot/plugins/tasks/dispatcher/juniper_junos.py
	modified:   nornir_nautobot/plugins/tasks/dispatcher/mikrotik_routeros_api.py
	deleted:    nornir_nautobot/plugins/tasks/dispatcher/platform_settings/__init__.py
	deleted:    nornir_nautobot/plugins/tasks/dispatcher/platform_settings/configuration.py
	modified:   nornir_nautobot/plugins/tasks/dispatcher/ruckus_fastiron.py
	modified:   pyproject.toml
    feature: refactor get_config method type
	modified:   nornir_nautobot/plugins/tasks/dispatcher/default.py
	modified:   nornir_nautobot/plugins/tasks/dispatcher/mikrotik_routeros_api.py
pato23arg added a commit to pato23arg/nornir-nautobot that referenced this pull request May 18, 2023
	modified:   nornir_nautobot/plugins/tasks/dispatcher/mikrotik_routeros.py
@pato23arg
Copy link
Contributor Author

Changes have been implemented, this is review-ready ::

Nornir Driver that provides functionality to handle Mikrotik RouterOS API interactions with v6.x and v7.x:

Generate Config backups in JSON format of selected features.
Features selected using class attributes at the driver level.
Future Platforms that require API interactions can use the same pattern.

Module-Level modifications:

 Commands to retrieve configurations are now defined as class-attributes at the driver level.
 get_config() methods converted to classmethods, in order to access local or inherited class attributes.
 Class attributes can be edited/monkey patched at runtime by users if required. -> @itdependsnetworks 

Copy link
Contributor

@jvanderaa jvanderaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not add a dependency that hasn't been updated since before I started here.

pyproject.toml Outdated
@@ -30,6 +30,7 @@ nornir-jinja2 = "^0"
nornir-netmiko = "^0"
pynautobot = "^1.0.1"
netutils = "^1"
routeros-api = "^0.17.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some concerns on why we are importing this as part of the full dependencies. There are no tags/releases since 2019 on the library and isn't needed in order to handle the calls for other platforms.

Is this something that we should look at going without or having a middle app that does this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, good point, should be optional and sanely error out if not importable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can convert it into an extra dependency, so it is installed only in environments that require it. In any other case would be ignored. Pushing that change.

@pato23arg pato23arg requested a review from jvanderaa May 25, 2023 17:38
pato23arg added a commit to pato23arg/nornir-nautobot that referenced this pull request May 26, 2023
pato23arg

This comment was marked as outdated.

@jvanderaa
Copy link
Contributor

@itdependsnetworks how are you feeling on this one?

Copy link
Contributor

@jvanderaa jvanderaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's take the functions/methods that we need from the library with attribution. I'd rather us copy the code in with attribution than to accept a library that hasn't had a release in over 3 years.

Copy link
Contributor

@jvanderaa jvanderaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's take the functions/methods that we need from the library with attribution. I'd rather us copy the code in with attribution than to accept a library that hasn't had a release in over 3 years.

@jvanderaa jvanderaa merged commit 915c964 into nautobot:develop Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants