Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
arthur-zzz
noc
Commits
2662f34e
Commit
2662f34e
authored
Jun 22, 2021
by
Dmitry Lukhtionov
Committed by
bee26
Jun 22, 2021
Browse files
Update Orion.NOS profile
parent
703e7f2e
Changes
8
Hide whitespace changes
Inline
Side-by-side
sa/profiles/Orion/NOS/get_arp.py
View file @
2662f34e
# ---------------------------------------------------------------------
# Orion.NOS.get_arp
# ---------------------------------------------------------------------
# Copyright (C) 2007-201
8
The NOC Project
# Copyright (C) 2007-20
2
1 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
import
re
# NOC modules
from
noc.core.script.base
import
BaseScript
from
noc.sa.interfaces.igetarp
import
IGetARP
import
re
class
Script
(
BaseScript
):
...
...
@@ -16,7 +18,7 @@ class Script(BaseScript):
interface
=
IGetARP
rx_line
=
re
.
compile
(
r
"^\s*(?P<ip>[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s+"
r
"(?P<mac>\S+)\s+\S+\s+(?P<interface>\S+)\s*
$
"
,
r
"(?P<mac>\S+)\s+\S+\s+(?P<interface>\S+)\s*"
,
re
.
MULTILINE
,
)
...
...
sa/profiles/Orion/NOS/get_chassis_id.py
View file @
2662f34e
# ---------------------------------------------------------------------
# Orion.NOS.get_chassis_id
# ---------------------------------------------------------------------
# Copyright (C) 2007-201
8
The NOC Project
# Copyright (C) 2007-20
2
1 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# NOC modules
from
noc.core.script.base
import
BaseScript
from
noc.sa.interfaces.igetchassisid
import
IGetChassisID
...
...
@@ -17,4 +18,7 @@ class Script(BaseScript):
def
execute_cli
(
self
):
v
=
self
.
profile
.
get_version
(
self
)
return
{
"first_chassis_mac"
:
v
[
"mac"
],
"last_chassis_mac"
:
v
[
"mac"
]}
r
=
[{
"first_chassis_mac"
:
v
[
"mac"
],
"last_chassis_mac"
:
v
[
"mac"
]}]
if
v
.
get
(
"mac2"
)
is
not
None
:
r
+=
[{
"first_chassis_mac"
:
v
[
"mac2"
],
"last_chassis_mac"
:
v
[
"mac2"
]}]
return
r
sa/profiles/Orion/NOS/get_interface_status.py
View file @
2662f34e
# ---------------------------------------------------------------------
# Orion.NOS.get_interface_status
# ---------------------------------------------------------------------
# Copyright (C) 2007-201
8
The NOC Project
# Copyright (C) 2007-20
2
1 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
...
...
@@ -18,10 +18,29 @@ class Script(BaseScript):
name
=
"Orion.NOS.get_interface_status"
interface
=
IGetInterfaceStatus
rx_port
=
re
.
compile
(
r
"^\s*(?P<port>\d+)\s+\S+\s+(?P<oper_status>\S+)"
,
re
.
MULTILINE
)
rx_port
=
re
.
compile
(
r
"^\s*
P?
(?P<port>\d+)\s+\S+\s+(?P<oper_status>\S+)"
,
re
.
MULTILINE
)
def
execute_cli
(
self
,
interface
=
None
):
r
=
[]
if
self
.
is_beta
:
port_count
=
self
.
profile
.
get_port_count
(
self
)
c
=
self
.
cli
((
"show interface port-list 1-%d"
%
port_count
),
cached
=
True
)
for
match
in
self
.
rx_port
.
finditer
(
c
):
if
(
interface
is
not
None
)
and
(
interface
==
match
.
group
(
"port"
)):
return
[
{
"interface"
:
match
.
group
(
"port"
),
"status"
:
"down"
not
in
match
.
group
(
"oper_status"
),
}
]
r
+=
[
{
"interface"
:
match
.
group
(
"port"
),
"status"
:
"down"
not
in
match
.
group
(
"oper_status"
),
}
]
return
r
for
match
in
self
.
rx_port
.
finditer
(
self
.
cli
(
"show interface port"
)):
if
(
interface
is
not
None
)
and
(
interface
==
match
.
group
(
"port"
)):
return
[
...
...
sa/profiles/Orion/NOS/get_interfaces.py
View file @
2662f34e
# ---------------------------------------------------------------------
# Orion.NOS.get_interfaces
# ---------------------------------------------------------------------
# Copyright (C) 2007-201
8
The NOC Project
# Copyright (C) 2007-20
2
1 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
...
...
@@ -21,6 +21,24 @@ class Script(BaseScript):
rx_port
=
re
.
compile
(
r
"^\s*(?P<port>\d+)\s+(?P<admin_status>\S+)\s+(?P<oper_status>\S+)\s+"
,
re
.
MULTILINE
)
rx_port_beta
=
re
.
compile
(
r
"^\s*P(?P<port>\d+)\s+(?P<admin_status>\S+)\s+(?P<oper_status>\S+)\s+"
r
"\S+\s+\S+\s+\S+\s+\S+\s+(?P<descr>\S+)\s*\n"
,
re
.
MULTILINE
,
)
rx_port_a26
=
re
.
compile
(
r
"^\s*(?P<ifname>\S+) is (?P<admin_status>\S+), line protocol is (?P<oper_status>\S+)(, dev index is (?P<ifindex>\d+))?\s*\n"
r
"(^\s*\S+ is layer 2 port, alias name is (?P<descr>\S+), index is (?P<snmp_ifindex>\d+)\s*\n)?"
r
"(^\s*Device flag .+\n)?"
r
"(^\s*Time since last status change.+\n)?"
r
"(^\s*IPv4 address is:\s*\n)?"
r
"(^\s*(?P<address>\S+)\s+(?P<mask>\S+)\s+\(Primary\)\s*\n)?"
r
"(^\s*VRF Bind: .+\n)?"
r
"^\s*Hardware is \S+, (active is \S+, )?address is (?P<mac>\S+)\s*\n"
r
"(^\s*PVID is (?P<pvid>\S+)\s*\n)?"
r
"^\s*MTU (is )?(?P<mtu>\d+) bytes"
,
re
.
MULTILINE
,
)
rx_descr
=
re
.
compile
(
r
"^(?P<port>\d+)(?P<descr>.+)$"
,
re
.
MULTILINE
)
rx_switchport
=
re
.
compile
(
r
"^Administrative Mode: (?P<mode>\S+)\s*\n"
...
...
@@ -33,18 +51,52 @@ class Script(BaseScript):
r
"^Administrative Trunk Allowed VLANs: (?P<vlans>\S+)\s*\n"
,
re
.
MULTILINE
,
)
rx_enabled
=
re
.
compile
(
r
"^\s*(?P<port>d+)\s+Ena"
,
re
.
MULTILINE
|
re
.
IGNORECASE
)
rx_switchport_beta
=
re
.
compile
(
r
"^Interface: port(?P<port>\d+)\s*\n"
r
"^Reject frame type: \S+\s*\n"
r
"^Administrative Mode: (?P<mode>\S+)\s*\n"
r
"^Operational Mode: \S+\s*\n"
r
"^Access Mode VLAN: (?P<access_vlan>\d+)\s*\n"
r
"^Administrative Access Egress VLANs:.*\n"
r
"^Operational Access Egress VLANs:.*\n"
r
"^Trunk Native Mode VLAN: (?P<native_vlan>\d+)\s*\n"
r
"^Administrative Trunk Allowed VLANs: (?P<vlans>\S+)\s*\n"
,
re
.
MULTILINE
,
)
rx_switchport_a26
=
re
.
compile
(
r
"^(?P<ifname>\S+)\s*\n"
r
"^Type :\S+\s*\n"
r
"^Mode :(?P<mode>\S+)\s*\n"
r
"^Port VID :(?P<pvid>\d+)\s*\n"
r
"(^Trunk allowed Vlan: (?P<vlans>\d+\S+)\s*\n)?"
,
re
.
MULTILINE
,
)
rx_enabled
=
re
.
compile
(
r
"^\s*P?(?P<port>\d+)\s+Ena"
,
re
.
MULTILINE
|
re
.
IGNORECASE
)
# do not verified
rx_oam
=
re
.
compile
(
r
"^\s*(?P<port>d+)operate"
,
re
.
MULTILINE
|
re
.
IGNORECASE
)
rx_oam
=
re
.
compile
(
r
"^\s*P?(?P<port>\d+)operate"
,
re
.
MULTILINE
|
re
.
IGNORECASE
)
rx_lldp
=
re
.
compile
(
r
"^\s*P?(?P<port>(?!0)\d+)\s+\d+"
,
re
.
MULTILINE
|
re
.
IGNORECASE
)
rx_ip
=
re
.
compile
(
r
"^\s*(?P<ifname>\S+)\s+(?P<ip_address>\S+)\s+(?P<ip_subnet>\S+)\s+"
r
"(?P<vlan_id>\d+)\s+(?P<admin_status>\S+)\s*\n"
,
re
.
MULTILINE
,
)
rx_ip_beta
=
re
.
compile
(
r
"^\s*(?P<ifname>\d+)\s+(?P<ip_address>\d\S+)\s+(?P<ip_subnet>\d\S+)\s+"
,
re
.
MULTILINE
,
)
rx_ip_beta_vlan
=
re
.
compile
(
r
"^\s*(?P<ifname>\d+)\s+(?P<vlan_id>\d+)\s*\n"
,
re
.
MULTILINE
,
)
port_count
=
0
def
get_gvrp
(
self
):
try
:
v
=
self
.
cli
(
"show gvrp configuration"
)
if
self
.
is_beta
:
v
=
self
.
cli
(
"show gvrp port-list 1-%d"
%
self
.
port_count
)
else
:
v
=
self
.
cli
(
"show gvrp configuration"
)
if
"GVRP Global Admin State: Disable"
not
in
v
:
return
self
.
rx_enabled
.
findall
(
v
)
except
self
.
CLISyntaxError
:
...
...
@@ -74,7 +126,10 @@ class Script(BaseScript):
v
=
self
.
cli
(
"show lldp statistic"
)
if
"LLDP is not enabled."
not
in
v
:
# Need more examples
return
self
.
rx_enabled
.
findall
(
v
)
if
self
.
is_beta
:
return
self
.
rx_lldp
.
findall
(
v
)
else
:
return
self
.
rx_enabled
.
findall
(
v
)
except
self
.
CLISyntaxError
:
return
[]
return
[]
...
...
@@ -82,7 +137,10 @@ class Script(BaseScript):
def
get_oam
(
self
):
try
:
# Need more examples
v
=
self
.
cli
(
"show extended-oam status"
)
if
self
.
is_beta
:
v
=
self
.
cli
(
"show extended-oam status port-list 1-%d"
%
self
.
port_count
)
else
:
v
=
self
.
cli
(
"show extended-oam status"
)
return
self
.
rx_enabled
.
findall
(
v
)
except
self
.
CLISyntaxError
:
return
[]
...
...
@@ -90,13 +148,158 @@ class Script(BaseScript):
def
execute_cli
(
self
):
interfaces
=
[]
descr
=
[]
if
self
.
is_a26
:
c
=
self
.
cli
(
"show interface"
)
for
match
in
self
.
rx_port_a26
.
finditer
(
c
):
ifname
=
match
.
group
(
"ifname"
)
iface
=
{
"name"
:
ifname
,
"type"
:
self
.
profile
.
get_interface_type
(
ifname
),
"admin_status"
:
"up"
in
match
.
group
(
"admin_status"
),
"oper_status"
:
"up"
in
match
.
group
(
"oper_status"
),
"mtu"
:
match
.
group
(
"mtu"
),
"subinterfaces"
:
[
{
"name"
:
ifname
,
"admin_status"
:
"up"
in
match
.
group
(
"admin_status"
),
"oper_status"
:
"up"
in
match
.
group
(
"oper_status"
),
"enabled_afi"
:
[],
}
],
}
if
match
.
group
(
"snmp_ifindex"
):
iface
[
"snmp_ifindex"
]
=
match
.
group
(
"snmp_ifindex"
)
if
match
.
group
(
"ifindex"
):
iface
[
"snmp_ifindex"
]
=
match
.
group
(
"ifindex"
)
if
match
.
group
(
"mac"
):
iface
[
"mac"
]
=
match
.
group
(
"mac"
)
if
match
.
group
(
"descr"
)
and
match
.
group
(
"descr"
)
!=
"(null)"
:
iface
[
"description"
]
=
match
.
group
(
"descr"
)
if
match
.
group
(
"mac"
):
iface
[
"subinterfaces"
][
0
][
"untagged_vlan"
]
=
match
.
group
(
"pvid"
)
if
iface
[
"type"
]
==
"physical"
:
iface
[
"subinterfaces"
][
0
][
"enabled_afi"
]
+=
[
"BRIDGE"
]
if
iface
[
"type"
]
==
"SVI"
:
iface
[
"subinterfaces"
][
0
][
"vlan_ids"
]
=
ifname
[
4
:]
if
match
.
group
(
"address"
)
and
match
.
group
(
"mask"
):
ip_address
=
match
.
group
(
"address"
)
ip_subnet
=
match
.
group
(
"mask"
)
ip_address
=
"%s/%s"
%
(
ip_address
,
IPv4
.
netmask_to_len
(
ip_subnet
))
iface
[
"subinterfaces"
][
0
][
"enabled_afi"
]
+=
[
"IPv4"
]
iface
[
"subinterfaces"
][
0
][
"ipv4_addresses"
]
=
[
ip_address
]
interfaces
+=
[
iface
]
c
=
self
.
cli
(
"show switchport interface"
)
for
match
in
self
.
rx_switchport_a26
.
finditer
(
c
):
ifname
=
match
.
group
(
"ifname"
)
for
iface
in
interfaces
:
if
iface
[
"name"
]
==
ifname
:
sub
=
iface
[
"subinterfaces"
][
0
]
if
match
.
group
(
"mode"
)
==
"Access"
:
sub
[
"untagged_vlan"
]
=
int
(
match
.
group
(
"pvid"
))
elif
match
.
group
(
"mode"
)
==
"Trunk"
:
sub
[
"untagged_vlan"
]
=
int
(
match
.
group
(
"pvid"
))
sub
[
"tagged_vlans"
]
=
self
.
expand_rangelist
(
match
.
group
(
"vlans"
).
replace
(
";"
,
","
)
)
else
:
raise
self
.
NotSupportedError
()
break
return
[{
"interfaces"
:
interfaces
}]
if
self
.
is_beta
:
self
.
port_count
=
self
.
profile
.
get_port_count
(
self
)
gvrp
=
self
.
get_gvrp
()
stp
=
self
.
get_stp
()
ctp
=
self
.
get_ctp
()
lldp
=
self
.
get_lldp
()
oam
=
self
.
get_lldp
()
for
l
in
self
.
cli
(
"show interface port description"
).
split
(
"
\n
"
):
match
=
self
.
rx_descr
.
match
(
l
.
strip
())
oam
=
self
.
get_oam
()
if
self
.
is_beta
:
c
=
self
.
cli
((
"show interface port-list 1-%d"
%
self
.
port_count
),
cached
=
True
)
for
match
in
self
.
rx_port_beta
.
finditer
(
c
):
ifname
=
match
.
group
(
"port"
)
iface
=
{
"name"
:
ifname
,
"type"
:
"physical"
,
"admin_status"
:
"enable"
in
match
.
group
(
"admin_status"
),
"oper_status"
:
"down"
not
in
match
.
group
(
"oper_status"
),
"enabled_protocols"
:
[],
"snmp_ifindex"
:
ifname
,
"description"
:
match
.
group
(
"descr"
),
"subinterfaces"
:
[
{
"name"
:
ifname
,
"admin_status"
:
"enable"
in
match
.
group
(
"admin_status"
),
"oper_status"
:
"down"
not
in
match
.
group
(
"oper_status"
),
"enabled_afi"
:
[
"BRIDGE"
],
}
],
}
if
ifname
in
gvrp
:
iface
[
"enabled_protocols"
]
+=
[
"GVRP"
]
if
ifname
in
stp
:
iface
[
"enabled_protocols"
]
+=
[
"STP"
]
if
ifname
in
ctp
:
iface
[
"enabled_protocols"
]
+=
[
"CTP"
]
if
ifname
in
lldp
:
iface
[
"enabled_protocols"
]
+=
[
"LLDP"
]
if
ifname
in
oam
:
iface
[
"enabled_protocols"
]
+=
[
"OAM"
]
interfaces
+=
[
iface
]
c
=
self
.
cli
((
"show interface port-list 1-%d switchport"
%
self
.
port_count
))
for
match
in
self
.
rx_switchport_beta
.
finditer
(
c
):
ifname
=
match
.
group
(
"port"
)
for
iface
in
interfaces
:
if
iface
[
"name"
]
==
ifname
:
sub
=
iface
[
"subinterfaces"
][
0
]
if
match
.
group
(
"mode"
)
==
"access"
:
sub
[
"untagged_vlan"
]
=
int
(
match
.
group
(
"access_vlan"
))
elif
match
.
group
(
"mode"
)
==
"trunk"
:
sub
[
"untagged_vlan"
]
=
int
(
match
.
group
(
"native_vlan"
))
sub
[
"tagged_vlans"
]
=
self
.
expand_rangelist
(
match
.
group
(
"vlans"
))
else
:
raise
self
.
NotSupportedError
()
break
mac
=
self
.
scripts
.
get_chassis_id
()[
0
].
get
(
"first_chassis_mac"
)
c
=
self
.
cli
(
"show interface ip"
)
for
match
in
self
.
rx_ip_beta
.
finditer
(
c
):
ip_address
=
match
.
group
(
"ip_address"
)
ip_subnet
=
match
.
group
(
"ip_subnet"
)
ip_address
=
"%s/%s"
%
(
ip_address
,
IPv4
.
netmask_to_len
(
ip_subnet
))
ifname
=
match
.
group
(
"ifname"
)
iface
=
{
"name"
:
"ip%s"
%
ifname
,
"type"
:
"SVI"
,
"admin_status"
:
True
,
"oper_status"
:
True
,
"mac"
:
mac
,
"subinterfaces"
:
[
{
"name"
:
"ip%s"
%
ifname
,
"admin_status"
:
True
,
"oper_status"
:
True
,
"mac"
:
mac
,
"enabled_afi"
:
[
"IPv4"
],
"ipv4_addresses"
:
[
ip_address
],
}
],
}
interfaces
+=
[
iface
]
c
=
self
.
cli
(
"show interface ip vlan"
)
for
match
in
self
.
rx_ip_beta_vlan
.
finditer
(
c
):
ifname
=
"ip%s"
%
match
.
group
(
"ifname"
)
vid
=
match
.
group
(
"vlan_id"
)
for
iface
in
interfaces
:
if
iface
[
"name"
]
==
ifname
:
sub
=
iface
[
"subinterfaces"
][
0
]
sub
[
"vlan_ids"
]
=
vid
break
# Not implemented
# c = self.cli("show interface ipv6")
return
[{
"interfaces"
:
interfaces
}]
for
line
in
self
.
cli
(
"show interface port description"
).
split
(
"
\n
"
):
match
=
self
.
rx_descr
.
match
(
line
.
strip
())
if
match
:
if
match
.
group
(
"port"
)
==
"Port"
:
continue
...
...
@@ -147,8 +350,8 @@ class Script(BaseScript):
interfaces
+=
[
iface
]
mac
=
self
.
profile
.
get_version
(
self
)[
"mac"
]
descr
=
[]
for
l
in
self
.
cli
(
"show interface ip description"
).
split
(
"
\n
"
):
match
=
self
.
rx_descr
.
match
(
l
.
strip
())
for
l
ine
in
self
.
cli
(
"show interface ip description"
).
split
(
"
\n
"
):
match
=
self
.
rx_descr
.
match
(
l
ine
.
strip
())
if
match
:
if
match
.
group
(
"port"
)
==
"Port"
:
continue
...
...
sa/profiles/Orion/NOS/get_lldp_neighbors.py
View file @
2662f34e
# ---------------------------------------------------------------------
# Orion.NOS.get_lldp_neighbors
# ---------------------------------------------------------------------
# Copyright (C) 2007-202
0
The NOC Project
# Copyright (C) 2007-202
1
The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
...
...
@@ -42,8 +42,8 @@ class Script(BaseScript):
"""
rx_lldp
=
re
.
compile
(
r
"^port(?P<port>\d+)\s+(?P<chassis_id>\S+)"
,
re
.
MULTILINE
)
rx_int
=
re
.
compile
(
r
"^Port\s+port(?P<interface>\d+)\s+has\s+1\s+remotes:\s*\n"
r
"^\s*\n"
r
"^P
(
ort\s+port
)?
(?P<interface>\d+)\s+has\s+1\s+remotes:\s*\n"
r
"
(
^\s*\n
)?
"
r
"^Remote\s*1\s*\n"
r
"^-+\s*\n"
r
"^ChassisIdSubtype\s*:\s+(?P<chassis_subtype>\S+)\s*\n"
...
...
@@ -57,9 +57,42 @@ class Script(BaseScript):
r
"^SysCapEnabled\s*:\s+(?P<caps>.+)\s*\n"
,
re
.
MULTILINE
,
)
rx_int_a26
=
re
.
compile
(
r
"^Port name\s*:\s*(?P<interface>\S+)\s*\n"
r
"^Port Remote Counter\s*:\s*1\s*\n"
r
"^TimeMark\s*:\s*\d+\s*\n"
r
"^ChassisIdSubtype\s*:\s*(?P<chassis_subtype>\d+)\s*\n"
r
"^ChassisId\s*:\s*(?P<chassis_id>\S+)\s*\n"
r
"^PortIdSubtype\s*:\s*(?P<port_subtype>\S+)\s*\n"
r
"^PortId\s*:\s*(?P<port_id>.+)\n"
r
"^PortDesc\s*:\s*(?P<port_descr>.+)\n"
r
"^SysName\s*:\s*(?P<sys_name>.*)\n"
,
re
.
MULTILINE
,
)
def
execute_cli
(
self
):
result
=
[]
if
self
.
is_a26
:
v
=
self
.
cli
(
"show lldp neighbors interface"
)
for
match
in
self
.
rx_int_a26
.
finditer
(
v
):
neighbor
=
{
"remote_chassis_id_subtype"
:
match
.
group
(
"chassis_subtype"
),
"remote_chassis_id"
:
match
.
group
(
"chassis_id"
),
"remote_port_subtype"
:
{
# Need more examples
"Interface"
:
LLDP_PORT_SUBTYPE_NAME
,
}[
match
.
group
(
"port_subtype"
)],
"remote_port"
:
match
.
group
(
"port_id"
),
}
if
match
.
group
(
"port_descr"
).
strip
():
p
=
match
.
group
(
"port_descr"
).
strip
()
neighbor
[
"remote_port_description"
]
=
p
if
match
.
group
(
"sys_name"
).
strip
():
p
=
match
.
group
(
"sys_name"
).
strip
()
neighbor
[
"remote_system_name"
]
=
p
result
+=
[{
"local_interface"
:
match
.
group
(
"interface"
),
"neighbors"
:
[
neighbor
]}]
return
result
chassis
=
{}
v
=
self
.
cli
(
"show lldp remote"
)
for
match
in
self
.
rx_lldp
.
finditer
(
v
):
...
...
@@ -101,12 +134,12 @@ class Script(BaseScript):
caps
=
lldp_caps_to_bits
(
match
.
group
(
"caps"
).
strip
().
split
(
","
),
{
"
O
ther"
:
LLDP_CAP_OTHER
,
"
R
epeater/
H
ub"
:
LLDP_CAP_REPEATER
,
"
B
ridge/
S
witch"
:
LLDP_CAP_BRIDGE
,
"
R
outer"
:
LLDP_CAP_ROUTER
,
"
T
elephone"
:
LLDP_CAP_TELEPHONE
,
"
S
tation"
:
LLDP_CAP_STATION_ONLY
,
"
o
ther"
:
LLDP_CAP_OTHER
,
"
r
epeater/
h
ub"
:
LLDP_CAP_REPEATER
,
"
b
ridge/
s
witch"
:
LLDP_CAP_BRIDGE
,
"
r
outer"
:
LLDP_CAP_ROUTER
,
"
t
elephone"
:
LLDP_CAP_TELEPHONE
,
"
s
tation"
:
LLDP_CAP_STATION_ONLY
,
},
)
neighbor
[
"remote_capabilities"
]
=
caps
...
...
sa/profiles/Orion/NOS/get_mac_address_table.py
View file @
2662f34e
# ---------------------------------------------------------------------
# Orion.NOS.get_mac_address_table
# ---------------------------------------------------------------------
# Copyright (C) 2007-201
8
The NOC Project
# Copyright (C) 2007-20
2
1 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
...
...
@@ -17,16 +17,15 @@ class Script(BaseScript):
name
=
"Orion.NOS.get_mac_address_table"
interface
=
IGetMACAddressTable
rx_port
=
re
.
compile
(
r
"^\s*(?P<port>\d+)"
,
re
.
MULTILINE
)
rx_line
=
re
.
compile
(
r
"^\s*(?P<mac>\S+)\s+(?:(?P<port>\d+)\s+)?(?P<vlan_id>\d+)\s+\S+\s*\n"
,
re
.
MULTILINE
r
"^\s*(?P<mac>\S+)\s+(?:
P?
(?P<port>\d+)\s+)?(?P<vlan_id>\d+)\s+\S+\s*\n"
,
re
.
MULTILINE
)
def
execute_cli
(
self
,
interface
=
None
,
vlan
=
None
,
mac
=
None
):
r
=
[]
# "show mac address-table" command do not show port name on some cases
f
or
match
in
self
.
rx_port
.
finditer
(
self
.
cli
(
"show port-security"
)):
port
=
match
.
group
(
"port"
)
p
or
t_count
=
self
.
profile
.
get_port_count
(
self
)
for
port
in
range
(
1
,
port_count
+
1
):
v
=
self
.
cli
(
"show mac-address-table l2-address port %s"
%
port
)
for
match1
in
self
.
rx_line
.
finditer
(
v
):
r
+=
[
...
...
sa/profiles/Orion/NOS/get_vlans.py
View file @
2662f34e
# ---------------------------------------------------------------------
# Orion.NOS.get_vlans
# ---------------------------------------------------------------------
# Copyright (C) 2007-201
8
The NOC Project
# Copyright (C) 2007-20
2
1 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
import
re
# NOC modules
from
noc.core.script.base
import
BaseScript
from
noc.sa.interfaces.igetvlans
import
IGetVlans
...
...
@@ -16,9 +19,17 @@ class Script(BaseScript):
interface
=
IGetVlans
rx_vlan
=
re
.
compile
(
r
"^\s*(?P<vlan_id>\d+)\s+(?P<name>\S+)"
,
re
.
MULTILINE
)
rx_vlan_beta
=
re
.
compile
(
r
"^VLAN ID: (?P<vlan_id>\d+)\s*\nName: (?P<name>\S+)"
,
re
.
MULTILINE
)
def
execute_cli
(
self
):
r
=
[]
if
self
.
is_beta
:
for
match
in
self
.
rx_vlan_beta
.
finditer
(
self
.
cli
(
"show vlan detail"
,
cached
=
True
)):
if
match
.
group
(
"vlan_id"
)
==
"1"
:
continue
r
+=
[
match
.
groupdict
()]
return
r
for
match
in
self
.
rx_vlan
.
finditer
(
self
.
cli
(
"show vlan"
)):
if
match
.
group
(
"vlan_id"
)
==
"1"
:
continue
...
...
sa/profiles/Orion/NOS/profile.py
View file @
2662f34e
...
...
@@ -2,7 +2,7 @@
# Vendor: Orion (Orion Networks)
# OS: NOS
# ---------------------------------------------------------------------
# Copyright (C) 2007-201
9
The NOC Project
# Copyright (C) 2007-20
2
1 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
...
...
@@ -28,7 +28,7 @@ class Profile(BaseProfile):
r
"tacacs(-server | accounting-server )encrypt-key \S+\n"
,
]
rx_interface_name
=
re
.
compile
(
r
"port\s*(?P<re_port>\d+)"
)
rx_interface_name
=
re
.
compile
(
r
"
(?:
port\s*
|P)
(?P<re_port>\d+)"
)
rx_ver
=
re
.
compile
(
r
"^Product name\s*:\s*(?P<platform>.+)\s*\n"
...
...
@@ -58,14 +58,49 @@ class Profile(BaseProfile):
re
.
MULTILINE
,
)
rx_ver3
=
re
.
compile
(
r
"^\s+Orion (?P<platform>Alpha \S+) Device, Compiled on .+\s*\n"
r
"^\s+sysLocation .+\n"
r
"^\s+CPU Mac (?P<mac>\S+)\s*\n"
r
"^\s+Vlan MAC (?P<mac2>\S+)\s*\n"
r
"^\s+SoftWare Version (?P<version>\S+)\s*\n"
r
"^\s+BootRom Version (?P<bootprom>\S+)\s*\n"
r
"^\s+HardWare Version (?P<hardware>\S+)\s*\n"
r
"(^\s+CPLD Version.+\n)?"
r
"^\s+Serial No.:\s*(?P<serial>\S+)\s*\n"
,
re
.
MULTILINE
,
)
rx_port
=
re
.
compile
(
r
"^\s*P?(?P<port>\d+)\s+"
,
re
.
MULTILINE
)
matchers
=
{
"is_beta"
:
{
"platform"
:
{
"$regex"
:
r
"^Beta-"
}},
"is_a26"
:
{
"platform"
:
{
"$regex"
:
r
"^Alpha A26"
}},
}
def
get_version
(
self
,
script
):
c
=
script
.
cli
(
"show version"
,
cached
=
True
)
match
=
self
.
rx_ver
.
search
(
c
)
if
not
match
:
match
=
self
.
rx_ver2
.
search
(
c
)
if
not
match
:
match
=
self
.
rx_ver3
.
search
(
c
)
return
match
.
groupdict
()
def
get_port_count
(
self
,
script
):
c
=
script
.
cli
(
"show port-security"
,
cached
=
True
)
return
len
(
self
.
rx_port
.
findall
(
c
))
def
convert_interface_name
(
self
,
s
):
if
self
.
rx_interface_name
.
match
(
s
):
return
self
.
rx_interface_name
.
match
(
s
).
group
(
"re_port"
)
return
s
INTERFACE_TYPES
=
{
"Et"
:
"physical"
,
# Ethernet
"Vl"
:
"SVI"
,
# Vlan
}
@
classmethod
def
get_interface_type
(
cls
,
name
):
return
cls
.
INTERFACE_TYPES
.
get
(
name
[:
2
])
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