Created
April 23, 2020 19:57
-
-
Save clayg/f8d25a1a7a7580b7cf1dc79bd88844c2 to your computer and use it in GitHub Desktop.
internal client based tool to set read-only sysmeta to true/false
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| from argparse import ArgumentParser | |
| import sys | |
| from swift.common.internal_client import InternalClient | |
| from swift.common.wsgi import ConfigString | |
| from swift.container.sync import ic_conf_body | |
| parser = ArgumentParser() | |
| parser.add_argument('account', help='the account name') | |
| parser.add_argument('--read-only', action='store_true', | |
| help='set account to read only') | |
| def main(): | |
| args = parser.parse_args() | |
| swift = InternalClient(ConfigString(ic_conf_body), | |
| 'internal-sysmeta', 1) | |
| metadata = { | |
| 'X-Account-Sysmeta-Read-Only': str(bool(args.read_only)).lower(), | |
| } | |
| swift.set_account_metadata(args.account, metadata) | |
| metadata = swift.get_account_metadata(args.account) | |
| for k, v in metadata.items(): | |
| print('%s: %s' % (k, v)) | |
| if __name__ == "__main__": | |
| sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment