In part 4 of this series, we looked at how to add LIFs to an existing DLR. In this post, we will look at removing LIFs from a DLR. The process of deleting LIFs is much simpler than adding LIFs and we will cover it pretty quickly.
From the API Guide:
Delete Interfaces
Deletes one or more interfaces for an NSX Edge Router. Stores the specified configuration in database. If any
appliance(s) are associated with this edge, disconnects and deletes the interface.
Example 7-9. Delete interface
Request:
DELETE https://<nsxmgr-ip>/api/4.0/edges/<edgeId>/interfaces/?index=<index1>&index=<index2>
Delete all Interfaces
Deletes all interfaces for an NSX Edge Router. Stores the specified configuration in database. If any
appliance(s) are associated with this edge, disconnects and deletes the interface.
Example 7-10. Delete all interfaces
Request:
DELETE https://<nsxmgr-ip>/api/4.0/edges/<edgeId>/interfaces
Delete All interfaces on a DLR (edge-15)
ndaher@ubuntu:~$ curl -k -u admin:Password! -X DELETE https://nsxman.local/api/4.0/edges/edge-15/interfaces
Delete Certain Interfaces on a DLR (edge-15)
Lets get the LIFs index numbers:
ndaher@ubuntu:~$ curl -k -u admin:Password! -H 'content-type: application/xml' -o dlrint.xml -X GET https://nsxman.local/api/4.0/edges/edge-15/interfaces
ndaher@ubuntu:~$ xml2csv --input "dlrint.xml" --output "dlrint.out" --tag "interface"
ndaher@ubuntu:~$ sed s/\"//g dlrint.out > dlrint.csv
Edit the dlrint.csv and remove any LIFs that you do not want to delete. Now delete the LIFs remaining in the CSV file.
ndaher@ubuntu:~$ tail -n+2 dlrint.csv | awk -F, '{print "curl -k -u admin:Password! -X DELETE https://nsxman.local/api/4.0/edges/edge-15/interfaces/?index=" $11}' | sh