In my case I needed to be able to change Memory Reservation settings. The thing is that all NSX appliances are deployed with 100% of memory reservation. My home lab grew up to almost 200Gb of RAM, but I still struggle with lack of memory especially when I run few nested deployments, each with its own NSX.
I am a big fan on PowerCLI so I tried to use Set-VMResourceConfiguration command let, but that attempt wasn't successful.
as you can see in the screenshot this method is disabled.
You can check all the methods disabled for VMs using this command
(get-vm VMname).ExtensionData.disabledmethod
As you can see the ReconfigVM_Task is in the list of disabled methods, which prevents any changes to the VM config.
There is a way to enable this method, but it can only be done through vSphere MOB, but I personally find it really confusing and not user friendly. And I had no clue how to automate this process. So, I gave up on this.
Then I thought there should be a way to change NSX appliances config through NSX RestAPI. And actually there is.
Here is how you can change the memory reservation of NSX edges using curl. Update the values in bold before using.
1. Grab the NSX edge config and save it in XML file
curl -k -u 'username:password' -H "Content-Type: application/xml" -X GET https://nsxFQDN:443/api/4.0/edges/Edge-ID/appliances/highAvailabilityIndex > XXX.xml
2. Update the memory reservation in xml file.
<limit>-1</limit>
<reservation>YYY</reservation>
</memoryReservation>
3. Update the edge config
curl -k -u 'username:password' -H "Content-Type:application/xml" PUT https://nsxFQDN:443/api/4.0/edges/Edge-ID/appliances/highAvailabilityIndex -d "@XXX.xml"
As you can see you can change some settings of the Edge, but you cannot do the same with controllers. At least I couldn't find anything similar for controllers in NSX RestAPI guide.
Also, it is not easy to automate.
Here is an example of how you can use PowerCLI to automate RestAPI calls
From here you can update anything you need and change the config using similar PowerCLI function.
As you can see it is more time consuming way of doing things. and again, this is not applicable for NSX controllers.
So I thought I should go back to the original idea of enabling ReconfigVM_task method and started searching for instructions when I found out (once again) that William Lam has already done this. In this post he explains how you can disable vMotion for some of the VMs by disabling MigrateVM_task method. But the most amazing part of that post was that he created PowerCLI functions to enable/disable any methods without using vSphere MOB.
From here it was really easy to create the following script which changes the memory reservation on any VMs - whether they are deployed by NSX or not.
The script grabs all VMs with 100% of memory reservations and changes this value to 99%. You can change this value to whatever you prefer. If ReconfigureVM method is disabled the script will re-enable it first. After the memory reservation is updated the script will change the ReconfigVM method back to disabled.
All you need to do is to update the vCenter name and credentials before you run the script.
A word of caution - this is not officially supported way of changing the settings of NSX appliances. It works but it's at your own risk.