Forum Discussion
Python data class values
Hi Kevin,
I'm not sure how to accomplish this with bigsuds but here's the solution with the Python SDK.
from f5.bigip import ManagementRoot
import urllib3
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
mgmt = ManagementRoot('192.168.1.1', 'admin', 'admin')
dgrp = mgmt.tm.ltm.data_group.internals.get_collection()
for datagroup in dgrp:
print(datagroup.name)
for record in datagroup.records:
print(record)
- Kevin_DaviesAug 02, 2018MVP
Joel can you provide an example of retrieving the data group values. I am trying data = bigip.ltm.data_group.internal.load(name='k2test',partition='Common') and its failing
- Joel_Breton_260Aug 02, 2018Nimbostratus
Hi Kevin,
The exemple above displays all the datagroups and their values. If you want a specific datagroup to display here`s how I was able to achieve it
from f5.bigip import ManagementRoot import urllib3 import requests from requests.packages.urllib3.exceptions import InsecureRequestWarning requests.packages.urllib3.disable_warnings(InsecureRequestWarning) mgmt = ManagementRoot('192.168.1.1', 'admin', 'admin') dgrp = mgmt.tm.ltm.data_group.internals.get_collection() for datagroup in dgrp: if (datagroup.name=='aol'): print(datagroup.name) print(datagroup.records)
Here`s an exemple of the output:
aol [{'name': '64.12.96.0/19', 'data': ''}, {'name': '195.93.16.0/20', 'data': ''}, {'name': '195.93.48.0/22', 'data': ''}, {'name': '195.93.64.0/19', 'data': ''}, {'name': '195.93.96.0/19', 'data': ''}, {'name': '198.81.0.0/22', 'data': ''}, {'name': '198.81.8.0/23', 'data': ''}, {'name': '198.81.16.0/20', 'data': ''}, {'name': '202.67.65.128/25', 'data': ''}, {'name': '205.188.112.0/20', 'data': ''}, {'name': '205.188.146.144/30', 'data': ''}, {'name': '205.188.192.0/20', 'data': ''}, {'name': '205.188.208.0/23', 'data': ''}, {'name': '207.200.112.0/21', 'data': ''}]
- Kevin_DaviesAug 02, 2018MVP
Thanks Joel, I did figure it out in the end. The naming convention is a little strange.
data = bigip.ltm.data_group.internals.internal.load(name='k2test',partition='Common')
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