Commit 5429d4cf authored by Andrey Vertiprahov's avatar Andrey Vertiprahov
Browse files

Meinberg.LANTIME. Cleanup black.

parent ece9c36f
......@@ -307,6 +307,9 @@ nav:
- Maipu:
- Overview: user/reference/profiles/Maipu/index.md
- Maipu.OS: user/reference/profiles/Maipu/Maipu.OS.md
- Meinberg:
- Overview: user/reference/profiles/Meinberg/index.md
- Meinberg.LANTIME: user/reference/profiles/Meinberg/Meinberg.LANTIME.md
- MikroTik:
- Overview: user/reference/profiles/MikroTik/index.md
- MikroTik.RouterOS: user/reference/profiles/MikroTik/MikroTik.RouterOS.md
......
......@@ -318,6 +318,9 @@ nav:
- Maipu:
- Overview: user/reference/profiles/Maipu/index.md
- Maipu.OS: user/reference/profiles/Maipu/Maipu.OS.md
- Meinberg:
- Overview: user/reference/profiles/Meinberg/index.md
- Meinberg.LANTIME: user/reference/profiles/Meinberg/Meinberg.LANTIME.md
- MikroTik:
- Overview: user/reference/profiles/MikroTik/index.md
- MikroTik.RouterOS: user/reference/profiles/MikroTik/MikroTik.RouterOS.md
......
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------
# Vendor: MEINBERG
# OS: LANTIME
# ---------------------------------------------------------------------
# Copyright (C) 2007-2018 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# NOC modules
from noc.core.profile.base import BaseProfile
class Profile(BaseProfile):
name = "Meinberg.LANTIME"
# supported_schemes = [NOCProfile.TELNET, NOCProfile.SSH]
pattern_username = "^((?!Last)\S+ login|[Ll]ogin):"
pattern_password = "^[Pp]assword:"
# use default BASH promt PS1='[\u@\h \W]\$ '
# pattern_prompt = r"^\[\S+@\S+\s\S+](#|\$)\s"
pattern_prompt = r"\[\S+@\S+\s\S+](#|\$)\s"
pattern_syntax_error = \
r"^(bash: \S+: command not found...\r\n|-\w+: \w+: not found|" \
r"-\w+: \w+: No such file or directory|\w+: \w+: command not found|" \
r"\w+: \w+: \w+: No such file or directory)"
# pattern_more = [
# (r"Install package.*\[N/y\]\s$", "\n"),
# (r"Is this ok \[y/N\]: ", "y\n")
# ]
command_disable_pager = \
"LANG=en_US.UTF-8 ; PATH=$PATH:/sbin:/usr/sbin ; PROMPT_COMMAND=''"
command_super = "sudo bash"
command_exit = "exit"
command_more = "\n"
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------
# Meinberg.LANTIME.get_capabilities
# ---------------------------------------------------------------------
# Copyright (C) 2007-2018 The NOC Project
# Copyright (C) 2007-2022 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
......@@ -12,4 +11,3 @@ from noc.sa.profiles.Generic.get_capabilities import Script as BaseScript
class Script(BaseScript):
name = "Meinberg.LANTIME.get_capabilities"
cache = True
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------
# Meinberg.LANTIME.get_chassis_id
# ---------------------------------------------------------------------
# Copyright (C) 2007-2018 The NOC Project
# Copyright (C) 2007-2022 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# NOC modules
from noc.core.script.base import BaseScript
from noc.sa.profiles.Generic.get_chassis_id import Script as BaseScript
from noc.sa.interfaces.igetchassisid import IGetChassisID
from noc.core.mib import mib
class Script(BaseScript):
name = "Meinberg.LANTIME.get_chassis_id"
cache = True
interface = IGetChassisID
def execute(self):
# Try SNMP first
if self.snmp:
try:
mac = self.snmp.get("1.3.6.1.2.1.2.2.1.6.2", cached=True)
if mac is not None:
return {"first_chassis_mac": mac, "last_chassis_mac": mac}
else:
return [
{
"first_chassis_mac": "00:00:00:00:00:00",
"last_chassis_mac": "00:00:00:00:00:00"
}
]
except self.snmp.TimeOutError:
pass
return
SNMP_GET_OIDS = {"SNMP": [mib["IF-MIB::ifPhysAddress", 2]]}
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------
# Meinberg.LANTIME.get_fqdn
# ---------------------------------------------------------------------
# Copyright (C) 2007-2018 The NOC Project
# Copyright (C) 2007-2022 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# NOC modules
from noc.core.script.base import BaseScript
from noc.sa.profiles.Generic.get_fqdn import Script as BaseScript
from noc.sa.interfaces.igetfqdn import IGetFQDN
class Script(BaseScript):
name = "Meinberg.LANTIME.get_fqdn"
interface = IGetFQDN
always_prefer = "S"
def execute(self):
if self.has_snmp():
# and self.access_profile.snmp_ro:
try:
# sysName.0
v = self.snmp.get("1.3.6.1.2.1.1.5.0", cached=True)
if v:
return v
except self.snmp.TimeOutError:
pass
def execute_cli(self, **kwargs):
v = self.cli("uname -n").strip()
fqdn = v
return fqdn
return v
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------
# Meinberg.LANTIME.get_interfaces
# ---------------------------------------------------------------------
# Copyright (C) 2007-2018 The NOC Project
# Copyright (C) 2007-2022 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
"""
......@@ -11,6 +10,7 @@ Important see: https://ru.wikipedia.org/w/index.php?oldid=75745192
"""
# Python modules
import re
# NOC modules
from noc.core.script.base import BaseScript
from noc.sa.interfaces.igetinterfaces import IGetInterfaces
......@@ -23,50 +23,50 @@ class Script(BaseScript):
rx_iface = re.compile(
r"\d+: (?P<name>\S+):\s<(?P<status>\S+)>\s[a-zA-Z0-9,<>_ \-]+\n"
r" link\/ether (?P<mac>\S+) brd", re.IGNORECASE | re.DOTALL
r" link\/ether (?P<mac>\S+) brd",
re.IGNORECASE | re.DOTALL,
)
rx_master = re.compile(
r"\d+: (?P<name>\S+):\s<(?P<status>\S+)>\s[a-zA-Z0-9,<>_ ]+ master (?P<master>\S+)\s.*\n"
r" link\/ether (?P<mac>\S+) brd", re.IGNORECASE | re.DOTALL
r" link\/ether (?P<mac>\S+) brd",
re.IGNORECASE | re.DOTALL,
)
def execute(self, interface=None):
def execute_cli(self, **kwargs):
interfaces = []
# Ethernet ports
ifcfg = ""
ifcfg = self.cli("ip link", cached=True)
for match in self.rx_iface.finditer(ifcfg):
# print match.group("status")
# print match.group("name")
typeif = "other"
# bonding interface: bondX
if 'MASTER' in match.group("status"):
if "MASTER" in match.group("status"):
typeif = "aggregated"
interfaces += [
{
"type": typeif,
"mac": match.group("mac"),
"subinterfaces": [{
"name": match.group("name"),
"enabled_afi": ["BRIDGE"]
}],
"subinterfaces": [{"name": match.group("name"), "enabled_afi": ["BRIDGE"]}],
}
]
# Bridge: brX, vnetX, virbrX, vifX.X, vethX(XEN), xenbr0, tapX, xapiX, ovs-system
if (match.group("name")[:4] in ["vnet", "virb", "veth", "xenb", "xapi", "ovs-"] or
match.group("name")[:2] in ["br", "vi", "ta"]):
if match.group("name")[:4] in [
"vnet",
"virb",
"veth",
"xenb",
"xapi",
"ovs-",
] or match.group("name")[:2] in ["br", "vi", "ta"]:
interfaces += [
{
"name": match.group("name"),
"type": typeif,
"mac": match.group("mac"),
"subinterfaces": []
"subinterfaces": [],
}
]
......@@ -75,7 +75,7 @@ class Script(BaseScript):
typeif = "physical"
# 2: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP qlen 1000
# slave interface in bonding
if 'SLAVE' in match.group("status"):
if "SLAVE" in match.group("status"):
ifmaster = self.cli("ip link show " + match.group("name"), cached=True)
for slaveif in self.rx_master.finditer(ifmaster):
# print slaveif.group("master"), "ddddddddddddddddddd"
......@@ -85,7 +85,7 @@ class Script(BaseScript):
"type": typeif,
"mac": match.group("mac"),
"subinterfaces": [],
"aggregated_interface": slaveif.group("master")
"aggregated_interface": slaveif.group("master"),
}
]
else:
......@@ -94,7 +94,7 @@ class Script(BaseScript):
"name": match.group("name"),
"type": typeif,
"mac": match.group("mac"),
"subinterfaces": []
"subinterfaces": [],
}
]
......
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------
# Meinberg.LANTIME.get_version
# ---------------------------------------------------------------------
# Copyright (C) 2007-2018 The NOC Project
# Copyright (C) 2007-2022 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
"""
"""
# Python modules
import re
# NOC modules
from noc.core.script.base import BaseScript
from noc.sa.interfaces.igetversion import IGetVersion
......@@ -24,7 +23,7 @@ class Script(BaseScript):
rx_ver = re.compile(
r"\((?P<distr>[^,]+)\) \((?P<version>[^,]+)\((?P<codename>[^,]+)\)\)",
re.MULTILINE | re.DOTALL | re.IGNORECASE
re.MULTILINE | re.DOTALL | re.IGNORECASE,
)
def execute(self):
......@@ -51,5 +50,5 @@ class Script(BaseScript):
"codename": codename,
"distro": distr,
"kernel": kernel.strip(),
}
},
}
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------
# Meinberg.LANTIME.get_vlans
# ---------------------------------------------------------------------
# Copyright (C) 2007-2014 The NOC Project
# Copyright (C) 2007-2022 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
'''
$ ip -details link show
6: bond0.2102@bond0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br1 state UP mode DEFAULT qlen 1000
link/ether 00:21:5a:5c:d6:b6 brd ff:ff:ff:ff:ff:ff promiscuity 1
vlan protocol 802.1Q id 2102 <REORDER_HDR>
bridge_slave addrgenmode eui64
'''
# Python modules
import re
# NOC modules
from noc.core.script.base import BaseScript
from noc.sa.interfaces.igetvlans import IGetVlans
......@@ -29,15 +20,25 @@ class Script(BaseScript):
rx_iface = re.compile(
r"\d+: (?P<name>\S+):\s<(?P<status>\S+)>\s[a-zA-Z0-9,<>_ \-]+\n"
r" link\/ether (?P<mac>\S+) brd .*\n"
r" vlan protocol 802.1Q id (?P<vlan_number>\d+)\s", re.IGNORECASE | re.DOTALL
r" vlan protocol 802.1Q id (?P<vlan_number>\d+)\s",
re.IGNORECASE | re.DOTALL,
)
def execute(self):
def execute_cli(self, **kwargs):
"""
$ ip -details link show
6: bond0.2102@bond0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br1 state UP mode DEFAULT qlen 1000
link/ether 00:21:5a:5c:d6:b6 brd ff:ff:ff:ff:ff:ff promiscuity 1
vlan protocol 802.1Q id 2102 <REORDER_HDR>
bridge_slave addrgenmode eui64
"""
r = [{'vlan_id': 1}]
r = [{"vlan_id": 1}]
vlans = self.cli("ip -details link show")
for match in self.rx_iface.finditer(vlans):
r += [{'vlan_id': match.group("vlan_number")}]
r += [{"vlan_id": match.group("vlan_number")}]
return r
# ---------------------------------------------------------------------
# Vendor: MEINBERG
# OS: LANTIME
# ---------------------------------------------------------------------
# Copyright (C) 2007-2022 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# NOC modules
from noc.core.profile.base import BaseProfile
class Profile(BaseProfile):
name = "Meinberg.LANTIME"
# supported_schemes = [NOCProfile.TELNET, NOCProfile.SSH]
pattern_username = rb"^((?!Last)\S+ login|[Ll]ogin):"
pattern_password = rb"^[Pp]assword:"
# use default BASH promt PS1='[\u@\h \W]\$ '
# pattern_prompt = r"^\[\S+@\S+\s\S+](#|\$)\s"
pattern_prompt = rb"\[\S+@\S+\s\S+](#|\$)\s"
pattern_syntax_error = (
rb"^(bash: \S+: command not found...\r\n|-\w+: \w+: not found|"
rb"-\w+: \w+: No such file or directory|\w+: \w+: command not found|"
rb"\w+: \w+: \w+: No such file or directory)"
)
# pattern_more = [
# (r"Install package.*\[N/y\]\s$", "\n"),
# (r"Is this ok \[y/N\]: ", "y\n")
# ]
command_disable_pager = "LANG=en_US.UTF-8 ; PATH=$PATH:/sbin:/usr/sbin ; PROMPT_COMMAND=''"
command_super = "sudo bash"
command_exit = "exit"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment