Forum Discussion
iControl to disable a virtual server
Hi, Apologies for probably asking a really basic question, but this is my first foray into iControl! We need to disable a virtualserver on our F5 during a maintenance window. I was looking into creating an iRule to check the date and then drop the connection if it was during the window, but it would be so much easier if we had an iControl app to just disable the service and then re-enable it when complete.
Using the iControl URL on our F5s I can see there are a bunch of different API objects, and each of those has a huge subset of SOAP commands - is it possible to get a simple SOAP post to "disable virtualserver1". I have had a bit of a dig around and can't see any examples which do this.
Thanks, Damian
8 Replies
- StephanManthey
Nacreous
Hi Damian,
maybe using REST is an option?
To retrieve a list of virtual server direct links you can use the following request:
curl -s -k -u admin:admin -H "Content-Type: application/json" -X GET https://localhost/mgmt/tm/ltm/virtual?\$select=selfLink | grep -ioE '"selfLink":"[^"]+"'It will return the links to access the virtual servers.
To enable / disable a specific virtual servers you can do the following:
curl -s -k -u admin:admin -H "Content-Type: application/json" -X PUT -d '{"enabled":true}' https://localhost/mgmt/tm/ltm/virtual/~Common~vs_101_8081 curl -s -k -u admin:admin -H "Content-Type: application/json" -X PUT -d '{"disabled":true}' https://localhost/mgmt/tm/ltm/virtual/~Common~vs_101_8081Thanks, Stephan
- damian_19221
Nimbostratus
Hi Stephan,
Thanks for the quick reply! using REST and curl would be an ideal option for us, but unfortunately I can't get the example you gave to work:
[damian@hp-elitebook-820 ~]$ curl -s -k -u admin:admin -H "Content-Type: application/json" -X GET https://10.241.100.11/mgmt/tm/ltm/virtual/~Common~vs_Bens_Test_VIP?ver=11.4.1 | sed -r 's/,(\{?")/,\n\1/g' {"code":404, "message":"http://localhost:8100/mgmt/tm/ltm/virtual/~Common~vs_Bens_Test_VIP?ver=11.4.1", "restOperationId":2287403, "errorStack":["com.f5.rest.common.RestWorkerUriNotFoundException: http://localhost:8100/mgmt/tm/ltm/virtual/~Common~vs_Bens_Test_VIP?ver=11.4.1", "at com.f5.rest.common.RestServer.trySendInProcess(RestServer.java:126)", "at com.f5.rest.common.RestRequestReceiver.dispatchToService(RestRequestReceiver.java:93)", "at com.f5.rest.common.RestRequestReceiver.processNext(RestRequestReceiver.java:57)", "at com.f5.rest.common.RestHelper$2.run(RestHelper.java:1480)", "at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)", "at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)",I've substituted "vs_101_8081" with the name of a test VS on our box (Bens_Test_VIP) and also updated with our version of the F5 firmware (1.4.1)
Thanks, Damian
- damian_19221
Nimbostratus
Actually I've made some progress... I didn't have the icrd running on my LTM. I can now run the first example you gave to describe my VS.
It's still failing with the below though:
curl -s -k -u admin:ourpassword -H "Content-Type: application/json" -X PUT -d '{"enabled":true}' https://10.241.100.11/mgmt/tm/ltm/virtual/~Common~Bens_Test_VIP{"code":400,"message":"Status code:400, uri:http://localhost:8110/tm/ltm/virtual/~Common~Bens_Test_VIP, body: {\"errorResponse\":\"{\\\"error\\\":{\\\"code\\\":400,\\\"message\\\":\\\"Found unexpected data at property /ltm/virtual/~Common~Bens_Test_VIP/enabled. The data is true.\\\"}}\",\"errorStack\":[]}","originalRequestBody":"{\"errorResponse\":\"{\\\"error\\\":{\\\"code\\\":400,\\\"message\\\":\\\"Found unexpected data at property /ltm/virtual/~Common~Bens_Test_VIP/enabled. The data is true.\\\"}}\",\"errorStack\":[]}","restOperationId":2290260,"errorStack":["java.net.ProtocolException: Status code:400, uri:http://localhost:8110/tm/ltm/virtual/~Common~Bens_Test_VIP, body: {\"errorResponse\":\"{\\\"error\\\":{\\\"code\\\":400,\\\"message\\\":\\\"Found unexpected data at property /ltm/virtual/~Common~Bens_Test_VIP/enabled. The data is true.\\\"}}\",\"errorStack\":[]}","at com.f5.rest.common.RestRequestSender.finish(RestRequestSender.java:412)","at com.f5.rest.common.RestRequestSender.processNext(RestRequestSender.java:397)","at com.f5.rest.common.RestHelper$2.run(RestHelper.java:1478)","at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)","at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)","at java.lang.Thread.run(Unknown Source)\n"]}
- StephanManthey
Nacreous
The syntax looks good. I tested in v11.5.1HF7. Will downgrade. Perhaps the attributes were renamed. To pull full list of attributes please just run: curl -s -k -u admin:admin -H "Content-Type: application/json" -X GET https://localhost/mgmt/tm/ltm/virtual? | sed -r 's/,(\{?")/,\n\1/g' - StephanManthey
Nacreous
Yepp, it was due to syntax change. This one works in v11.4.1: curl -s -k -u admin:admin -H "Content-Type: application/json" -X PUT -d '{"disabled":null}' https://localhost/mgmt/tm/ltm/virtual/vs_apitest curl -s -k -u admin:admin -H "Content-Type: application/json" -X PUT -d '{"enabled":null}' https://localhost/mgmt/tm/ltm/virtual/vs_apitest - damian_19221
Nimbostratus
AWESOME! That works,thanks a lot Stephan!!
- StephanManthey
Nacreous
Here is the right syntax to retrieve the proper links (was a bit in a hurry when answering):
curl -s -k -u admin:admin -H "Content-Type: application/json" -X GET https://localhost/mgmt/tm/ltm/virtual?\$select=selfLink | grep -ioE '"selfLink":"[^"]+"'
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com