permissions : Get object read/write permissions
publish : Publish an object
purge : Purge a container
- quota : Get quota for account [or container]
+ quota : Get quota for account
setgroup : Create/update a new user group
setmeta : Set a new metadatum for account [, container [or object]]
setpermissions: Set sharing permissions
containerlimit: Container size limit commands
- set : Set copntainer data limit
+ set : Set container data limit
+ get : Get container data limit
setversioning : Set new versioning (auto, none) for account [or container]
sharers : List the accounts that share objects with default account
touch : Create an empty object (file)
* setgroup Set a user group
* setmeta Set a piece of metadata for account, container or object
* setpermissions Set permissions for an object
-* containerlimit set Set new quota (in KB) for account or container
+* containerlimit set Set new limit for container
+* containerlimit get Get container limit
* setversioning Set versioning mode (auto, none) for account or container
* sharers List the accounts that share objects with current user
* touch Create an empty object (file)
'Set user account (not permanent)',
('-A', '--account'))
- def _run(self):
+ def _run(self, custom_account=None):
super(_file_account_command, self)._run()
- if self['account']:
+ if custom_account:
+ self.client.account = custom_account
+ elif self['account']:
self.client.account = self['account']
@errors.generic.all
versioning=ValueArgument(
'set container versioning (auto/none)',
'--versioning'),
- quota=IntArgument('set default container quota', '--quota'),
+ limit=IntArgument('set default container limit', '--limit'),
meta=KeyValueArgument(
'set container metadata (can be repeated)',
'--meta')
@errors.pithos.container
def _run(self):
self.client.container_put(
- quota=self['quota'],
+ limit=self['limit'],
versioning=self['versioning'],
metadata=self['meta'])
@command(pithos_cmds)
class file_quota(_file_account_command):
- """Get quota for account or container"""
+ """Get account quota"""
arguments = dict(
in_bytes=FlagArgument('Show result in bytes', ('-b', '--bytes'))
@errors.generic.all
@errors.pithos.connection
- @errors.pithos.container
def _run(self):
- if self.container:
- reply = self.client.get_container_quota(self.container)
- else:
- reply = self.client.get_account_quota()
+ reply = self.client.get_account_quota()
if not self['in_bytes']:
for k in reply:
reply[k] = format_size(reply[k])
print_dict(pretty_keys(reply, '-'))
- def main(self, container=None):
- super(self.__class__, self)._run()
- self.container = container
+ def main(self, custom_uuid=None):
+ super(self.__class__, self)._run(custom_account=custom_uuid)
self._run()
@command(pithos_cmds)
+class file_containerlimit_get(_file_container_command):
+ """Get container size limit"""
+
+ arguments = dict(
+ in_bytes=FlagArgument('Show result in bytes', ('-b', '--bytes'))
+ )
+
+ @errors.generic.all
+ @errors.pithos.container
+ def _run(self):
+ reply = self.client.get_container_limit(self.container)
+ if not self['in_bytes']:
+ for k in reply:
+ reply[k] = format_size(reply[k])
+ print_dict(pretty_keys(reply, '-'))
+
+ def main(self, container=None):
+ super(self.__class__, self)._run()
+ self.container = container
+ self._run()
+
+
+@command(pithos_cmds)
class file_containerlimit_set(_file_account_command):
"""Set new storage limit for a container
By default, the limit is set in bytes
Users may specify a different unit, e.g:
/file containerlimit set 2.3GB mycontainer
- Valide units: B, KiB (1024 B), KB (1000 B), MiB, MB, GiB, GB, TiB, TB
+ Valid units: B, KiB (1024 B), KB (1000 B), MiB, MB, GiB, GB, TiB, TB
"""
@errors.generic.all
you don't have permissions to modify those at account level
"""
- newquota = 1000000
- self.client.set_account_quota(newquota)
+ #newquota = 1000000
+ #self.client.set_account_quota(newquota)
#r = self.client.get_account_info()
#print(unicode(r))
#r = self.client.get_account_quota()
r = self.client.container_put()
self.assertEqual(r.status_code, 202)
- r = self.client.get_container_quota(self.client.container)
+ r = self.client.get_container_limit(self.client.container)
cquota = r.values()[0]
newquota = 2 * int(cquota)
r = self.client.container_put(quota=newquota)
self.assertEqual(r.status_code, 202)
- r = self.client.get_container_quota(self.client.container)
+ r = self.client.get_container_limit(self.client.container)
xquota = int(r.values()[0])
self.assertEqual(newquota, xquota)
self.assertEqual(r['x-container-meta-m2'], 'v2a')
"""check quota"""
- r = self.client.get_container_quota(self.client.container)
+ r = self.client.get_container_limit(self.client.container)
cquota = r.values()[0]
newquota = 2 * int(cquota)
- r = self.client.set_container_quota(newquota)
- r = self.client.get_container_quota(self.client.container)
+ r = self.client.set_container_limit(newquota)
+ r = self.client.get_container_limit(self.client.container)
xquota = int(r.values()[0])
self.assertEqual(newquota, xquota)
- r = self.client.set_container_quota(cquota)
- r = self.client.get_container_quota(self.client.container)
+ r = self.client.set_container_limit(cquota)
+ r = self.client.get_container_limit(self.client.container)
xquota = r.values()[0]
self.assertEqual(cquota, xquota)
"""
self.account_post(update=True, metadata={metakey: ''})
+ """
def set_account_quota(self, quota):
- """
+ ""
:param quota: (int)
- """
+ ""
self.account_post(update=True, quota=quota)
+ """
def set_account_versioning(self, versioning):
"""
finally:
self.container = cnt_back_up
- def get_container_quota(self, container=None):
+ def get_container_limit(self, container=None):
"""
:param container: (str)
self.client.set_account_meta(metas)
post.assert_called_once_with(update=True, metadata=metas)
+ """
@patch('%s.account_post' % pithos_pkg, return_value=FR())
def test_set_account_quota(self, post):
qu = 1024
self.client.set_account_quota(qu)
post.assert_called_once_with(update=True, quota=qu)
+ """
@patch('%s.account_post' % pithos_pkg, return_value=FR())
def test_set_account_versioning(self, post):
self.assertEqual(bu_cnt, self.client.container)
@patch('%s.get_container_info' % pithos_pkg, return_value=container_info)
- def test_get_container_quota(self, GCI):
+ def test_get_container_limit(self, GCI):
key = 'x-container-policy-quota'
cont = 'c0n7-417'
bu_cnt = self.client.container
for container in (None, cont):
- r = self.client.get_container_quota(container=container)
+ r = self.client.get_container_limit(container=container)
self.assertEqual(r[key], container_info[key])
self.assertEqual(GCI.mock_calls[-1], call())
self.assertEqual(bu_cnt, self.client.container)