Skip to content
Snippets Groups Projects
Commit d869f740 authored by wachsylon's avatar wachsylon
Browse files

Use container for toggling

parent 9299a0e9
No related branches found
No related tags found
No related merge requests found
...@@ -171,15 +171,16 @@ def get_token(swift_base, account, username=None, **kwargs): ...@@ -171,15 +171,16 @@ def get_token(swift_base, account, username=None, **kwargs):
env,expires = _get_envtoken(**kwargs) env,expires = _get_envtoken(**kwargs)
return env return env
def toggle_public(fsmap): def toggle_public(container):
"toggle container public read_acl settings" "toggle container public read_acl settings"
getenv = os.environ.get getenv = os.environ.get
conn = Connection(preauthurl=getenv('OS_STORAGE_URL'), osurl=getenv('OS_STORAGE_URL')
conn = Connection(preauthurl=osurl,
preauthtoken=getenv('OS_AUTH_TOKEN')) preauthtoken=getenv('OS_AUTH_TOKEN'))
acl = conn.head_container(fsmap.root).get("x-container-read", "") acl = conn.head_container(container).get("x-container-read", "")
if ".r:*" in acl: if ".r:*" in acl:
acl = acl.replace(".r:*", "") acl = acl.replace(".r:*", "")
else: else:
acl = ",".join([acl, ".r:*,.rlistings"]) acl = ",".join([acl, ".r:*,.rlistings"])
acl = ",".join(sorted(filter(None, set(acl.split(","))))) acl = ",".join(sorted(filter(None, set(acl.split(",")))))
conn.post_container(fsmap.root, headers={"X-Container-Read": acl}) conn.post_container(container, headers={"X-Container-Read": acl})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment