Revision 326c3ec8 snf-cyclades-app/synnefo/api/floating_ips.py

b/snf-cyclades-app/synnefo/api/floating_ips.py
40 40
from snf_django.lib.api import faults, utils
41 41
from synnefo.api import util
42 42
from synnefo import quotas
43
from synnefo.db.models import Network, FloatingIP, NetworkInterface
43
from synnefo.db.models import Network, IPAddress, NetworkInterface
44 44

  
45 45

  
46 46
from logging import getLogger
......
92 92
    log.debug("list_floating_ips")
93 93

  
94 94
    userid = request.user_uniq
95
    floating_ips = FloatingIP.objects.filter(userid=userid).order_by("id")
95
    floating_ips = IPAddress.objects.filter(userid=userid).order_by("id")
96 96
    floating_ips = utils.filter_modified_since(request, objects=floating_ips)
97 97

  
98 98
    floating_ips = map(ip_to_dict, floating_ips)
......
109 109
    """Return information for a floating IP."""
110 110
    userid = request.user_uniq
111 111
    try:
112
        floating_ip = FloatingIP.objects.get(id=floating_ip_id,
112
        floating_ip = IPAddress.objects.get(id=floating_ip_id,
113 113
                                             deleted=False,
114 114
                                             userid=userid)
115
    except FloatingIP.DoesNotExist:
115
    except IPAddress.DoesNotExist:
116 116
        raise faults.ItemNotFound("Floating IP '%s' does not exist" %
117 117
                                  floating_ip_id)
118 118
    request.serialization = "json"
......
155 155
            else:
156 156
                # User specified an IP address. Check that it is not a used
157 157
                # floating IP
158
                if FloatingIP.objects.filter(network=network,
158
                if IPAddress.objects.filter(network=network,
159 159
                                             deleted=False,
160 160
                                             ipv4=address).exists():
161 161
                    msg = "Floating IP '%s' is reserved" % address
......
178 178
                    except NetworkInterface.DoesNotExist:
179 179
                        msg = "Address '%s' is already in use" % address
180 180
                        raise faults.Conflict(msg)
181
        floating_ip = FloatingIP.objects.create(ipv4=address, network=network,
181
        floating_ip = IPAddress.objects.create(ipv4=address, network=network,
182 182
                                                userid=userid, machine=machine)
183 183
        quotas.issue_and_accept_commission(floating_ip)
184 184
    except:
......
202 202
    userid = request.user_uniq
203 203
    log.info("release_floating_ip '%s'. User '%s'.", floating_ip_id, userid)
204 204
    try:
205
        floating_ip = FloatingIP.objects.select_for_update()\
205
        floating_ip = IPAddress.objects.select_for_update()\
206 206
                                        .get(id=floating_ip_id,
207 207
                                             deleted=False,
208 208
                                             userid=userid)
209
    except FloatingIP.DoesNotExist:
209
    except IPAddress.DoesNotExist:
210 210
        raise faults.ItemNotFound("Floating IP '%s' does not exist" %
211 211
                                  floating_ip_id)
212 212

  

Also available in: Unified diff