|
|
@ -142,7 +142,7 @@ EXAMPLES = '''
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
import pyrax
|
|
|
|
import pyrax
|
|
|
|
HAS_PYRAX = True
|
|
|
|
HAS_PYRAX = True
|
|
|
|
except ImportError, e:
|
|
|
|
except ImportError as e:
|
|
|
|
HAS_PYRAX = False
|
|
|
|
HAS_PYRAX = False
|
|
|
|
|
|
|
|
|
|
|
|
EXIT_DICT = dict(success=True)
|
|
|
|
EXIT_DICT = dict(success=True)
|
|
|
@ -152,7 +152,7 @@ META_PREFIX = 'x-container-meta-'
|
|
|
|
def _get_container(module, cf, container):
|
|
|
|
def _get_container(module, cf, container):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
return cf.get_container(container)
|
|
|
|
return cf.get_container(container)
|
|
|
|
except pyrax.exc.NoSuchContainer, e:
|
|
|
|
except pyrax.exc.NoSuchContainer as e:
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -162,7 +162,7 @@ def _fetch_meta(module, container):
|
|
|
|
for k, v in container.get_metadata().items():
|
|
|
|
for k, v in container.get_metadata().items():
|
|
|
|
split_key = k.split(META_PREFIX)[-1]
|
|
|
|
split_key = k.split(META_PREFIX)[-1]
|
|
|
|
EXIT_DICT['meta'][split_key] = v
|
|
|
|
EXIT_DICT['meta'][split_key] = v
|
|
|
|
except Exception, e:
|
|
|
|
except Exception as e:
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -172,7 +172,7 @@ def meta(cf, module, container_, state, meta_, clear_meta):
|
|
|
|
if meta_ and state == 'present':
|
|
|
|
if meta_ and state == 'present':
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
meta_set = c.set_metadata(meta_, clear=clear_meta)
|
|
|
|
meta_set = c.set_metadata(meta_, clear=clear_meta)
|
|
|
|
except Exception, e:
|
|
|
|
except Exception as e:
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
elif meta_ and state == 'absent':
|
|
|
|
elif meta_ and state == 'absent':
|
|
|
|
remove_results = []
|
|
|
|
remove_results = []
|
|
|
@ -214,12 +214,12 @@ def container(cf, module, container_, state, meta_, clear_meta, ttl, public,
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
c = cf.get_container(container_)
|
|
|
|
c = cf.get_container(container_)
|
|
|
|
except pyrax.exc.NoSuchContainer, e:
|
|
|
|
except pyrax.exc.NoSuchContainer as e:
|
|
|
|
# Make the container if state=present, otherwise bomb out
|
|
|
|
# Make the container if state=present, otherwise bomb out
|
|
|
|
if state == 'present':
|
|
|
|
if state == 'present':
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
c = cf.create_container(container_)
|
|
|
|
c = cf.create_container(container_)
|
|
|
|
except Exception, e:
|
|
|
|
except Exception as e:
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
EXIT_DICT['changed'] = True
|
|
|
|
EXIT_DICT['changed'] = True
|
|
|
@ -232,7 +232,7 @@ def container(cf, module, container_, state, meta_, clear_meta, ttl, public,
|
|
|
|
if state == 'absent':
|
|
|
|
if state == 'absent':
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
cont_deleted = c.delete()
|
|
|
|
cont_deleted = c.delete()
|
|
|
|
except Exception, e:
|
|
|
|
except Exception as e:
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
EXIT_DICT['deleted'] = True
|
|
|
|
EXIT_DICT['deleted'] = True
|
|
|
@ -240,7 +240,7 @@ def container(cf, module, container_, state, meta_, clear_meta, ttl, public,
|
|
|
|
if meta_:
|
|
|
|
if meta_:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
meta_set = c.set_metadata(meta_, clear=clear_meta)
|
|
|
|
meta_set = c.set_metadata(meta_, clear=clear_meta)
|
|
|
|
except Exception, e:
|
|
|
|
except Exception as e:
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
finally:
|
|
|
|
finally:
|
|
|
|
_fetch_meta(module, c)
|
|
|
|
_fetch_meta(module, c)
|
|
|
@ -248,7 +248,7 @@ def container(cf, module, container_, state, meta_, clear_meta, ttl, public,
|
|
|
|
if ttl:
|
|
|
|
if ttl:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
c.cdn_ttl = ttl
|
|
|
|
c.cdn_ttl = ttl
|
|
|
|
except Exception, e:
|
|
|
|
except Exception as e:
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
EXIT_DICT['ttl'] = c.cdn_ttl
|
|
|
|
EXIT_DICT['ttl'] = c.cdn_ttl
|
|
|
@ -256,7 +256,7 @@ def container(cf, module, container_, state, meta_, clear_meta, ttl, public,
|
|
|
|
if public:
|
|
|
|
if public:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
cont_public = c.make_public()
|
|
|
|
cont_public = c.make_public()
|
|
|
|
except Exception, e:
|
|
|
|
except Exception as e:
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
EXIT_DICT['container_urls'] = dict(url=c.cdn_uri,
|
|
|
|
EXIT_DICT['container_urls'] = dict(url=c.cdn_uri,
|
|
|
@ -267,7 +267,7 @@ def container(cf, module, container_, state, meta_, clear_meta, ttl, public,
|
|
|
|
if private:
|
|
|
|
if private:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
cont_private = c.make_private()
|
|
|
|
cont_private = c.make_private()
|
|
|
|
except Exception, e:
|
|
|
|
except Exception as e:
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
EXIT_DICT['set_private'] = True
|
|
|
|
EXIT_DICT['set_private'] = True
|
|
|
@ -275,7 +275,7 @@ def container(cf, module, container_, state, meta_, clear_meta, ttl, public,
|
|
|
|
if web_index:
|
|
|
|
if web_index:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
cont_web_index = c.set_web_index_page(web_index)
|
|
|
|
cont_web_index = c.set_web_index_page(web_index)
|
|
|
|
except Exception, e:
|
|
|
|
except Exception as e:
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
EXIT_DICT['set_index'] = True
|
|
|
|
EXIT_DICT['set_index'] = True
|
|
|
@ -285,7 +285,7 @@ def container(cf, module, container_, state, meta_, clear_meta, ttl, public,
|
|
|
|
if web_error:
|
|
|
|
if web_error:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
cont_err_index = c.set_web_error_page(web_error)
|
|
|
|
cont_err_index = c.set_web_error_page(web_error)
|
|
|
|
except Exception, e:
|
|
|
|
except Exception as e:
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
EXIT_DICT['set_error'] = True
|
|
|
|
EXIT_DICT['set_error'] = True
|
|
|
|