def output(context, id): """output(context, id) Show a job output. >>> dcictl job-output [OPTIONS] :param string id: ID of the job to show [required] """ colors = { 'pre-run': '\x1b[6;30;44m', 'running': '\x1b[6;30;42m', 'post-run': '\x1b[6;30;44m', 'failure': '\x1b[6;30;41m'} result = job.list_jobstates(context, id=id) jobstates = result.json()['jobstates'] for js in jobstates: color = colors.get(js['status'], '') click.echo('%s[%s]\x1b[0m %s' % ( color, js['status'], js['comment'])) f_l = dci_file.list( context, where='jobstate_id:' + js['id']) for f in f_l.json()['files']: click.echo(dci_file.content(context, id=f['id']).text)
def output(context, args): result = job.list_jobstates(context, id=args.id, sort="created_at") jobstates = result.json()["jobstates"] res = [] for js in jobstates: f_l = job.list_files(context, id=args.id, where="jobstate_id:" + js["id"], sort="created_at") for f in f_l.json()["files"]: res.append(dci_file.content(context, id=f["id"]).text) return res
def main(): module = AnsibleModule( argument_spec=dict( state=dict(default='present', choices=['present', 'absent'], type='str'), dci_login=dict(required=False, type='str'), dci_password=dict(required=False, type='str'), dci_cs_url=dict(required=False, type='str'), undercloud_ip=dict(type='str'), undercloud_user=dict(required=False, default='stack', type='str'), remoteci=dict(type='str'), job_id=dict(type='str'), key_filename=dict(default='text/plain', type='str'), stack_name=dict(required=False, default='overcloud', type='str'), ), ) if not requests_found: module.fail_json(msg='The python requests module is required') login, password, url = get_details(module) if not login or not password: module.fail_json(msg='login and/or password have not been specified') ctx = dci_context.build_dci_context(url, login, password, 'ansible') last_js = dci_job.list_jobstates(ctx, module.params['job_id']).json()['jobstates'][0] ctx.last_job_id = last_js['job_id'] ctx.last_jobstate_id = last_js['id'] dci_tripleo_helper.run_tests( ctx, undercloud_ip=module.params['undercloud_ip'], key_filename=module.params['key_filename'], remoteci_id=module.params['remoteci'], stack_name=module.params['stack_name'], user=module.params['undercloud_user']) module.exit_json(changed=True)
def get_jobstates_with_files(job_id): context = build_dci_context() r = dci_job.list_jobstates(context, id=job_id, embed="files") r.raise_for_status() return r.json()["jobstates"]