Forum Discussion
Kevin_Davies_40
Sep 22, 2017Nacreous
Python data class values
I have some python code (bigsuds) I use to display data class members names but do not know how to display the data group values. What I would like is to output the following name value
name val...
Joel_Breton
Nimbostratus
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)
Joel_Breton
Aug 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': ''}]
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