Revision f8675683 snf-cyclades-app/synnefo/api/util.py
b/snf-cyclades-app/synnefo/api/util.py | ||
---|---|---|
59 | 59 |
from snf_django.lib.api import faults |
60 | 60 |
from synnefo.db.models import (Flavor, VirtualMachine, VirtualMachineMetadata, |
61 | 61 |
Network, BackendNetwork, NetworkInterface, |
62 |
BridgePoolTable, MacPrefixPoolTable, Backend) |
|
62 |
BridgePoolTable, MacPrefixPoolTable, Backend, |
|
63 |
FloatingIP) |
|
63 | 64 |
from synnefo.db.pools import EmptyPool |
64 | 65 |
|
65 | 66 |
from snf_django.lib.astakos import get_user |
... | ... | |
224 | 225 |
network = objects.get(Q(userid=user_id) | Q(public=True), |
225 | 226 |
id=network_id) |
226 | 227 |
if non_deleted and network.deleted: |
227 |
raise faults.BadRequest("Networkhas been deleted.") |
|
228 |
raise faults.BadRequest("Network has been deleted.")
|
|
228 | 229 |
return network |
229 | 230 |
except (ValueError, Network.DoesNotExist): |
230 | 231 |
raise faults.ItemNotFound('Network not found.') |
231 | 232 |
|
232 | 233 |
|
234 |
def get_floating_ip(user_id, ipv4, for_update=False): |
|
235 |
try: |
|
236 |
objects = FloatingIP.objects |
|
237 |
if for_update: |
|
238 |
objects = objects.select_for_update() |
|
239 |
return objects.get(userid=user_id, ipv4=ipv4, deleted=False) |
|
240 |
except FloatingIP.DoesNotExist: |
|
241 |
raise faults.ItemNotFound("Floating IP does not exist.") |
|
242 |
|
|
243 |
|
|
233 | 244 |
def validate_network_params(subnet, gateway=None, subnet6=None, gateway6=None): |
234 | 245 |
try: |
235 | 246 |
# Use strict option to not all subnets with host bits set |
Also available in: Unified diff