Advertisement
Guest User

Untitled

a guest
Aug 15th, 2013
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. class Script(NOCScript):
  2. name = "Cisco.IOSXR.get_fqdn"
  3. implements = [IGetFQDN]
  4. rx_hostname = re.compile(r"^hostname\s+(?P<hostname>\S+)", re.MULTILINE)
  5. rx_domain_name = re.compile(r"^domain[ ]name\s+(?P<domain>\S+)",
  6. re.MULTILINE)
  7.  
  8. def execute(self):
  9. if self.snmp and self.access_profile.snmp_ro:
  10. try:
  11. # sysName.0
  12. v = self.snmp.get("1.3.6.1.2.1.1.5.0", cached=True)
  13. if v:
  14. return v
  15. except self.snmp.TimeOutError:
  16. pass
  17. v = self.cli(
  18. "show running-config | utility egrep hostname|domain name[ ]"
  19. fqdn = []
  20. match = self.rx_hostname.search(v)
  21. if match:
  22. fqdn += [match.group("hostname")]
  23. match = self.rx_domain_name.search(v)
  24. if match:
  25. fqdn += [match.group("domain")]
  26. return ".".join(fqdn)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement