12-20-2018 01:02 PM
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"))
Solved! Go to Solution.
01-10-2019 06:07 AM
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
01-01-2019 12:17 PM
Don't know the answer.
Is your MDS model supported, according to
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
01-08-2019 06:36 AM
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
01-10-2019 06:07 AM
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
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide