The first step is to obtain a UAA access token. Follow the instructions in the article, How to use UAAC to curl Ops Manager API to fetch a token using `uaac
` as the Ops Manager admin user. You can run `uaac context
` to view and copy the `access_token
`.
When you have your access token, proceed to run the following steps.
1. Run `export TOKEN='<paste in access token>
'`.
2. Run `export HOST='<your ops man host'>
`. This should be the fully qualified domain name of your Ops Manager server.
3. Run `curl -H "Authorization: bearer $TOKEN" https
:
//$HOST/api/v0/staged/products | jq -r '.[] | select(.type == "cf") | .guid'
`. This will print the product guid for the CF product.
4. Run `export PGUID='<paste CF product guid from #3>
'`.
5. Run `curl -H "Authorization: bearer $TOKEN" https
:
//$HOST/api/v0/staged/products/$PGUID/jobs | jq -r '.jobs[] | select(.name == "diego_cell") | .guid'
`. This will print the Diego Cell job guid.
6. Run `export JGUID='<paste Diego Cell job guid from #5>'
`.
7. Run `curl -H "Authorization: bearer $TOKEN" https
:
//$HOST/api/v0/staged/products/$PGUID/jobs/$JGUID/resource_config | jq . > rc.json
`. This will dump the current resource config to a file name `rc.json
`.
8. Edit the `rc.json
` file. Change the value of `swap_as_percent_of_memory_size
` to `0
`. This will disable swap. You could alternatively use a value greater than zero which would set the percent of RAM that is used for swap. For example, if you wanted to have swap set to 10% of RAM, you could set the value to 10. When done, save and close the file.
9. Run `curl -X PUT -d @rc.json -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" https
:
//$HOST/api/v0/staged/products/$PGUID/jobs/$JGUID/resource_config
`. This will update the resource config in Ops Manager with the values in your `rc.json
` file.
10. Run `curl -H "Authorization: bearer $TOKEN" https
:
//$HOST/api/v0/staged/products/$PGUID/jobs/$JGUID/resource_config | jq .
`. This will print the current resource config settings, which should show you the new swap value. The new swap value is 0 in our demo but should match the value you set in `rc.json
`.
11. Apply changes. This will run and update all of your Diego Cells. Please be aware that this step recreates the VM, so it may take some time to roll out if you have a large number of Cells. After the apply changes has completed, you can confirm that swap has been disabled by running `bosh ssh -c 'swapon -s'
`. This will run `swapon -s
`, which reports the swap usage on each VM. If swap is enabled, you'll see a message similar to the one below. If it's not enabled, you'll see nothing output from the command.
$ swapon -s Filename Type Size Used Priority /dev/sdb1 partition 4194300 0 -2
If your Ops Manager has an untrusted TLS certificate, you will need to add the `-k
` option to all of the `curl
` commands above. This instructs `curl
` to ignore TLS certificate errors.