Forum Discussion

atatps_250754's avatar
atatps_250754
Icon for Altocumulus rankAltocumulus
Mar 05, 2018
Solved

Syntax Error when deploying iApp template using iControl ReST API

I have an iApp template that works great through TMSH but due to need for automation, I must to be able to deploy it via ReST.

**Command:**
curl -sku admin:admin -X POST -H "Content-type: application/json" -d "{\"command\":\"run\", \"utilCmdArgs\": \"-c 'tmsh create sys app template iApp-Automation-Test'\"}" [https://LTM/mgmt/tm/util/bash](https://LTM/mgmt/tm/util/bash)

**Output:**
{"kind":"tm:util:bash:runstate","command":"run","utilCmdArgs":"-c 'tmsh create sys app template iApp-Automation-Test'",**"commandResult":"01070734:3: Configuration error: An application template (/Common/iApp-Automation-Test) must define a \"definition\" action\n"**}

The above output tells me the command is working just like in TMSH so like in TMSH, I included the complete template script with the "definition":

**Command:**
curl -sku admin:admin -X POST -H "Content-type: application/json" -d "{\"command\":\"run\", \"utilCmdArgs\": \"-c 'tmsh create sys app template iApp-Automation-Test { actions replace-all-with { definition { html-help {} implementation { tmsh::create { ltm node 10.111.222.102 address 10.111.222.102 } tmsh::create { ltm node 10.111.222.103 address 10.111.222.103 } tmsh::create { ltm pool iApp-Automation-Test-ebiz-http members replace-all-with { 10.111.222.102:80 { address 10.111.222.102 } 10.111.222.103:80 { address 10.111.222.103 } } monitor http  } } macro { } presentation {  insert apl script } } } description none requires-bigip-version-max none requires-bigip-version-min none requires-modules none } '\"}" [https://LTM/mgmt/tm/util/bash](https://LTM/mgmt/tm/util/bash)

**Output**
{"kind":"tm:util:bash:runstate","command":"run","utilCmdArgs":"-c 'tmsh create sys app template iApp-Automation-Test { actions replace-all-with { definition { html-help {} implementation { tmsh::create { ltm node 10.111.222.102 address 10.111.222.102 } tmsh::create { ltm node 10.111.222.103 address 10.111.222.103 } tmsh::create { ltm pool iApp-Automation-Test-ebiz-http members replace-all-with { 10.111.222.102:80 { address 10.111.222.102 } 10.111.222.103:80 { address 10.111.222.103 } } monitor http  } } macro {} presentation {} } } description none requires-bigip-version-max none requires-bigip-version-min none requires-modules none } '",**"commandResult":"Syntax Error: \"actions\" may not be specified in the context of the \"create\" command. \"actions\" may be specified using the following commands: edit, list, modify\n"**}   

Any input on how to format this command properly is greatly appreciated.

  • After much experimentation, I got it working. For anyone else who may find this useful:

     

    This is the original TMSH method of creating an iApp template:

     

    create test_template {
    actions replace-all-with {
    definition {
    html-help {
    
    }
    implementation {
    tmsh::create {
    ltm node 10.111.222.102
    address 10.111.222.102
    }
    tmsh::create {
    ltm node 10.111.222.103
    address 10.111.222.103
    }
    
    tmsh::create {
    ltm pool iApp-Automation-Test-ebiz-http
    members replace-all-with {
    10.111.222.102:80 {
    address 10.111.222.102
    }
    10.111.222.103:80 {
    address 10.111.222.103
    }
    }
    monitor http 
    }
    
    }
    macro {
    }
    presentation {
     insert apl script
    }
    }
    }
    description none
    requires-bigip-version-max none
    requires-bigip-version-min none
    requires-modules none
    }

    To convert the TMSH template code to ReST client (ARC or POSTMAN) syntax, you must replace all the line breaks with \n. In our case it would look like this:

     

    Method: POST
    URL: https://ltmip/mgmt/tm/sys/application/template/
    Body: {"name":"test_template","actions":[{"name":"definition","htmlHelp":"","implementation":"tmsh::create { \n ltm node 10.111.222.102 \n address 10.111.222.102 \n } \n tmsh::create { \n ltm node 10.111.222.103 \n address 10.111.222.103 \n } \n  \n tmsh::create { \n ltm pool iApp-Automation-Test-ebiz-http \n members replace-all-with { \n 10.111.222.102:80 { \n address 10.111.222.102 \n } \n 10.111.222.103:80 { \n address 10.111.222.103 \n } \n } \n monitor http  \n }","macro":"","roleAcl":["admin","manager","resource-admin"],"presentation":""}],"totalSigningStatus":"not-all-signed","requiresBigipVersionMax":"","ignoreVerification":"false","requiresModules":[""],"requiresBigipVersionMin":"11.0.0"}

    To convert to CURL, the additional step of escaping all the quotation marks must be taken:

     

    curl -sku admin:admin -X POST -H "Content-type: application/json" -d "{\"name\":\"test_template\",\"actions\":[{\"name\":\"definition\",\"htmlHelp\":\"\",\"implementation\":\"tmsh::create { \n ltm node 10.111.222.102 \n address 10.111.222.102 \n } \n tmsh::create { \n ltm node 10.111.222.103 \n address 10.111.222.103 \n } \n  \n tmsh::create { \n ltm pool iApp-Automation-Test-ebiz-http \n members replace-all-with { \n 10.111.222.102:80 { \n address 10.111.222.102 \n } \n 10.111.222.103:80 { \n address 10.111.222.103 \n } \n } \n monitor http  \n }\",\"macro\":\"\",\"roleAcl\":[\"admin\",\"manager\",\"resource-admin\"],\"presentation\":\"\"}],\"totalSigningStatus\":\"not-all-signed\",\"requiresBigipVersionMax\":\"\",\"ignoreVerification\":\"false\",\"requiresModules\":[\"\"],\"requiresBigipVersionMin\":\"11.0.0\"}" https://ltmip/mgmt/tm/sys/application/template

    Hope somebody finds this useful.

     

2 Replies

  • I understand iApps are not a common topic on here. I researched the issue pretty thoroughly and came across several options two of which are the "Application Services Integration iApp" and this article. The first utilizes python and will not work in my environment, the second option was more viable but my template, unlike the one in the article does not use use "presentation" code and thus I could not find a way of specifying my VS/pools/nodes...etc. Somebody must have run into this before...

     

  • After much experimentation, I got it working. For anyone else who may find this useful:

     

    This is the original TMSH method of creating an iApp template:

     

    create test_template {
    actions replace-all-with {
    definition {
    html-help {
    
    }
    implementation {
    tmsh::create {
    ltm node 10.111.222.102
    address 10.111.222.102
    }
    tmsh::create {
    ltm node 10.111.222.103
    address 10.111.222.103
    }
    
    tmsh::create {
    ltm pool iApp-Automation-Test-ebiz-http
    members replace-all-with {
    10.111.222.102:80 {
    address 10.111.222.102
    }
    10.111.222.103:80 {
    address 10.111.222.103
    }
    }
    monitor http 
    }
    
    }
    macro {
    }
    presentation {
     insert apl script
    }
    }
    }
    description none
    requires-bigip-version-max none
    requires-bigip-version-min none
    requires-modules none
    }

    To convert the TMSH template code to ReST client (ARC or POSTMAN) syntax, you must replace all the line breaks with \n. In our case it would look like this:

     

    Method: POST
    URL: https://ltmip/mgmt/tm/sys/application/template/
    Body: {"name":"test_template","actions":[{"name":"definition","htmlHelp":"","implementation":"tmsh::create { \n ltm node 10.111.222.102 \n address 10.111.222.102 \n } \n tmsh::create { \n ltm node 10.111.222.103 \n address 10.111.222.103 \n } \n  \n tmsh::create { \n ltm pool iApp-Automation-Test-ebiz-http \n members replace-all-with { \n 10.111.222.102:80 { \n address 10.111.222.102 \n } \n 10.111.222.103:80 { \n address 10.111.222.103 \n } \n } \n monitor http  \n }","macro":"","roleAcl":["admin","manager","resource-admin"],"presentation":""}],"totalSigningStatus":"not-all-signed","requiresBigipVersionMax":"","ignoreVerification":"false","requiresModules":[""],"requiresBigipVersionMin":"11.0.0"}

    To convert to CURL, the additional step of escaping all the quotation marks must be taken:

     

    curl -sku admin:admin -X POST -H "Content-type: application/json" -d "{\"name\":\"test_template\",\"actions\":[{\"name\":\"definition\",\"htmlHelp\":\"\",\"implementation\":\"tmsh::create { \n ltm node 10.111.222.102 \n address 10.111.222.102 \n } \n tmsh::create { \n ltm node 10.111.222.103 \n address 10.111.222.103 \n } \n  \n tmsh::create { \n ltm pool iApp-Automation-Test-ebiz-http \n members replace-all-with { \n 10.111.222.102:80 { \n address 10.111.222.102 \n } \n 10.111.222.103:80 { \n address 10.111.222.103 \n } \n } \n monitor http  \n }\",\"macro\":\"\",\"roleAcl\":[\"admin\",\"manager\",\"resource-admin\"],\"presentation\":\"\"}],\"totalSigningStatus\":\"not-all-signed\",\"requiresBigipVersionMax\":\"\",\"ignoreVerification\":\"false\",\"requiresModules\":[\"\"],\"requiresBigipVersionMin\":\"11.0.0\"}" https://ltmip/mgmt/tm/sys/application/template

    Hope somebody finds this useful.