Export NSX-v DFW Rules as CSV File

From NSX-v version 6.4.0, NSX API begins to support JSON format for its response not like before only XML format. From my own expereince, I prefer to use JSON format than XML format as it is easier to decode and encode JSON data than XML data. So I took 1 weekend to re-write my old Python code. Now this code can get Json format NSX-V DFW rules from NSX manager and then place into a CSV file so that you can view and search your DFW rules easily.

Below is a sample of CSV file which is generated by my Python code.

dfw-csv

I have put the source code in Github:

https://github.com/insidepacket/NSX-Toolkit/blob/master/export_dfw_to_csv.py

Feel free to enjoy.

 

Install Python Paramiko on Centos 7

You need the following packages installed so that the Paramiko module installation can be completed successfully:

yum install python-devel

yum install libffi-devel

yum install -y openssl-devel

[root@localhost python2.7]# pip install paramiko
Collecting paramiko
Using cached paramiko-2.0.2-py2.py3-none-any.whl
Collecting cryptography>=1.1 (from paramiko)
Using cached cryptography-1.5.tar.gz
Requirement already satisfied (use –upgrade to upgrade): pyasn1>=0.1.7 in ./site-packages (from paramiko)
Requirement already satisfied (use –upgrade to upgrade): idna>=2.0 in ./site-packages (from cryptography>=1.1->paramiko)
Requirement already satisfied (use –upgrade to upgrade): six>=1.4.1 in ./site-packages (from cryptography>=1.1->paramiko)
Requirement already satisfied (use –upgrade to upgrade): setuptools>=11.3 in ./site-packages (from cryptography>=1.1->paramiko)
Requirement already satisfied (use –upgrade to upgrade): enum34 in ./site-packages (from cryptography>=1.1->paramiko)
Requirement already satisfied (use –upgrade to upgrade): ipaddress in ./site-packages (from cryptography>=1.1->paramiko)
Requirement already satisfied (use –upgrade to upgrade): cffi>=1.4.1 in /usr/lib64/python2.7/site-packages (from cryptography>=1.1->paramiko)
Requirement already satisfied (use –upgrade to upgrade): pycparser in ./site-packages (from cffi>=1.4.1->cryptography>=1.1->paramiko)
Building wheels for collected packages: cryptography
Running setup.py bdist_wheel for cryptography … done
Stored in directory: /root/.cache/pip/wheels/d4/98/43/a428a8aed7285f934d18efd787647455d7ef9a9dda81f22839
Successfully built cryptography
Installing collected packages: cryptography, paramiko
Found existing installation: cryptography 0.8.2
Uninstalling cryptography-0.8.2:
Successfully uninstalled cryptography-0.8.2
Successfully installed cryptography-1.5 paramiko-2.0.2
[root@localhost python2.7]#

Note: Paramiko is a Python (2.6+, 3.3+) implementation of the SSHv2 protocol providing both client and server functionality.

If you want to know more about Paramiko module. Please go to http://www.paramiko.org