Forum Discussion
Mark_Stradling_
May 31, 2016Cirrus
F5 Python SDK - How to Get Profiles on a Virtual
I am using the F5 python SDK. It is awesome. Very useful. I am not, however, able to figure out how to access the subcollection of monitors attached to a virtual object. Any one have any idea how to ...
Mark_Stradling_
Cirrus
Thanks for your reply. I've read through the documentation, and I've done the same for things like pool members and other subcollections, but profiles seem different. The virtual object does not have an attribute "profiles." It does, however, have an attribute called "profilesReference". I cannot enumerate it though. Here is the output i get when I try to enumerate it:
virt = srcf5.tm.ltm.virtuals.virtual.load(partition="Common", name="my.virt.com")
for profile in virt.profilesReferences.get_collection():
print profile.name
`
(I also tried profilesReference_s, profilesReferences, and profilesReference just in case)
results in:
`Traceback (most recent call last):
File "./profiles.py", line 31, in <module>
for profile in virt.profilesReference.get_collection():
AttributeError: 'dict' object has no attribute 'get_collection'</module>
`
If I just try to print the profilesReference attribute I get a self link to the object which I suppose I could craft my own rest request to utilize. I was just hoping the f5 sdk would be able to handle the profile subcollection like it does pool members
`{u'isSubcollection': True, u'link': u'https://localhost/mgmt/tm/ltm/virtual/~Common~my.virt.com/profiles?ver=11.6.0'}
tatmotiv
Jun 02, 2016Cirrostratus
RE: The virtual object does not have an attribute "profiles."
You are right, but that's what I already mentioned. It does have a "Profiles_s" subcollection class though, as you also can see here:
https://github.com/F5Networks/f5-common-python/blob/0.1/f5/bigip/tm/ltm/virtual.py
The code snippet I provided above works for me. It outputs a list of profile names.
I'm using f5-Python SDK version 0.1
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