def massaged_oozie_jobs_for_json(oozie_jobs, user, just_sla=False): jobs = [] for job in oozie_jobs: if not just_sla or (just_sla and job.has_sla) and job.appName != 'pig-app-hue-script': last_modified_time_millis = hasattr(job, 'lastModTime') and job.lastModTime and (time.time() - time.mktime(job.lastModTime)) * 1000 or 0 duration_millis = job.durationTime massaged_job = { 'id': job.id, 'lastModTime': hasattr(job, 'lastModTime') and job.lastModTime and format_time(job.lastModTime) or None, 'lastModTimeInMillis': last_modified_time_millis, 'lastModTimeFormatted': last_modified_time_millis and format_duration_in_millis(last_modified_time_millis) or None, 'kickoffTime': hasattr(job, 'kickoffTime') and job.kickoffTime and format_time(job.kickoffTime) or '', 'kickoffTimeInMillis': hasattr(job, 'kickoffTime') and job.kickoffTime and time.mktime(catch_unicode_time(job.kickoffTime)) or 0, 'nextMaterializedTime': hasattr(job, 'nextMaterializedTime') and job.nextMaterializedTime and format_time(job.nextMaterializedTime) or '', 'nextMaterializedTimeInMillis': hasattr(job, 'nextMaterializedTime') and job.nextMaterializedTime and time.mktime(job.nextMaterializedTime) or 0, 'timeOut': hasattr(job, 'timeOut') and job.timeOut or None, 'endTime': job.endTime and format_time(job.endTime) or None, 'pauseTime': hasattr(job, 'pauseTime') and job.pauseTime and format_time(job.endTime) or None, 'concurrency': hasattr(job, 'concurrency') and job.concurrency or None, 'endTimeInMillis': job.endTime and time.mktime(job.endTime) or 0, 'lastActionInMillis': hasattr(job, 'lastAction') and job.lastAction and time.mktime(job.lastAction) or 0, 'status': job.status, 'group': job.group, 'isRunning': job.is_running(), 'duration': duration_millis and format_duration_in_millis(duration_millis) or None, 'durationInMillis': duration_millis, 'appName': job.appName, 'progress': job.get_progress(), 'user': job.user, 'absoluteUrl': job.get_absolute_url(), 'canEdit': has_job_edition_permission(job, user), 'killUrl': reverse('oozie:manage_oozie_jobs', kwargs={'job_id':job.id, 'action':'kill'}), 'suspendUrl': reverse('oozie:manage_oozie_jobs', kwargs={'job_id':job.id, 'action':'suspend'}), 'resumeUrl': reverse('oozie:manage_oozie_jobs', kwargs={'job_id':job.id, 'action':'resume'}), 'created': hasattr(job, 'createdTime') and job.createdTime and format_time(job.createdTime) or '', 'createdInMillis': job.submissionTime, 'startTime': hasattr(job, 'startTime') and format_time(job.startTime) or None, 'startTimeInMillis': hasattr(job, 'startTime') and job.startTime and time.mktime(job.startTime) or 0, 'run': hasattr(job, 'run') and job.run or 0, 'frequency': hasattr(job, 'frequency') and Coordinator.CRON_MAPPING.get(job.frequency, job.frequency) or None, 'timeUnit': hasattr(job, 'timeUnit') and job.timeUnit or None, 'parentUrl': hasattr(job, 'parentId') and job.parentId and get_link(job.parentId) or '', 'submittedManually': hasattr(job, 'parentId') and (job.parentId is None or 'C@' not in job.parentId) } jobs.append(massaged_job) return { 'jobs': jobs }
def massaged_sla_for_json(sla, request): massaged_sla = { 'slaStatus': sla['slaStatus'], 'id': sla['id'], 'appType': sla['appType'], 'appName': sla['appName'], 'appUrl': get_link(sla['id']), 'user': sla['user'], 'nominalTime': sla['nominalTime'], 'expectedStart': sla['expectedStart'], 'actualStart': sla['actualStart'], 'expectedEnd': sla['expectedEnd'], 'actualEnd': sla['actualEnd'], 'jobStatus': sla['jobStatus'], 'expectedDuration': sla['expectedDuration'], 'actualDuration': sla['actualDuration'], 'lastModified': sla['lastModified'] } return massaged_sla
def massaged_sla_for_json(sla): massaged_sla = { 'slaStatus': sla['slaStatus'], 'id': sla['id'], 'appType': sla['appType'], 'appName': sla['appName'], 'appUrl': get_link(sla['id']), 'user': sla['user'], 'nominalTime': sla['nominalTime'], 'expectedStart': sla['expectedStart'], 'actualStart': sla['actualStart'], 'expectedEnd': sla['expectedEnd'], 'actualEnd': sla['actualEnd'], 'jobStatus': sla['jobStatus'], 'expectedDuration': sla['expectedDuration'], 'actualDuration': sla['actualDuration'], 'lastModified': sla['lastModified'] } return massaged_sla
def massaged_sla_for_json(sla, request): massaged_sla = { "slaStatus": sla["slaStatus"], "id": sla["id"], "appType": sla["appType"], "appName": sla["appName"], "appUrl": get_link(sla["id"]), "user": sla["user"], "nominalTime": sla["nominalTime"], "expectedStart": sla["expectedStart"], "actualStart": sla["actualStart"], "expectedEnd": sla["expectedEnd"], "actualEnd": sla["actualEnd"], "jobStatus": sla["jobStatus"], "expectedDuration": sla["expectedDuration"], "actualDuration": sla["actualDuration"], "lastModified": sla["lastModified"], } return massaged_sla
def massaged_oozie_jobs_for_json(oozie_jobs, user, just_sla=False): jobs = [] for job in oozie_jobs: if not just_sla or (just_sla and job.has_sla) and job.appName != "pig-app-hue-script": last_modified_time_millis = ( hasattr(job, "lastModTime") and job.lastModTime and (time.time() - time.mktime(job.lastModTime)) * 1000 or 0 ) duration_millis = ( job.endTime and job.startTime and ((time.mktime(job.endTime) - time.mktime(job.startTime)) * 1000) or 0 ) massaged_job = { "id": job.id, "lastModTime": hasattr(job, "lastModTime") and job.lastModTime and format_time(job.lastModTime) or None, "lastModTimeInMillis": last_modified_time_millis, "lastModTimeFormatted": last_modified_time_millis and format_duration_in_millis(last_modified_time_millis) or None, "kickoffTime": hasattr(job, "kickoffTime") and job.kickoffTime and format_time(job.kickoffTime) or "", "kickoffTimeInMillis": hasattr(job, "kickoffTime") and job.kickoffTime and time.mktime(catch_unicode_time(job.kickoffTime)) or 0, "nextMaterializedTime": hasattr(job, "nextMaterializedTime") and job.nextMaterializedTime and format_time(job.nextMaterializedTime) or "", "nextMaterializedTimeInMillis": hasattr(job, "nextMaterializedTime") and job.nextMaterializedTime and time.mktime(job.nextMaterializedTime) or 0, "timeOut": hasattr(job, "timeOut") and job.timeOut or None, "endTime": job.endTime and format_time(job.endTime) or None, "pauseTime": hasattr(job, "pauseTime") and job.pauseTime and format_time(job.endTime) or None, "concurrency": hasattr(job, "concurrency") and job.concurrency or None, "endTimeInMillis": job.endTime and time.mktime(job.endTime) or 0, "status": job.status, "isRunning": job.is_running(), "duration": duration_millis and format_duration_in_millis(duration_millis) or None, "durationInMillis": duration_millis, "appName": job.appName, "progress": job.get_progress(), "user": job.user, "absoluteUrl": job.get_absolute_url(), "canEdit": has_job_edition_permission(job, user), "killUrl": reverse("oozie:manage_oozie_jobs", kwargs={"job_id": job.id, "action": "kill"}), "suspendUrl": reverse("oozie:manage_oozie_jobs", kwargs={"job_id": job.id, "action": "suspend"}), "resumeUrl": reverse("oozie:manage_oozie_jobs", kwargs={"job_id": job.id, "action": "resume"}), "created": hasattr(job, "createdTime") and job.createdTime and format_time(job.createdTime) or "", "createdInMillis": hasattr(job, "createdTime") and job.createdTime and time.mktime(catch_unicode_time(job.createdTime)) or 0, "startTime": hasattr(job, "startTime") and format_time(job.startTime) or None, "startTimeInMillis": hasattr(job, "startTime") and job.startTime and time.mktime(job.startTime) or 0, "run": hasattr(job, "run") and job.run or 0, "frequency": hasattr(job, "frequency") and Coordinator.CRON_MAPPING.get(job.frequency, job.frequency) or None, "timeUnit": hasattr(job, "timeUnit") and job.timeUnit or None, "parentUrl": hasattr(job, "parentId") and job.parentId and get_link(job.parentId) or "", "submittedManually": hasattr(job, "parentId") and _submitted_manually(job, user), } jobs.append(massaged_job) return {"jobs": jobs}