First install pynsxv using pip:
$ sudo pip install pynsxv
You may confirm that the installation was successful by executing the following commands:
$ pynsxv -h usage: pynsxv [-h] [-i INI] [-v] [-d] {lswitch,dlr,esg,dhcp,lb,dfw,usage} ... PyNSXv Command Line Client for NSX for vSphere positional arguments: {lswitch,dlr,esg,dhcp,lb,dfw,usage} lswitch Functions for logical switches dlr Functions for distributed logical routers esg Functions for edge services gateways dhcp Functions for Edge DHCP lb Functions for Edge Load Balancer dfw Functions for distributed firewall usage Functions to retrieve NSX-v usage statistics optional arguments: -h, --help show this help message and exit -i INI, --ini INI nsx configuration file -v, --verbose increase output verbosity -d, --debug print low level debug of http transactions
You may encounter the following error due to some version mismatching:
pkg_resources.DistributionNotFound: The 'urllib3<1.22,>=1.21.1' distribution was not found and is required by requests
By repeating with the version explicitly specified for pip, this issue can be fixed:
$ sudo pip2 install pynsxv $ pynsxv lswitch -h usage: pynsxv lswitch [-h] [-t TRANSPORT_ZONE] [-n NAME] command Functions for logical switches positional arguments: command create: create a new logical switch read: return the virtual wire id of a logical switch delete: delete a logical switch" list: return a list of all logical switches optional arguments: -h, --help show this help message and exit -t TRANSPORT_ZONE, --transport_zone TRANSPORT_ZONE nsx transport zone -n NAME, --name NAME logical switch name, needed for create, read and delete
A Python code to use the RESTful API of NSX Manager can be downloaded from https://code.vmware.com/samples/1988/python-code-to-use-the-nsx-manager-rest-api-interface, and can be executed using the following command:
$ python snippet.py
Optionally, you may also install the Python nsx library for OpenStack using the following command:
$ sudo pip install vmware-nsx