~ubuntu-branches/ubuntu/quantal/nova/quantal-proposed

« back to all changes in this revision

Viewing changes to nova/api/openstack/compute/contrib/floating_ips.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-08-16 14:04:11 UTC
  • mto: This revision was merged to the branch mainline in revision 84.
  • Revision ID: package-import@ubuntu.com-20120816140411-0mr4n241wmk30t9l
Tags: upstream-2012.2~f3
ImportĀ upstreamĀ versionĀ 2012.2~f3

Show diffs side-by-side

added added

removed removed

Lines of Context:
120
120
        fixed_ip_id = floating_ip['fixed_ip_id']
121
121
        floating_ip['fixed_ip'] = self._get_fixed_ip(context,
122
122
                                                     fixed_ip_id)
123
 
        instance_id = None
 
123
        instance_uuid = None
124
124
        if floating_ip['fixed_ip']:
125
 
            instance_id = floating_ip['fixed_ip']['instance_id']
 
125
            instance_uuid = floating_ip['fixed_ip']['instance_uuid']
126
126
 
127
 
        if instance_id:
 
127
        if instance_uuid:
128
128
            floating_ip['instance'] = self._get_instance(context,
129
 
                                                         instance_id)
 
129
                                                         instance_uuid)
130
130
        else:
131
131
            floating_ip['instance'] = None
132
132
 
169
169
        try:
170
170
            address = self.network_api.allocate_floating_ip(context, pool)
171
171
            ip = self.network_api.get_floating_ip_by_address(context, address)
172
 
        except exception.NoMoreFloatingIps:
 
172
        except exception.NoMoreFloatingIps, nmfi:
173
173
            if pool:
174
 
                msg = _("No more floating ips in pool %s.") % pool
 
174
                nmfi.message = _("No more floating ips in pool %s.") % pool
175
175
            else:
176
 
                msg = _("No more floating ips available.")
177
 
            raise webob.exc.HTTPBadRequest(explanation=msg)
 
176
                nmfi.message = _("No more floating ips available.")
 
177
            raise nmfi
178
178
 
179
179
        return _translate_floating_ip_view(ip)
180
180
 
282
282
        instance = get_instance_by_floating_ip_addr(self, context, address)
283
283
 
284
284
        # disassociate if associated
285
 
        if floating_ip.get('fixed_ip_id'):
 
285
        if instance and floating_ip.get('fixed_ip_id'):
286
286
            disassociate_floating_ip(self, context, instance, address)
287
 
 
288
 
        return webob.Response(status_int=202)
 
287
            return webob.Response(status_int=202)
 
288
        else:
 
289
            return webob.Response(status_int=404)
289
290
 
290
291
 
291
292
class Floating_ips(extensions.ExtensionDescriptor):