Enabling and disabling hosts

Hosts may be enabled or disabled by setting a single value. Let's disable our IPMI host and re-enable it a moment later. To do this, we'll need the host ID. Usually, when using the API, we'd query the API itself for the ID. In this case, let's keep things simple and look up the ID in the host properties—as with the item before, open the host properties and copy the value for the hostid parameter from the URL. Also, don't forget to replace your correct authorization ID. With that number available, let's set our JSON variable:

$ json='{"jsonrpc":"2.0","method":"host.update","params":{"hostid":"10132","status":1},"auth":"df83119ab78bbeb2065049412309f9b4","id":1}'  
We got back to using an ID of 1. It really doesn't matter when using curl like this.

Run the curl command again; the output should look like the following:

{"jsonrpc":"2.0","result":{"hostids":["10132"]},"id":1} 

This should indicate success, and the host should be disabled—check the host state in the frontend. Enabling it again is easy, too:

$ json='{"jsonrpc":"2.0","method":"host.update","params":{"hostid":"10132","status":0},"auth":"df83119ab78bbeb2065049412309f9b4","id":1}'

Run the curl command again to re-enable this host.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.239.123