vmware-archive / powernsx

PowerShell module that abstracts the VMware NSX-v API to a set of easily used PowerShell functions
173 stars 89 forks source link

Delete Autosaved Firewall configurations #604

Closed haripetrov closed 5 years ago

haripetrov commented 5 years ago

Is there any way using PowerNSX to delete autosaved firewall configurations.

Here is the API calls information:

We need to do one GET API call to get all the saved configurations and their IDs: https://nsx_manager_IP/api/4.0/firewall/globalroot-0/drafts

This will return a list of saved configurations with name and draft id, an example here: <?xml version="1.0" encoding="UTF-8"?>

Auto saved configuration false vsphere.local\administrator autosaved

We should then use the ID to delete a draft with the following DELETE API call: https://nsx_manager_IP/api/4.0/firewall/globalroot-0/drafts/draft-ID

Where we would replace the "draft-ID" with the number of the draft, for example to delete the above ID 2: https://nsx_manager_IP/api/4.0/firewall/globalroot-0/drafts/2

I saw in previous issue that there is Get command in PowerNSX: Get-NsxFirewallSavedConfiguration

dcoghlan commented 5 years ago

There are commands available

C:\Users\Administrator> get-command -module PowerNSX | ? {$_.name -match "saved"}

CommandType     Name                                               ModuleName
-----------     ----                                               ----------
Function        Get-NsxFirewallSavedConfiguration                  PowerNsx
Function        New-NsxFirewallSavedConfiguration                  PowerNsx
Function        Remove-NsxFirewallSavedConfiguration               PowerNsx
Function        Set-NsxFirewallSavedConfiguration                  PowerNsx

 C:\Users\Administrator> Get-PowerNsxVersion

Version                       Path                          Author                        CompanyName
-------                       ----                          ------                        -----------
3.0.1125                      C:\Users\Administrator\Doc... Nick Bradford                 VMware
haripetrov commented 5 years ago

Thank you very much about this information!