def handle_providers(entries, providers): """ Add the output from the providers to the list of the GIP entries. This will match the DNs; if two DNs are repeated, then one will be thrown out @param entries: A list of LdapData objects @param providers: A list of provider information dictionaries. @returns: The altered entries list. """ provider_entries = [] for provider, p_info in providers.items(): if 'output' in p_info: fp = cStringIO.StringIO(p_info['output']) provider_entries += read_ldap(fp, multi=True) remove_entries = [] # Calculate all the duplicate entries, build a list of the ones # to remove. for entry in entries: for p_entry in provider_entries: if compareDN(entry, p_entry): remove_entries.append(entry) for entry in sets.Set(remove_entries): log.debug("Removing entry %s" % entry) try: entries.remove(entry) except ValueError: pass # Now add all the new entries from the providers for p_entry in provider_entries: entries.append(p_entry) return entries
def handle_providers(entries, providers): """ Add the output from the providers to the list of the GIP entries. This will match the DNs; if two DNs are repeated, then one will be thrown out @param entries: A list of LdapData objects @param providers: A list of provider information dictionaries. @returns: The altered entries list. """ provider_entries = [] for _, p_info in providers.items(): if 'output' in p_info: fp = cStringIO.StringIO(p_info['output']) provider_entries += read_ldap(fp, multi=True) remove_entries = [] # Calculate all the duplicate entries, build a list of the ones # to remove. for entry in entries: for p_entry in provider_entries: if compareDN(entry, p_entry): remove_entries.append(entry) for entry in sets.Set(remove_entries): log.debug("Removing entry %s" % entry) try: entries.remove(entry) except ValueError: pass # Now add all the new entries from the providers for p_entry in provider_entries: entries.append(p_entry) return entries
def handle_plugins(entries, plugins): # Make a list of all the plugin GLUE entries plugin_entries = [] for plugin, plugin_info in plugins.items(): if 'output' in plugin_info: fp = cStringIO.StringIO(plugin_info['output']) plugin_entries += read_ldap(fp, multi=True) # Merge all the plugin entries into the main stream. for p_entry in plugin_entries: log.debug("Plugin contents:\n%s" % p_entry) for entry in entries: for p_entry in plugin_entries: if compareDN(entry, p_entry): for glue, value in p_entry.glue.items(): entry.glue[glue] = value for key, value in p_entry.nonglue.items(): entry.nonglue[key] = value return entries
def handle_plugins(entries, plugins): # Make a list of all the plugin GLUE entries plugin_entries = [] for _, plugin_info in plugins.items(): if 'output' in plugin_info: fp = cStringIO.StringIO(plugin_info['output']) plugin_entries += read_ldap(fp, multi=True) # Merge all the plugin entries into the main stream. for p_entry in plugin_entries: log.debug("Plugin contents:\n%s" % p_entry) for entry in entries: for p_entry in plugin_entries: if compareDN(entry, p_entry): for glue, value in p_entry.glue.items(): entry.glue[glue] = value for key, value in p_entry.nonglue.items(): entry.nonglue[key] = value return entries
def run_compareDN(self, string1, string2, should_match=False): orig_entries = [] fp = cStringIO.StringIO(string1) orig_entries += read_ldap(fp, multi=True) other_entries = [] fp = cStringIO.StringIO(string2) other_entries += read_ldap(fp, multi=True) result = compareDN(orig_entries[0], other_entries[0]) if should_match: self.failIf(not result, msg="compareDN returned False when it should have "\ "returned True.\n\nDN1: %s \nDN2: %s" % \ (prettyDN(orig_entries[0].dn),prettyDN(other_entries[0].dn))) else: self.failIf(result, msg="compareDN returned True when it should have "\ "returned False.\n\nDN1: %s \nDN2: %s" % \ (prettyDN(orig_entries[0].dn),prettyDN(other_entries[0].dn))) return result
def run_compareDN(self, string1, string2, should_match = False): orig_entries = [] fp = cStringIO.StringIO(string1) orig_entries += read_ldap(fp, multi=True) other_entries = [] fp = cStringIO.StringIO(string2) other_entries += read_ldap(fp, multi=True) result = compareDN(orig_entries[0], other_entries[0]) if should_match: self.failIf(not result, msg="compareDN returned False when it should have "\ "returned True.\n\nDN1: %s \nDN2: %s" % \ (prettyDN(orig_entries[0].dn),prettyDN(other_entries[0].dn))) else: self.failIf(result, msg="compareDN returned True when it should have "\ "returned False.\n\nDN1: %s \nDN2: %s" % \ (prettyDN(orig_entries[0].dn),prettyDN(other_entries[0].dn))) return result
log.debug("Successfully opened the remove_attributes file.") # Collect all the DNs to be removed remove_dns = [] for line in output.splitlines(): if len(line.strip()) == 0 or line.startswith('#'): continue dn = line.strip() remove_dns.append(LdapData(dn)) log.debug("There are %i entries to remove." % len(remove_dns)) # Match all the entries: remove_entries = [] for entry in entries: for dn in remove_dns: if compareDN(entry, dn): remove_entries.append(entry) # Remove all the unwanted entries for entry in remove_entries: entries.remove(entry) return entries def handle_plugins(entries, plugins): # Make a list of all the plugin GLUE entries plugin_entries = [] for plugin, plugin_info in plugins.items(): if 'output' in plugin_info: fp = cStringIO.StringIO(plugin_info['output']) plugin_entries += read_ldap(fp, multi=True)
log.debug("Successfully opened the remove_attributes file.") # Collect all the DNs to be removed remove_dns = [] for line in output.splitlines(): if len(line.strip()) == 0 or line.startswith('#'): continue dn = line.strip() remove_dns.append(LdapData(dn)) log.debug("There are %i entries to remove." % len(remove_dns)) # Match all the entries: remove_entries = [] for entry in entries: for dn in remove_dns: if compareDN(entry, dn): remove_entries.append(entry) # Remove all the unwanted entries for entry in remove_entries: entries.remove(entry) return entries def handle_plugins(entries, plugins): # Make a list of all the plugin GLUE entries plugin_entries = [] for _, plugin_info in plugins.items(): if 'output' in plugin_info: fp = cStringIO.StringIO(plugin_info['output'])