Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Script(NOCScript):
- name = "Cisco.IOSXR.get_fqdn"
- implements = [IGetFQDN]
- rx_hostname = re.compile(r"^hostname\s+(?P<hostname>\S+)", re.MULTILINE)
- rx_domain_name = re.compile(r"^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 | utility egrep hostname|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