Revision 3bf0f656
b/kamaki/cli.py | ||
---|---|---|
717 | 717 |
print_dict(reply) |
718 | 718 |
|
719 | 719 |
@command(api='storage') |
720 |
class store_meta(_store_account_command): |
|
721 |
"""Get custom meta-content for account [, container [or object]]""" |
|
722 |
|
|
723 |
def main(self, container = None, object = None): |
|
724 |
super(store_meta, self).main() |
|
725 |
if container is None: |
|
726 |
reply = self.client.get_account_meta() |
|
727 |
elif object is None: |
|
728 |
reply = self.client.get_container_meta(container) |
|
729 |
else: |
|
730 |
self.client.container = container |
|
731 |
reply = self.client.get_object_meta(object) |
|
732 |
print_dict(reply) |
|
733 |
|
|
734 |
@command(api='storage') |
|
720 | 735 |
class store_create(_store_account_command): |
721 | 736 |
"""Create a container [or a directory object]""" |
722 | 737 |
|
b/kamaki/clients/storage.py | ||
---|---|---|
33 | 33 |
|
34 | 34 |
from . import Client, ClientError |
35 | 35 |
|
36 |
def filter_dict_with_prefix(d, prefix): |
|
37 |
return {key:d[key] for key in d if key.startswith(prefix)} |
|
36 | 38 |
|
37 | 39 |
class StorageClient(Client): |
38 | 40 |
"""OpenStack Object Storage API 1.0 client""" |
... | ... | |
59 | 61 |
raise ClientError("No authorization") |
60 | 62 |
return r.headers |
61 | 63 |
|
64 |
def get_account_meta(self): |
|
65 |
return filter_dict_with_prefix(self.get_account_info(), 'X-Account-Meta-') |
|
66 |
|
|
62 | 67 |
def create_container(self, container): |
63 | 68 |
self.assert_account() |
64 | 69 |
path = '/%s/%s' % (self.account, container) |
... | ... | |
82 | 87 |
|
83 | 88 |
return reply |
84 | 89 |
|
90 |
def get_container_meta(self, container): |
|
91 |
return filter_dict_with_prefix(self.get_container_info(container), 'X-Container-Meta-') |
|
92 |
|
|
85 | 93 |
def delete_container(self, container): |
86 | 94 |
#Response codes |
87 | 95 |
# Success 204 |
... | ... | |
123 | 131 |
r = self.head(path, success=200) |
124 | 132 |
return r.headers |
125 | 133 |
|
134 |
def get_object_meta(self, object): |
|
135 |
return filter_dict_with_prefix(self.get_object_info(object), 'X-Object-Meta-') |
|
136 |
|
|
126 | 137 |
def get_object(self, object): |
127 | 138 |
self.assert_container() |
128 | 139 |
path = '/%s/%s/%s' % (self.account, self.container, object) |
b/kamaki/utils.py | ||
---|---|---|
95 | 95 |
size /= 1024 |
96 | 96 |
s = ('%.1f' % size).rstrip('.0') |
97 | 97 |
return s + unit |
98 |
|
Also available in: Unified diff