Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
noc
noc
Commits
5980caba
Commit
5980caba
authored
Jun 25, 2022
by
Andrey Vertiprahov
Browse files
Merge branch 'cherry-pick-
640cc7a1
' into 'release-22.1'
release-22.1:Backport!5084 See merge request
!6407
parents
eaf89850
ccabcc3c
Changes
2
Hide whitespace changes
Inline
Side-by-side
inv/models/discoveryid.py
View file @
5980caba
...
...
@@ -49,11 +49,12 @@ class DiscoveryID(Document):
"collection"
:
"noc.inv.discovery_id"
,
"strict"
:
False
,
"auto_create_index"
:
False
,
"indexes"
:
[
"object"
,
"hostname"
,
"udld_id"
,
"macs"
],
"indexes"
:
[
"object"
,
"hostname"
,
"hostname_id"
,
"udld_id"
,
"macs"
],
}
object
=
ForeignKeyField
(
ManagedObject
)
chassis_mac
=
ListField
(
EmbeddedDocumentField
(
MACRange
))
hostname
=
StringField
()
hostname_id
=
StringField
()
router_id
=
StringField
()
udld_id
=
StringField
()
# UDLD local identifier
#
...
...
@@ -115,6 +116,7 @@ class DiscoveryID(Document):
old_macs
=
set
(
m
.
first_mac
for
m
in
o
.
chassis_mac
)
o
.
chassis_mac
=
ranges
o
.
hostname
=
hostname
o
.
hostname_id
=
hostname
.
lower
()
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
,
hostname_id
=
hostname
.
lower
(),
router_id
=
router_id
,
macs
=
macs
,
).
save
()
@
classmethod
...
...
services/discovery/jobs/base.py
View file @
5980caba
...
...
@@ -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
=
hostname
)[:
2
]
hosts
=
DiscoveryID
.
objects
.
filter
(
hostname
_id
=
hostname
)[:
2
]
n
=
None
if
len
(
hosts
)
==
1
:
n
=
hosts
[
0
].
object
...
...
@@ -1011,7 +1012,7 @@ class TopologyDiscoveryCheck(DiscoveryCheck):
# Try to resolve anyway
m
=
list
(
DiscoveryID
.
objects
.
filter
(
hostname__istartswith
=
hostname
+
"."
if
"."
not
in
hostname
else
hostname
hostname_
id_
_istartswith
=
hostname
+
"."
if
"."
not
in
hostname
else
hostname
)
)
if
len
(
m
)
==
1
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment