Revision 3f18f035
b/snf-cyclades-app/synnefo/api/floating_ips.py | ||
---|---|---|
157 | 157 |
network = util.get_network(network_id, userid, for_update=True, |
158 | 158 |
non_deleted=True) |
159 | 159 |
if not network.floating_ip_pool: |
160 |
msg = ("Can not allocate floating IP from network %s. Network is" |
|
161 |
" not a floating IP pool." % network) |
|
162 |
raise faults.Conflict(msg) |
|
160 |
msg = ("Can not allocate floating IP. Network %s is" |
|
161 |
" not a floating IP pool.") |
|
162 |
raise faults.Conflict(msg % network.id) |
|
163 |
if network.action == "DESTROY": |
|
164 |
msg = "Can not allocate floating IP. Network %s is being deleted." |
|
165 |
raise faults.Conflict(msg % network.id) |
|
163 | 166 |
|
164 | 167 |
address = api.utils.get_attribute(floating_ip_dict, |
165 | 168 |
"floating_ip_address", |
b/snf-cyclades-app/synnefo/api/util.py | ||
---|---|---|
307 | 307 |
|
308 | 308 |
def allocate_ip(network, userid, address=None, floating_ip=False): |
309 | 309 |
"""Try to allocate an IP from networks IP pools.""" |
310 |
if network.action == "DESTROY": |
|
311 |
raise faults.Conflict("Can not allocate IP. Network %s is being" |
|
312 |
" deleted" % network.id) |
|
310 | 313 |
ip_pools = IPPoolTable.objects.select_for_update()\ |
311 | 314 |
.filter(subnet__network=network) |
312 | 315 |
try: |
... | ... | |
336 | 339 |
ip_pool_rows = IPPoolTable.objects.select_for_update()\ |
337 | 340 |
.prefetch_related("subnet__network")\ |
338 | 341 |
.filter(subnet__deleted=False)\ |
342 |
.filter(subnet__network__deleted=False)\ |
|
339 | 343 |
.filter(subnet__network__public=True)\ |
340 | 344 |
.filter(subnet__network__drained=False) |
341 | 345 |
if floating_ip: |
b/snf-cyclades-app/synnefo/logic/networks.py | ||
---|---|---|
160 | 160 |
raise faults.Conflict(msg) |
161 | 161 |
|
162 | 162 |
network.action = "DESTROY" |
163 |
# Mark network as drained to prevent automatic allocation of |
|
164 |
# public/floating IPs while the network is being deleted |
|
165 |
network.drained = True |
|
163 | 166 |
network.save() |
164 | 167 |
|
165 | 168 |
# Delete network to all backends that exists |
b/snf-cyclades-app/synnefo/logic/servers.py | ||
---|---|---|
456 | 456 |
if network.state != "ACTIVE": |
457 | 457 |
raise faults.BuildInProgress("Can not create port while network is in" |
458 | 458 |
" state %s" % network.state) |
459 |
if network.action == "DESTROY": |
|
460 |
msg = "Can not create port. Network %s is being deleted." |
|
461 |
raise faults.Conflict(msg % network.id) |
|
459 | 462 |
ipaddress = None |
460 | 463 |
if use_ipaddress is not None: |
461 | 464 |
# Use an existing IPAddress object. |
Also available in: Unified diff