Skip to content

Commit

Permalink
fix: πŸ› Add check that Area parent is defined before trying to assign.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdrew82 committed Oct 30, 2024
1 parent 09cdefc commit 759ca39
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions nautobot_ssot/integrations/dna_center/diffsync/models/nautobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,16 @@ def create(cls, adapter, ids, attrs):
location_type=adapter.job.area_loctype,
status_id=adapter.status_map["Active"],
)
try:
parents_parent = "Global"
if ids["parent"] == "Global":
parents_parent = None
new_area.parent_id = adapter.region_map[parents_parent][ids["parent"]]
except KeyError:
adapter.job.logger.warning(
f"Unable to find {adapter.job.area_loctype.name} {ids['parent']} for {ids['name']}."
)
if ids.get("parent"):
try:
parents_parent = "Global"
if ids["parent"] == "Global":
parents_parent = None
new_area.parent_id = adapter.region_map[parents_parent][ids["parent"]]
except KeyError:
adapter.job.logger.warning(
f"Unable to find {adapter.job.area_loctype.name} {ids['parent']} for {ids['name']}."
)
new_area.validated_save()
if ids["parent"] not in adapter.region_map:
adapter.region_map[ids["parent"]] = {}
Expand Down

0 comments on commit 759ca39

Please sign in to comment.