~rvb/maas/maas.serializable

« back to all changes in this revision

Viewing changes to src/maasserver/models/staticipaddress.py

[r=rvb][bug=1383231][author=gmb] StaticIPAddressManager._attempt_allocation() now gives a useful error message to the StaticIPAddressUnavailable that it raises when someone is already using a static IP.

Previously, API users were confronted with a blank line when trying to request an in-use IP  address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
            ipaddress.save()
104
104
        except IntegrityError:
105
105
            # The address is already taken.
106
 
            raise StaticIPAddressUnavailable()
 
106
            raise StaticIPAddressUnavailable(
 
107
                "The IP address %s is already in use." %
 
108
                requested_address.format())
107
109
        else:
108
110
            # We deliberately do *not* save the user until now because it
109
111
            # might result in an IntegrityError, and we rely on the latter