Forum Discussion
DarioGB_339840
Jul 04, 2018Altostratus
Check if property exists in F5 SDK Python
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.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects