Forum Discussion
bitva_135199
Nimbostratus
Mar 07, 2016How to Create/Modify iApp via API?
Hi! I've been trying to follow some of the articles I've found around this but am having no luck. I think I'm missing something simple but not sure what yet. Any help you can give would be greatly ap...
JamesSevedge_23
Mar 07, 2016Historic F5 Account
The post removed my comment symbols out, below should be correct as it is in a code block.
!/bin/bash
This script will create an application service using the f5.http template. Commandline arg... -a is iapp name, -v is virtual server ip, -m is for pool member ip,
-b is the big ip address, -u is for username, -p for password (defaults of admin/admin if flags not present) -d is an optional paramater if you would like to delete the iapp.
Full Command would look like: ./createiapp_http.sh -b 2.2.2.2 -a httpapp -v 1.1.1.1 -m 1.1.1.2 -u admin -p admin
Full Command to delete would add the delete flag: ./createiapp_http.sh -b 2.2.2.2 -a httpapp -v 1.1.1.1 -m 1.1.1.2 -u admin -p admin -d
delete=false
user=admin
pwd=admin
while getopts a:v:b:u:p:m:d option
do case "$option" in
a) appname=$OPTARG;;
v) vsip=$OPTARG;;
m) pmember=$OPTARG;;
b) bigip=$OPTARG;;
u) user=$OPTARG;;
p) pwd=$OPTARG;;
d) delete=true;;
esac
done
echo "Delete equals: $delete"
echo "Connecting to BIG IP: $bigip as $user"
echo "iAPP Name: $appname"
echo "VS IP: $vsip"
echo "Pool Member: $pmember"
if [ $delete == false ] ; then
curl -sk -u $user:$pwd https://$bigip/mgmt/tm/sys/application/service/ -H 'Content-Type: application/json' -X POST -d '{"kind":"tm:sys:application:service:servicestate",
"name":'\"$appname\"',
"partition":"Common",
"execute-action":"definition",
"template":"/Common/f5.http",
"templateReference":{"link":"https://localhost/mgmt/tm/sys/application/template/~Common~f5.http?ver=12.0.0"},
"templateModified":"no",
"trafficGroup":"/Common/traffic-group-1",
"trafficGroupReference":{"link":"https://localhost/mgmt/tm/cm/traffic-group/~Common~traffic-group-1?ver=12.0.0"},
"tables":[{"name":"basic__snatpool_members"},
{"name":"net__snatpool_members"},
{"name":"optimizations__hosts"},
{"name":"pool__hosts",
"columnNames":["name"],"rows":[{"row":["test.test.com"]}]},
{"name":"pool__members",
"columnNames":["addr","port","connection_limit"],
"rows":[{"row":['\"$pmember\"',"80","0"]}]},
{"name":"server_pools__servers"}],
"variables":[{"name":"client__http_compression",
"encrypted":"no",
"value":"/create_new"},
{"name":"monitor__monitor",
"encrypted":"no","value":"/create_new"},
{"name":"monitor__response","encrypted":"no","value":"none"},
{"name":"monitor__uri","encrypted":"no","value":"/"},
{"name":"net__client_mode","encrypted":"no","value":"wan"},
{"name":"net__server_mode","encrypted":"no","value":"lan"},
{"name":"pool__addr","encrypted":"no","value":'\"$vsip\"'},
{"name":"pool__pool_to_use","encrypted":"no","value":"/create_new"},
{"name":"pool__port","encrypted":"no","value":"80"},
{"name":"asm__use_asm","value":"/do_not_use"},
{"name":"ssl__mode","encrypted":"no","value":"no_ssl"},
{"name":"ssl_encryption_questions__advanced","encrypted":"no","value":"no"},
{"name":"ssl_encryption_questions__help","encrypted":"no","value":"hide"}]}' | jq .
fi
if [ $delete == true ] ; then
curl -sk -u admin:admin https://$bigip/mgmt/tm/sys/application/service/~Common~$appname.app~$appname -H 'Content-Type: application/json' -X DELETE | jq .
echo "iAPP $appname deleted"
fi
bitva_135199
Nimbostratus
Mar 07, 2016Hey, thanks for the reply. What you're doing there is another way I was thinking of going about a full create/destroy of an iApp. But I still couldn't add or remove nodes without deleting the full iApp stack and recreating.
My understanding is I could resubmit with new/removed pool members or iRules right?
I've put the JSON file I'm trying to POST (or PUT for modify I assumed) here:
http://pastebin.com/8cWjMtk2
Thanks again!
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects