--- /dev/null
+#!/usr/bin/python
+#
+# Given a cfengine atom visible in LDAP, list the FQDN of the hosts
+# where this atom is enabled.
+
+import os, sys, inspect
+
+# use this if you want to include modules from a subforder
+cmd_subfolder = os.path.realpath(os.path.abspath(os.path.join(os.path.split(inspect.getfile( inspect.currentframe() ))[0],"../lib")))
+if cmd_subfolder not in sys.path:
+ sys.path.insert(0, cmd_subfolder)
+
+import TSD
+import ldap
+import socket
+
+def main():
+ try:
+ atom = sys.argv[1]
+ except:
+ print "error: need atom to look up hosts"
+ return 1
+
+ if atom is None or "" == atom:
+ print "error: need atom to look up hosts"
+ return 1
+
+ lref = TSD.common.ldap_connect()
+ hosts = TSD.common.atom2hosts(lref, atom)
+ if 0 < len(hosts):
+ print "\n".join(hosts);
+ lref.unbind()
+
+if __name__ == "__main__":
+ main()