Psst.. new poll here.
[email protected] webmail now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!
Paste
Pasted as Python by NOC ( 10 years ago )
# -*- coding: utf-8 -*-
##----------------------------------------------------------------------
## Eltex.LTE.get_chassis_id
##----------------------------------------------------------------------
## Copyright (C) 2007-2014 The NOC Project
## See LICENSE for details
##----------------------------------------------------------------------
## Python modules
from __future__ import with_statement
import re
## NOC modules
from noc.sa.script import Script as NOCScript
from noc.sa.interfaces import IGetChassisID
class Script(NOCScript):
name = "Eltex.LTE.get_chassis_id"
implements = [IGetChassisID]
cache = True
rx_mac = re.compile(r"^\s+MAC address:\s+(?P<mac>\S+)$", re.MULTILINE)
def execute(self):
# Fallback to CLI
with self.profile.switch(self):
# with self.configure():
# self.cli("switch")
mac = self.cli("show interfaces mac-address front-port 0",
cached=True)
match = self.rx_mac.search(mac)
mac1 = match.group("mac")
mac = self.cli("show interfaces mac-address pon-port 7",
cached=True)
match = self.rx_mac.search(mac)
mac2 = match.group("mac")
# self.cli("exit")
return {
"first_chassis_mac": mac1,
"last_chassis_mac": mac2
}
Revise this Paste