Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- ##----------------------------------------------------------------------
- ## Cisco.IOS.get_fqdn
- ##----------------------------------------------------------------------
- ## Copyright (C) 2007-2013 The NOC Project
- ## See LICENSE for details
- ##----------------------------------------------------------------------
- ## Python modules
- import re
- ## NOC modules
- from noc.sa.script import Script as NOCScript
- from noc.sa.interfaces import IGetFQDN
- class Script(NOCScript):
- name = "EdgeCore.ES.get_fqdn"
- implements = [IGetFQDN]
- rx_hostname = re.compile(r"^hostname\s+(?P<hostname>\S+)", re.MULTILINE)
- rx_domain_name = re.compile(r"^ip domain[ \-]name\s+(?P<domain>\S+)",
- re.MULTILINE)
- def execute(self):
- if self.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
- v = self.cli(
- "show running-config | include ^(hostname|ip domain.name)")
- fqdn = []
- match = self.rx_hostname.search(v)
- if match:
- fqdn += [match.group("hostname")]
- match = self.rx_domain_name.search(v)
- if match:
- fqdn += [match.group("domain")]
- return ".".join(fqdn)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement