Revision 326a79b9
b/docs/commands.rst | ||
---|---|---|
333 | 333 |
setgroup : Create/update a new user group |
334 | 334 |
setmeta : Set a new metadatum for account [, container [or object]] |
335 | 335 |
setpermissions: Set sharing permissions |
336 |
setquota : Set new quota (in KB) for account [or container] |
|
336 |
containerlimit: Container size limit commands |
|
337 |
set : Set copntainer data limit |
|
337 | 338 |
setversioning : Set new versioning (auto, none) for account [or container] |
338 | 339 |
sharers : List the accounts that share objects with default account |
339 | 340 |
touch : Create an empty object (file) |
b/docs/man/kamaki.rst | ||
---|---|---|
178 | 178 |
file commands |
179 | 179 |
************** |
180 | 180 |
|
181 |
* append Append local file to (existing) remote object |
|
182 |
* cat Print remote file contents to console |
|
183 |
* copy Copy an object from container to (another) container |
|
184 |
* create Create a container |
|
185 |
* delete Delete a container [or an object] |
|
186 |
* delgroup Delete a user group |
|
187 |
* delmeta Delete metadata from account, container or object |
|
188 |
* delpermissions Delete all permissions set on object |
|
189 |
* download Download remote object as local file |
|
190 |
* group Get groups and group members |
|
191 |
* hashmap Get the hash-map of an object |
|
192 |
* info Get detailed info for account, containers or objects |
|
193 |
* list List containers, object trees or objects in a directory |
|
194 |
* manifest Create a remote file of uploaded parts by manifestation |
|
195 |
* meta Get metadata for account, containers or objects |
|
196 |
* mkdir Create a directory |
|
197 |
* move Copy an object |
|
198 |
* overwrite Overwrite part (from start to end) of a remote file |
|
199 |
* permissions Get read and write permissions of an object |
|
200 |
* publish Publish the object and print the public url |
|
201 |
* purge Delete a container and release related data blocks |
|
202 |
* quota Get quota (in KB) for account or container |
|
203 |
* setgroup Set a user group |
|
204 |
* setmeta Set a piece of metadata for account, container or object |
|
205 |
* setpermissions Set permissions for an object |
|
206 |
* setquota Set new quota (in KB) for account or container
|
|
207 |
* setversioning Set versioning mode (auto, none) for account or container |
|
208 |
* sharers List the accounts that share objects with current user |
|
209 |
* touch Create an empty object (file) |
|
210 |
* truncate Truncate remote file up to a size |
|
211 |
* unpublish Unpublish an object |
|
212 |
* upload Upload a file |
|
213 |
* versioning Get versioning for account or container |
|
214 |
* versions Get the list of object versions |
|
181 |
* append Append local file to (existing) remote object
|
|
182 |
* cat Print remote file contents to console
|
|
183 |
* copy Copy an object from container to (another) container
|
|
184 |
* create Create a container
|
|
185 |
* delete Delete a container [or an object]
|
|
186 |
* delgroup Delete a user group
|
|
187 |
* delmeta Delete metadata from account, container or object
|
|
188 |
* delpermissions Delete all permissions set on object
|
|
189 |
* download Download remote object as local file
|
|
190 |
* group Get groups and group members
|
|
191 |
* hashmap Get the hash-map of an object
|
|
192 |
* info Get detailed info for account, containers or objects
|
|
193 |
* list List containers, object trees or objects in a directory
|
|
194 |
* manifest Create a remote file of uploaded parts by manifestation
|
|
195 |
* meta Get metadata for account, containers or objects
|
|
196 |
* mkdir Create a directory
|
|
197 |
* move Copy an object
|
|
198 |
* overwrite Overwrite part (from start to end) of a remote file
|
|
199 |
* permissions Get read and write permissions of an object
|
|
200 |
* publish Publish the object and print the public url
|
|
201 |
* purge Delete a container and release related data blocks
|
|
202 |
* quota Get quota (in KB) for account or container
|
|
203 |
* setgroup Set a user group
|
|
204 |
* setmeta Set a piece of metadata for account, container or object
|
|
205 |
* setpermissions Set permissions for an object
|
|
206 |
* containerlimit set Set new quota (in KB) for account or container
|
|
207 |
* setversioning Set versioning mode (auto, none) for account or container
|
|
208 |
* sharers List the accounts that share objects with current user
|
|
209 |
* touch Create an empty object (file)
|
|
210 |
* truncate Truncate remote file up to a size
|
|
211 |
* unpublish Unpublish an object
|
|
212 |
* upload Upload a file
|
|
213 |
* versioning Get versioning for account or container
|
|
214 |
* versions Get the list of object versions
|
|
215 | 215 |
|
216 | 216 |
|
217 | 217 |
test commands (hidden) |
b/kamaki/cli/commands/pithos.py | ||
---|---|---|
1771 | 1771 |
|
1772 | 1772 |
|
1773 | 1773 |
@command(pithos_cmds) |
1774 |
class file_setquota(_file_account_command): |
|
1775 |
"""Set new quota for account or container |
|
1776 |
By default, quota is set in bytes |
|
1774 |
class file_containerlimit(_pithos_init): |
|
1775 |
"""Container size limit commands""" |
|
1776 |
|
|
1777 |
|
|
1778 |
@command(pithos_cmds) |
|
1779 |
class file_containerlimit_set(_file_account_command): |
|
1780 |
"""Set new storage limit for a container |
|
1781 |
By default, the limit is set in bytes |
|
1777 | 1782 |
Users may specify a different unit, e.g: |
1778 |
/file setquota 2.3GB mycontainer
|
|
1779 |
Accepted units: B, KiB (1024 B), KB (1000 B), MiB, MB, GiB, GB, TiB, TB
|
|
1783 |
/file containerlimit set 2.3GB mycontainer
|
|
1784 |
Valide units: B, KiB (1024 B), KB (1000 B), MiB, MB, GiB, GB, TiB, TB
|
|
1780 | 1785 |
""" |
1781 | 1786 |
|
1782 | 1787 |
@errors.generic.all |
1783 |
def _calculate_quota(self, user_input):
|
|
1784 |
quota = 0
|
|
1788 |
def _calculate_limit(self, user_input):
|
|
1789 |
limit = 0
|
|
1785 | 1790 |
try: |
1786 |
quota = int(user_input)
|
|
1791 |
limit = int(user_input)
|
|
1787 | 1792 |
except ValueError: |
1788 | 1793 |
index = 0 |
1789 | 1794 |
digits = [str(num) for num in range(0, 10)] + ['.'] |
1790 | 1795 |
while user_input[index] in digits: |
1791 | 1796 |
index += 1 |
1792 |
quota = user_input[:index]
|
|
1797 |
limit = user_input[:index]
|
|
1793 | 1798 |
format = user_input[index:] |
1794 | 1799 |
try: |
1795 |
return to_bytes(quota, format)
|
|
1800 |
return to_bytes(limit, format)
|
|
1796 | 1801 |
except Exception as qe: |
1797 | 1802 |
msg = 'Failed to convert %s to bytes' % user_input, |
1798 | 1803 |
raiseCLIError(qe, msg, details=[ |
1799 |
'Syntax: setquota <quota>[format] [container]',
|
|
1800 |
'e.g.: setquota 2.3GB mycontainer',
|
|
1801 |
'Acceptable formats:',
|
|
1804 |
'Syntax: containerlimit set <limit>[format] [container]',
|
|
1805 |
'e.g.: containerlimit set 2.3GB mycontainer',
|
|
1806 |
'Valid formats:',
|
|
1802 | 1807 |
'(*1024): B, KiB, MiB, GiB, TiB', |
1803 | 1808 |
'(*1000): B, KB, MB, GB, TB']) |
1804 |
return quota
|
|
1809 |
return limit
|
|
1805 | 1810 |
|
1806 | 1811 |
@errors.generic.all |
1807 | 1812 |
@errors.pithos.connection |
1808 | 1813 |
@errors.pithos.container |
1809 |
def _run(self, quota):
|
|
1814 |
def _run(self, limit):
|
|
1810 | 1815 |
if self.container: |
1811 | 1816 |
self.client.container = self.container |
1812 |
self.client.set_container_quota(quota) |
|
1813 |
else: |
|
1814 |
self.client.set_account_quota(quota) |
|
1817 |
self.client.set_container_limit(limit) |
|
1815 | 1818 |
|
1816 |
def main(self, quota, container=None):
|
|
1819 |
def main(self, limit, container=None):
|
|
1817 | 1820 |
super(self.__class__, self)._run() |
1818 |
quota = self._calculate_quota(quota)
|
|
1821 |
limit = self._calculate_limit(limit)
|
|
1819 | 1822 |
self.container = container |
1820 |
self._run(quota)
|
|
1823 |
self._run(limit)
|
|
1821 | 1824 |
|
1822 | 1825 |
|
1823 | 1826 |
@command(pithos_cmds) |
b/kamaki/clients/pithos/__init__.py | ||
---|---|---|
837 | 837 |
""" |
838 | 838 |
self.container_post(update=True, metadata={metakey: ''}) |
839 | 839 |
|
840 |
def set_container_quota(self, quota):
|
|
840 |
def set_container_limit(self, limit):
|
|
841 | 841 |
""" |
842 |
:param quota: (int)
|
|
842 |
:param limit: (int)
|
|
843 | 843 |
""" |
844 |
self.container_post(update=True, quota=quota)
|
|
844 |
self.container_post(update=True, quota=limit)
|
|
845 | 845 |
|
846 | 846 |
def set_container_versioning(self, versioning): |
847 | 847 |
""" |
b/kamaki/clients/pithos/test.py | ||
---|---|---|
1370 | 1370 |
AP.assert_called_once_with(update=True, metadata={'somekey': ''}) |
1371 | 1371 |
|
1372 | 1372 |
@patch('%s.container_post' % pithos_pkg, return_value=FR()) |
1373 |
def test_set_container_quota(self, post):
|
|
1373 |
def test_set_container_limit(self, post):
|
|
1374 | 1374 |
qu = 1024 |
1375 |
self.client.set_container_quota(qu)
|
|
1375 |
self.client.set_container_limit(qu)
|
|
1376 | 1376 |
post.assert_called_once_with(update=True, quota=qu) |
1377 | 1377 |
|
1378 | 1378 |
@patch('%s.container_post' % pithos_pkg, return_value=FR()) |
Also available in: Unified diff