Commit d1856abf authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Added policy handling

In CLI setversioning, versioning, setquota, quota for account and container
In storage(pithos) set_container_versioning, set_container_quota, set_account_versioning, set_account_quota
    also get_*_policy methods are split to get_*_versioning and get_*_quota
parent e742badc
......@@ -748,6 +748,30 @@ class store_setmeta(_store_account_command):
else:
self.client.set_object_meta(object, {metakey:metavalue})
@command(api='storage')
class store_setquota(_store_account_command):
"""Set new quota (in KB) for account [or container]"""
def main(self, quota, container = None):
super(store_setquota, self).main()
if container is None:
self.client.set_account_quota(quota)
else:
self.client.container = container
self.client.set_container_quota(quota)
@command(api='storage')
class store_setversioning(_store_account_command):
"""Set new versioning (auto, none) for account [or container]"""
def main(self, versioning, container = None):
super(store_setversioning, self).main()
if container is None:
self.client.set_account_versioning(versioning)
else:
self.client.container = container
self.client.set_container_versioning(versioning)
@command(api='storage')
class store_delmeta(_store_account_command):
"""Delete an existing metadatum of account [, container [or object]]"""
......@@ -764,15 +788,27 @@ class store_delmeta(_store_account_command):
self.client.delete_object_meta(metakey, object)
@command(api='storage')
class store_policy(_store_account_command):
"""Get policy for account [, container [or object]]"""
class store_quota(_store_account_command):
"""Get quota for account [or container]"""
def main(self, container = None):
super(store_quota, self).main()
if container is None:
reply = self.client.get_account_quota()
else:
reply = self.client.get_container_quota(container)
print_dict(reply)
@command(api='storage')
class store_versioning(_store_account_command):
"""Get versioning for account [or container ]"""
def main(self, container = None):
super(store_policy, self).main()
super(store_versioning, self).main()
if container is None:
reply = self.client.get_account_policy()
reply = self.client.get_account_versioning()
else:
reply = self.client.get_container_policy(container)
reply = self.client.get_container_versioning(container)
print_dict(reply)
@command(api='storage')
......
......@@ -127,8 +127,11 @@ class PithosClient(StorageClient):
self.put(path, json=hashmap,
success=201)
def get_account_policy(self):
return filter_in(self.get_account_info(), 'X-Account-Policy-')
def get_account_quota(self):
return filter_in(self.get_account_info(), 'X-Account-Policy-Quota')
def get_account_versioning(self):
return filter_in(self.get_account_info(), 'X-Account-Policy-Versioning')
def get_account_meta(self):
return filter_in(self.get_account_info(), 'X-Account-Meta-')
......@@ -141,8 +144,23 @@ class PithosClient(StorageClient):
self.set_header('X-Account-Meta-'+key, val)
self.post(path, success=202)
def get_container_policy(self, container):
return filter_in(self.get_container_info(container), 'X-Container-Policy-')
def set_account_quota(self, quota):
self.assert_account()
path = path4url(self.account)+params4url({'update':None})
self.set_header('X-Account-Policy-Quota', quota)
self.post(path, success=202)
def set_account_versioning(self, versioning):
self.assert_account()
path = path4url(self.account)+params4url({'update':None})
self.set_header('X-Account-Policy-Versioning', versioning)
self.post(path, success=202)
def get_container_versioning(self, container):
return filter_in(self.get_container_info(container), 'X-Container-Policy-Versioning')
def get_container_quota(self, container):
return filter_in(self.get_container_info(container), 'X-Container-Policy-Quota')
def get_container_meta(self, container):
return filter_in(self.get_container_info(container), 'X-Container-Meta-')
......@@ -173,6 +191,18 @@ class PithosClient(StorageClient):
self.set_header('X-Container-Meta-'+key, val)
self.post(path, success=202)
def set_container_quota(self, quota):
self.assert_container()
path = path4url(self.account, self.container)+params4url({'update':None})
self.set_header('X-Container-Policy-Quota', quota)
self.post(path, success=202)
def set_container_versioning(self, versioning):
self.assert_container()
path = path4url(self.account, self.container)+params4url({'update':None})
self.set_header('X-Container-Policy-Versioning', versioning)
self.post(path, success=202)
def set_object_meta(self, object, metapairs):
assert(type(metapairs) is dict)
self.assert_container()
......@@ -192,6 +222,3 @@ class PithosClient(StorageClient):
path = path4url(self.account, self.container, object)+params4url({'update':None})
self.set_header('X-Object-Public', False)
self.post(path, success=202)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment