Skip to content

Commit

Permalink
Add ability to template device name
Browse files Browse the repository at this point in the history
  • Loading branch information
MinDBreaK committed Nov 4, 2024
1 parent 0e4a6b8 commit 5d6389d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion plugins/inventory/nb_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -1775,8 +1775,12 @@ def extract_name(self, host):
# Use virtual chassis name if set by the user.
if self.virtual_chassis_name and self._get_host_virtual_chassis_master(host):
return host["virtual_chassis"]["name"] or str(uuid.uuid4())
elif self.hostname_field:
elif self.hostname_field and self.hostname_field in host["custom_fields"]:
return host["custom_fields"][self.hostname_field]
elif self.hostname_field and (
self.hostname_field in host or "." in self.hostname_field
):
return self._compose(self.hostname_field, host) or str(uuid.uuid4())
else:
return host["name"] or str(uuid.uuid4())

Expand Down

0 comments on commit 5d6389d

Please sign in to comment.