Forum Discussion

Zdenda's avatar
Zdenda
Icon for Cirrus rankCirrus
Jun 15, 2015

Best choice for automation

Hi, have been playing with automation for a while and so far I've been using excel templates generating tmsh codes I need. Lately I started to play with iControl REST and my excel generates API commands instead of tmsh commands - I did it mostly as template for our automation guys whose are developing applications (orchestrators) able to make a calls to devices (cisco, LBs) and create needed config (partition, VIPs, openings in AFM).

 

I have a feeling API REST is the easiest way to use API. But our automation team somehow wants still to use tmsh for sending a commands into LB instead of API REST commands. Creating scripts for TMSH is easier for me as well, but it looks like it is not a trend, but API is.

 

Now the question - as I have to somehow convince our automation team to use API and not bought modules from 3rd parties which can communicate with our LBs through SSH (TMSH).

 

  1. So what can be the benefit of having API REST for orchesrating since we could do the same using TMSH?
  2. I already played with API REST using CURL and I was able to create almost everything. But is the correct way to not use directly these commands (calling them inside PHP for example), but rather create functions in PERL/Python and then call these functions?
  3. Is it so there is no library of all tmsh commands available for PERL/Python and we have to firstly write each function by ourselves before we can use it?

I am still quite new in this, any advice would really help me.

 

Thanks, Zdenek

 

1 Reply

  • Python was easiest for me. Look how simple this is:

    !/usr/bin/python3.4
    
    import requests,json
    
    def provisionSoftwareModule(ipAddress,verifyHttpsCert,userName,password,moduleName,provisioningLevel):
      payload = {}
      payload['name'] = moduleName
      payload['level'] = provisioningLevel
      apiCall = requests.session()
      apiCall.auth = (userName, password) 
      apiCall.verify = verifyHttpsCert
      apiCall.headers.update({'Content-Type' : 'application/json'})
      apiUrl = 'https://' + ipAddress + '/mgmt/tm/sys/provision/' + moduleName
      apiResponse = apiCall.put(apiUrl,data=json.dumps(payload))
      if not '"generation"' in apiResponse.text:
        print(apiResponse.text)
    
    provisionSoftwareModule('192.168.1.1',False,'admin','mypassword','ltm','nominal')