diff --git a/app/models.py b/app/models.py index 15cfce8054c5dbe58d88789bbab977220b6a756d..e91ebcd089a1deb6b4e0f2c298aa496461310bef 100644 --- a/app/models.py +++ b/app/models.py @@ -943,6 +943,17 @@ class Host(CreatedMixin, db.Model): except IndexError: return None + @property + def fqdn(self): + """Return the host fully qualified domain name + + The domain is based on the main interface + """ + if self.main_interface: + return f"{self.name}.{self.main_interface.network.domain}" + else: + return self.name + def __str__(self): return str(self.name) diff --git a/app/templates/network/view_host.html b/app/templates/network/view_host.html index 92537b65e0a3d063d14894748ee1bcdb693eb832..589e9247f72d313ac0918856dd4df43c8684a113 100644 --- a/app/templates/network/view_host.html +++ b/app/templates/network/view_host.html @@ -22,7 +22,7 @@ <div class="col-sm-9"> <dl class="row"> <dt class="col-sm-3">Hostname</dt> - <dd class="col-sm-9">{{ host.name }}</dd> + <dd class="col-sm-9">{{ host.fqdn }}</dd> <dt class="col-sm-3">Device Type</dt> <dd class="col-sm-9">{{ host.device_type }}</dd> {% if host.items %}