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

Unable to create rack reservations #204

Open
austind opened this issue Nov 6, 2024 · 1 comment
Open

Unable to create rack reservations #204

austind opened this issue Nov 6, 2024 · 1 comment

Comments

@austind
Copy link

austind commented Nov 6, 2024

Environment

  • Python version: 3.12.7
  • Nautobot version: v2.3.11b1
  • nautobot-design-builder version: 2.1.0

Expected Behavior

This should work:

rack_reservations:
  - rack: "{{ rack }}"
    user__name: admin
    description: Power Shelf
    units:
      - 4
      - 5
      - 6

Observed Behavior

Job fails with the following trace:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/celery/app/trace.py", line 477, in trace_task
    R = retval = fun(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/celery/app/trace.py", line 760, in __protected_call__
    return self.run(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/source/nautobot/extras/jobs.py", line 1136, in run_job
    result = job(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^
  File "/source/nautobot/extras/jobs.py", line 149, in __call__
    return self.run(*args, **deserialized_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/nautobot_design_builder/design_job.py", line 250, in run
    return self._run_in_transaction(dryrun, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/contextlib.py", line 81, in inner
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/nautobot_design_builder/design_job.py", line 355, in _run_in_transaction
    raise ex
  File "/usr/local/lib/python3.12/site-packages/nautobot_design_builder/design_job.py", line 316, in _run_in_transaction
    self.implement_design(context, design_file, not dryrun)
  File "/usr/local/lib/python3.12/site-packages/nautobot_design_builder/design_job.py", line 216, in implement_design
    self.environment.implement_design(design, commit)
  File "/usr/local/lib/python3.12/site-packages/nautobot_design_builder/design.py", line 831, in implement_design
    raise ex
  File "/usr/local/lib/python3.12/site-packages/nautobot_design_builder/design.py", line 815, in implement_design
    self._create_objects(self.model_map[key], value)
  File "/usr/local/lib/python3.12/site-packages/nautobot_design_builder/design.py", line 892, in _create_objects
    model = model_class(self, model_instance)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/nautobot_design_builder/design.py", line 591, in __init__
    self._update_fields()
  File "/usr/local/lib/python3.12/site-packages/nautobot_design_builder/design.py", line 620, in _update_fields
    setattr(self, field_name, value)
  File "/usr/local/lib/python3.12/site-packages/nautobot_design_builder/fields.py", line 204, in __set__
    setter()
  File "/usr/local/lib/python3.12/site-packages/nautobot_design_builder/fields.py", line 191, in setter
    model_instance = self._get_instance(obj, value)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/nautobot_design_builder/fields.py", line 179, in _get_instance
    value = obj.design_metadata.create_child(related_model, value, relationship_manager)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/nautobot_design_builder/design.py", line 321, in create_child
    model_class = self.environment.model_class_index[model_class]
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: <class 'nautobot.users.models.User'>

Steps to Reproduce

  1. Create a Design Builder job
  2. Try to create a rack reservation
@austind
Copy link
Author

austind commented Nov 6, 2024

Issue appears to be related to this line, which excludes the users model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants