|
|
@ -199,7 +199,7 @@ except ImportError, e:
|
|
|
|
print("failed=True msg='pyrax is required for this module'")
|
|
|
|
print("failed=True msg='pyrax is required for this module'")
|
|
|
|
sys.exit(1)
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
EXIT_DICT = {'success': False}
|
|
|
|
EXIT_DICT = dict(success=False)
|
|
|
|
META_PREFIX = 'x-object-meta-'
|
|
|
|
META_PREFIX = 'x-object-meta-'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -257,9 +257,9 @@ def upload(module, cf, container, src, dest, meta, expires):
|
|
|
|
num_objs_after = len(c.get_object_names())
|
|
|
|
num_objs_after = len(c.get_object_names())
|
|
|
|
|
|
|
|
|
|
|
|
if not meta:
|
|
|
|
if not meta:
|
|
|
|
meta = {}
|
|
|
|
meta = dict()
|
|
|
|
|
|
|
|
|
|
|
|
meta_result = {}
|
|
|
|
meta_result = dict()
|
|
|
|
if meta:
|
|
|
|
if meta:
|
|
|
|
if cont_obj:
|
|
|
|
if cont_obj:
|
|
|
|
meta_result = cont_obj.set_metadata(meta)
|
|
|
|
meta_result = cont_obj.set_metadata(meta)
|
|
|
@ -294,9 +294,7 @@ def upload(module, cf, container, src, dest, meta, expires):
|
|
|
|
if cont_obj or locals().get('bytes'):
|
|
|
|
if cont_obj or locals().get('bytes'):
|
|
|
|
EXIT_DICT['changed'] = True
|
|
|
|
EXIT_DICT['changed'] = True
|
|
|
|
if meta_result:
|
|
|
|
if meta_result:
|
|
|
|
EXIT_DICT['meta'] = {
|
|
|
|
EXIT_DICT['meta'] = dict(updated=True)
|
|
|
|
'updated': True
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if cont_obj:
|
|
|
|
if cont_obj:
|
|
|
|
EXIT_DICT['bytes'] = cont_obj.total_bytes
|
|
|
|
EXIT_DICT['bytes'] = cont_obj.total_bytes
|
|
|
@ -431,14 +429,18 @@ def get_meta(module, cf, container, src, dest):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
objs = c.get_object_names()
|
|
|
|
objs = c.get_object_names()
|
|
|
|
|
|
|
|
|
|
|
|
results = {}
|
|
|
|
results = dict()
|
|
|
|
for obj in objs:
|
|
|
|
for obj in objs:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
meta = c.get_object(obj).get_metadata()
|
|
|
|
meta = c.get_object(obj).get_metadata()
|
|
|
|
except Exception, e:
|
|
|
|
except Exception, e:
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
results[obj] = {k.split(META_PREFIX)[-1]: v for k, v in meta.iteritems()}
|
|
|
|
results[obj] = dict()
|
|
|
|
|
|
|
|
for k, v in meta.items():
|
|
|
|
|
|
|
|
meta_key = k.split(META_PREFIX)[-1]
|
|
|
|
|
|
|
|
results[obj][meta_key] = v
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EXIT_DICT['container'] = c.name
|
|
|
|
EXIT_DICT['container'] = c.name
|
|
|
|
if results:
|
|
|
|
if results:
|
|
|
@ -452,7 +454,6 @@ def put_meta(module, cf, container, src, dest, meta, clear_meta):
|
|
|
|
Passing a true value to clear_meta clears the metadata stored in Cloud
|
|
|
|
Passing a true value to clear_meta clears the metadata stored in Cloud
|
|
|
|
Files before setting the new metadata to the value of "meta".
|
|
|
|
Files before setting the new metadata to the value of "meta".
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
objs = None
|
|
|
|
objs = None
|
|
|
|
if src and dest:
|
|
|
|
if src and dest:
|
|
|
|
module.fail_json(msg="Error: ambiguous instructions; files to set meta"
|
|
|
|
module.fail_json(msg="Error: ambiguous instructions; files to set meta"
|
|
|
@ -570,7 +571,7 @@ def main():
|
|
|
|
dest=dict(),
|
|
|
|
dest=dict(),
|
|
|
|
method=dict(default='get', choices=['put', 'get', 'delete']),
|
|
|
|
method=dict(default='get', choices=['put', 'get', 'delete']),
|
|
|
|
type=dict(default='file', choices=['file', 'meta']),
|
|
|
|
type=dict(default='file', choices=['file', 'meta']),
|
|
|
|
meta=dict(type='dict', default={}),
|
|
|
|
meta=dict(type='dict', default=dict()),
|
|
|
|
clear_meta=dict(choices=BOOLEANS, default=False, type='bool'),
|
|
|
|
clear_meta=dict(choices=BOOLEANS, default=False, type='bool'),
|
|
|
|
structure=dict(choices=BOOLEANS, default=True, type='bool'),
|
|
|
|
structure=dict(choices=BOOLEANS, default=True, type='bool'),
|
|
|
|
expires=dict(type='int'),
|
|
|
|
expires=dict(type='int'),
|
|
|
|