cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1516
Views
0
Helpful
3
Replies

Python 3.6 - MDS 9000 - some commands do not work in Python telnet

svarol001
Level 1
Level 1

Hello, 

I am trying to automate MDS 9000 log collections using Python 3.6. Some commands work fine, but not all of them. It is a very basic scripts as you see below.

 

The ones working:

- "clear counters interface fc 1/1"

- "show topology vsan 2"

- "show fcns database vsan 2"

- "show interface fc 1/1"

- "show interface fc 1/1 brief"

 

Not working commands:

* "show interface fc 1/1 counters"

* "show interface fc 1/1 transceiver"

* "show version"

* "show running-config"

 

I am guessing that there are some more commands that do not work.

 

Could you please help what might be the solution if someone tried it?

 

Thanks,

Seckin

 

 

 

import argparse
import telnetlib
import sys

parser = argparse.ArgumentParser()
parser.add_argument('--ip', '-i', type=str, help='IP Address. default: 10.181.xx.yy', default="10.181.xx.yy")
parser.add_argument('--username', '-u', type=str, help='Username. default: admin', default="admin")
parser.add_argument('--password', '-p', type=str, help='Password. default: password', default="password")

args = parser.parse_args()

tn = telnetlib.Telnet(args.ip)

tn.read_until(b"login:")
tn.write(args.username.encode('ascii') + b"\n")

if args.password:
tn.read_until(b"Password: ")
tn.write(args.password.encode('ascii') + b"\n")

tn.write(b"show version" + b"\n")

tn.write(b"exit" + b"\n")

txt = tn.read_all().replace(b'\xf2',b'')

print(txt.decode("utf-8"))
 

 

1 Accepted Solution

Accepted Solutions

Hello,

 

My co-worker (Dan Palmer) figured it out what the problem is actually. Cisco MDS has this "--More--" when the CLI respond exceeds the number of line for the terminal. It was expecting any charcter is given after the command issued.

My workaround is first run "terminal length 511" then run the commands that has long output. 

 

Regards,

Seckin

View solution in original post

3 Replies 3

Walter Dey
VIP Alumni
VIP Alumni

Don't know the answer.

Is your MDS model supported, according to 

https://www.cisco.com/c/en/us/td/docs/switches/datacenter/mds9000/sw/8_x/programmability/cisco_mds9000_programmability_guide_8x/cisco_mds9000_programmability_guide_8x_chapter_011.html

Python is supported on the following Cisco MDS 9000 Series Switches:

  • Cisco MDS 9700 Series Switches

    All Fibre Channel Switching Modules

  • Cisco MDS 9132T Multilayer Fabric Switch

  • Cisco MDS 9148T Multilayer Fabric Switch

  • Cisco MDS 9396T Multilayer Fabric Switch

Hello Walter,

 

Thank you for your time. According to that document Cisco MDS 9250i is not supported, but Cisco MDS 32T is supported.

The purpose of the document is to help for using APIs by built-in Ver.2.7 Python module. (I looked at my switches and could not found any Python install under "bootflash". But this was not my purpose anyway)

 

I am just trying to login to the switch via my script and run some commands.

 

Thanks,

Seckin

 

Hello,

 

My co-worker (Dan Palmer) figured it out what the problem is actually. Cisco MDS has this "--More--" when the CLI respond exceeds the number of line for the terminal. It was expecting any charcter is given after the command issued.

My workaround is first run "terminal length 511" then run the commands that has long output. 

 

Regards,

Seckin

Review Cisco Networking for a $25 gift card