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
380e0771
Commit
380e0771
authored
Jun 17, 2021
by
Dmitry Lukhtionov
Committed by
bee26
Jun 17, 2021
Browse files
Update Eltex.LTE profile
parent
94d18e4e
Changes
5
Hide whitespace changes
Inline
Side-by-side
sa/profiles/Eltex/LTE/get_arp.py
View file @
380e0771
# ---------------------------------------------------------------------
# Eltex.LTE.get_arp
# ---------------------------------------------------------------------
# Copyright (C) 2007-201
7
The NOC Project
# Copyright (C) 2007-20
2
1 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
...
...
@@ -21,14 +21,25 @@ class Script(BaseScript):
rx_line
=
re
.
compile
(
r
"^\s*\d+\s+port\s+(?P<interface>\d+)\s+"
r
"(?P<mac>\S+)\s+(?P<ip>\d+\S+)"
,
re
.
MULTILINE
)
rx_line2
=
re
.
compile
(
r
"^\s*(?P<vlan>\d+)\s+(?P<ip>\d+\S+)\s+(?P<mac>\S+)\s+(?P<interface>\S+\s\d+)\s+"
,
re
.
MULTILINE
)
def
execute
(
self
):
r
=
[]
with
self
.
profile
.
switch
(
self
):
arp
=
self
.
cli
(
"show arp"
,
cached
=
True
)
for
match
in
self
.
rx_line
.
finditer
(
arp
):
if
match
.
group
(
"mac"
)
==
"00:00:00:00:00:00"
:
r
+=
[{
"ip"
:
match
.
group
(
"ip"
),
"mac"
:
None
,
"interface"
:
None
}]
else
:
r
+=
[
match
.
groupdict
()]
try
:
arp
=
self
.
cli
(
"show arp"
,
cached
=
True
)
for
match
in
self
.
rx_line
.
finditer
(
arp
):
if
match
.
group
(
"mac"
)
==
"00:00:00:00:00:00"
:
r
+=
[{
"ip"
:
match
.
group
(
"ip"
),
"mac"
:
None
,
"interface"
:
None
}]
else
:
r
+=
[
match
.
groupdict
()]
except
self
.
CLISyntaxError
:
arp
=
self
.
cli
(
"show ip arp table"
,
cached
=
True
)
for
match
in
self
.
rx_line2
.
finditer
(
arp
):
if
match
.
group
(
"mac"
)
==
"00:00:00:00:00:00"
:
r
+=
[{
"ip"
:
match
.
group
(
"ip"
),
"mac"
:
None
,
"interface"
:
None
}]
else
:
r
+=
[
match
.
groupdict
()]
return
r
sa/profiles/Eltex/LTE/get_chassis_id.py
View file @
380e0771
# ---------------------------------------------------------------------
# Eltex.LTE.get_chassis_id
# ---------------------------------------------------------------------
# Copyright (C) 2007-201
7
The NOC Project
# Copyright (C) 2007-20
2
1 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
...
...
@@ -24,12 +24,15 @@ class Script(BaseScript):
def
execute
(
self
):
macs
=
[]
with
self
.
profile
.
switch
(
self
):
cmd
=
self
.
cli
(
"show version"
)
match
=
self
.
rx_mac1
.
search
(
cmd
)
if
match
:
macs
+=
[
match
.
group
(
"mac"
)]
cmd
=
self
.
cli
(
"show interfaces mac-address"
)
macs
+=
self
.
rx_mac2
.
findall
(
cmd
)
try
:
cmd
=
self
.
cli
(
"show version"
)
match
=
self
.
rx_mac1
.
search
(
cmd
)
if
match
:
macs
+=
[
match
.
group
(
"mac"
)]
cmd
=
self
.
cli
(
"show interfaces mac-address"
)
macs
+=
self
.
rx_mac2
.
findall
(
cmd
)
except
self
.
CLISyntaxError
:
pass
if
not
macs
:
mac_table
=
self
.
scripts
.
get_mac_address_table
()
for
m
in
mac_table
:
...
...
sa/profiles/Eltex/LTE/get_interfaces.py
View file @
380e0771
# ---------------------------------------------------------------------
# Eltex.LTE.get_interfaces
# ---------------------------------------------------------------------
# Copyright (C) 2007-201
9
The NOC Project
# Copyright (C) 2007-20
2
1 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
...
...
@@ -11,6 +11,7 @@ import re
# NOC modules
from
noc.core.script.base
import
BaseScript
from
noc.sa.interfaces.igetinterfaces
import
IGetInterfaces
from
noc.core.text
import
parse_table
class
Script
(
BaseScript
):
...
...
@@ -32,59 +33,165 @@ class Script(BaseScript):
rx_ip
=
re
.
compile
(
r
"\n\nIP address:\s+(?P<ip>\d+\S+)"
)
rx_mgmt_ip
=
re
.
compile
(
r
"^Management interface: \((?P<state>\S+)\)\s*\n"
r
"^Management interface:
(
\((?P<state>\S+)\)
)?
\s*\n"
r
"^IP address:\s+(?P<ip>\d+\S+)\s*\n"
r
"(^Default gateway:.+\n)?"
r
"^VID:\s+(?P<vlan_id>\d+|none)"
,
re
.
MULTILINE
,
)
rx_mac
=
re
.
compile
(
r
"^\s+MAC address: (?P<mac>\S+)"
,
re
.
MULTILINE
)
rx_status
=
re
.
compile
(
r
"^.+\d\s+(?P<oper_status>up|down|off)"
,
re
.
MULTILINE
)
def
normalize_ifname
(
self
,
port
):
port
=
port
.
strip
()
while
port
.
find
(
" "
)
!=
-
1
:
port
=
port
.
replace
(
" "
,
" "
)
while
port
.
find
(
"- "
)
!=
-
1
:
port
=
port
.
replace
(
"- "
,
"-"
)
return
port
def
create_iface
(
self
,
i
,
iftype
):
ifname
=
" "
.
join
(
i
[
0
].
split
())
if
not
ifname
.
startswith
(
iftype
):
return
None
pvid
=
i
[
1
]
if
i
[
4
]
not
in
[
"none"
,
"N/S"
]:
tagged
=
self
.
expand_rangelist
(
i
[
4
])
else
:
tagged
=
[]
untagged
=
i
[
5
]
if
untagged
in
[
"none"
,
"N/S"
]:
untagged
=
pvid
iface
=
{
"name"
:
ifname
,
"type"
:
"physical"
,
"subinterfaces"
:
[{
"name"
:
ifname
,
"enabled_afi"
:
[
"BRIDGE"
]}],
}
if
untagged
!=
"N/S"
:
iface
[
"subinterfaces"
][
0
][
"untagged_vlan"
]
=
int
(
untagged
)
if
tagged
:
iface
[
"subinterfaces"
][
0
][
"tagged_vlans"
]
=
tagged
return
iface
def
execute
(
self
):
interfaces
=
[]
macs
=
{}
tagged_vlans
=
{}
untagged_vlans
=
{}
with
self
.
profile
.
switch
(
self
):
cmd
=
self
.
cli
(
"show interfaces mac-address"
)
for
match
in
self
.
rx_mac1
.
finditer
(
cmd
):
macs
[
match
.
group
(
"port"
)]
=
match
.
group
(
"mac"
)
for
l
in
self
.
cli
(
"show interfaces vlans"
).
split
(
"
\n\n
"
):
match
=
self
.
rx_vlan
.
search
(
l
)
try
:
with
self
.
profile
.
switch
(
self
):
cmd
=
self
.
cli
(
"show interfaces mac-address"
)
for
match
in
self
.
rx_mac1
.
finditer
(
cmd
):
macs
[
match
.
group
(
"port"
)]
=
match
.
group
(
"mac"
)
for
line
in
self
.
cli
(
"show interfaces vlans"
).
split
(
"
\n\n
"
):
match
=
self
.
rx_vlan
.
search
(
line
)
if
match
:
if
match
.
group
(
"tagged"
)
!=
"none"
:
tagged_vlans
[
match
.
group
(
"port"
)]
=
self
.
expand_rangelist
(
match
.
group
(
"tagged"
)
)
if
match
.
group
(
"untagged"
)
!=
"none"
:
untagged_vlans
[
match
.
group
(
"port"
)]
=
match
.
group
(
"untagged"
)
cmd
=
self
.
cli
(
"show version"
)
match
=
self
.
rx_mac2
.
search
(
cmd
)
if
match
:
if
match
.
group
(
"tagged"
)
!=
"none"
:
tagged_vlans
[
match
.
group
(
"port"
)]
=
self
.
expand_rangelist
(
match
.
group
(
"tagged"
)
)
if
match
.
group
(
"untagged"
)
!=
"none"
:
untagged_vlans
[
match
.
group
(
"port"
)]
=
match
.
group
(
"untagged"
)
cmd
=
self
.
cli
(
"show version"
)
match
=
self
.
rx_mac2
.
search
(
cmd
)
if
match
:
ip_mac
=
match
.
group
(
"mac"
)
else
:
ip_mac
=
""
ports
=
self
.
scripts
.
get_interface_status
()
for
i
in
ports
:
iface
=
{
"name"
:
i
[
"interface"
],
"type"
:
"physical"
,
"oper_status"
:
i
[
"status"
],
"mac"
:
macs
[
i
[
"interface"
]],
"subinterfaces"
:
[
{
"name"
:
i
[
"interface"
],
"oper_status"
:
i
[
"status"
],
"enabled_afi"
:
[
"BRIDGE"
],
"mac"
:
macs
[
i
[
"interface"
]],
}
],
}
t
=
tagged_vlans
.
get
(
i
[
"interface"
])
if
t
:
iface
[
"subinterfaces"
][
0
][
"tagged_vlans"
]
=
t
u
=
untagged_vlans
.
get
(
i
[
"interface"
])
if
u
:
iface
[
"subinterfaces"
][
0
][
"untagged_vlan"
]
=
u
interfaces
+=
[
iface
]
ip_mac
=
match
.
group
(
"mac"
)
else
:
ip_mac
=
""
ports
=
self
.
scripts
.
get_interface_status
()
for
i
in
ports
:
iface
=
{
"name"
:
i
[
"interface"
],
"type"
:
"physical"
,
"oper_status"
:
i
[
"status"
],
"mac"
:
macs
[
i
[
"interface"
]],
"subinterfaces"
:
[
{
"name"
:
i
[
"interface"
],
"oper_status"
:
i
[
"status"
],
"enabled_afi"
:
[
"BRIDGE"
],
"mac"
:
macs
[
i
[
"interface"
]],
}
],
}
t
=
tagged_vlans
.
get
(
i
[
"interface"
])
if
t
:
iface
[
"subinterfaces"
][
0
][
"tagged_vlans"
]
=
t
u
=
untagged_vlans
.
get
(
i
[
"interface"
])
if
u
:
iface
[
"subinterfaces"
][
0
][
"untagged_vlan"
]
=
u
interfaces
+=
[
iface
]
except
self
.
CLISyntaxError
:
# We are already in `switch` context
c
=
self
.
cli
(
"show vlan"
,
cached
=
True
)
t
=
parse_table
(
c
,
allow_wrap
=
True
,
footer
=
"dummy footer"
)
for
i
in
t
:
vlan_id
=
i
[
0
]
if
i
[
2
]
!=
"none"
:
tagged
=
i
[
2
].
split
(
", "
)
for
port
in
tagged
:
ifname
=
self
.
normalize_ifname
(
port
)
found
=
False
for
iface
in
interfaces
:
if
iface
[
"name"
]
==
ifname
:
if
"tagged_vlans"
in
iface
[
"subinterfaces"
][
0
]:
iface
[
"subinterfaces"
][
0
][
"tagged_vlans"
]
+=
[
vlan_id
]
else
:
iface
[
"subinterfaces"
][
0
][
"tagged_vlans"
]
=
[
vlan_id
]
found
=
True
break
if
not
found
:
iface
=
{
"name"
:
ifname
,
"type"
:
"physical"
,
"subinterfaces"
:
[
{
"name"
:
ifname
,
"enabled_afi"
:
[
"BRIDGE"
],
"tagged_vlans"
:
[
vlan_id
],
}
],
}
interfaces
+=
[
iface
]
if
i
[
3
]
!=
"none"
:
untagged
=
i
[
3
].
split
(
", "
)
for
port
in
untagged
:
ifname
=
self
.
normalize_ifname
(
port
)
found
=
False
for
iface
in
interfaces
:
if
iface
[
"name"
]
==
ifname
:
iface
[
"subinterfaces"
][
0
][
"untagged_vlan"
]
=
vlan_id
found
=
True
break
if
not
found
:
iface
=
{
"name"
:
ifname
,
"type"
:
"physical"
,
"subinterfaces"
:
[
{
"name"
:
ifname
,
"enabled_afi"
:
[
"BRIDGE"
],
"untagged_vlan"
:
vlan_id
,
}
],
}
interfaces
+=
[
iface
]
for
i
in
interfaces
:
c
=
self
.
cli
(
"show interfaces mac-address %s"
%
i
[
"name"
])
match
=
self
.
rx_mac
.
search
(
c
)
if
match
:
i
[
"mac"
]
=
match
.
group
(
"mac"
)
i
[
"subinterfaces"
][
0
][
"mac"
]
=
match
.
group
(
"mac"
)
try
:
c
=
self
.
cli
(
"show interfaces status %s"
%
i
[
"name"
])
match
=
self
.
rx_status
.
search
(
c
)
i
[
"oper_status"
]
=
match
.
group
(
"oper_status"
)
==
"up"
i
[
"subinterfaces"
][
0
][
"oper_status"
]
=
match
.
group
(
"oper_status"
)
==
"up"
i
[
"admin_status"
]
=
match
.
group
(
"oper_status"
)
!=
"off"
i
[
"subinterfaces"
][
0
][
"admin_status"
]
=
match
.
group
(
"oper_status"
)
!=
"off"
except
self
.
CLISyntaxError
:
pass
c
=
self
.
cli
(
"exit"
)
# manually exit from `switch` context
cmd
=
self
.
cli
(
"show system information"
)
match
=
self
.
rx_ip
.
search
(
cmd
)
if
match
:
...
...
sa/profiles/Eltex/LTE/get_vlans.py
View file @
380e0771
# ---------------------------------------------------------------------
# Eltex.LTE.get_vlans
# ---------------------------------------------------------------------
# Copyright (C) 2007-201
7
The NOC Project
# Copyright (C) 2007-20
2
1 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
...
...
@@ -11,6 +11,7 @@ import re
# NOC modules
from
noc.core.script.base
import
BaseScript
from
noc.sa.interfaces.igetvlans
import
IGetVlans
from
noc.core.text
import
parse_table
class
Script
(
BaseScript
):
...
...
@@ -22,6 +23,11 @@ class Script(BaseScript):
def
execute
(
self
):
r
=
[]
with
self
.
profile
.
switch
(
self
):
for
match
in
self
.
rx_vlan
.
finditer
(
self
.
cli
(
"show vlan"
)):
c
=
self
.
cli
(
"show vlan"
,
cached
=
True
)
for
match
in
self
.
rx_vlan
.
finditer
(
c
):
r
+=
[
match
.
groupdict
()]
if
not
r
:
t
=
parse_table
(
c
,
allow_wrap
=
True
,
footer
=
"dummy footer"
)
for
i
in
t
:
r
+=
[{
"vlan_id"
:
i
[
0
],
"name"
:
i
[
1
]}]
return
r
sa/profiles/Eltex/LTE/profile.py
View file @
380e0771
...
...
@@ -2,7 +2,7 @@
# Vendor: Eltex
# OS: LTE
# ---------------------------------------------------------------------
# Copyright (C) 2007-201
7
The NOC Project
# Copyright (C) 2007-20
2
1 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
...
...
@@ -15,7 +15,7 @@ class Profile(BaseProfile):
pattern_username
=
r
"(?<!Last )login: "
pattern_more
=
[(
r
"\[Yes/press any key for no\]"
,
"Y"
)]
# pattern_unprivileged_prompt = r"^\S+>"
pattern_syntax_error
=
r
"
^
(Command not found|Incomplete command|Invalid argument)"
pattern_syntax_error
=
r
"
\n
(Command not found|Incomplete command|Invalid argument)"
pattern_operation_error
=
r
"Data verify failed, bad MAC!"
username_submit
=
"
\r
"
password_submit
=
"
\r
"
...
...
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