- l.simple_bind_s("","");
-
-HBaseDn = "ou=hosts,dc=debian,dc=org";
-HostDn = "host=" + Host + "," + HBaseDn;
+ l = ldap.open(LDAPServer);
+ l.simple_bind_s("","")
+
+if ListMode == 1:
+ Attrs = l.search_s(HostBaseDn,ldap.SCOPE_ONELEVEL,"host=*")
+ hosts = []
+ for hAttrs in Attrs:
+ hosts.append(hAttrs[1]['host'][0])
+ hosts.sort()
+
+ print "%-12s %-10s %-38s %-25s %s" % ("Host name","Arch","Distribution","Access","Status")
+ print "-"*115
+ for host in hosts:
+ for hAttrs in Attrs:
+ if host == hAttrs[1]['host'][0]:
+ Overview(hAttrs)
+ sys.exit(0)
+elif FingerPrints == 1:
+ if Host is not None:
+ Attrs = l.search_s(HostBaseDn,ldap.SCOPE_ONELEVEL,"host=" + Host)
+ else:
+ Attrs = l.search_s(HostBaseDn,ldap.SCOPE_ONELEVEL,"host=*")
+ hosts = []
+ for hAttrs in Attrs:
+ hosts.append(hAttrs[1]['host'][0])
+ hosts.sort()
+
+ tmpfile = CalcTempFile()
+ for host in hosts:
+ for hAttrs in Attrs:
+ if host == hAttrs[1]['host'][0]:
+ if 'sshRSAHostKey' in hAttrs[1].keys():
+ for key in hAttrs[1]['sshRSAHostKey']:
+ tmp = open(tmpfile, 'w')
+ tmp.write(key + '\n')
+ tmp.close()
+ fp = os.popen('/usr/bin/ssh-keygen -l -f ' + tmpfile, "r")
+ input = fp.readline()
+ fp.close()
+ fingerprint = input.split(' ')
+ print "%s %s root@%s" % (fingerprint[0], fingerprint[1], host)
+ os.unlink(tmpfile)
+ sys.exit(0)
+
+HostDn = "host=" + Host + "," + HostBaseDn;