In my last (horribly misspelled in earlier versions) blog post on this subject we looked at how to deploy a new application service from an iApp template using an iControl REST API call.
So far so good. Now I want to update this application service programmatically. Let’s say I’m adding a pool member, a fairly common task. I’ve got a couple of options here. I could switch off the ‘strict updates’ setting in the template, then I could use REST commands to create a new node and pool member. Then I probably want to turn the strict updates setting back on. Not too difficult, but it’s multiple calls and I’m pretty lazy.
Much better to take advantage of the fact that iApp templates are reentrant (file that word with other ones I nearly always have to look up to properly understand. See also: idempotent). What this means is I can modify the template or the values and simply redeploy the template – really only the changed values and settings are applied. I can even change the template and redeploy – but that’s beyond this simple introduction.
So, in theory, I can just make the same call again with some additional values. All I need to do is edit my original REST POST call and I should be reconfiguring my application service on the fly.
Yes and no. It turns out there are a few things I need to modify and change. The first is that I’m not using the POST method any more – POST is for new things. For modifying I need to use PUT. That’s an easy change in the Advanced REST Client.
Now, we’re also going to need to make some changes in our body too, first and most obvious is the addition of the extra pool member.
So far this all makes logical sense. The next change is a little more obscure. We need to add this line to the payload
This is the REST equivalent of the “Finished” button. If you don’t have this line your call will execute, you will get a nice 200 OK response code, but nothing will happen. It’s kind of like telling your teenager to do something. They nod, smile and promise to get on with it, but nothing seems to actually happen. If only there was a setting for that.
Hopefully these posts have served as a basic introduction to using REST and iApp templates. Next we might take a look at something a bit more scalable than the Advanced REST client and see how to use common tools to automate BIG-IP’s using REST and iApps. Comment below if there is a tool you would particularly like to see tested.