Lately I’ve been working more with the API for multiple versions of NSX with my colleague @VirtSouthWest. Here are a couple of of API calls that we have been using which are something I’d like to keep track of for future configurations and hope they help someone else:
To get started you need a REST API Client/plugin, here is one I use that works with FireFox – RESTCLIENT
Once you have that installed you are ready connect to your NSX manager. If you have a self signed cert you may need to go to the NSX Manager and accept the “not secure connection”. That is something good to check if you get a response like the one below:
Once you accept the security warning you and ensure you have the correct Authorization and Header in place you should get a 200 OK response as shown below:
Here is a sample configuration of what you would send to a NSX manager API to configure Syslog. Make sure to specify the protocol TCP/UDP) and which port you have your syslog configured on, the standard being 514.
<syslogserver> <syslogServer>Syslog-Server-FQDN/IP</syslogServer> <port>514</port> - Port Configured on your Syslog Server <protocol>UDP</protocol> - TCP/UDP </syslogserver>
Here is a sample configuration of what you would send to a NSX manager API to configure NTP, you can configure 2 NTP servers using IP or FQDN which is great for redundancy.
<timeSettings> <ntpServer> <string>NTPServer-IP1</string><string>time1.google.com</string> - You can configure 2 NTP Servers </ntpServer> <timezone>UTC</timezone> </timeSettings>
From the limited experince I have the backups are small ranging from 10-40MB.
Please note that once they reach their destination you configure they stay there and NSX does not currently clean up the backups. Meaning if you configure a backup job to run daily, after 1 year you will have 365 backups. This can take a while to load on the backup/restore screen. Please configure a job on the destination end to cleanup the backup jobs as needed. NSX will reflect these backups being gone and the list will be come shorter/load faster.
Here is a sample configuration of what you would send to a NSX manager API to configure scheduled Backups. In the example I have the time scheduled for 19:50 and for each manager you can configure the backup time. I have mine set to be staggered every 5 minutes.
Replace the following fields(Snip from the API Guide 6.2 below):
transferProtocol: FTP, SFTP
frequency: weekly, daily, hourly
dayOfWeek: SUNDAY, MONDAY, …., SATURDAY(Not in my example below)
Hour of Day: [0 ‐ 24 [ Minute of hour: [0 ‐ 60 [
Exclude Tables: AUDIT_LOG, SYSTEM_EVENTS, FLOW_RECORDS
The tables specified in the excludeTables parameter are not backed up.
<backupRestoreSettings> <ftpSettings> <transferProtocol>FTP</transferProtocol> <hostNameIPAddress>Backup-Destination/IP-Address</hostNameIPAddress> <port>21</port> <userName>FTPUSER</userName><password>Password-for-FTPUSER</password> <passPhrase>passPhrase</passPhrase> - For the backup file to restore <backupDirectory>NSXBackupDir/</backupDirectory> <filenamePrefix>NSX-Manager1-</filenamePrefix> <passiveMode>true</passiveMode> <useEPRT>false</useEPRT> <useEPSV>true</useEPSV> </ftpSettings> <backupFrequency> <frequency>DAILY</frequency> <hourOfDay>19</hourOfDay> <minuteOfHour>50</minuteOfHour> </backupFrequency> <excludeTables> <excludeTable>AUDIT_LOGS</excludeTable> <excludeTable>SYSTEM_EVENTS</excludeTable> </excludeTables> </backupRestoreSettings>
There are many of other things you can do via the NSX API and the above are just some some calls to get started. You can create controllers, controller backups, edges, etc.. Please review the guides below for the version you have.
API Guides link for different versions: