[lc_ldap] Usage de conn.get_local_machines généralisé

This commit is contained in:
Valentin Samir 2014-03-18 22:50:19 +01:00
parent 266cf73a0a
commit 9311f2abcf
2 changed files with 2 additions and 14 deletions

View file

@ -20,14 +20,6 @@ conn = lc_ldap.shortcuts.lc_ldap_admin(user=u'sshfingerprint')
ssh_algo = config.sshfp_algo.keys()
def ip4_addresses():
ip_list = []
for interface in interfaces():
if interface!='lo' and AF_INET in ifaddresses(interface).keys():
for link in ifaddresses(interface)[AF_INET]:
ip_list.append(link['addr'])
return ip_list
def ssh_keyscan(host,algo):
p=subprocess.Popen(["/usr/bin/ssh-keyscan", "-t", "%s" % algo,"%s" % host],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
ret=p.communicate()[0].split()
@ -57,11 +49,7 @@ def ssh_keygen(algo,size):
print("Nouvelle clef %s générée" % key_path)
def get_machines():
filter=""
for ip in set(ip4_addresses()):
filter+=u'(ipHostNumber=%s)' % ip
filter = u"(|%s)" % filter
return conn.search(filter, mode='rw')
return conn.get_local_machines(mode='rw')
def check_keys_age(key_path,algo):
age=time.time()-os.path.getmtime(key_path)

View file

@ -150,7 +150,7 @@ class LdapCertFS(fuse.Fuse):
elif self.ldap_filter:
machines = conn.search("(&(%s)(mid=*))" % self.ldap_filter, sizelimit=8000)
else:
machines = get_machines()
machines = conn.get_local_machines()
for machine in machines:
if not machine.certificats():