From 2156baccde7cfd3ff367d7cc506c448dc0ee49af Mon Sep 17 00:00:00 2001 From: Josef Fuchs Date: Wed, 10 Jul 2024 05:49:23 +0200 Subject: [PATCH 1/3] Add Check Point Gaia netmiko backup --- .../tasks/dispatcher/checkpoint_gaia.py | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 nornir_nautobot/plugins/tasks/dispatcher/checkpoint_gaia.py diff --git a/nornir_nautobot/plugins/tasks/dispatcher/checkpoint_gaia.py b/nornir_nautobot/plugins/tasks/dispatcher/checkpoint_gaia.py new file mode 100644 index 0000000..4ba77a7 --- /dev/null +++ b/nornir_nautobot/plugins/tasks/dispatcher/checkpoint_gaia.py @@ -0,0 +1,50 @@ +"""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: } + """ + 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 From 8cce151ff7f28ce5f61e8a64e7f5f006ea8b1936 Mon Sep 17 00:00:00 2001 From: Josef Fuchs Date: Thu, 11 Jul 2024 06:44:49 +0200 Subject: [PATCH 2/3] Enable backup for Checkpoint Gaia via netmiko --- docs/task/task.md | 28 +++++++++++++++++++ .../tasks/dispatcher/checkpoint_gaia.py | 1 + pyproject.toml | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/docs/task/task.md b/docs/task/task.md index 71cb9af..374a557 100644 --- a/docs/task/task.md +++ b/docs/task/task.md @@ -110,3 +110,31 @@ class DispatcherMixin: | ----- | ----------- | | NORNIR_NAUTOBOT_REVERT_IN_SECONDS | Amount in seconds to revert if a config based method fails. | | NORNIR_NAUTOBOT_NETMIKO_ENABLE_DEFAULT | Override the default(True) to not automatically call the `enable` function before running commands. | + + +## Dispatcher Configuration for Nautobot Golden Config + +here are the steps needed to configure dispatchers for Nautobot Golden Config. + +### checkpoint_gaia + +This section describes the **checkpoint_gaia** dispatcher that provides backup functionality for Check Point firewalls. + +To configure the dispatcher for Nautobot Golden Config, follow these steps: + +1. Go to **Nautobot / Admin / Configuration**. +2. In the **Golden Configuration** section, set the default framework to `"checkpoint_gaia": "netmiko"`. + + Here is an example of the configuration in JSON format: + + ```json + { + "all": "napalm", + "checkpoint_gaia": "netmiko" + } + ``` + +3. Add the Platform **checkpoint_gaia** to the **Platform** model in the Nautobot admin interface. + + - **Name**: "checkpoint_gaia" + - **Network driver**: "checkpoint_gaia" diff --git a/nornir_nautobot/plugins/tasks/dispatcher/checkpoint_gaia.py b/nornir_nautobot/plugins/tasks/dispatcher/checkpoint_gaia.py index 4ba77a7..ebab033 100644 --- a/nornir_nautobot/plugins/tasks/dispatcher/checkpoint_gaia.py +++ b/nornir_nautobot/plugins/tasks/dispatcher/checkpoint_gaia.py @@ -1,4 +1,5 @@ """nornir dispatcher for checkpoint_gaia.""" + from nornir.core.task import Result, Task from nornir_nautobot.plugins.tasks.dispatcher.default import NapalmDefault, NetmikoDefault diff --git a/pyproject.toml b/pyproject.toml index b22ef37..f69d0d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] readme = "README.md" From b4c14121b5e5161ac8309f41d8853c64111e96c0 Mon Sep 17 00:00:00 2001 From: Josef Fuchs Date: Tue, 14 Jan 2025 07:39:05 +0100 Subject: [PATCH 3/3] Update docs/task/task.md Co-authored-by: Jeff Kala <48843785+jeffkala@users.noreply.github.com> --- docs/task/task.md | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/docs/task/task.md b/docs/task/task.md index 374a557..71cb9af 100644 --- a/docs/task/task.md +++ b/docs/task/task.md @@ -110,31 +110,3 @@ class DispatcherMixin: | ----- | ----------- | | NORNIR_NAUTOBOT_REVERT_IN_SECONDS | Amount in seconds to revert if a config based method fails. | | NORNIR_NAUTOBOT_NETMIKO_ENABLE_DEFAULT | Override the default(True) to not automatically call the `enable` function before running commands. | - - -## Dispatcher Configuration for Nautobot Golden Config - -here are the steps needed to configure dispatchers for Nautobot Golden Config. - -### checkpoint_gaia - -This section describes the **checkpoint_gaia** dispatcher that provides backup functionality for Check Point firewalls. - -To configure the dispatcher for Nautobot Golden Config, follow these steps: - -1. Go to **Nautobot / Admin / Configuration**. -2. In the **Golden Configuration** section, set the default framework to `"checkpoint_gaia": "netmiko"`. - - Here is an example of the configuration in JSON format: - - ```json - { - "all": "napalm", - "checkpoint_gaia": "netmiko" - } - ``` - -3. Add the Platform **checkpoint_gaia** to the **Platform** model in the Nautobot admin interface. - - - **Name**: "checkpoint_gaia" - - **Network driver**: "checkpoint_gaia"