Forum Discussion

Wally_Steadman_'s avatar
Wally_Steadman_
Icon for Nimbostratus rankNimbostratus
Nov 13, 2012

Using PyControl for LTMs v9.4.8 through 11.2

So I am new to Python and IControl. I have built a python script that will take a list of hostnames and make sure they are reachable. This is a text file with the following format:

 

hostname1.mydomain.com

 

hostname2.mydomain.com

 

hostname3.mydomain.com

 

It runs fine, but now I want to log into the devices and find out what version of code they are running. I don't know how to have python be able to tell when it logs in if the Load Balancer is running version 9.4.8 or 10.2.4 or 11.2 as we have all three in our enivornment. I was trying to avoid having to write a script for each device type as that would be a management nightmare.

 

I have instally PyControl 2 and also BigSuds in my environment.

 

So basically the flow would be

 

Open File with LTM Hostnames

 

Read a line

 

Log into that host and find out the OS version

 

Pass the value to another text file

 

Rinse and Repeat for each line in the File

 

Close the File

 

Print out the newly created File

 

 

Since version 11.x doesn't support bpshell and v9.x doesn't support tmsh, I am not sure how to work this out.

 

Any advice, guidance or examples would be greatly appreciated

 

Thanks

 

Wally

 

 

2 Replies

  • I got it figured out after some reading. I see that IControl handles the different device types already so I am not able to get a list of hostnames and version of code.
  • Hello,

     

    For getting version of BIG-IP software can be used next code:

     

    !/usr/bin/python

     

    def get_version(obj):

     

    try:

     

    return obj.LocalLB.VirtualServer.get_version()

     

    except Exception, e:

     

    print e

     

     

    if __name__ == "__main__":

     

     

    import bigsuds

     

    import getpass

     

     

    f = open('./devices_list.txt', 'rU')

     

    o = open('./versions_list.txt', 'w')

     

    for list in f:

     

    b = bigsuds.BIGIP(

     

    hostname = list.rstrip(),

     

    username = "username",

     

    password = "password",)

     

    fstr = "Device %s is running version %s\n" % (list.rstrip(), get_version(b))

     

    o.write(fstr)

     

    print fstr.rstrip()

     

    f.close()

     

    o.close()

     

     

     

     

    Regards,

     

    Indrek