Revision 443315d6 snf-cyclades-app/synnefo/db/models.py
b/snf-cyclades-app/synnefo/db/models.py | ||
---|---|---|
675 | 675 |
("ERROR", "Error"), |
676 | 676 |
) |
677 | 677 |
|
678 |
IP_TYPES = ( |
|
679 |
("FIXED", "Fixed IP Address"), |
|
680 |
("FLOATING", "Floating IP Address"), |
|
681 |
) |
|
682 |
|
|
678 | 683 |
machine = models.ForeignKey(VirtualMachine, related_name='nics', |
679 | 684 |
on_delete=models.CASCADE) |
680 | 685 |
network = models.ForeignKey(Network, related_name='nics', |
... | ... | |
689 | 694 |
max_length=30, null=True) |
690 | 695 |
state = models.CharField(max_length=32, null=False, default="ACTIVE", |
691 | 696 |
choices=STATES) |
697 |
ip_type = models.CharField(max_length=32, null=False, default="FIXED", |
|
698 |
choices=IP_TYPES) |
|
692 | 699 |
|
693 | 700 |
@property |
694 | 701 |
def backend_uuid(self): |
... | ... | |
700 | 707 |
(self.id, self.machine_id, self.network_id, self.ipv4, |
701 | 708 |
self.ipv6) |
702 | 709 |
|
703 |
@property |
|
704 |
def is_floating_ip(self): |
|
705 |
network = self.network |
|
706 |
if self.ipv4 and network.floating_ip_pool: |
|
707 |
return network.floating_ips.filter(machine=self.machine, |
|
708 |
ipv4=self.ipv4, |
|
709 |
deleted=False).exists() |
|
710 |
return False |
|
711 |
|
|
712 | 710 |
class Meta: |
713 | 711 |
# Assert than an IPv4 address from the same network will not be |
714 | 712 |
# assigned to more than one NICs |
Also available in: Unified diff