Forum Discussion

Arindam_Majumd1's avatar
Arindam_Majumd1
Icon for Nimbostratus rankNimbostratus
Apr 22, 2019

how can i create a virtual server with properties set, profiles and vlans attached?

This question is on iControl REST, how can I want create a virtual server with appropriate properties set, profiles and vlans set? the iControl doc does not have such references, is there any other relevant documentation to look at?

 

3 Replies

  • Hi,

    here the documentation you need:

    https://devcentral.f5.com/d/icontrol-rest-user-guide-version-131-246

    Here, you can folow this lab, it will show you how to use API rest (you can download Postman_collection with request already built for vs, pool, ... creation)

    http://clouddocs.f5.com/training/community/programmability/html/class1/module1/lab2.html

    Below, an example with curl:

    1.1.1.1 is you management IP

    1 - authentication, retrieve token

    This token will be re-use on the next steps...

    curl -k -X POST -H "Content-Type: application/json" -d '{"username":"restapiuser","password":"restapiuser","loginProviderName": "tmos"}' https://1.1.1.1/mgmt/shared/authn/login

    In response you should retrieve a token ...":{"token":"2MBZTX4RV2QKQDXWDRGG4XAETU"....

    You have to reuse this token in order to access to F5

    2 - monitor creation

    curl -k -X POST -H "Content-Type: application/json" -H "X-F5-Auth-Token:2MBZTX4RV2QKQDXWDRGG4XAETU" -d '{"name":"my-monitor-api","send":"GET / HTTP/1.1\r\nHost: mymonitor.mydomain.com\r\nConnection: Close\r\n\r\n","recv":""}' https://1.1.1.1/mgmt/tm/ltm/monitor/http

    3 - pool creation

    curl -k -X POST -H "Content-Type: application/json" -H "X-F5-Auth-Token:2MBZTX4RV2QKQDXWDRGG4XAETU" -d '{"name":"my-pool-api","monitor":"/Common/my-monitor-api"}' https://1.1.1.1/mgmt/tm/ltm/pool

    4 - http profile creation

    curl -k -X POST -H "Content-Type: application/json" -H "X-F5-Auth-Token:2MBZTX4RV2QKQDXWDRGG4XAETU" -d '{"name":"my-http-profile-api","insertXforwarderFor":"enabled","serverAgentName":"spirit"}' https://1.1.1.1/mgmt/tm/ltm/profile/http

    5 - vs creation

    curl -k -X POST -H "Content-Type: application/json" -H "X-F5-Auth-Token:2MBZTX4RV2QKQDXWDRGG4XAETU" -d '{"name":"my-vs-api","destination":"1.2.3.4:80","ipProtocol":"tcp","pool":"/Common/my-pool-api","sourceAddressTranslation":{"type":"automap"},"profiles": [{"name":"/Common/tcp", "context":"clientside" },{"name":"/Common/tcp-wan-optimized", "context":"serverside" },"/Common/my-http-profile-api"]}' https://1.1.1.1/mgmt/tm/ltm/virtual

    You have also a great article:

    https://devcentral.f5.com/codeshare/rest-api-calls-to-create-a-virtual-server-1100

    regards

  • To get the information of a pool, call GET /mgmt/tm/ltm/pool/<poolName>: e.g.,

    curl -sku <user>:<pass> https://<mgmtIP>/mgmt/tm/ltm/pool/<poolName>

     

    Because the pool members are stored as a subcollection, they are shown only as links. If you want to expand the subcollection, append the 'expandSubcollections' query option to the call: e.g.,

     

    curl -sku <user>:<pass> https://<mgmtIP>/mgmt/tm/ltm/pool/<poolName>?expandSubcollections=true