Forum Discussion
python rest api: How to get profiles details?
- Jun 13, 2019
This SelfLink doesn't contain any info regarding configuration. It's only a reference pointing itself.
Check this ->
# curl -sku admin:XXXX https://localhost/mgmt/tm/ltm/virtual/~Common~myvirtual/profiles/~Common~tcp | json-format { "kind": "tm:ltm:virtual:profiles:profilesstate", "name": "tcp", "partition": "Common", "fullPath": "/Common/tcp", "generation": 239, "selfLink": "https://localhost/mgmt/tm/ltm/virtual/~Common~myvirtual/profiles/~Common~tcp?ver\u003d12.1.4.1", "context": "all" }
But if you search just for the profile you have all the configuration ->
# curl -sku admin:XXXX https://localhost/mgmt/tm/ltm/profile/tcp/~Common~tcp | json-format { "kind": "tm:ltm:profile:tcp:tcpstate", "name": "tcp", "partition": "Common", "fullPath": "/Common/tcp", "generation": 1, "selfLink": "https://localhost/mgmt/tm/ltm/profile/tcp/~Common~tcp?ver\u003d12.1.4.1", "abc": "enabled", "ackOnPush": "enabled", "closeWaitTimeout": 5, ... }
So, as I have already said, you need to capture both queries and associate them.
KR,
Dario.
Hello.
To use SDK is similar of using iControl REST.
This command captures all the profile names bonded to a specific VS (without specifying category)
# https:// <F5_mgmt_IP>/mgmt/tm/ltm/virtual/<virtual_name>/profiles
And this command captures all Client SSL profiles configured in the device
# https:// <F5_mgmt_IP>/mgmt/tm/ltm/profile/client-ssl
If I want to associate what profiles from the first output are Client SSL profiles, I need to compare both outputs.
For SDK is the same.
# CAPTURE ALL CLIENT SSL PROFILES
client_ssls = session.tm.ltm.profile.client_ssls.get_collection()
# https:// <F5_mgmt_IP>/mgmt/tm/ltm/profile/client-ssl
# CAPTURE ALL VIRTUALS
virtuals = session.tm.ltm.virtuals.get_collection()
# https:// <F5_mgmt_IP>/mgmt/tm/ltm/virtual
# SHOW VS AND THEIR CLIENT SSL PROFILES
for virtual in virtuals:
print("------------")
print("Virtual: {}".format(virtual.name))
listClientSsl_inUse = []
for profile in virtual.profiles_s.get_collection():
# https:// <F5_mgmt_IP>/mgmt/tm/ltm/virtual/<virtual_name>/profiles
if profile.name in listClientSsl:
listClientSsl_inUse.append(profile.name)
if listClientSsl_inUse:
for prof in listClientSsl_inUse:
print("Client SSL: {}".format(prof))
else:
print("Client SSL: None")
I recommend you to check this example
https://devcentral.f5.com/s/articles/Displaying-VS-config-using-SDK
KR,
Dario.
Thanks a lot Dario. That is great! I wonder though, if there is a way to "load" the profile directly using the information provided by the profile object found in the virtual server.
In my code above, I get the profile in variable "p", which has an attribute "attrs", which pprinted looks like this:
{'context': 'all',
'fullPath': '/Common/udp',
'generation': 1,
'kind': 'tm:ltm:virtual:profiles:profilesstate',
'name': 'udp',
'partition': 'Common',
'selfLink': 'https://localhost/mgmt/tm/ltm/virtual/~Common~syslog-udp-514-vs/profiles/~Common~udp?ver=14.1.0.2'}
Is there a method load(p.selfLink) or something like that?
- Jun 13, 2019
This SelfLink doesn't contain any info regarding configuration. It's only a reference pointing itself.
Check this ->
# curl -sku admin:XXXX https://localhost/mgmt/tm/ltm/virtual/~Common~myvirtual/profiles/~Common~tcp | json-format { "kind": "tm:ltm:virtual:profiles:profilesstate", "name": "tcp", "partition": "Common", "fullPath": "/Common/tcp", "generation": 239, "selfLink": "https://localhost/mgmt/tm/ltm/virtual/~Common~myvirtual/profiles/~Common~tcp?ver\u003d12.1.4.1", "context": "all" }
But if you search just for the profile you have all the configuration ->
# curl -sku admin:XXXX https://localhost/mgmt/tm/ltm/profile/tcp/~Common~tcp | json-format { "kind": "tm:ltm:profile:tcp:tcpstate", "name": "tcp", "partition": "Common", "fullPath": "/Common/tcp", "generation": 1, "selfLink": "https://localhost/mgmt/tm/ltm/profile/tcp/~Common~tcp?ver\u003d12.1.4.1", "abc": "enabled", "ackOnPush": "enabled", "closeWaitTimeout": 5, ... }
So, as I have already said, you need to capture both queries and associate them.
KR,
Dario.
- Mohamed_LrhaziJun 13, 2019Altocumulus
Cool. I was hoping for a way to get the profile without even knowing it is an client_ssl or tcp profile... but I guess that's what the API provides. One needs to figure out what the all possible profile types are and how to pull them all, then perform lookups based on profile name, hoping that is unique.
Thank you so much.
- Jun 13, 2019
"Hoping" no. It must be unique 😊
(tmos)# create ltm profile client-ssl tcp 01070293:3: The profile name (/Common/tcp) is already assigned to another profile.
You are welcome.
KR,
Dario.
- Mohamed_LrhaziJun 14, 2019Altocumulus
Cool. though one needs to include the partition name too.
Recent Discussions
Related Content
* 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