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

Netscaler - less intrusive algorithm for syncing cs_policybindings (#32855)

* use less intrusive algorithm for syncing cs_policybindings

* fix some pylint and pep issues

* fix one other pylint and pep issue

* fix two lines between methods
This commit is contained in:
John Walsh 2017-11-22 10:56:12 -05:00 committed by John R Barker
parent 69575e25d0
commit aa42a2680e

View file

@ -667,17 +667,28 @@ def cs_policybindings_identical(client, module):
def sync_cs_policybindings(client, module):
log('Syncing cs policybindings')
actual_bindings = get_actual_policybindings(client, module)
configured_bindings = get_configured_policybindings(client, module)
# Delete all actual bindings
for binding in get_actual_policybindings(client, module).values():
log('Deleting binding for policy %s' % binding.policyname)
csvserver_cspolicy_binding.delete(client, binding)
# Delete actual bindings not in configured
delete_keys = list(set(actual_bindings.keys()) - set(configured_bindings.keys()))
for key in delete_keys:
log('Deleting binding for policy %s' % key)
csvserver_cspolicy_binding.delete(client, actual_bindings[key])
# Add all configured bindings
# Add configured bindings not in actual
add_keys = list(set(configured_bindings.keys()) - set(actual_bindings.keys()))
for key in add_keys:
log('Adding binding for policy %s' % key)
configured_bindings[key].add()
for binding in get_configured_policybindings(client, module).values():
log('Adding binding for policy %s' % binding.policyname)
binding.add()
# Update existing if changed
modify_keys = list(set(configured_bindings.keys()) & set(actual_bindings.keys()))
for key in modify_keys:
if not configured_bindings[key].has_equal_attributes(actual_bindings[key]):
log('Updating binding for policy %s' % key)
csvserver_cspolicy_binding.delete(client, actual_bindings[key])
configured_bindings[key].add()
def ssl_certkey_bindings_identical(client, module):