Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
2090e75e
Commit
2090e75e
authored
Jan 23, 2014
by
Paul Durivage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use dict constructors
parent
d8bf5033
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
library/cloud/rax_files_objects
+11
-10
No files found.
library/cloud/rax_files_objects
View file @
2090e75e
...
@@ -199,7 +199,7 @@ except ImportError, e:
...
@@ -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):
...
@@ -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):
...
@@ -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):
...
@@ -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):
...
@@ -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():
...
@@ -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'
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment