Set max volume size limit for the tenant
There is a need to limit maximum size of a volume to levels that the storage infrastructure can handle. Setting a maximum limit on size of a volume also prevents a tenant from creating large volumes that have not been tested and certified to satisfy SLA objectives. This feature allows admin to set volume size limit [per_volume_gigabytes] for a tenant. Change-Id: Iab584c72a34f9171000b20b2200ac12d21fc40ae Implements: blueprint cinder-quota-define-per-volume
This commit is contained in:
		@@ -539,7 +539,8 @@ class FakeHTTPClient(base_client.HTTPClient):
 | 
			
		||||
                          'gigabytes': 1,
 | 
			
		||||
                          'backups': 1,
 | 
			
		||||
                          'backup_gigabytes': 1,
 | 
			
		||||
                          'consistencygroups': 1}})
 | 
			
		||||
                          'consistencygroups': 1,
 | 
			
		||||
                          'per_volume_gigabytes': 1, }})
 | 
			
		||||
 | 
			
		||||
    def get_os_quota_sets_test_defaults(self):
 | 
			
		||||
        return (200, {}, {'quota_set': {
 | 
			
		||||
@@ -550,7 +551,8 @@ class FakeHTTPClient(base_client.HTTPClient):
 | 
			
		||||
                          'gigabytes': 1,
 | 
			
		||||
                          'backups': 1,
 | 
			
		||||
                          'backup_gigabytes': 1,
 | 
			
		||||
                          'consistencygroups': 1}})
 | 
			
		||||
                          'consistencygroups': 1,
 | 
			
		||||
                          'per_volume_gigabytes': 1, }})
 | 
			
		||||
 | 
			
		||||
    def put_os_quota_sets_test(self, body, **kw):
 | 
			
		||||
        assert list(body) == ['quota_set']
 | 
			
		||||
@@ -564,7 +566,8 @@ class FakeHTTPClient(base_client.HTTPClient):
 | 
			
		||||
                          'gigabytes': 1,
 | 
			
		||||
                          'backups': 1,
 | 
			
		||||
                          'backup_gigabytes': 1,
 | 
			
		||||
                          'consistencygroups': 2}})
 | 
			
		||||
                          'consistencygroups': 2,
 | 
			
		||||
                          'per_volume_gigabytes': 1, }})
 | 
			
		||||
 | 
			
		||||
    def delete_os_quota_sets_1234(self, **kw):
 | 
			
		||||
        return (200, {}, {})
 | 
			
		||||
@@ -585,7 +588,8 @@ class FakeHTTPClient(base_client.HTTPClient):
 | 
			
		||||
                          'gigabytes': 1,
 | 
			
		||||
                          'backups': 1,
 | 
			
		||||
                          'backup_gigabytes': 1,
 | 
			
		||||
                          'consistencygroups': 1}})
 | 
			
		||||
                          'consistencygroups': 1,
 | 
			
		||||
                          'per_volume_gigabytes': 1, }})
 | 
			
		||||
 | 
			
		||||
    def put_os_quota_class_sets_test(self, body, **kw):
 | 
			
		||||
        assert list(body) == ['quota_class_set']
 | 
			
		||||
@@ -599,7 +603,8 @@ class FakeHTTPClient(base_client.HTTPClient):
 | 
			
		||||
                          'gigabytes': 1,
 | 
			
		||||
                          'backups': 1,
 | 
			
		||||
                          'backup_gigabytes': 1,
 | 
			
		||||
                          'consistencygroups': 2}})
 | 
			
		||||
                          'consistencygroups': 2,
 | 
			
		||||
                          'per_volume_gigabytes': 1}})
 | 
			
		||||
 | 
			
		||||
    #
 | 
			
		||||
    # VolumeTypes
 | 
			
		||||
 
 | 
			
		||||
@@ -31,7 +31,7 @@ class QuotaClassSetsTest(utils.TestCase):
 | 
			
		||||
        q = cs.quota_classes.get('test')
 | 
			
		||||
        q.update(volumes=2, snapshots=2, gigabytes=2000,
 | 
			
		||||
                 backups=2, backup_gigabytes=2000,
 | 
			
		||||
                 consistencygroups=2)
 | 
			
		||||
                 consistencygroups=2, per_volume_gigabytes=100)
 | 
			
		||||
        cs.assert_called('PUT', '/os-quota-class-sets/test')
 | 
			
		||||
 | 
			
		||||
    def test_refresh_quota(self):
 | 
			
		||||
@@ -43,6 +43,7 @@ class QuotaClassSetsTest(utils.TestCase):
 | 
			
		||||
        self.assertEqual(q.backups, q2.backups)
 | 
			
		||||
        self.assertEqual(q.backup_gigabytes, q2.backup_gigabytes)
 | 
			
		||||
        self.assertEqual(q.consistencygroups, q2.consistencygroups)
 | 
			
		||||
        self.assertEqual(q.per_volume_gigabytes, q2.per_volume_gigabytes)
 | 
			
		||||
        q2.volumes = 0
 | 
			
		||||
        self.assertNotEqual(q.volumes, q2.volumes)
 | 
			
		||||
        q2.snapshots = 0
 | 
			
		||||
@@ -55,6 +56,8 @@ class QuotaClassSetsTest(utils.TestCase):
 | 
			
		||||
        self.assertNotEqual(q.backup_gigabytes, q2.backup_gigabytes)
 | 
			
		||||
        q2.consistencygroups = 0
 | 
			
		||||
        self.assertNotEqual(q.consistencygroups, q2.consistencygroups)
 | 
			
		||||
        q2.per_volume_gigabytes = 0
 | 
			
		||||
        self.assertNotEqual(q.per_volume_gigabytes, q2.per_volume_gigabytes)
 | 
			
		||||
        q2.get()
 | 
			
		||||
        self.assertEqual(q.volumes, q2.volumes)
 | 
			
		||||
        self.assertEqual(q.snapshots, q2.snapshots)
 | 
			
		||||
@@ -62,3 +65,4 @@ class QuotaClassSetsTest(utils.TestCase):
 | 
			
		||||
        self.assertEqual(q.backups, q2.backups)
 | 
			
		||||
        self.assertEqual(q.backup_gigabytes, q2.backup_gigabytes)
 | 
			
		||||
        self.assertEqual(q.consistencygroups, q2.consistencygroups)
 | 
			
		||||
        self.assertEqual(q.per_volume_gigabytes, q2.per_volume_gigabytes)
 | 
			
		||||
 
 | 
			
		||||
@@ -40,6 +40,7 @@ class QuotaSetsTest(utils.TestCase):
 | 
			
		||||
        q.update(backups=2)
 | 
			
		||||
        q.update(backup_gigabytes=2000)
 | 
			
		||||
        q.update(consistencygroups=2)
 | 
			
		||||
        q.update(per_volume_gigabytes=100)
 | 
			
		||||
        cs.assert_called('PUT', '/os-quota-sets/test')
 | 
			
		||||
 | 
			
		||||
    def test_refresh_quota(self):
 | 
			
		||||
@@ -51,6 +52,7 @@ class QuotaSetsTest(utils.TestCase):
 | 
			
		||||
        self.assertEqual(q.backups, q2.backups)
 | 
			
		||||
        self.assertEqual(q.backup_gigabytes, q2.backup_gigabytes)
 | 
			
		||||
        self.assertEqual(q.consistencygroups, q2.consistencygroups)
 | 
			
		||||
        self.assertEqual(q.per_volume_gigabytes, q2.per_volume_gigabytes)
 | 
			
		||||
        q2.volumes = 0
 | 
			
		||||
        self.assertNotEqual(q.volumes, q2.volumes)
 | 
			
		||||
        q2.snapshots = 0
 | 
			
		||||
@@ -63,6 +65,8 @@ class QuotaSetsTest(utils.TestCase):
 | 
			
		||||
        self.assertNotEqual(q.backup_gigabytes, q2.backup_gigabytes)
 | 
			
		||||
        q2.consistencygroups = 0
 | 
			
		||||
        self.assertNotEqual(q.consistencygroups, q2.consistencygroups)
 | 
			
		||||
        q2.per_volume_gigabytes = 0
 | 
			
		||||
        self.assertNotEqual(q.per_volume_gigabytes, q2.per_volume_gigabytes)
 | 
			
		||||
        q2.get()
 | 
			
		||||
        self.assertEqual(q.volumes, q2.volumes)
 | 
			
		||||
        self.assertEqual(q.snapshots, q2.snapshots)
 | 
			
		||||
@@ -70,6 +74,7 @@ class QuotaSetsTest(utils.TestCase):
 | 
			
		||||
        self.assertEqual(q.backups, q2.backups)
 | 
			
		||||
        self.assertEqual(q.backup_gigabytes, q2.backup_gigabytes)
 | 
			
		||||
        self.assertEqual(q.consistencygroups, q2.consistencygroups)
 | 
			
		||||
        self.assertEqual(q.per_volume_gigabytes, q2.per_volume_gigabytes)
 | 
			
		||||
 | 
			
		||||
    def test_delete_quota(self):
 | 
			
		||||
        tenant_id = 'test'
 | 
			
		||||
 
 | 
			
		||||
@@ -892,7 +892,7 @@ def do_credentials(cs, args):
 | 
			
		||||
 | 
			
		||||
_quota_resources = ['volumes', 'snapshots', 'gigabytes',
 | 
			
		||||
                    'backups', 'backup_gigabytes',
 | 
			
		||||
                    'consistencygroups']
 | 
			
		||||
                    'consistencygroups', 'per_volume_gigabytes']
 | 
			
		||||
_quota_infos = ['Type', 'In_use', 'Reserved', 'Limit']
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -998,6 +998,10 @@ def do_quota_defaults(cs, args):
 | 
			
		||||
           metavar='<volume_type_name>',
 | 
			
		||||
           default=None,
 | 
			
		||||
           help='Volume type. Default=None.')
 | 
			
		||||
@utils.arg('--per-volume-gigabytes',
 | 
			
		||||
           metavar='<per_volume_gigabytes>',
 | 
			
		||||
           type=int, default=None,
 | 
			
		||||
           help='Set max volume size limit. Default=None.')
 | 
			
		||||
@utils.service_type('volumev2')
 | 
			
		||||
def do_quota_update(cs, args):
 | 
			
		||||
    """Updates quotas for a tenant."""
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user