Revision cb7b1c23 snf-cyclades-app/synnefo/logic/backend.py
b/snf-cyclades-app/synnefo/logic/backend.py | ||
---|---|---|
37 | 37 |
from synnefo.db.models import (Backend, VirtualMachine, Network, |
38 | 38 |
BackendNetwork, BACKEND_STATUSES, |
39 | 39 |
pooled_rapi_client, VirtualMachineDiagnostic, |
40 |
Flavor) |
|
40 |
Flavor, FloatingIP)
|
|
41 | 41 |
from synnefo.logic import utils |
42 | 42 |
from synnefo import quotas |
43 | 43 |
from synnefo.api.util import release_resource |
... | ... | |
325 | 325 |
"""Release the IPv4 address of a NIC. |
326 | 326 |
|
327 | 327 |
Check if an instance's NIC has an IPv4 address and release it if it is not |
328 |
a Floating IP. |
|
328 |
a Floating IP. If it is as Floating IP, then disassociate the FloatingIP |
|
329 |
from the machine. |
|
329 | 330 |
|
330 | 331 |
""" |
331 | 332 |
|
332 |
if nic.ipv4 and not nic.ip_type == "FLOATING": |
|
333 |
nic.network.release_address(nic.ipv4) |
|
333 |
if nic.ipv4: |
|
334 |
if nic.ip_type == "FLOATING": |
|
335 |
FloatingIP.objects.filter(machine=nic.machine_id, |
|
336 |
network=nic.network_id, |
|
337 |
ipv4=nic.ipv4).update(machine=None) |
|
338 |
else: |
|
339 |
nic.network.release_address(nic.ipv4) |
|
334 | 340 |
|
335 | 341 |
|
336 | 342 |
@transaction.commit_on_success |
Also available in: Unified diff