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

AttributeError in running Generate FW Config via Capirca job #210

Open
glennmatthews opened this issue Jan 11, 2024 · 0 comments
Open

AttributeError in running Generate FW Config via Capirca job #210

glennmatthews opened this issue Jan 11, 2024 · 0 comments

Comments

@glennmatthews
Copy link
Contributor

Environment

  • Python version: 3.11
  • Nautobot version: 2.1.1
  • nautobot-firewall-models version: 2.0.3

Expected Behavior

Job to run to completion or fail with a user-friendly explanation.

Observed Behavior

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 581, in get_or_create
    return self.get(**kwargs), False
           ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 435, in get
    raise self.model.DoesNotExist(
nautobot_firewall_models.models.capirca_policy.CapircaPolicy.DoesNotExist: CapircaPolicy matching query does not exist.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/celery/app/trace.py", line 477, in trace_task
    R = retval = fun(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/nautobot/extras/jobs.py", line 152, in __call__
    return self.run(*args, **deserialized_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/nautobot/.local/lib/python3.11/site-packages/nautobot_firewall_models/jobs.py", line 51, in run
    CapircaPolicy.objects.update_or_create(device=device_obj)
  File "/usr/local/lib/python3.11/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 608, in update_or_create
    obj, created = self.select_for_update().get_or_create(defaults, **kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 588, in get_or_create
    return self.create(**params), True
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 453, in create
    obj.save(force_insert=True, using=self.db)
  File "/opt/nautobot/.local/lib/python3.11/site-packages/nautobot_firewall_models/models/capirca_policy.py", line 54, in save
    cap_obj.get_all_capirca_cfg()
  File "/opt/nautobot/.local/lib/python3.11/site-packages/nautobot_firewall_models/utils/capirca.py", line 600, in get_all_capirca_cfg
    self.validate_policy_data()
  File "/opt/nautobot/.local/lib/python3.11/site-packages/nautobot_firewall_models/utils/capirca.py", line 356, in validate_policy_data
    "from-zone": rule["source_zone"].name,
                 ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'name'

Steps to Reproduce

  1. Create a Policy Rule with no source_zone or destination_zone value
  2. Attach the policy rule to a device
  3. Run Generate FW Config via Capirca job with the given device
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant