Advertisement
Guest User

Untitled

a guest
Apr 30th, 2015
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1.  
  2. # -*- coding: utf-8 -*-
  3. ##----------------------------------------------------------------------
  4. ## NAG.SNR.get_config
  5. ##----------------------------------------------------------------------
  6. ## Copyright (C) 2007-2012 The NOC Project
  7. ## See LICENSE for details
  8. ##----------------------------------------------------------------------
  9.  
  10. ## NOC modules
  11. from noc.sa.script import Script as NOCScript
  12. from noc.sa.interfaces import IGetConfig
  13.  
  14.  
  15. class Script(NOCScript):
  16. name = "NAG.SNR.get_config"
  17. implements = [IGetConfig]
  18.  
  19. def execute(self, TFTP_root='', TFTP_IP='', file_name=''):
  20. # Try snmp first
  21. #
  22. #
  23. # See bug NOC-291: http://bt.nocproject.org/browse/NOC-291
  24. raise Exception("Not implemented")
  25. #
  26. #
  27. if self.snmp and self.access_profile.snmp_rw and TFTP_IP and file_name:
  28. try:
  29. # The ConfigCopyProtocol is set to TFTP
  30. self.snmp.set('1.3.6.1.4.1.9.9.96.1.1.1.1.2.111', 1)
  31. # Set the SourceFileType to running-config
  32. self.snmp.set('1.3.6.1.4.1.9.9.96.1.1.1.1.3.111', 4)
  33. # Set the DestinationFileType to networkfile
  34. self.snmp.set('1.3.6.1.4.1.9.9.96.1.1.1.1.4.111', 1)
  35. # Sets the ServerAddress to the IP address of the TFTP server
  36. self.snmp.set('1.3.6.1.4.1.9.9.96.1.1.1.1.5.111', TFTP_IP)
  37. # Sets the CopyFilename to your desired file name.
  38. self.snmp.set('1.3.6.1.4.1.9.9.96.1.1.1.1.6.111', file_name)
  39. # Sets the CopyStatus to active which starts the copy process.
  40. self.snmp.set('1.3.6.1.4.1.9.9.96.1.1.1.1.14.111', 1)
  41. conf_file = open(TFTP_root + '/' + file_name, 'r')
  42. config = conf_file.read()
  43. conf_file.close()
  44. # config = self.strip_first_lines(config, 0)
  45. return self.cleaned_config(config)
  46. except self.snmp.TimeOutError:
  47. pass
  48.  
  49. # Fallback to CLI
  50. raise Exception("Not implemented")
  51.  
  52.  
  53. # -*- coding: utf-8 -*-
  54. ##----------------------------------------------------------------------
  55. ## Copyright (C) 2007-2009 The NOC Project
  56. ## See LICENSE for details
  57. ##----------------------------------------------------------------------
  58. """
  59. """
  60. import noc.sa.script
  61. from noc.sa.interfaces import IGetConfig
  62.  
  63.  
  64. class Script(noc.sa.script.Script):
  65. name = "SNR.IOS.get_config"
  66. implements = [IGetConfig]
  67.  
  68. def execute(self):
  69. config = self.cli("show running-config")
  70. return self.cleaned_config(config)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement