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
788e783b
Commit
788e783b
authored
Oct 21, 2013
by
bennojoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix for overwrite in put operation
parent
c876ce4b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
library/cloud/gc_storage
+11
-10
No files found.
library/cloud/gc_storage
View file @
788e783b
...
...
@@ -69,7 +69,7 @@ options:
required: true
default: null
aliases: []
choices: [ '
upload', 'download', 'get_url', 'get_str
' ]
choices: [ '
get', 'put', 'get_url', 'get_str', 'delete', 'create
' ]
gcs_secret_key:
description:
- GCS secret key. If not set then the value of the GCS_SECRET_KEY environment variable is used.
...
...
@@ -89,10 +89,10 @@ author: benno@ansibleworks.com Note. Most of the code has been taken from the S3
EXAMPLES
=
'''
# upload some content
- gc_storage: bucket=mybucket object=key.txt src=/usr/local/myfile.txt mode=
upload
permission=public-read
- gc_storage: bucket=mybucket object=key.txt src=/usr/local/myfile.txt mode=
put
permission=public-read
# download some content
- gc_storage: bucket=mybucket object=key.txt dest=/usr/local/myfile.txt mode=
download
- gc_storage: bucket=mybucket object=key.txt dest=/usr/local/myfile.txt mode=
get
# Download an object as a string to use else where in your playbook
- gc_storage: bucket=mybucket object=key.txt mode=get_str
...
...
@@ -265,6 +265,8 @@ def handle_get(module, gs, bucket, obj, overwrite, dest):
md5_local
=
hashlib
.
md5
(
open
(
dest
,
'rb'
)
.
read
())
.
hexdigest
()
if
md5_local
==
md5_remote
and
not
overwrite
:
module
.
exit_json
(
changed
=
False
)
if
md5_local
!=
md5_remote
and
not
overwrite
:
module
.
exit_json
(
msg
=
"WARNING: Checksums do not match. Use overwrite parameter to force download."
,
failed
=
True
)
else
:
download_gsfile
(
module
,
gs
,
bucket
,
obj
,
dest
)
...
...
@@ -277,13 +279,12 @@ def handle_put(module, gs, bucket, obj, overwrite, src, expiration):
if
bucket_rc
and
key_rc
:
md5_remote
=
keysum
(
module
,
gs
,
bucket
,
obj
)
md5_local
=
hashlib
.
md5
(
open
(
src
,
'rb'
)
.
read
())
.
hexdigest
()
if
md5_local
==
md5_remote
:
module
.
exit_json
(
msg
=
"Local and remote object are identical."
,
changed
=
False
)
if
md5_local
==
md5_remote
and
not
overwrite
:
module
.
exit_json
(
msg
=
"Local and remote object are identical. Use overwrite to force upload"
,
changed
=
False
)
if
md5_local
!=
md5_remote
and
not
overwrite
:
module
.
exit_json
(
msg
=
"WARNING: Checksums do not match. Use overwrite parameter to force upload."
,
failed
=
True
)
else
:
if
overwrite
:
upload_gsfile
(
module
,
gs
,
bucket
,
obj
,
src
,
expiration
)
else
:
module
.
exit_json
(
msg
=
"WARNING: Checksums do not match. Use overwrite parameter to force upload."
,
failed
=
True
)
upload_gsfile
(
module
,
gs
,
bucket
,
obj
,
src
,
expiration
)
if
not
bucket_rc
:
create_bucket
(
module
,
gs
,
bucket
)
...
...
@@ -353,7 +354,7 @@ def main():
if
dest
:
dest
=
os
.
path
.
expanduser
(
dest
)
mode
=
module
.
params
.
get
(
'mode'
)
expiry
=
module
.
params
.
get
(
'expir
y
'
)
expiry
=
module
.
params
.
get
(
'expir
ation
'
)
gs_secret_key
=
module
.
params
.
get
(
'gs_secret_key'
)
gs_access_key
=
module
.
params
.
get
(
'gs_access_key'
)
overwrite
=
module
.
params
.
get
(
'overwrite'
)
...
...
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