Verified Commit 6e7ce0f8 authored by Andrey Vertiprahov's avatar Andrey Vertiprahov
Browse files

Add hostname_raw.

parent a02e0772
Pipeline #35968 passed with stages
in 25 minutes and 44 seconds
......@@ -54,6 +54,7 @@ class DiscoveryID(Document):
object = ForeignKeyField(ManagedObject)
chassis_mac = ListField(EmbeddedDocumentField(MACRange))
hostname = StringField()
hostname_raw = StringField()
router_id = StringField()
udld_id = StringField() # UDLD local identifier
#
......@@ -114,7 +115,8 @@ class DiscoveryID(Document):
if o:
old_macs = set(m.first_mac for m in o.chassis_mac)
o.chassis_mac = ranges
o.hostname = hostname
o.hostname = hostname.lower()
o.hostname_raw = hostname
o.router_id = router_id
old_macs -= set(m.first_mac for m in o.chassis_mac)
if old_macs:
......@@ -124,7 +126,12 @@ class DiscoveryID(Document):
o.save()
else:
cls(
object=object, chassis_mac=ranges, hostname=hostname, router_id=router_id, macs=macs
object=object,
chassis_mac=ranges,
hostname=hostname.lower(),
hostname_raw=hostname,
router_id=router_id,
macs=macs,
).save()
@classmethod
......
......@@ -1001,8 +1001,9 @@ class TopologyDiscoveryCheck(DiscoveryCheck):
"""
Resolve neighbor by hostname
"""
hostname = hostname.lower()
if hostname not in self.neighbor_hostname_cache:
hosts = DiscoveryID.objects.filter(hostname__iexact=hostname)[:2]
hosts = DiscoveryID.objects.filter(hostname=hostname)[:2]
n = None
if len(hosts) == 1:
n = hosts[0].object
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment