... and a sample python code.
The code becomes complex because the data type of the allowService field value depends on what you specify.
Allow All is a string: 'all'
Allow default is a list containing the string default: ['default']
Allow none is represented by absence of the allowService field.
The code is not sophisticated and there should be a better way, but at least it does the job for you.
!/usr/bin/env python
from f5.bigip import ManagementRoot
mgmt = ManagementRoot('xx.xx.xx.xx', 'admin', 'adminPass')
def showSelfIp(str):
selfIp = mgmt.tm.net.selfips.get_collection()
selfIpList = {ip.raw['name']: ip for ip in selfIp}
print('--- {}'.format(str))
for ip, obj in selfIpList.iteritems():
try:
allowService = obj.raw['allowService']
except KeyError:
allowService = 'None'
allowServiceType = type(allowService)
print('{:<20}{:<20}{}'.format(ip, allowService, allowServiceType))
return selfIpList
# Get a list of selfIP
selfIpList = showSelfIp('Before')
# Change allowService of 'vmnet1-self' from 'all' to 'default' ([list])
selfIp1 = selfIpList['vmnet1-self']
selfIp1.raw['allowService'] = ['default']
selfIp1.update()
selfIpList = showSelfIp('vmnet1-self to default')
# Change allowService from 'default' to 'all' (string)
selfIp2 = selfIpList['vmnet2-self']
selfIp2.raw['allowService'] = 'all'
selfIp2.update()
selfIpList = showSelfIp('vmnet2-self to all')
# Change allowService from 'default' to 'None' (no field)
selfIp3 = selfIpList['vmnet3-self']
del selfIp3.raw['allowService']
selfIp3.update()
selfIpList = showSelfIp('vmnet3-self to None')
# Done