Add support of snapshot gigabytes quotas

Manila is going to support separate gigabyte quota for snapshots. Need add
its support to client.

Change-Id: I6566c0f696fbe033cb036be5cda720f706fdc222
This commit is contained in:
Valeriy Ponomaryov 2015-02-24 15:37:31 +02:00
parent 58cc003661
commit 363a4d6917
4 changed files with 39 additions and 4 deletions

View File

@ -85,6 +85,7 @@ class FakeHTTPClient(httpclient.HTTPClient):
'shares': 1, 'shares': 1,
'snapshots': 1, 'snapshots': 1,
'gigabytes': 1, 'gigabytes': 1,
'snapshot_gigabytes': 1,
'share_networks': 1, 'share_networks': 1,
} }
} }
@ -98,6 +99,7 @@ class FakeHTTPClient(httpclient.HTTPClient):
'shares': 1, 'shares': 1,
'snapshots': 1, 'snapshots': 1,
'gigabytes': 1, 'gigabytes': 1,
'snapshot_gigabytes': 1,
'share_networks': 1, 'share_networks': 1,
} }
} }
@ -114,6 +116,7 @@ class FakeHTTPClient(httpclient.HTTPClient):
'shares': 2, 'shares': 2,
'snapshots': 2, 'snapshots': 2,
'gigabytes': 1, 'gigabytes': 1,
'snapshot_gigabytes': 1,
'share_networks': 1, 'share_networks': 1,
} }
} }
@ -131,6 +134,7 @@ class FakeHTTPClient(httpclient.HTTPClient):
'shares': 1, 'shares': 1,
'snapshots': 1, 'snapshots': 1,
'gigabytes': 1, 'gigabytes': 1,
'snapshot_gigabytes': 1,
'share_networks': 1, 'share_networks': 1,
} }
} }
@ -147,6 +151,7 @@ class FakeHTTPClient(httpclient.HTTPClient):
'shares': 2, 'shares': 2,
'snapshots': 2, 'snapshots': 2,
'gigabytes': 1, 'gigabytes': 1,
'snapshot_gigabytes': 1,
'share_networks': 1, 'share_networks': 1,
} }
} }

View File

@ -41,16 +41,22 @@ class QuotaSetsTest(utils.TestCase):
def test_update_quota(self): def test_update_quota(self):
q = cs.quotas.get('test') q = cs.quotas.get('test')
q.update(shares=2) q.update(shares=1)
q.update(snapshots=2) q.update(snapshots=2)
q.update(gigabytes=3)
q.update(snapshot_gigabytes=4)
q.update(share_networks=5)
cs.assert_called('PUT', '/os-quota-sets/test') cs.assert_called('PUT', '/os-quota-sets/test')
def test_update_user_quota(self): def test_update_user_quota(self):
tenant_id = 'test' tenant_id = 'test'
user_id = 'fake_user' user_id = 'fake_user'
q = cs.quotas.get(tenant_id) q = cs.quotas.get(tenant_id)
q.update(shares=2, user_id=user_id) q.update(shares=1, user_id=user_id)
q.update(snapshots=2, user_id=user_id) q.update(snapshots=2, user_id=user_id)
q.update(gigabytes=3, user_id=user_id)
q.update(snapshot_gigabytes=4, user_id=user_id)
q.update(share_networks=5, user_id=user_id)
url = '/os-quota-sets/%s?user_id=%s' % (tenant_id, user_id) url = '/os-quota-sets/%s?user_id=%s' % (tenant_id, user_id)
cs.assert_called('PUT', url) cs.assert_called('PUT', url)

View File

@ -40,7 +40,8 @@ class QuotaSetManager(base.ManagerWithFind):
url = "/os-quota-sets/%s" % tenant_id url = "/os-quota-sets/%s" % tenant_id
return self._get(url, "quota_set") return self._get(url, "quota_set")
def update(self, tenant_id, shares=None, snapshots=None, gigabytes=None, def update(self, tenant_id, shares=None, snapshots=None,
gigabytes=None, snapshot_gigabytes=None,
share_networks=None, force=None, user_id=None): share_networks=None, force=None, user_id=None):
body = { body = {
@ -49,6 +50,7 @@ class QuotaSetManager(base.ManagerWithFind):
'shares': shares, 'shares': shares,
'snapshots': snapshots, 'snapshots': snapshots,
'gigabytes': gigabytes, 'gigabytes': gigabytes,
'snapshot_gigabytes': snapshot_gigabytes,
'share_networks': share_networks, 'share_networks': share_networks,
'force': force, 'force': force,
}, },

View File

@ -143,7 +143,13 @@ def do_credentials(cs, args):
cliutils.print_dict(catalog['user'], "User Credentials") cliutils.print_dict(catalog['user'], "User Credentials")
cliutils.print_dict(catalog['token'], "Token") cliutils.print_dict(catalog['token'], "Token")
_quota_resources = ['shares', 'snapshots', 'gigabytes', 'share_networks'] _quota_resources = [
'shares',
'snapshots',
'gigabytes',
'snapshot_gigabytes',
'share_networks',
]
def _quota_show(quotas): def _quota_show(quotas):
@ -232,6 +238,14 @@ def do_quota_defaults(cs, args):
type=int, type=int,
default=None, default=None,
help='New value for the "gigabytes" quota.') help='New value for the "gigabytes" quota.')
@cliutils.arg(
'--snapshot-gigabytes',
'--snapshot_gigabytes', # alias
metavar='<snapshot_gigabytes>',
type=int,
default=None,
action='single_alias',
help='New value for the "snapshot_gigabytes" quota.')
@cliutils.arg( @cliutils.arg(
'--share-networks', '--share-networks',
metavar='<share-networks>', metavar='<share-networks>',
@ -305,6 +319,14 @@ def do_quota_class_show(cs, args):
type=int, type=int,
default=None, default=None,
help='New value for the "gigabytes" quota.') help='New value for the "gigabytes" quota.')
@cliutils.arg(
'--snapshot-gigabytes',
'--snapshot_gigabytes', # alias
metavar='<snapshot_gigabytes>',
type=int,
default=None,
action='single_alias',
help='New value for the "snapshot_gigabytes" quota.')
@cliutils.arg( @cliutils.arg(
'--share-networks', '--share-networks',
metavar='<share-networks>', metavar='<share-networks>',