Revision cb7b1c23 snf-cyclades-app/synnefo/db/models.py

b/snf-cyclades-app/synnefo/db/models.py
712 712
        # assigned to more than one NICs
713 713
        unique_together = ("network", "ipv4")
714 714

  
715
    def delete(self):
716
        """Custom method for deleting NetworkInterfaces.
717

  
718
        In case the NIC is of 'FLOATING' type, this method clears the 'machine'
719
        flag of the FloatingIP object, before deleting the NIC.
720

  
721
        """
722
        if self.ip_type == "FLOATING":
723
            FloatingIP.objects.filter(machine=self.machine_id,
724
                                      network=self.network_id,
725
                                      ipv4=self.ipv4).update(machine=None)
726
        super(NetworkInterface, self).delete()
727

  
715 728

  
716 729
class FloatingIP(models.Model):
717 730
    userid = models.CharField("UUID of the owner", max_length=128,

Also available in: Unified diff