Not sure if it is a well-known fact, but Cisco's Nexus 3K switch platform supports running Python scripts for a few months now.
Here is the API doc:
Cisco Nexus 3000 Switch 5.0(3)U3(2) Python API
The biggest difference between a traditional Python environment is that you need to import a Cisco module in order to execute CLI commands from Python, as well as take advantage of some of the built-in methods.
Nexus-3064# python
Python 2.7.2 (default, Mar 6 2012, 15:51:12)
[GCC 3.4.3 (MontaVista 3.4.3-25.0.143.0800417 2008-02-22)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Loaded cisco NxOS lib!
>>> import cisco
>>> dir(cisco)
['BufferDepthMonitor', 'CLI', 'CheckPortDiscards', 'FTPTransfer', 'HTTPTransfer', 'History', 'Interface', 'Key', 'LineParser', 'PasswordProtoTransfer', 'Routes', 'SCPTransfer', 'SFTPTransfer', 'SectionParser', 'TFTPTransfer', 'Transfer', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_bcm_sdk_shell', '_cisco', '_get_cli_output', '_get_merged_cli_output', '_get_op_prompt_pat', '_get_status_from_prompt', '_merge', '_op_prmpt_re', 'cfg_if', 'cli', 'commands', 'copy', 'datetime', 'deque', 'get_valid_port', 'os', 'pexpect', 're', 'show_queues', 'show_run', 'sys', 'transfer']
>>>
>>> cisco.cli('show hostname')
(0, 'Nexus-3064 \n')
>>> output = cisco.cli('show hostname')
>>> output[1]
'Nexus-3064 \n'
>>> output[1].strip()
'Nexus-3064'
>>> exit()
Nexus-3064#
The word on the street is that this at least will stay in the future roadmap for Nexus platforms.
can I use python to generate custom syslog messages in N-3064?
ReplyDeletei tried EEM but it doesnt have watchdog timer's like IOS.
Great Article
ReplyDeleteFinal Year Projects for CSE in Python
FInal Year Project Centers in Chennai
Python Training in Chennai
Python Training in Chennai