+# Generate the debianhosts file (list of all IP addresses)
+def GenHosts(l,File):
+ F = None;
+ try:
+ OldMask = os.umask(0022);
+ F = open(File + ".tmp","w",0644);
+ os.umask(OldMask);
+
+ # Fetch all the hosts
+ HostNames = l.search_s(HostBaseDn,ldap.SCOPE_ONELEVEL,"hostname=*",\
+ ["hostname"]);
+
+ if HostNames == None:
+ raise "No Hosts";
+
+ for x in HostNames:
+ if x[1].has_key("hostname") == 0:
+ continue;
+ Host = GetAttr(x,"hostname");
+ Addr = socket.gethostbyname(Host);
+ F.write(Addr + "\n");
+ # Oops, something unspeakable happened.
+ except:
+ Die(File,F,None);
+ raise;
+ Done(File,F,None);