Skip to content

# Package

## `nautobot_plugin_nornir`

App declaration for nautobot_plugin_nornir.

### `NautobotPluginNornirConfig`

Bases: `NautobotAppConfig`

App configuration for the nautobot_plugin_nornir app.

Source code in `nautobot_plugin_nornir/__init__.py`

    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    class NautobotPluginNornirConfig(NautobotAppConfig):
        """App configuration for the nautobot_plugin_nornir app."""

        name = "nautobot_plugin_nornir"
        verbose_name = "Nautobot Plugin for Nornir"
        version = __version__
        author = "Network to Code, LLC"
        description = (
            "Nautobot App that provides a shim layer to simplify using Nornir within other Nautobot Apps and Nautobot Jobs."
        )
        base_url = "plugin-nornir"
        required_settings = []
        default_settings = {}
        docs_view_name = "plugins:nautobot_plugin_nornir:docs"
        searchable_models = []

        def ready(self):
            """Check for accidental legacy configurations."""
            from django.conf import settings  # pylint: disable=import-outside-toplevel

            plugin_settings = settings.PLUGINS_CONFIG["nautobot_plugin_nornir"]

            dispatcher_mapping_message = (
                "The `dispatcher_mapping` key is no longer functional, failing early "
                "to ensure your application works as expected, please see: "
                "https://docs.nautobot.com/projects/plugin-nornir/en/latest/admin/migrating_to_v2/#dispatcher-settings for more details."
            )
            verify_setting(plugin_settings, "dispatcher_mapping", dispatcher_mapping_message)
            custom_dispatcher_message = (
                "The `custom_dispatcher` key is only meant for `golden_config_plugin` settings "
                "and not `nautobot_plugin_nornir` settings, please see: "
                "https://docs.nautobot.com/projects/plugin-nornir/en/latest/admin/migrating_to_v2/#dispatcher-settings for more details."
            )
            verify_setting(plugin_settings, "custom_dispatcher", custom_dispatcher_message)
            verify_setting(
                plugin_settings, "credentials", "The `credentials` key should be within the `nornir_settings` dictionary"
            )
            verify_setting(
                plugin_settings, "runners", "The `runners` key should be within the `nornir_settings` dictionary"
            )
            verify_setting(
                plugin_settings,
                "nornir_settings.connection_options",
                "The `connection_options` key should NOT be within the `nornir_settings` dictionary",
            )
            verify_setting(
                plugin_settings,
                "nornir_settings.use_config_context",
                "The `use_config_context` key should NOT be within the `nornir_settings` dictionary",
            )
            # TODO: Commenting the below out, which I believe are correct but want to verify first
            # verify_setting(plugin_settings, "nornir_settings.username", "The `username` key should NOT be within the `nornir_settings` dictionary")
            # verify_setting(plugin_settings, "nornir_settings.password", "The `password` key should NOT be within the `nornir_settings` dictionary")
            # verify_setting(plugin_settings, "nornir_settings.secret", "The `secret` key should NOT be within the `nornir_settings` dictionary")
            # verify_setting(plugin_settings, "nornir_settings.connection_secret_path", "The `connection_secret_path` key should NOT be within the `nornir_settings` dictionary")
            # verify_setting(plugin_settings, "nornir_settings.secret_access_type", "The `secret_access_type` key should NOT be within the `nornir_settings` dictionary")
            super().ready()

#### `ready()`

Check for accidental legacy configurations.

Source code in `nautobot_plugin_nornir/__init__.py`

    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    def ready(self):
        """Check for accidental legacy configurations."""
        from django.conf import settings  # pylint: disable=import-outside-toplevel

        plugin_settings = settings.PLUGINS_CONFIG["nautobot_plugin_nornir"]

        dispatcher_mapping_message = (
            "The `dispatcher_mapping` key is no longer functional, failing early "
            "to ensure your application works as expected, please see: "
            "https://docs.nautobot.com/projects/plugin-nornir/en/latest/admin/migrating_to_v2/#dispatcher-settings for more details."
        )
        verify_setting(plugin_settings, "dispatcher_mapping", dispatcher_mapping_message)
        custom_dispatcher_message = (
            "The `custom_dispatcher` key is only meant for `golden_config_plugin` settings "
            "and not `nautobot_plugin_nornir` settings, please see: "
            "https://docs.nautobot.com/projects/plugin-nornir/en/latest/admin/migrating_to_v2/#dispatcher-settings for more details."
        )
        verify_setting(plugin_settings, "custom_dispatcher", custom_dispatcher_message)
        verify_setting(
            plugin_settings, "credentials", "The `credentials` key should be within the `nornir_settings` dictionary"
        )
        verify_setting(
            plugin_settings, "runners", "The `runners` key should be within the `nornir_settings` dictionary"
        )
        verify_setting(
            plugin_settings,
            "nornir_settings.connection_options",
            "The `connection_options` key should NOT be within the `nornir_settings` dictionary",
        )
        verify_setting(
            plugin_settings,
            "nornir_settings.use_config_context",
            "The `use_config_context` key should NOT be within the `nornir_settings` dictionary",
        )
        # TODO: Commenting the below out, which I believe are correct but want to verify first
        # verify_setting(plugin_settings, "nornir_settings.username", "The `username` key should NOT be within the `nornir_settings` dictionary")
        # verify_setting(plugin_settings, "nornir_settings.password", "The `password` key should NOT be within the `nornir_settings` dictionary")
        # verify_setting(plugin_settings, "nornir_settings.secret", "The `secret` key should NOT be within the `nornir_settings` dictionary")
        # verify_setting(plugin_settings, "nornir_settings.connection_secret_path", "The `connection_secret_path` key should NOT be within the `nornir_settings` dictionary")
        # verify_setting(plugin_settings, "nornir_settings.secret_access_type", "The `secret_access_type` key should NOT be within the `nornir_settings` dictionary")
        super().ready()