Odyssey
Classes | Functions
cli.cumanage Namespace Reference

Classes

class  CUManageCommand
 

Functions

def task_exit_code (client, cluster, task_arns)
 
def run_cumanage_task (stack, proxyargs, wait_until_complete=False, passphrase=None)
 

Detailed Description

Run cumanage operations in an AWS hosted stack.

Function Documentation

◆ run_cumanage_task()

def cli.cumanage.run_cumanage_task (   stack,
  proxyargs,
  wait_until_complete = False,
  passphrase = None 
)
Submit and run cumanage

Definition at line 57 of file cumanage.py.

57 def run_cumanage_task(stack,
58  proxyargs,
59  wait_until_complete=False,
60  passphrase=None):
61  '''Submit and run cumanage'''
62  if passphrase is None:
63  passphrase = ''
64  client = boto3.client('ecs', region_name=stack.region)
65  taskdef = 'odyssey-%s-cumanage-tool' % stack.name
66  shellish.vtmlprint("<b>Submitting:</b> <blue>%s</blue>" %
67  ' '.join(proxyargs))
68  overrides = {
69  "containerOverrides": [{
70  "name": "cumanage",
71  "command": proxyargs
72  }]
73  }
74  response = client.run_task(cluster=stack.cluster,
75  taskDefinition=taskdef,
76  overrides=overrides)
77  stack.save('Ran cumanage: %s' % ' '.join(proxyargs), passphrase)
78  if wait_until_complete:
79  task_arns = [x['taskArn'] for x in response['tasks']]
80  waiter = client.get_waiter('tasks_stopped')
81  if waiter.wait(cluster=stack.cluster, tasks=task_arns):
82  raise SystemExit('Task waiter timed out!')
83  return task_exit_code(client, stack.cluster, task_arns)
84  return 0

◆ task_exit_code()

def cli.cumanage.task_exit_code (   client,
  cluster,
  task_arns 
)
Check tasks exit codes on `cluster`

Definition at line 44 of file cumanage.py.

44 def task_exit_code(client, cluster, task_arns):
45  '''Check tasks exit codes on `cluster`'''
46  response = client.describe_tasks(cluster=cluster, tasks=task_arns)
47  tasks = response['tasks']
48  containers = [container for containers in (x['containers'] for x in tasks)
49  for container in containers]
50  exit_codes = [x.get('exitCode', -1) for x in containers]
51  for code in exit_codes:
52  if code != 0:
53  return code
54  return 0
55 
56