Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Andrey Yemelyanov
noc
Commits
7b93a5aa
Verified
Commit
7b93a5aa
authored
Sep 18, 2018
by
Dmitry Volodin
Browse files
Fix DiscoveryID flaps when disabling interface discovery
parent
6c95ac26
Changes
1
Hide whitespace changes
Inline
Side-by-side
services/discovery/jobs/box/id.py
View file @
7b93a5aa
...
...
@@ -2,13 +2,14 @@
# ---------------------------------------------------------------------
# ID check
# ---------------------------------------------------------------------
# Copyright (C) 2007-201
5
The NOC Project
# Copyright (C) 2007-201
8
The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# NOC modules
from
noc.services.discovery.jobs.base
import
DiscoveryCheck
from
noc.inv.models.discoveryid
import
DiscoveryID
from
noc.inv.models.interface
import
Interface
class
IDCheck
(
DiscoveryCheck
):
...
...
@@ -27,7 +28,7 @@ class IDCheck(DiscoveryCheck):
"%s - %s"
%
(
m
[
"first_chassis_mac"
],
m
[
"last_chassis_mac"
])
for
m
in
cm
if
"first_chassis_mac"
in
m
and
"last_chassis_mac"
in
m
)
interface_macs
=
self
.
get_a
rtefact
(
"interface
_macs
"
)
interface_macs
=
self
.
get_a
dditional
_macs
(
)
self
.
logger
.
info
(
"Identity found: "
"Chassis MACs = %s, hostname = %s, router-id = %s, "
...
...
@@ -44,3 +45,39 @@ class IDCheck(DiscoveryCheck):
router_id
=
result
.
get
(
"router_id"
),
additional_macs
=
interface_macs
)
def
get_additional_macs
(
self
):
"""
Returns list of additional macs
:return:
"""
if
self
.
object
.
object_profile
.
enable_box_discovery_interface
:
return
self
.
get_macs_from_artefact
()
return
self
.
get_macs_from_interfaces
()
def
get_macs_from_artefact
(
self
):
"""
Return MACs from interface discovery artefact
:return:
"""
return
self
.
get_artefact
(
"interface_macs"
)
def
get_macs_from_interfaces
(
self
):
"""
Return MACs from collected interfaces
:return:
"""
return
list
(
set
(
str
(
d
[
"mac"
])
for
d
in
Interface
.
_get_collection
().
find
({
"managed_object"
:
self
.
object
.
id
,
"mac"
:
{
"$exists"
:
True
}
},
{
"_id"
:
0
,
"mac"
:
1
})
if
d
[
"mac"
]
)
)
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