Forum Discussion

Lingxu_217141's avatar
Lingxu_217141
Icon for Nimbostratus rankNimbostratus
Oct 25, 2018

How to read cert via F5 SDK in python ?

Hi All,

 

I am new to F5 iControl and iControlREST, but interested to do some auto work via iControlREST. I have a problem when try to read a existing ssl cert info by using F5 SDK. the code I wrote is: mgmt = ManagementRoot(ip, username, password) cert_a = mgmt.tm.sys.file.Ssl_Certs(a.crt) --but it says file has no attribute"Ssl_Certs" Can someone help, what is the right method to do similar as "tmsh list sys file ssl-cert a.crt" thanks.

 

2 Replies

  • F5 Python SDK is just a wrapper for iControl REST. Have you tested using a bare iControl REST call? e.g.,

     curl -sku : https:///mgmt/tm/sys/file/ssl-cert/default.crt | python -m json.tool
    
  • Python version here. Use lower cases for Ssl_Certs (ssl_certs)

    !/usr/bin/python
    
    from f5.bigip import ManagementRoot
    mgmt = ManagementRoot('192.168.184.40', 'admin', 'admin')
    
    cert = mgmt.tm.sys.file.ssl_certs.get_collection()
    for c in cert:
        print('--- {}'.format(c.raw['name']))
        for d in c.__dict__:
            print(' {}: {}'.format(d, c.raw[d]))