Skip to content

Commit

Permalink
docs, clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
gsnider2195 committed Oct 31, 2024
1 parent e217856 commit b99ae09
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 8 additions & 4 deletions nautobot_golden_config/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class GenerateIntendedConfigException(APIException):


def _nornir_task_inject_graphql_data(task, graphql_data, **kwargs):
"""Inject the GraphQL data into the Nornir task host data and then run dispatcher.
"""Inject the GraphQL data into the Nornir task host data and then run nornir_nautobot.plugins.tasks.dispatcher.dispatcher subtask.
This is a small stub of the logic in nautobot_golden_config.nornir_plays.config_intended.run_template.
"""
Expand Down Expand Up @@ -264,7 +264,7 @@ def get(self, request, *args, **kwargs):
intended_config = self._render_config_nornir_serial(
device=device,
jinja_template=filesystem_path.name,
filesystem_path=filesystem_path.parent,
jinja_root_path=filesystem_path.parent,
graphql_data=context,
)
except Exception as exc:
Expand All @@ -279,7 +279,11 @@ def get(self, request, *args, **kwargs):

raise GenerateIntendedConfigException("Unable to generate the intended config for this device")

def _render_config_nornir_serial(self, device, jinja_template, filesystem_path, graphql_data):
def _render_config_nornir_serial(self, device, jinja_template, jinja_root_path, graphql_data):
"""Render the Jinja template for the device using Nornir serial runner.
This is a small stub of the logic in nornir_plays.config_intended.config_intended.
"""
jinja_env = get_django_env()
with InitNornir(
runner={"plugin": "serial"},
Expand All @@ -303,7 +307,7 @@ def _render_config_nornir_serial(self, device, jinja_template, filesystem_path,
dispatcher.__module__
), # The nornir tasks are built for logging to a JobResult, pass a standard logger here
jinja_template=jinja_template,
jinja_root_path=filesystem_path,
jinja_root_path=jinja_root_path,
output_file_location="/dev/null", # The nornir task outputs the templated config to a file, but this API doesn't need it
jinja_filters=jinja_env.filters,
jinja_env=jinja_env,
Expand Down
3 changes: 0 additions & 3 deletions nautobot_golden_config/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from django.urls import reverse
from nautobot.core.testing import APITestCase, APIViewTestCases
from nautobot.dcim.models import Device, Platform
from nautobot.extras.management import populate_role_choices, populate_status_choices
from nautobot.extras.models import DynamicGroup, GitRepository, GraphQLQuery, Status
from rest_framework import status

Expand Down Expand Up @@ -416,8 +415,6 @@ class GenerateIntendedConfigViewAPITestCase(APITestCase):

@classmethod
def setUpTestData(cls):
populate_role_choices()
populate_status_choices()
# Delete the automatically created GoldenConfigSetting object
GoldenConfigSetting.objects.all().delete()
create_device_data()
Expand Down

0 comments on commit b99ae09

Please sign in to comment.