Created
January 7, 2011 22:01
-
-
Save glarizza/770193 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def searchContactNodes(self, nodeToFind): | |
"""A utility function to search through Contact nodes looking for a specific node | |
--- | |
Arguments: | |
nodeToFind - The node you're looking to find. | |
Returns: Nothing | |
""" | |
for node in pymacds.GetLDAPv3ContactsNodes(): | |
if node == nodeToFind: | |
return "true" | |
return "" | |
def searchSearchNodes(self, nodeToFind): | |
"""A utility function to search through Contact nodes looking for a specific node | |
--- | |
Arguments: | |
nodeToFind - The node you're looking to find. | |
Returns: Nothing | |
""" | |
for node in pymacds.GetLDAPv3SearchNodes(): | |
if node == nodeToFind: | |
return "true" | |
return "" | |
def ensureLDAPNodes(self, nodes): | |
"""A utility function to ensure our LDAP Search and Contact Nodes. Checks to | |
make sure nodes aren't already listed before it adds them. | |
--- | |
Arguments: | |
nodes - a list of nodes to ensure. | |
Returns: Nothing | |
""" | |
for node in nodes: | |
if not self.searchSearchNodes(node): | |
pymacds.EnsureSearchNodePresent(node) | |
syslog.syslog(syslog.LOG_ALERT, "Added " + node + " to the Search path." | |
if not self.searchContactNodes(node): | |
pymacds.EnsureContactsNodePresent(node) | |
syslog.syslog(syslog.LOG_ALERT, "Added " + node + " to the Contacts path." | |
def removeLDAPNodes(self, nodeToRemove): | |
"""A utility function to remove specific LDAP Search and Contact Nodes. Checks to | |
make sure nodes aren't already listed before it adds them. | |
--- | |
Arguments: | |
nodes - a list of nodes to remove. | |
Returns: Nothing | |
""" | |
for node in nodes: | |
if self.searchSearchNodes(node): | |
pymacds.EnsureSearchNodeAbsent(node) | |
syslog.syslog(syslog.LOG_ALERT, "Removed " + node + " from the Search path." | |
if self.searchContactNodes(node): | |
pymacds.EnsureContactsNodeAbsent(node) | |
syslog.syslog(syslog.LOG_ALERT, "Removed " + node + " from the Contacts path." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment