VMware Networking Community
SaurabhRV
Enthusiast
Enthusiast
Jump to solution

NSX controller API to get Mac for all VM's related to VNI

Hello All,

I need to know if any REST API available to get list of mac-table entries for particular VNI using NSX manager or NSX controller???

Basically i need RESt API for CLI on NSX controller i.e.

"show control-cluster logical-switches mac-table 5005"

Thanks in advance,

Saurabh Jain

Please consider marking this answer "correct" or "helpful" if you think your query have been answered correctly. http://www.linkedin.com/in/ saurabh-jain-a7b7bb9
Tags (1)
1 Solution

Accepted Solutions
AA120
VMware Employee
VMware Employee
Jump to solution

Hi,

If you use NSX-v 6.2 and later, central CLI can be executed by REST API.

I consider that you can get MAC table on a specified controller by using the following API.

=========

* Central CLI REST API

POST https://NSX-Manager-IP-Address/api/1.0/nsx/cli?action=execute

Request Body:

<nsxcli>

<command>CLI</command>

</nsxcli>

---

* My example

$ curl -k -u <USER>:<PASSWORD> -H "Accept: text/plain" -H "Content-Type: application/xml" https://NSXMGR-ADDR/api/1.0/nsx/cli?action=execute -d "<nsxcli><command>show logical-switch controller controller-4 vni 5000 mac</command></nsxcli>"

VNI      MAC               VTEP-IP         Connection-ID

5000     00:50:56:xx:xx:xx 192.168.xxx.xxx  14

5000     00:50:56:yy:yy:yy 192.168.xxx.xxx  14

5000     00:50:56:zz:zz:zz 192.168.xxx.xxx  15

==========


Regards,
Mizo

View solution in original post

2 Replies
AA120
VMware Employee
VMware Employee
Jump to solution

Hi,

If you use NSX-v 6.2 and later, central CLI can be executed by REST API.

I consider that you can get MAC table on a specified controller by using the following API.

=========

* Central CLI REST API

POST https://NSX-Manager-IP-Address/api/1.0/nsx/cli?action=execute

Request Body:

<nsxcli>

<command>CLI</command>

</nsxcli>

---

* My example

$ curl -k -u <USER>:<PASSWORD> -H "Accept: text/plain" -H "Content-Type: application/xml" https://NSXMGR-ADDR/api/1.0/nsx/cli?action=execute -d "<nsxcli><command>show logical-switch controller controller-4 vni 5000 mac</command></nsxcli>"

VNI      MAC               VTEP-IP         Connection-ID

5000     00:50:56:xx:xx:xx 192.168.xxx.xxx  14

5000     00:50:56:yy:yy:yy 192.168.xxx.xxx  14

5000     00:50:56:zz:zz:zz 192.168.xxx.xxx  15

==========


Regards,
Mizo

arahimidris
Contributor
Contributor
Jump to solution

Just to add instead of specifying the controller one can use "master" keyword to facilitate automation i.e. in e.g. below

curl -k -u <USER>:<PASSWORD> -H "Accept: text/plain" -H "Content-Type: application/xml" https://NSXMGR-ADDR/api/1.0/nsx/cli?action=execute -d "<nsxcli><command>show logical-switch controller controller-4 master vni 5000 mac</command></nsxcli>"