cancel
Showing results for 
Search instead for 
Did you mean: 

Check if property exists in F5 SDK Python

DarioGB_339840
Nimbostratus
Nimbostratus

Hello.

 

After get a virtual server collection, I'm looking for a method to validate if an specific resource property exists, for example pools & rules, which are optional parameters.

 

Next below, three ways with errors:

 

virtuals = session.tm.ltm.virtuals.get_collection() for virtual in virtuals: if virtual.pool != None: print(virtual.pool) --->> AttributeError: '' object has no attribute 'pool' if virtual.get('pool') != None: print(virtual.pool) --->> AttributeError: '' object has no attribute 'get' if virtual['pool'] != None: print(virtual.pool) --->> TypeError: 'Virtual' object is not subscriptable

Same way for rules :-S

 

I'm newbie in python. How do you do this in your scenarios?

 

Thanks in advance!

 

KR, Dario.

 

1 REPLY 1

Already found a solution here.

 

Likewise, thanks.

 

Regards,
Dario.