1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fixes the bigip_selfip module to respect traffic groups (#3009)

The code for traffic groups was not being tested and therefore
had errors associated with it. It is now covered in coverage tests
and bugs that were found in it have been fixed.

See this issue for details
https://github.com/F5Networks/f5-ansible/issues/28
This commit is contained in:
Tim Rupp 2016-09-22 23:20:19 -07:00 committed by Matt Clay
parent 4ff086c1a8
commit 15df1c84ad

View file

@ -367,6 +367,20 @@ class BigIpSelfIp(object):
else:
return list(services)
def traffic_groups(self):
result = []
groups = self.api.tm.cm.traffic_groups.get_collection()
for group in groups:
# Just checking for the addition of the partition here for
# different versions of BIG-IP
if '/' + self.params['partition'] + '/' in group.name:
result.append(group.name)
else:
full_name = '/%s/%s' % (self.params['partition'], group.name)
result.append(str(full_name))
return result
def update(self):
changed = False
svcs = []
@ -408,8 +422,11 @@ class BigIpSelfIp(object):
)
if traffic_group is not None:
groups = self.api.tm.cm.traffic_groups.get_collection()
params['trafficGroup'] = "/%s/%s" % (partition, traffic_group)
traffic_group = "/%s/%s" % (partition, traffic_group)
if traffic_group not in self.traffic_groups():
raise F5ModuleError(
'The specified traffic group was not found'
)
if 'traffic_group' in current:
if traffic_group != current['traffic_group']:
@ -417,11 +434,6 @@ class BigIpSelfIp(object):
else:
params['trafficGroup'] = traffic_group
if traffic_group not in groups:
raise F5ModuleError(
'The specified traffic group was not found'
)
if vlan is not None:
vlans = self.get_vlans()
vlan = "/%s/%s" % (partition, vlan)
@ -527,9 +539,9 @@ class BigIpSelfIp(object):
if traffic_group is None:
params['trafficGroup'] = "/%s/%s" % (partition, DEFAULT_TG)
else:
groups = self.api.tm.cm.traffic_groups.get_collection()
if traffic_group in groups:
params['trafficGroup'] = "/%s/%s" % (partition, traffic_group)
traffic_group = "/%s/%s" % (partition, traffic_group)
if traffic_group in self.traffic_groups():
params['trafficGroup'] = traffic_group
else:
raise F5ModuleError(
'The specified traffic group was not found'