Skip to content

Commit

Permalink
Merge pull request nautobot#239 from nrnvgh/237/cable_creation_hanging
Browse files Browse the repository at this point in the history
nautobot#237: when searching for cables, use pynautobot's filter() API to lim…
  • Loading branch information
joewesch authored Sep 6, 2023
2 parents 691f4c9 + 4328109 commit 07c0775
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions plugins/module_utils/dcim.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,12 @@ def run(self):
data["color"] = data["color"].lower()

if self.endpoint == "cables":
cables = [
cable
for cable in nb_endpoint.all()
if cable.termination_a_type == data["termination_a_type"]
and cable.termination_a_id == data["termination_a_id"]
and cable.termination_b_type == data["termination_b_type"]
and cable.termination_b_id == data["termination_b_id"]
]
cables = nb_endpoint.filter(
termination_a_type=data["termination_a_type"],
termination_a_id=data["termination_a_id"],
termination_b_type=data["termination_b_type"],
termination_b_id=data["termination_b_id"],
)
if len(cables) == 0:
self.nb_object = None
elif len(cables) == 1:
Expand Down

0 comments on commit 07c0775

Please sign in to comment.