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
ce512e18
Commit
ce512e18
authored
Mar 27, 2015
by
Toshio Kuratomi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove fireball connection plugin. v2 will have accelerate but not fireball
parent
dc9b36cc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
151 deletions
+0
-151
v2/ansible/plugins/connections/fireball.py
+0
-151
No files found.
v2/ansible/plugins/connections/fireball.py
deleted
100644 → 0
View file @
dc9b36cc
# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
import
json
import
os
import
base64
from
ansible.callbacks
import
vvv
from
ansible
import
utils
from
ansible
import
errors
from
ansible
import
constants
HAVE_ZMQ
=
False
try
:
import
zmq
HAVE_ZMQ
=
True
except
ImportError
:
pass
class
Connection
(
object
):
''' ZeroMQ accelerated connection '''
def
__init__
(
self
,
runner
,
host
,
port
,
*
args
,
**
kwargs
):
self
.
runner
=
runner
self
.
has_pipelining
=
False
# attempt to work around shared-memory funness
if
getattr
(
self
.
runner
,
'aes_keys'
,
None
):
utils
.
AES_KEYS
=
self
.
runner
.
aes_keys
self
.
host
=
host
self
.
key
=
utils
.
key_for_hostname
(
host
)
self
.
context
=
None
self
.
socket
=
None
if
port
is
None
:
self
.
port
=
constants
.
ZEROMQ_PORT
else
:
self
.
port
=
port
def
connect
(
self
):
''' activates the connection object '''
if
not
HAVE_ZMQ
:
raise
errors
.
AnsibleError
(
"zmq is not installed"
)
# this is rough/temporary and will likely be optimized later ...
self
.
context
=
zmq
.
Context
()
socket
=
self
.
context
.
socket
(
zmq
.
REQ
)
addr
=
"tcp://
%
s:
%
s"
%
(
self
.
host
,
self
.
port
)
socket
.
connect
(
addr
)
self
.
socket
=
socket
return
self
def
exec_command
(
self
,
cmd
,
tmp_path
,
sudo_user
,
sudoable
=
False
,
executable
=
'/bin/sh'
,
in_data
=
None
,
su_user
=
None
,
su
=
None
):
''' run a command on the remote host '''
if
in_data
:
raise
errors
.
AnsibleError
(
"Internal Error: this module does not support optimized module pipelining"
)
vvv
(
"EXEC COMMAND
%
s"
%
cmd
)
if
(
self
.
runner
.
sudo
and
sudoable
)
or
(
self
.
runner
.
su
and
su
):
raise
errors
.
AnsibleError
(
"When using fireball, do not specify sudo or su to run your tasks. "
+
"Instead sudo the fireball action with sudo. "
+
"Task will communicate with the fireball already running in sudo mode."
)
data
=
dict
(
mode
=
'command'
,
cmd
=
cmd
,
tmp_path
=
tmp_path
,
executable
=
executable
,
)
data
=
utils
.
jsonify
(
data
)
data
=
utils
.
encrypt
(
self
.
key
,
data
)
self
.
socket
.
send
(
data
)
response
=
self
.
socket
.
recv
()
response
=
utils
.
decrypt
(
self
.
key
,
response
)
response
=
utils
.
parse_json
(
response
)
return
(
response
.
get
(
'rc'
,
None
),
''
,
response
.
get
(
'stdout'
,
''
),
response
.
get
(
'stderr'
,
''
))
def
put_file
(
self
,
in_path
,
out_path
):
''' transfer a file from local to remote '''
vvv
(
"PUT
%
s TO
%
s"
%
(
in_path
,
out_path
),
host
=
self
.
host
)
if
not
os
.
path
.
exists
(
in_path
):
raise
errors
.
AnsibleFileNotFound
(
"file or module does not exist:
%
s"
%
in_path
)
data
=
file
(
in_path
)
.
read
()
data
=
base64
.
b64encode
(
data
)
data
=
dict
(
mode
=
'put'
,
data
=
data
,
out_path
=
out_path
)
# TODO: support chunked file transfer
data
=
utils
.
jsonify
(
data
)
data
=
utils
.
encrypt
(
self
.
key
,
data
)
self
.
socket
.
send
(
data
)
response
=
self
.
socket
.
recv
()
response
=
utils
.
decrypt
(
self
.
key
,
response
)
response
=
utils
.
parse_json
(
response
)
# no meaningful response needed for this
def
fetch_file
(
self
,
in_path
,
out_path
):
''' save a remote file to the specified path '''
vvv
(
"FETCH
%
s TO
%
s"
%
(
in_path
,
out_path
),
host
=
self
.
host
)
data
=
dict
(
mode
=
'fetch'
,
in_path
=
in_path
)
data
=
utils
.
jsonify
(
data
)
data
=
utils
.
encrypt
(
self
.
key
,
data
)
self
.
socket
.
send
(
data
)
response
=
self
.
socket
.
recv
()
response
=
utils
.
decrypt
(
self
.
key
,
response
)
response
=
utils
.
parse_json
(
response
)
response
=
response
[
'data'
]
response
=
base64
.
b64decode
(
response
)
fh
=
open
(
out_path
,
"w"
)
fh
.
write
(
response
)
fh
.
close
()
def
close
(
self
):
''' terminate the connection '''
# Be a good citizen
try
:
self
.
socket
.
close
()
self
.
context
.
term
()
except
:
pass
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