Skip to content

Commit

Permalink
Merge pull request #14 from ssorenso/feature.updating_common_f5_14930…
Browse files Browse the repository at this point in the history
…55588_5

Feature.updating common f5 ecb43646dec4eea8c6c3c4e6ed0629befff3a9e8
  • Loading branch information
andrewjjenkins authored Apr 24, 2017
2 parents 6209c92 + 5de9b04 commit e7ed78d
Showing 1 changed file with 34 additions and 32 deletions.
66 changes: 34 additions & 32 deletions f5_cccl/_f5.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,26 +328,6 @@ def _apply_config(self, config):
log_sequence('cloud_pool_list', cloud_pool_list)
log_sequence('cloud_virtual_list', cloud_virtual_list)

# virtual delete
virt_delete = list_diff(f5_virtual_list, cloud_virtual_list)
log_sequence('Virtual Servers to delete', virt_delete)
for virt in virt_delete:
self.virtual_delete(partition, virt)

# pool delete
pool_delete_list = list_diff(f5_pool_list, cloud_pool_list)
log_sequence('Pools to delete', pool_delete_list)
for pool in pool_delete_list:
self.pool_delete(partition, pool)

# healthcheck delete
health_delete = list_diff(f5_healthcheck_list,
cloud_healthcheck_list)
log_sequence('Healthchecks to delete', health_delete)
for hc in health_delete:
self.healthcheck_delete(partition, hc,
f5_healthcheck_dict[hc]['type'])

# healthcheck config needs to happen before pool config because
# the pool is where we add the healthcheck
# healthcheck add: use the name of the virt for the healthcheck
Expand Down Expand Up @@ -398,6 +378,26 @@ def _apply_config(self, config):
for virt in virt_intersect:
self.virtual_update(partition, virt, config[virt])

# virtual delete
virt_delete = list_diff(f5_virtual_list, cloud_virtual_list)
log_sequence('Virtual Servers to delete', virt_delete)
for virt in virt_delete:
self.virtual_delete(partition, virt)

# pool delete
pool_delete_list = list_diff(f5_pool_list, cloud_pool_list)
log_sequence('Pools to delete', pool_delete_list)
for pool in pool_delete_list:
self.pool_delete(partition, pool)

# healthcheck delete
health_delete = list_diff(f5_healthcheck_list,
cloud_healthcheck_list)
log_sequence('Healthchecks to delete', health_delete)
for hc in health_delete:
self.healthcheck_delete(partition, hc,
f5_healthcheck_dict[hc]['type'])

# add/update/remove pool members
# need to iterate over pool_add and pool_intersect (note that
# removing a pool also removes members, so don't have to
Expand Down Expand Up @@ -561,22 +561,24 @@ def pool_update(self, partition, pool, data):
data = data['pool']
pool = self.get_pool(partition, pool)

def genChange(p, d):
"""Update pool members config data."""
def find_change(p, d):
"""Check if data for pool has been updated."""
for key, val in p.__dict__.iteritems():
if key in d:
if None is not val:
yield d[key] == val.strip()
else:
yield d[key] == val

no_change = all(genChange(pool, data))

if no_change:
if val is not None and (d[key] != val.strip()):
return True
elif (d[key] != val):
return True
for key, _ in d.iteritems():
if key not in p.__dict__:
return True
return False

pool.modify(**data)
return True
if find_change(pool, data):
pool.modify(**data)
return True

return False

def get_member(self, partition, pool, member):
"""Get a pool-member object.
Expand Down

0 comments on commit e7ed78d

Please sign in to comment.