~ubuntu-branches/ubuntu/precise/nova/precise-updates

« back to all changes in this revision

Viewing changes to nova/volume/api.py

  • Committer: Package Import Robot
  • Author(s): Adam Gandelman
  • Date: 2012-08-27 14:50:40 UTC
  • mfrom: (79.1.3 precise-proposed)
  • Revision ID: package-import@ubuntu.com-20120827145040-vlkdab5i0smvnhei
Tags: 2012.1.3+stable-20120827-4d2a4afe-0ubuntu1
* New upstream snapshot, fixes FTBFS in -proposed. (LP: #1041120)
* Resynchronize with stable/essex (4d2a4afe):
  - [5d63601] Inappropriate exception handling on kvm live/block migration
    (LP: #917615)
  - [ae280ca] Deleted floating ips can cause instance delete to fail
    (LP: #1038266)

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
        else:
81
81
            snapshot_id = None
82
82
 
83
 
        if quota.allowed_volumes(context, 1, size) < 1:
 
83
        result = quota.allowed_volumes(context, 1, size)
 
84
 
 
85
        overs = result['overs']
 
86
        usages = result['usages']
 
87
        quotas = result['quotas']
 
88
        allowed = result['allowed']
 
89
 
 
90
        if allowed['volumes'] < 1:
84
91
            pid = context.project_id
85
 
            LOG.warn(_("Quota exceeded for %(pid)s, tried to create"
86
 
                    " %(size)sG volume") % locals())
87
 
            raise exception.QuotaError(code="VolumeSizeTooLarge")
 
92
            if 'gigabytes' in overs:
 
93
                consumed = usages['gigabytes']
 
94
                limit = quotas['gigabytes']
 
95
                LOG.warn(_("Quota exceeded for %(pid)s, tried to create "
 
96
                           "%(size)sG volume (%(consumed)dG of %(limit)dG "
 
97
                           "already consumed)") % locals())
 
98
                code = "VolumeSizeTooLarge"
 
99
            elif 'volumes' in overs:
 
100
                consumed = usages['volumes']
 
101
                LOG.warn(_("Quota exceeded for %(pid)s, tried to create "
 
102
                           "volume (%(consumed)d volumes already consumed)")
 
103
                           % locals())
 
104
                code = "VolumeLimitExceeded"
 
105
            raise exception.QuotaError(code=code)
88
106
 
89
107
        if availability_zone is None:
90
108
            availability_zone = FLAGS.storage_availability_zone