Thursday, June 22, 2017

CLI for VMware Virtual Distributed Switch

A few weeks ago I have been asked by one of my customers if VMware Virtual Distributed Switch (aka VDS) supports Cisco like command line interface. The key idea behind was to integrate vSphere switch with open-source tool Network Tracking Database (NetDB) which they use for tracking MAC addresses within their network. I have been told by customer that NetDB can telnet/ssh to Cisco switches and do screen scraping so would not it be cool to have the most popular switch CLI commands for VDS? These commands are

  • show mac-address-table
  • show interface status
The official answer is NO, but wait a minute. Almost anything is possible with VMware API. So my solution is leveraging VMware's vSphere Perl SDK to pull information out of Distributed Virtual Switches. I have prepared PERL script which currently supports two commands mentioned above. It goes through all VMware Distributed Switches on single vCenter. Script along with shell wrappers are available on GITHUB here

See screenshots below to get an idea what script does.

The output of the command --username readonly --password readonly --cmd show-port-status
looks as depicted in screenshot below.

and output of the command --username readonly --password readonly --cmd show-mac-address-table
Now, I'm working on ssh/telnet daemon which will simulate remotely accessible switch CLI. It will just call PERL scripts above but that is what network administrators want for their day to day operations. I'm testing interactive shell ( with Python to emulate Cisco like CLI.

No comments: