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
0845151c
Commit
0845151c
authored
Jun 22, 2015
by
Toshio Kuratomi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better error messages when the file to be transferred does not exist.
parent
0056f025
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
29 deletions
+34
-29
lib/ansible/runner/connection_plugins/jail.py
+17
-15
lib/ansible/runner/connection_plugins/zone.py
+17
-14
No files found.
lib/ansible/runner/connection_plugins/jail.py
View file @
0845151c
...
...
@@ -134,25 +134,27 @@ class Connection(object):
vvv
(
"PUT
%
s TO
%
s"
%
(
in_path
,
out_path
),
host
=
self
.
jail
)
with
open
(
in_path
,
'rb'
)
as
in_file
:
try
:
p
=
self
.
_buffered_exec_command
(
'dd of=
%
s'
%
out_path
,
None
,
stdin
=
in_file
)
except
OSError
:
raise
errors
.
AnsibleError
(
"jail connection requires dd command in the jail"
)
try
:
stdout
,
stderr
=
p
.
communicate
()
except
:
traceback
.
print_exc
()
raise
errors
.
AnsibleError
(
"failed to transfer file to
%
s"
%
out_path
)
if
p
.
returncode
!=
0
:
raise
errors
.
AnsibleError
(
"failed to transfer file to
%
s:
\n
%
s
\n
%
s"
%
(
out_path
,
stdout
,
stderr
))
try
:
with
open
(
in_path
,
'rb'
)
as
in_file
:
try
:
p
=
self
.
_buffered_exec_command
(
'dd of=
%
s'
%
out_path
,
None
,
stdin
=
in_file
)
except
OSError
:
raise
errors
.
AnsibleError
(
"jail connection requires dd command in the jail"
)
try
:
stdout
,
stderr
=
p
.
communicate
()
except
:
traceback
.
print_exc
()
raise
errors
.
AnsibleError
(
"failed to transfer file
%
s to
%
s"
%
(
in_path
,
out_path
))
if
p
.
returncode
!=
0
:
raise
errors
.
AnsibleError
(
"failed to transfer file
%
s to
%
s:
\n
%
s
\n
%
s"
%
(
in_path
,
out_path
,
stdout
,
stderr
))
except
IOError
:
raise
errors
.
AnsibleError
(
"file or module does not exist at:
%
s"
%
in_path
)
def
fetch_file
(
self
,
in_path
,
out_path
):
''' fetch a file from jail to local '''
vvv
(
"FETCH
%
s TO
%
s"
%
(
in_path
,
out_path
),
host
=
self
.
jail
)
try
:
p
=
self
.
_buffered_exec_command
(
'dd if=
%
s bs=
%
s'
%
(
in_path
,
BUFSIZE
),
None
)
except
OSError
:
...
...
@@ -164,10 +166,10 @@ class Connection(object):
out_file
.
write
(
chunk
)
except
:
traceback
.
print_exc
()
raise
errors
.
AnsibleError
(
"failed to transfer file
to
%
s"
%
out_path
)
raise
errors
.
AnsibleError
(
"failed to transfer file
%
s to
%
s"
%
(
in_path
,
out_path
)
)
stdout
,
stderr
=
p
.
communicate
()
if
p
.
returncode
!=
0
:
raise
errors
.
AnsibleError
(
"failed to transfer file
to
%
s:
\n
%
s
\n
%
s"
%
(
out_path
,
stdout
,
stderr
))
raise
errors
.
AnsibleError
(
"failed to transfer file
%
s to
%
s:
\n
%
s
\n
%
s"
%
(
in_path
,
out_path
,
stdout
,
stderr
))
def
close
(
self
):
''' terminate the connection; nothing to do here '''
...
...
lib/ansible/runner/connection_plugins/zone.py
View file @
0845151c
...
...
@@ -147,18 +147,21 @@ class Connection(object):
vvv
(
"PUT
%
s TO
%
s"
%
(
in_path
,
out_path
),
host
=
self
.
zone
)
with
open
(
in_path
,
'rb'
)
as
in_file
:
try
:
p
=
self
.
_buffered_exec_command
(
'dd of=
%
s'
%
out_path
,
None
,
stdin
=
in_file
)
except
OSError
:
raise
errors
.
AnsibleError
(
"zone connection requires dd command in the zone"
)
try
:
stdout
,
stderr
=
p
.
communicate
()
except
:
traceback
.
print_exc
()
raise
errors
.
AnsibleError
(
"failed to transfer file to
%
s"
%
out_path
)
if
p
.
returncode
!=
0
:
raise
errors
.
AnsibleError
(
"failed to transfer file to
%
s:
\n
%
s
\n
%
s"
%
(
out_path
,
stdout
,
stderr
))
try
:
with
open
(
in_path
,
'rb'
)
as
in_file
:
try
:
p
=
self
.
_buffered_exec_command
(
'dd of=
%
s'
%
out_path
,
None
,
stdin
=
in_file
)
except
OSError
:
raise
errors
.
AnsibleError
(
"jail connection requires dd command in the jail"
)
try
:
stdout
,
stderr
=
p
.
communicate
()
except
:
traceback
.
print_exc
()
raise
errors
.
AnsibleError
(
"failed to transfer file
%
s to
%
s"
%
(
in_path
,
out_path
))
if
p
.
returncode
!=
0
:
raise
errors
.
AnsibleError
(
"failed to transfer file
%
s to
%
s:
\n
%
s
\n
%
s"
%
(
in_path
,
out_path
,
stdout
,
stderr
))
except
IOError
:
raise
errors
.
AnsibleError
(
"file or module does not exist at:
%
s"
%
in_path
)
def
fetch_file
(
self
,
in_path
,
out_path
):
''' fetch a file from zone to local '''
...
...
@@ -178,10 +181,10 @@ class Connection(object):
out_file
.
write
(
chunk
)
except
:
traceback
.
print_exc
()
raise
errors
.
AnsibleError
(
"failed to transfer file
to
%
s"
%
out_path
)
raise
errors
.
AnsibleError
(
"failed to transfer file
%
s to
%
s"
%
(
in_path
,
out_path
)
)
stdout
,
stderr
=
p
.
communicate
()
if
p
.
returncode
!=
0
:
raise
errors
.
AnsibleError
(
"failed to transfer file
to
%
s:
\n
%
s
\n
%
s"
%
(
out_path
,
stdout
,
stderr
))
raise
errors
.
AnsibleError
(
"failed to transfer file
%
s to
%
s:
\n
%
s
\n
%
s"
%
(
in_path
,
out_path
,
stdout
,
stderr
))
def
close
(
self
):
''' terminate the connection; nothing to do here '''
...
...
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