Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-analytics-data-api
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
edx
edx-analytics-data-api
Commits
5a2313f6
Commit
5a2313f6
authored
Jan 28, 2014
by
Gabe Mulley
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6 from mulby/gabe/fix-remote-task
fix remote task execution
parents
68754b75
a08f5582
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
27 deletions
+17
-27
edx/analytics/tasks/remote.py
+16
-25
requirements/default.txt
+0
-1
share/task.yml
+1
-1
No files found.
edx/analytics/tasks/remote.py
View file @
5a2313f6
"""Remote Task
Usage:
remote-task [--job-flow-id=ID] [--branch=BRANCH] [--repo=REPO] [--name=NAME] [--verbose] [<launch-task-args>]
Options:
--job-flow-id=ID EMR job flow to run the task
--branch=BRANCH git branch to checkout before running the task [default: release]
--repo=REPO git repository to clone
--name=NAME an identifier for this task
--verbose display very verbose output
<launch-task-args> a single-quoted string of arguments to pass-through to launch-task on the remote machine
"""
import
argparse
import
os
from
subprocess
import
Popen
import
sys
import
uuid
from
docopt
import
docopt
def
main
():
arguments
=
docopt
(
__doc__
)
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--job-flow-id'
,
help
=
'EMR job flow to run the task'
)
parser
.
add_argument
(
'--branch'
,
help
=
'git branch to checkout before running the task'
,
default
=
'release'
)
parser
.
add_argument
(
'--repo'
,
help
=
'git repository to clone'
)
parser
.
add_argument
(
'--remote-name'
,
help
=
'an identifier for this remote task'
)
parser
.
add_argument
(
'--verbose'
,
action
=
'store_true'
,
help
=
'display very verbose output'
)
arguments
,
extra_args
=
parser
.
parse_known_args
()
arguments
.
launch_task_arguments
=
extra_args
change_directory_to_ansible_script_home
()
extra_vars
=
convert_cli_arguments_to_ansible_extra_vars
(
arguments
)
run_ansible_playbook
(
arguments
.
get
(
'--verbose'
,
False
)
,
extra_vars
)
run_ansible_playbook
(
arguments
.
verbose
,
extra_vars
)
def
change_directory_to_ansible_script_home
():
...
...
@@ -36,15 +28,15 @@ def change_directory_to_ansible_script_home():
def
convert_cli_arguments_to_ansible_extra_vars
(
arguments
):
uid
=
arguments
.
get
(
'--name'
)
or
str
(
uuid
.
uuid4
())
uid
=
arguments
.
remote_name
or
str
(
uuid
.
uuid4
())
extra_vars
=
{
'name'
:
arguments
[
'--job-flow-id'
]
,
'branch'
:
arguments
.
get
(
'--branch'
,
'release'
)
,
'task_arguments'
:
arguments
.
get
(
'<launch-task-args>'
,
''
)
+
' >/tmp/{0}.out 2>/tmp/{0}.err'
.
format
(
uid
),
'name'
:
arguments
.
job_flow_id
,
'branch'
:
arguments
.
branch
,
'task_arguments'
:
' '
.
join
(
arguments
.
launch_task_arguments
)
+
' >/tmp/{0}.out 2>/tmp/{0}.err'
.
format
(
uid
),
'uuid'
:
uid
,
}
if
arguments
[
'--repo'
]
:
extra_vars
[
'repo'
]
=
arguments
[
'--repo'
]
if
arguments
.
repo
:
extra_vars
[
'repo'
]
=
arguments
.
repo
return
' '
.
join
([
"{}='{}'"
.
format
(
k
,
extra_vars
[
k
])
for
k
in
extra_vars
])
...
...
@@ -60,7 +52,6 @@ def run_ansible_playbook(verbose, extra_vars):
env
.
update
({
'ANSIBLE_SSH_ARGS'
:
'-o ForwardAgent=yes'
})
with
open
(
'/dev/null'
,
'rw'
)
as
devnull
:
proc
=
Popen
(
command
,
stdin
=
devnull
,
env
=
env
)
proc
.
communicate
()
requirements/default.txt
View file @
5a2313f6
...
...
@@ -4,6 +4,5 @@ pbr==0.5.23
stevedore==0.13
tornado==3.1.1
ansible==1.4.4
docopt==0.6.1
-e git+https://github.com/spotify/luigi.git@a33756c781b9bf7e51384f0eb19d6a25050ef136#egg=luigi
share/task.yml
View file @
5a2313f6
...
...
@@ -21,7 +21,7 @@
-
task_arguments
:
'
'
-
git_server_hostname
:
github.com
-
git_server_ip_address
:
207.97.227.239
-
git_server_public_key
:
'
ssh-rsa
AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=='
'
-
git_server_public_key
:
'
ssh-rsa
AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=='
tasks
:
-
name
:
known_hosts file exists
...
...
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