merge trunk/dossier machines
This commit is contained in:
commit
2c4032d25d
@ -6,6 +6,7 @@ username_base_dn = "ou=membres,"
|
|||||||
room_base_dn = "ou=chambres,"
|
room_base_dn = "ou=chambres,"
|
||||||
group_base_dn = "ou=groupes,"
|
group_base_dn = "ou=groupes,"
|
||||||
parametres_base_dn = "ou=parametres,"
|
parametres_base_dn = "ou=parametres,"
|
||||||
|
machine_base_dn = "cn=machines,"
|
||||||
ip_reservation_base_dn = "uid=pool_ip," + parametres_base_dn
|
ip_reservation_base_dn = "uid=pool_ip," + parametres_base_dn
|
||||||
plugins_base_dn = "uid=plugins," + parametres_base_dn
|
plugins_base_dn = "uid=plugins," + parametres_base_dn
|
||||||
|
|
||||||
|
@ -161,7 +161,6 @@ class MachineAddController(AuthenticatedRestController):
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
# Génération de l'id de la machine et recherche d'une ip libre
|
# Génération de l'id de la machine et recherche d'une ip libre
|
||||||
machine_id = str(uuid.uuid4())
|
|
||||||
ip = IpReservation.get_first_free(self.user, residence_dn)
|
ip = IpReservation.get_first_free(self.user, residence_dn)
|
||||||
|
|
||||||
# Rendre l'ip prise
|
# Rendre l'ip prise
|
||||||
@ -169,7 +168,7 @@ class MachineAddController(AuthenticatedRestController):
|
|||||||
self.user.ldap_bind.add_attr(ip.dn, taken_attribute)
|
self.user.ldap_bind.add_attr(ip.dn, taken_attribute)
|
||||||
|
|
||||||
# Attributs ldap de l'objet machine (regroupant dns et dhcp)
|
# Attributs ldap de l'objet machine (regroupant dns et dhcp)
|
||||||
machine_top = Machine.entry_attr(machine_id)
|
machine_top = Machine.entry_attr(name)
|
||||||
|
|
||||||
# Attributs ldap des objets dhcp et dns, fils de l'objet machine
|
# Attributs ldap des objets dhcp et dns, fils de l'objet machine
|
||||||
machine_dhcp = Machine.dhcp_attr(name, mac)
|
machine_dhcp = Machine.dhcp_attr(name, mac)
|
||||||
@ -177,7 +176,7 @@ class MachineAddController(AuthenticatedRestController):
|
|||||||
|
|
||||||
# Construction du dn et ajout de l'objet machine
|
# Construction du dn et ajout de l'objet machine
|
||||||
# en fils du membre (membre.dn)
|
# en fils du membre (membre.dn)
|
||||||
machine_dn = "cn=" + machine_id + "," + member.dn
|
machine_dn = "cn=" + name + "," + ldap_config.machine_base_dn + member.dn
|
||||||
self.user.ldap_bind.add_entry(machine_dn, machine_top)
|
self.user.ldap_bind.add_entry(machine_dn, machine_top)
|
||||||
|
|
||||||
# Construction du dn et ajout de l'objet dhcp
|
# Construction du dn et ajout de l'objet dhcp
|
||||||
@ -209,7 +208,7 @@ class MachineDeleteController(AuthenticatedRestController):
|
|||||||
# Note : on cherche la machine seulement sur le membre (member.dn)
|
# Note : on cherche la machine seulement sur le membre (member.dn)
|
||||||
member = Member.get_by_uid(self.user, residence_dn, member_uid)
|
member = Member.get_by_uid(self.user, residence_dn, member_uid)
|
||||||
machine = Machine.get_machine_by_id(self.user, member.dn, machine_id)
|
machine = Machine.get_machine_by_id(self.user, member.dn, machine_id)
|
||||||
dns = Machine.get_dns_by_id(self.user, machine.dn, machine_id)
|
dns = Machine.get_dns_by_id(self.user, machine.dn)
|
||||||
ip = IpReservation.get_ip(self.user, residence_dn, dns.dlzData.first())
|
ip = IpReservation.get_ip(self.user, residence_dn, dns.dlzData.first())
|
||||||
|
|
||||||
# Si la machine existe effectivement, on la supprime
|
# Si la machine existe effectivement, on la supprime
|
||||||
|
@ -4,13 +4,20 @@ import ldap
|
|||||||
|
|
||||||
from brie.config import ldap_config
|
from brie.config import ldap_config
|
||||||
|
|
||||||
|
|
||||||
|
""" Classe de manipulation de la base ldap """
|
||||||
class Ldap(object):
|
class Ldap(object):
|
||||||
__connection = None
|
__connection = None
|
||||||
|
|
||||||
|
""" Connexion à la base """
|
||||||
def __init__(self, connection):
|
def __init__(self, connection):
|
||||||
self.__connection = connection
|
self.__connection = connection
|
||||||
#end def
|
#end def
|
||||||
|
|
||||||
|
""" Methode de connexion à la base de donnée
|
||||||
|
dn : dn de connexion
|
||||||
|
password : mot de passe
|
||||||
|
"""
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def connect(dn, password):
|
def connect(dn, password):
|
||||||
connection = None
|
connection = None
|
||||||
@ -28,6 +35,11 @@ class Ldap(object):
|
|||||||
return None
|
return None
|
||||||
#end def
|
#end def
|
||||||
|
|
||||||
|
""" Recherche sur la base
|
||||||
|
dn : base de recherche
|
||||||
|
filter : filtre ldap de recherche
|
||||||
|
scope : portée de recherche (SCOPE_SUBTREE, SCOPE_BASE, SCOPE_ONELEVEL)
|
||||||
|
"""
|
||||||
def search(self, dn, filter, scope = ldap.SCOPE_SUBTREE):
|
def search(self, dn, filter, scope = ldap.SCOPE_SUBTREE):
|
||||||
try:
|
try:
|
||||||
results = self.__connection.search_s(dn, scope, filter)
|
results = self.__connection.search_s(dn, scope, filter)
|
||||||
@ -45,17 +57,20 @@ class Ldap(object):
|
|||||||
for attribute in attributes.iteritems():
|
for attribute in attributes.iteritems():
|
||||||
name = attribute[0]
|
name = attribute[0]
|
||||||
values = attribute[1]
|
values = attribute[1]
|
||||||
ldap_value = LdapValue(name, values)
|
ldap_value = LdapAttribute(name, values)
|
||||||
val_dict[name] = ldap_value
|
val_dict[name] = ldap_value
|
||||||
#end for
|
#end for
|
||||||
|
|
||||||
ldap_result = LdapResult(result_dn, val_dict)
|
ldap_result = LdapEntry(result_dn, val_dict)
|
||||||
ldap_results.append(ldap_result)
|
ldap_results.append(ldap_result)
|
||||||
#end for
|
#end for
|
||||||
|
|
||||||
return ldap_results
|
return ldap_results
|
||||||
#end def
|
#end def
|
||||||
|
|
||||||
|
""" Recherche le premier resultat sur la base
|
||||||
|
appel la methode "search" en interne
|
||||||
|
"""
|
||||||
def search_first(self, dn, filter, scope = ldap.SCOPE_SUBTREE):
|
def search_first(self, dn, filter, scope = ldap.SCOPE_SUBTREE):
|
||||||
results = self.search(dn, filter, scope)
|
results = self.search(dn, filter, scope)
|
||||||
if results is None: return None
|
if results is None: return None
|
||||||
@ -67,9 +82,14 @@ class Ldap(object):
|
|||||||
return None
|
return None
|
||||||
#end def
|
#end def
|
||||||
|
|
||||||
|
""" Recherche seulement l'element décrit par le dn donnée """
|
||||||
def search_dn(self, dn):
|
def search_dn(self, dn):
|
||||||
return self.search_first(dn, "(objectClass=*)", ldap.SCOPE_BASE)
|
return self.search_first(dn, "(objectClass=*)", ldap.SCOPE_BASE)
|
||||||
|
|
||||||
|
""" Remplace les attributs d'un dn donné
|
||||||
|
dn : adresse de l'élément
|
||||||
|
attributes : dictionnaire d'attributs
|
||||||
|
"""
|
||||||
def replace_attr(self, dn, attributes):
|
def replace_attr(self, dn, attributes):
|
||||||
modlist = []
|
modlist = []
|
||||||
for attribute in attributes.iteritems():
|
for attribute in attributes.iteritems():
|
||||||
@ -78,6 +98,10 @@ class Ldap(object):
|
|||||||
self.__connection.modify_s(dn, modlist)
|
self.__connection.modify_s(dn, modlist)
|
||||||
#end def
|
#end def
|
||||||
|
|
||||||
|
""" Ajouter les attributs d'un dn donné
|
||||||
|
dn : addresse de l'élément
|
||||||
|
attributes : dictionnaire des nouveaux attributs
|
||||||
|
"""
|
||||||
def add_attr(self, dn, attributes):
|
def add_attr(self, dn, attributes):
|
||||||
modlist = []
|
modlist = []
|
||||||
for attribute in attributes.iteritems():
|
for attribute in attributes.iteritems():
|
||||||
@ -89,6 +113,10 @@ class Ldap(object):
|
|||||||
pass
|
pass
|
||||||
#end def
|
#end def
|
||||||
|
|
||||||
|
""" Supprime les attributs d'un dn donné
|
||||||
|
dn : adresse de l'élément
|
||||||
|
attributes : dictionnaire des attributs à supprimer
|
||||||
|
"""
|
||||||
def delete_attr(self, dn, attributes):
|
def delete_attr(self, dn, attributes):
|
||||||
modlist = []
|
modlist = []
|
||||||
for attribute in attributes.iteritems():
|
for attribute in attributes.iteritems():
|
||||||
@ -100,6 +128,10 @@ class Ldap(object):
|
|||||||
# pass
|
# pass
|
||||||
#end def
|
#end def
|
||||||
|
|
||||||
|
""" Ajoute un nouvelle élément
|
||||||
|
dn : adresse du nouvelle élément
|
||||||
|
attributes : dictionnaire des attributes de l'élément
|
||||||
|
"""
|
||||||
def add_entry(self, dn, attributes):
|
def add_entry(self, dn, attributes):
|
||||||
modlist = []
|
modlist = []
|
||||||
for attribute in attributes.iteritems():
|
for attribute in attributes.iteritems():
|
||||||
@ -112,6 +144,7 @@ class Ldap(object):
|
|||||||
## pass
|
## pass
|
||||||
#end def
|
#end def
|
||||||
|
|
||||||
|
""" Supprime un élement donné """
|
||||||
def delete_entry(self, dn):
|
def delete_entry(self, dn):
|
||||||
#try:
|
#try:
|
||||||
self.__connection.delete_s(dn)
|
self.__connection.delete_s(dn)
|
||||||
@ -119,6 +152,7 @@ class Ldap(object):
|
|||||||
# pass
|
# pass
|
||||||
#end def
|
#end def
|
||||||
|
|
||||||
|
""" Supprime récursivement un élément et ses fils """
|
||||||
def delete_entry_subtree(self, dn):
|
def delete_entry_subtree(self, dn):
|
||||||
entries = self.search(dn, "(objectClass=*)")
|
entries = self.search(dn, "(objectClass=*)")
|
||||||
for entry in reversed(entries):
|
for entry in reversed(entries):
|
||||||
@ -126,26 +160,84 @@ class Ldap(object):
|
|||||||
#end for
|
#end for
|
||||||
#end def
|
#end def
|
||||||
|
|
||||||
|
""" Renomme un élément """
|
||||||
def rename_entry(self, dn, newdn, superior):
|
def rename_entry(self, dn, newdn, superior):
|
||||||
self.__connection.rename_s(dn, newdn, newsuperior= superior)
|
self.__connection.rename_s(dn, newdn, newsuperior= superior)
|
||||||
|
|
||||||
|
""" Sauvegarde en base une valeur l'élément donné """
|
||||||
|
def save(self, ldap_entry):
|
||||||
|
modlist = []
|
||||||
|
|
||||||
|
for global_deletion in ldap_entry._deletions:
|
||||||
|
modlist.append((ldap.MOD_DELETE, global_deletion, NONE))
|
||||||
|
#end for
|
||||||
|
ldap_entry._deletions = []
|
||||||
|
|
||||||
|
ldap_attributes = (
|
||||||
|
attribute
|
||||||
|
for attribute in ldap_entry.__dict__.itervalues()
|
||||||
|
if isinstance(attribute, LdapAttribute)
|
||||||
|
)
|
||||||
|
|
||||||
|
for ldap_attribute in ldap_attributes:
|
||||||
|
print "name : " + ldap_attribute.name
|
||||||
|
print "values : " + str(ldap_attribute.values)
|
||||||
|
print "deletions : " + str(ldap_attribute._deletions)
|
||||||
|
print "additions : " + str(ldap_attribute._additions)
|
||||||
|
print "modified : " + str(ldap_attribute._modified)
|
||||||
|
|
||||||
|
if ldap_attribute._deletions != []:
|
||||||
|
modlist.append((ldap.MOD_DELETE, ldap_attribute.name, ldap_attribute._deletions))
|
||||||
|
ldap_attribute._deletions = []
|
||||||
|
#end if
|
||||||
|
|
||||||
|
if ldap_attribute._additions != []:
|
||||||
|
modlist.append((ldap.MOD_ADD, ldap_attribute.name, ldap_attribute._additions))
|
||||||
|
ldap_attribute._additions = []
|
||||||
|
#end if
|
||||||
|
|
||||||
|
if ldap_attribute._modified:
|
||||||
|
str_values = [str(value) for value in ldap_attribute.values]
|
||||||
|
modlist.append((ldap.MOD_REPLACE, ldap_attribute.name, str_values))
|
||||||
|
ldap_attribute._modified = False
|
||||||
|
#end for
|
||||||
|
|
||||||
|
|
||||||
|
#end for
|
||||||
|
|
||||||
|
print "dn : " + ldap_entry.dn
|
||||||
|
print "modlist : " + str(modlist)
|
||||||
|
if modlist != []:
|
||||||
|
self.__connection.modify_s(ldap_entry.dn, modlist)
|
||||||
|
|
||||||
|
# On recharge l'entrée après la sauvegarde
|
||||||
|
entry_reloaded = self.search_dn(ldap_entry.dn)
|
||||||
|
ldap_entry.__dict__ = entry_reloaded.__dict__
|
||||||
|
#end def
|
||||||
|
|
||||||
|
""" Ferme la connexion à la base """
|
||||||
def close(self):
|
def close(self):
|
||||||
self.__connection.unbind()
|
self.__connection.unbind()
|
||||||
|
|
||||||
#end class
|
#end class
|
||||||
|
|
||||||
class LdapResult(object):
|
""" Classe représentant un élément ldap """
|
||||||
|
class LdapEntry(object):
|
||||||
dn = None
|
dn = None
|
||||||
|
|
||||||
|
_deletions = []
|
||||||
|
|
||||||
def __init__(self, dn, var_dict):
|
def __init__(self, dn, var_dict):
|
||||||
self.__dict__ = var_dict
|
self.__dict__ = var_dict
|
||||||
self.dn = dn.decode("utf-8")
|
self.dn = dn.decode("utf-8")
|
||||||
#end def
|
#end def
|
||||||
|
|
||||||
|
""" Retourne si un attribut existe sur cette élément """
|
||||||
def has(self, attribute_name):
|
def has(self, attribute_name):
|
||||||
return attribute_name in self.__dict__
|
return attribute_name in self.__dict__
|
||||||
#end def
|
#end def
|
||||||
|
|
||||||
|
""" Retourne la valeur d'un attribut donné """
|
||||||
def get(self, name):
|
def get(self, name):
|
||||||
if name in self.__dict__:
|
if name in self.__dict__:
|
||||||
return self.__dict__[name]
|
return self.__dict__[name]
|
||||||
@ -158,23 +250,127 @@ class LdapResult(object):
|
|||||||
return None
|
return None
|
||||||
#end def
|
#end def
|
||||||
|
|
||||||
|
""" Ajoute un attribut """
|
||||||
|
def add(self, name, value = None):
|
||||||
|
if self.has(name):
|
||||||
|
if value is not None:
|
||||||
|
value = self.get(name)
|
||||||
|
value.add(value)
|
||||||
|
#end if
|
||||||
|
else:
|
||||||
|
values = []
|
||||||
|
if value is not None:
|
||||||
|
values = [value]
|
||||||
|
#end if
|
||||||
|
|
||||||
|
|
||||||
|
self.__dict__[name] = LdapAttribute(name, values)
|
||||||
|
self.__dict__[name]._additions = values
|
||||||
|
#end if
|
||||||
|
#end def
|
||||||
|
|
||||||
|
""" Supprime un attribut """
|
||||||
|
def delete(self, name, value = None):
|
||||||
|
if self.has(name):
|
||||||
|
if value is not None:
|
||||||
|
value = self.get(name)
|
||||||
|
value.delete(value)
|
||||||
|
else:
|
||||||
|
del self.__dict__[name]
|
||||||
|
self._deletions.append(name)
|
||||||
|
#end if
|
||||||
|
#end if
|
||||||
|
#end def
|
||||||
|
|
||||||
#end class
|
#end class
|
||||||
|
|
||||||
class LdapValue(object):
|
|
||||||
|
""" Classe représentant la valeur d'un attribut """
|
||||||
|
class LdapAttribute(object):
|
||||||
name = None
|
name = None
|
||||||
values = []
|
values = None
|
||||||
|
|
||||||
|
_deletions = None
|
||||||
|
_additions = None
|
||||||
|
_modified = False
|
||||||
|
|
||||||
def __init__(self, name, values):
|
def __init__(self, name, values):
|
||||||
self.values = [value.decode("utf-8") for value in values]
|
self.values = [value.decode("utf-8") for value in values]
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
|
self._deletions = list()
|
||||||
|
self._additions = list()
|
||||||
#end def
|
#end def
|
||||||
|
|
||||||
|
""" Retourne la première valeur de cet attribut """
|
||||||
def first(self, default = None):
|
def first(self, default = None):
|
||||||
for value in self.values:
|
for value in self.values:
|
||||||
return value
|
return unicode(value)
|
||||||
#end for
|
#end for
|
||||||
|
|
||||||
return default
|
return unicode(default)
|
||||||
|
#end def
|
||||||
|
|
||||||
|
""" Retourne toutes les valeurs de cet attribut """
|
||||||
|
def all(self):
|
||||||
|
return self.values
|
||||||
|
#end def
|
||||||
|
|
||||||
|
""" Ajoute une valeur à cet attribut
|
||||||
|
Note : la valeur ne sera pas ajouté si elle existe déjà
|
||||||
|
"""
|
||||||
|
def add(self, value):
|
||||||
|
if not value in self.values:
|
||||||
|
self.values.append(value)
|
||||||
|
self._additions.append(value)
|
||||||
|
#end if
|
||||||
|
#end def
|
||||||
|
|
||||||
|
""" Supprime une valeur de cet attribut """
|
||||||
|
def delete(self, value):
|
||||||
|
if value in self.values:
|
||||||
|
self.values = [old for old in self.values if old != value]
|
||||||
|
|
||||||
|
# Si il vient d'être ajouté, on l'enleve simplement
|
||||||
|
# de la queue d'ajout
|
||||||
|
# sinon on l'ajoute dans la queue de suppression
|
||||||
|
if value in self._additions:
|
||||||
|
self._additions = [old for old in self._additions if old != value]
|
||||||
|
else:
|
||||||
|
self._deletions.append(value)
|
||||||
|
#end if
|
||||||
|
#end if
|
||||||
|
#end def
|
||||||
|
|
||||||
|
""" Modifie une valeur de cet attribut
|
||||||
|
si la valeur est nulle, modifie la première valeur
|
||||||
|
"""
|
||||||
|
def replace(self, old, new):
|
||||||
|
|
||||||
|
# Fonction usuelle de remplacement
|
||||||
|
def replace(current):
|
||||||
|
if current == old:
|
||||||
|
return new
|
||||||
|
#end if
|
||||||
|
|
||||||
|
return current
|
||||||
|
#end def
|
||||||
|
|
||||||
|
# Si la valeur modifié existe déjà
|
||||||
|
# l'ancienne valeur n'est que supprimée
|
||||||
|
if new in self.values:
|
||||||
|
self.delete(old)
|
||||||
|
else:
|
||||||
|
self.values = [replace(value) for value in self.values]
|
||||||
|
|
||||||
|
# Si la valeur modifié vient d'être ajouté,
|
||||||
|
# elle est modifié dans la queue d'addition
|
||||||
|
self._additions = [replace(value) for value in self._additions]
|
||||||
|
|
||||||
|
self._modified = True
|
||||||
|
#end if
|
||||||
|
|
||||||
|
|
||||||
#end def
|
#end def
|
||||||
#end class
|
#end class
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
from brie.config import ldap_config
|
from brie.config import ldap_config
|
||||||
|
import ldap
|
||||||
|
|
||||||
class Member(object):
|
class Member(object):
|
||||||
|
|
||||||
@ -130,7 +132,7 @@ class Machine(object):
|
|||||||
def dhcp_attr(name, mac):
|
def dhcp_attr(name, mac):
|
||||||
return {
|
return {
|
||||||
"objectClass" : ["top", "uidObject", "dhcpHost"],
|
"objectClass" : ["top", "uidObject", "dhcpHost"],
|
||||||
"cn" : str(name),
|
"cn" : "dhcp",
|
||||||
"uid" : "machine_membre",
|
"uid" : "machine_membre",
|
||||||
"dhcpHWAddress" : str("ethernet " + mac),
|
"dhcpHWAddress" : str("ethernet " + mac),
|
||||||
"dhcpStatements" : str("fixed-address " + name)
|
"dhcpStatements" : str("fixed-address " + name)
|
||||||
@ -140,7 +142,8 @@ class Machine(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def dns_attr(name, ip):
|
def dns_attr(name, ip):
|
||||||
return {
|
return {
|
||||||
"objectClass" : ["top", "dlzAbstractRecord", "dlzGenericRecord"],
|
"objectClass" : ["top", "organizationalRole", "dlzAbstractRecord", "dlzGenericRecord"],
|
||||||
|
"cn" : "dns",
|
||||||
"dlzData" : str(ip),
|
"dlzData" : str(ip),
|
||||||
"dlzHostName" : str(name),
|
"dlzHostName" : str(name),
|
||||||
"dlzRecordId" : "1",
|
"dlzRecordId" : "1",
|
||||||
@ -153,7 +156,7 @@ class Machine(object):
|
|||||||
def auth_attr(flat_mac):
|
def auth_attr(flat_mac):
|
||||||
return {
|
return {
|
||||||
"objectClass" : ["top", "organizationalRole", "simpleSecurityObject", "uidObject"],
|
"objectClass" : ["top", "organizationalRole", "simpleSecurityObject", "uidObject"],
|
||||||
"cn" : "mac",
|
"cn" : "mac_auth",
|
||||||
"uid" : flat_mac,
|
"uid" : flat_mac,
|
||||||
"userPassword" : flat_mac
|
"userPassword" : flat_mac
|
||||||
}
|
}
|
||||||
@ -161,7 +164,8 @@ class Machine(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_machine_tuples_of_member(user_session, member_dn):
|
def get_machine_tuples_of_member(user_session, member_dn):
|
||||||
results = user_session.ldap_bind.search(member_dn, "(objectClass=organizationalRole)")
|
machine_dn = ldap_config.machine_base_dn + member_dn
|
||||||
|
results = user_session.ldap_bind.search(machine_dn, "(objectClass=organizationalRole)", scope = ldap.SCOPE_ONELEVEL)
|
||||||
machines = list()
|
machines = list()
|
||||||
for result in results:
|
for result in results:
|
||||||
dhcp = user_session.ldap_bind.search_first(result.dn, "(objectClass=dhcpHost)")
|
dhcp = user_session.ldap_bind.search_first(result.dn, "(objectClass=dhcpHost)")
|
||||||
@ -170,10 +174,9 @@ class Machine(object):
|
|||||||
mac = dhcp.dhcpHWAddress.first().replace("ethernet ", "")
|
mac = dhcp.dhcpHWAddress.first().replace("ethernet ", "")
|
||||||
machines.append(
|
machines.append(
|
||||||
(
|
(
|
||||||
dhcp.cn.first(),
|
result.cn.first(),
|
||||||
mac,
|
mac,
|
||||||
dns.dlzData.first(),
|
dns.dlzData.first()
|
||||||
result.cn.first()
|
|
||||||
) #tuple
|
) #tuple
|
||||||
)
|
)
|
||||||
#end if
|
#end if
|
||||||
@ -184,11 +187,12 @@ class Machine(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_machine_by_id(user_session, member_dn, machine_id):
|
def get_machine_by_id(user_session, member_dn, machine_id):
|
||||||
return user_session.ldap_bind.search_first(member_dn, "(cn=" + machine_id + ")")
|
machines_dn = ldap_config.machine_base_dn + member_dn
|
||||||
|
return user_session.ldap_bind.search_first(machines_dn, "(cn=" + machine_id + ")")
|
||||||
#end def
|
#end def
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_dns_by_id(user_session, machine_dn, machine_id):
|
def get_dns_by_id(user_session, machine_dn):
|
||||||
return user_session.ldap_bind.search_first(machine_dn, "(objectClass=dlzAbstractRecord)")
|
return user_session.ldap_bind.search_first(machine_dn, "(objectClass=dlzAbstractRecord)")
|
||||||
#end def
|
#end def
|
||||||
|
|
||||||
|
@ -62,13 +62,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<span class="section_name show_section_name">MACHINES</span>
|
<span class="section_name show_section_name">MACHINES</span>
|
||||||
<div py:for="name, mac, ip, id in machines">
|
<div py:for="name, mac, ip in machines">
|
||||||
<span class="item_name">${name}</span>
|
<span class="item_name">${name}</span>
|
||||||
<span>${mac} : ${ip}</span>
|
<span>${mac} : ${ip}</span>
|
||||||
<form action="/edit/machine/delete/" method="post" class="inline_block">
|
<form action="/edit/machine/delete/" method="post" class="inline_block">
|
||||||
<input type="hidden" name="residence" value="${residence}"/>
|
<input type="hidden" name="residence" value="${residence}"/>
|
||||||
<input type="hidden" name="member_uid" value="${member_ldap.uid.first()}"/>
|
<input type="hidden" name="member_uid" value="${member_ldap.uid.first()}"/>
|
||||||
<input type="hidden" name="machine_id" value="${id}"/>
|
<input type="hidden" name="machine_id" value="${name}"/>
|
||||||
<input type="submit" value="X" class="button"/>
|
<input type="submit" value="X" class="button"/>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user