-
Notifications
You must be signed in to change notification settings - Fork 25
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
Enable backup for Check Point Gaia via netmiko #166
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
"""nornir dispatcher for checkpoint_gaia.""" | ||
|
||
from nornir.core.task import Result, Task | ||
|
||
from nornir_nautobot.plugins.tasks.dispatcher.default import NapalmDefault, NetmikoDefault | ||
from nornir_nautobot.exceptions import NornirNautobotException | ||
|
||
NETMIKO_DEVICE_TYPE = "linux" | ||
|
||
|
||
class NapalmCheckpointGaia(NapalmDefault): | ||
"""Collection of Napalm Nornir Tasks specific to Check Point Gaia devices.""" | ||
|
||
|
||
class NetmikoCheckpointGaia(NetmikoDefault): | ||
"""Collection of Netmiko Nornir Tasks specific to Check Point Gaia devices.""" | ||
|
||
config_command = 'clish -c "show configuration"' | ||
|
||
@classmethod | ||
def get_config( # pylint: disable=R0913,R0914 | ||
cls, task: Task, logger, obj, backup_file: str, remove_lines: list, substitute_lines: list | ||
) -> Result: | ||
"""Get the latest configuration from the device. | ||
|
||
Args: | ||
task (Task): Nornir Task. | ||
logger (logging.Logger): Logger that may be a Nautobot Jobs or Python logger. | ||
obj (Device): A Nautobot Device Django ORM object instance. | ||
backup_file (str): The file location of where the back configuration should be saved. | ||
remove_lines (list): A list of regex lines to remove configurations. | ||
substitute_lines (list): A list of dictionaries with to remove and replace lines. | ||
|
||
Returns: | ||
Result: Nornir Result object with a dict as a result containing the running configuration | ||
{ "config: <running configuration> } | ||
""" | ||
try: | ||
task.host.platform = NETMIKO_DEVICE_TYPE | ||
result = super().get_config( | ||
task, | ||
logger, | ||
obj, | ||
backup_file, | ||
remove_lines, | ||
substitute_lines, | ||
) | ||
return result | ||
except Exception as exc: | ||
error_msg = f"Failed to get configuration from {task.host.name} on {task.host.platform}" | ||
raise NornirNautobotException(error_msg) from exc | ||
Comment on lines
+20
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't believe any of this is needed. The overload of the |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "nornir-nautobot" | ||
version = "3.2.0" | ||
version = "3.2.1" | ||
description = "Nornir Nautobot" | ||
authors = ["Network to Code, LLC <[email protected]>"] | ||
readme = "README.md" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory this will come directly from the nornir inventory in the platform definition. Would like to avoid hardcoding it here.