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
1124c473
Verified
Commit
1124c473
authored
Sep 25, 2021
by
Andrey Vertiprahov
Browse files
Juniper.JUNOS. Fix get_interface_type for ConfDB use.
parent
61f8f933
Pipeline
#33588
passed with stages
in 15 minutes and 54 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
sa/profiles/Juniper/JUNOS/confdb/applicator.py
0 → 100644
View file @
1124c473
# ----------------------------------------------------------------------
# IfaceTypeJunosApplicator
# ----------------------------------------------------------------------
# Copyright (C) 2007-2021 The NOC Project
# See LICENSE for details
# ----------------------------------------------------------------------
# NOC modules
from
noc.core.confdb.applicator.query
import
QueryApplicator
class
IfaceTypeJunosApplicator
(
QueryApplicator
):
"""
Set missed interface types from matchers
"""
QUERY
=
[
"("
"Match('meta', 'matchers', 'is_work_em') "
"and Match('interfaces', X) and Re('^em.+', X)) or "
"(Match('meta', 'matchers', 'is_srx_6xx') "
"and Match('interfaces', X) and Re('^reth.+', X)) "
"and Fact('interfaces', X, 'type', 'physical')"
]
sa/profiles/Juniper/JUNOS/get_interfaces.py
View file @
1124c473
...
...
@@ -73,6 +73,13 @@ class Script(BaseScript):
return
False
return
True
def
clean_iftype
(
self
,
ifname
:
str
,
ifindex
=
None
)
->
str
:
if
self
.
is_srx_6xx
and
ifname
.
startswith
(
"reth"
):
return
"physical"
elif
self
.
is_work_em
and
ifname
.
startswith
(
"em"
):
return
"physical"
return
self
.
profile
.
get_interface_type
(
ifname
)
def
execute_cli
(
self
):
untagged
=
{}
tagged
=
{}
...
...
@@ -99,28 +106,7 @@ class Script(BaseScript):
if
not
self
.
filter_interface
(
0
,
name
,
True
):
continue
# Detect interface type
if
name
.
startswith
(
"lo"
):
iftype
=
"loopback"
elif
name
.
startswith
((
"fxp"
,
"me"
)):
iftype
=
"management"
elif
name
.
startswith
((
"ae"
,
"reth"
,
"fab"
,
"swfab"
)):
iftype
=
"aggregated"
elif
name
.
startswith
((
"vlan"
,
"vme"
)):
iftype
=
"SVI"
elif
name
.
startswith
(
"irb"
):
iftype
=
"SVI"
elif
name
.
startswith
((
"fc"
,
"fe"
,
"ge"
,
"xe"
,
"sxe"
,
"xle"
,
"et"
,
"fte"
)):
iftype
=
"physical"
elif
name
.
startswith
((
"gr"
,
"ip"
,
"st"
)):
iftype
=
"tunnel"
elif
name
.
startswith
(
"em"
):
if
self
.
is_work_em
:
iftype
=
"physical"
else
:
iftype
=
"management"
else
:
iftype
=
"unknown"
iftype
=
self
.
clean_iftype
(
name
)
# Get interface parameters
iface
=
{
"name"
:
name
,
...
...
sa/profiles/Juniper/JUNOS/profile.py
View file @
1124c473
...
...
@@ -42,6 +42,7 @@ class Profile(BaseProfile):
(
"hints"
,
"protocols"
,
"ntp"
,
"mode"
,
"server"
),
(
"hints"
,
"protocols"
,
"ntp"
,
"version"
,
"3"
),
]
config_applicators
=
[
"IfaceTypeJunosApplicator"
]
collators
=
[
"noc.core.confdb.collator.ifpath.IfPathCollator"
]
...
...
@@ -51,6 +52,7 @@ class Profile(BaseProfile):
"is_olive"
:
{
"platform"
:
{
"$regex"
:
"olive"
}},
"is_work_em"
:
{
"platform"
:
{
"$regex"
:
"vrr|csrx"
}},
"is_gte_16"
:
{
"version"
:
{
"$gte"
:
"16"
}},
"is_srx_6xx"
:
{
"platform"
:
{
"$regex"
:
r
"srx6.\d+"
}},
}
rx_ver
=
re
.
compile
(
r
"\d+"
)
...
...
@@ -181,9 +183,6 @@ class Profile(BaseProfile):
elif
name
.
startswith
((
"gr"
,
"ip"
,
"st"
)):
return
"tunnel"
elif
name
.
startswith
(
"em"
):
if
cls
.
is_work_em
:
return
"physical"
else
:
return
"management"
return
"management"
else
:
return
"unknown"
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