From a5864c074413ef76391c97139736881b436ff75f Mon Sep 17 00:00:00 2001 From: Romain Beuque Date: Tue, 4 Nov 2014 11:04:02 +0100 Subject: [PATCH] =?UTF-8?q?prise=20en=20charge=20de=20la=20suppression=20d?= =?UTF-8?q?e=20machine=20dont=20l'IP=20n'est=20plus=20dans=20le=20pool=20(?= =?UTF-8?q?pr=C3=A9paration=20de=20nettoyage=20pour=20augmenter=20nos=20pl?= =?UTF-8?q?ages=20admins=20publiques)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Brie/brie/controllers/edit.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Brie/brie/controllers/edit.py b/Brie/brie/controllers/edit.py index 806a89c..52234e9 100644 --- a/Brie/brie/controllers/edit.py +++ b/Brie/brie/controllers/edit.py @@ -790,7 +790,11 @@ class MachineDeleteController(AuthenticatedRestController): machine = Machine.get_machine_by_id(self.user, member.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_machines = Machine.get_dns_by_ip(self.user, residence_dn, ip.cn.first()) + ip_machines = [] + #on vérifie si l'IP est bien dans le pool, et qu'elle n'est pas utilisée par plusieurs machines + if ip is not None: + ip_machines = Machine.get_dns_by_ip(self.user, residence_dn, ip.cn.first()) + #end if # Si la machine existe effectivement, on la supprime if machine is not None: @@ -799,7 +803,8 @@ class MachineDeleteController(AuthenticatedRestController): self.user.ldap_bind.delete_entry_subtree(machine.dn) - if len(ip_machines) == 1: + #si l'IP n'est pas null et qu'on a qu'une seule machine sur cette IP (la notre), alors on delete dans le pool + if ip is not None and len(ip_machines) == 1: taken_attribute = IpReservation.taken_attr(ip.get("x-taken").first()) self.user.ldap_bind.delete_attr(ip.dn, taken_attribute) #end if