def sync_monitor_bindings(client, module, monitor_bindings_rw_attrs): configured_proxys = get_configured_monitor_bindings( client, module, monitor_bindings_rw_attrs) actual_bindings = get_actual_monitor_bindings(client, module) configured_keyset = set(configured_proxys.keys()) actual_keyset = set(actual_bindings.keys()) # Delete extra delete_keys = list(actual_keyset - configured_keyset) for monitor_name in delete_keys: log('Deleting binding for monitor %s' % monitor_name) lbmonitor_service_binding.delete(client, actual_bindings[monitor_name]) # Delete and re-add modified common_keyset = list(configured_keyset & actual_keyset) for monitor_name in common_keyset: proxy = configured_proxys[monitor_name] actual = actual_bindings[monitor_name] if not proxy.has_equal_attributes(actual): log('Deleting and re adding binding for monitor %s' % monitor_name) lbmonitor_service_binding.delete(client, actual) proxy.add() # Add new new_keys = list(configured_keyset - actual_keyset) for monitor_name in new_keys: log('Adding binding for monitor %s' % monitor_name) configured_proxys[monitor_name].add()
def sync_monitor_bindings(client, module, monitor_bindings_rw_attrs): configured_proxys = get_configured_monitor_bindings(client, module, monitor_bindings_rw_attrs) actual_bindings = get_actual_monitor_bindings(client, module) configured_keyset = set(configured_proxys.keys()) actual_keyset = set(actual_bindings.keys()) # Delete extra delete_keys = list(actual_keyset - configured_keyset) for monitor_name in delete_keys: log('Deleting binding for monitor %s' % monitor_name) lbmonitor_service_binding.delete(client, actual_bindings[monitor_name]) # Delete and re-add modified common_keyset = list(configured_keyset & actual_keyset) for monitor_name in common_keyset: proxy = configured_proxys[monitor_name] actual = actual_bindings[monitor_name] if not proxy.has_equal_attributes(actual): log('Deleting and re adding binding for monitor %s' % monitor_name) lbmonitor_service_binding.delete(client, actual) proxy.add() # Add new new_keys = list(configured_keyset - actual_keyset) for monitor_name in new_keys: log('Adding binding for monitor %s' % monitor_name) configured_proxys[monitor_name].add()
def sync_monitor_bindings(): log('Entering sync_monitor_bindings') # Delete existing bindings for binding in get_actual_monitor_bindings().values(): b = lbmonitor_service_binding() b.monitorname = binding.monitor_name b.servicename = module.params['name'] # Cannot remove default monitor bindings if b.monitorname in ('tcp-default', 'ping-default'): continue lbmonitor_service_binding.delete(client, b) continue binding.monitorname = binding.monitor_name log('Will delete %s' % dir(binding)) log('Name %s' % binding.name) log('monitor Name %s' % binding.monitor_name) binding.delete(client, binding) #service_lbmonitor_binding.delete(client, binding) # Apply configured bindings for binding in get_configured_monitor_bindings().values(): binding.add()
def delete_all_bindings(): log('Entering delete_all_bindings') actual_bindings = get_actual_service_bindings() for binding in actual_bindings.values(): lbmonitor_service_binding.delete(client, binding)