Skip to content

Commit

Permalink
Merge remote branch 'liraz/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
alonswartz committed Nov 15, 2012
2 parents e0290ca + 182cc37 commit 0dd697f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
33 changes: 32 additions & 1 deletion cloudtask/reporter.py
Expand Up @@ -17,6 +17,8 @@
from email.Message import Message
from command import Command

import StringIO

class Error(Exception):
pass

Expand Down Expand Up @@ -92,16 +94,45 @@ def __init__(self, expr):
self.recipients = args[1:]
self.sendmail = self.Sendmail()

@staticmethod
def fmt_taskconf(taskconf):
sio = StringIO.StringIO()

table = []
for attr in ('split', 'command',
'ec2-region', 'ec2-size', 'ec2-type',
'user', 'backup-id', 'workers',
'overlay', 'post', 'pre', 'timeout', 'report'):

val = taskconf[attr.replace('-', '_')]
if isinstance(val, list):
val = " ".join(val)
if not val:
val = "-"
table.append((attr, val))

print >> sio, " Parameter Value"
print >> sio, " --------- -----"
print >> sio
for row in table:
print >> sio, " %-15s %s" % (row[0], row[1])

print >> sio

return sio.getvalue()

def __call__(self, session):
mlog = file(session.paths.log).read()
taskconf = session.taskconf

body = self.fmt_taskconf(taskconf) + mlog

for recipient in self.recipients:

subject = "[Cloudtask] " + taskconf.command

self.sendmail(self.sender, recipient,
subject, mlog)
subject, body)


class ShellHandler:
Expand Down
4 changes: 3 additions & 1 deletion cloudtask/task.py
Expand Up @@ -23,6 +23,8 @@
--hub-apikey= Hub API KEY (required if launching workers)
--backup-id= TurnKey Backup ID to restore on launch
--ami-id= Force launch a specific AMI ID (default is the latest Core)
--ec2-region= Region for instance launch (default: us-east-1)
--ec2-size= Instance launch size (default: m1.small)
--ec2-type= Instance launch type <s3|ebs> (default: s3)
Expand Down Expand Up @@ -253,7 +255,7 @@ def main(cls):
if isfile(taskconf.workers):
taskconf.workers = file(taskconf.workers).read().splitlines()
else:
taskconf.workers = [ worker.strip() for worker in taskconf.workers.split(',') ]
taskconf.workers = [ worker.strip() for worker in re.split('\s+', taskconf.workers) ]
else:
taskconf.workers = list(taskconf.workers)

Expand Down
6 changes: 6 additions & 0 deletions cloudtask/taskconf.py
Expand Up @@ -25,6 +25,8 @@ class TaskConf:

hub_apikey = None
backup_id = None
ami_id = None

ec2_region = 'us-east-1'
ec2_size = 'm1.small'
ec2_type = 's3'
Expand Down Expand Up @@ -63,4 +65,8 @@ def ec2_opts(self):
opts['label'] = 'Cloudtask: ' + self.command
if self.backup_id:
opts['backup_id'] = self.backup_id

if self.ami_id:
opts['ami_id'] = self.ami_id

return opts
2 changes: 2 additions & 0 deletions cmd_launch_workers.py
Expand Up @@ -23,6 +23,7 @@
Environment: HUB_APIKEY
--backup-id TurnKey Backup ID to restore
--ami-id Force launch a specific AMI ID (default is the latest Core)
--region Region for instance launch (default: us-east-1)
Regions:
Expand Down Expand Up @@ -82,6 +83,7 @@ def main():
'type': "s3",
'label': "Cloudtask worker",
'backup_id': None,
'ami_id': None,
}

hub_apikey = os.environ.get('HUB_APIKEY', os.environ.get('CLOUDTASK_HUB_APIKEY'))
Expand Down

0 comments on commit 0dd697f

Please sign in to comment.