Created
March 28, 2019 00:52
-
-
Save jpboyce/56c54a32637645d2fbece61ac1cd3d91 to your computer and use it in GitHub Desktop.
Set the state of a F5 Pool Member
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This snippet expects the following inputs: | |
- memberName (string) | |
- memberPort (number) | |
- poolName (string) | |
- restOperation (REST:RESTOperation) | |
- state (string) | |
restOperation will be a RESTOperation object that uses the URL for setting a Pool Member's state | |
*/ | |
// Construct payload based on the state value | |
switch(state) { | |
case "enable": | |
// | |
payload = '{"state": "user-up", "session": "user-enabled"}'; | |
break; | |
case "disable": | |
// | |
payload = '{"state": "user-up", "session": "user-disabled"}'; | |
break; | |
case "forceoffline": | |
// | |
payload = '{"state": "user-down", "session": "user-disabled"}'; | |
break; | |
default: | |
// throw an error | |
throw "An invalid value (" + state + ") was submitted for the input parameter state"; | |
} | |
System.log("Payload value has been set to: " + payload); | |
// Set inputs for the REST call | |
var inputs = [poolName,memberName,memberPort]; | |
// Create request | |
var request = restOperation.createRequest(inputs,payload); | |
// Execute request | |
var response = request.execute(); | |
// Parse and output response | |
var jsonObject = JSON.parse(response.contentAsString); | |
System.log(response.contentAsString); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment