void HoldJob( const char* long_reason, const char* short_reason, int reason_code, int reason_subcode ) { char subject[ BUFSIZ ]; FILE *mailer; sprintf( subject, "Condor Job %d.%d put on hold\n", Proc->id.cluster, Proc->id.proc ); if( ! JobAd ) { dprintf( D_ALWAYS, "In HoldJob() w/ NULL JobAd!\n" ); exit( JOB_SHOULD_HOLD ); } ExitReason = JOB_SHOULD_HOLD; if ( !ConnectQ(schedd, SHADOW_QMGMT_TIMEOUT) ) { dprintf( D_ALWAYS, "Failed to connect to schedd!\n" ); } SetAttributeString( Proc->id.cluster, Proc->id.proc, ATTR_HOLD_REASON, short_reason ); SetAttributeInt( Proc->id.cluster, Proc->id.proc, ATTR_HOLD_REASON_CODE, reason_code ); SetAttributeInt( Proc->id.cluster, Proc->id.proc, ATTR_HOLD_REASON_SUBCODE, reason_subcode ); if ( !DisconnectQ(0) ) { dprintf( D_ALWAYS, "Failed to commit updated job queue status!\n" ); } mailer = email_user_open(JobAd, subject); if( ! mailer ) { // User didn't want email, so just exit now with the right // value so the schedd actually puts the job on hold. dprintf( D_ALWAYS, "Job going into Hold state.\n"); dprintf( D_ALWAYS, "********** Shadow Exiting(%d) **********\n", JOB_SHOULD_HOLD); exit( JOB_SHOULD_HOLD ); } fprintf( mailer, "Your condor job " ); if( Proc->args_v1or2[0] ) { ArgList args; MyString args_string; args.AppendArgsV1or2Raw(Proc->args_v1or2[0],NULL); args.GetArgsStringForDisplay(&args_string); fprintf( mailer, "%s %s ", Proc->cmd[0], args_string.Value() ); } else { fprintf( mailer, "%s ", Proc->cmd[0] ); } fprintf( mailer, "\nis being put on hold.\n\n" ); fprintf( mailer, "%s", long_reason ); email_close(mailer); // Now that the user knows why, exit with the right code. dprintf( D_ALWAYS, "Job going into Hold state.\n"); dprintf( D_ALWAYS, "********** Shadow Exiting(%d) **********\n", JOB_SHOULD_HOLD); exit( JOB_SHOULD_HOLD ); }
FILE* BaseShadow::emailUser( const char *subjectline ) { dprintf(D_FULLDEBUG, "BaseShadow::emailUser() called.\n"); if( !jobAd ) { return NULL; } return email_user_open( jobAd, subjectline ); }
void NotifyUser( char *buf, PROC *proc ) { FILE *mailer; char subject[ BUFSIZ ]; dprintf(D_FULLDEBUG, "NotifyUser() called.\n"); sprintf( subject, "Condor Job %d.%d", proc->id.cluster, proc->id.proc ); if( ! JobAd ) { dprintf( D_ALWAYS, "In NotifyUser() w/ NULL JobAd!\n" ); return; } // email HACK for John Bent <*****@*****.**> // added by Derek Wright <*****@*****.**> 2005-02-20 char* email_cc = param( "EMAIL_NOTIFICATION_CC" ); if( email_cc ) { bool allows_cc = true; int bool_val; if( JobAd->LookupBool(ATTR_ALLOW_NOTIFICATION_CC, bool_val) ) { dprintf( D_FULLDEBUG, "Job defined %s to %s\n", ATTR_ALLOW_NOTIFICATION_CC, bool_val ? "TRUE" : "FALSE" ); allows_cc = (bool)bool_val; } else { dprintf( D_FULLDEBUG, "%s not defined, assuming TRUE\n", ATTR_ALLOW_NOTIFICATION_CC ); } if( allows_cc ) { dprintf( D_FULLDEBUG, "%s is TRUE, sending email to \"%s\"\n", ATTR_ALLOW_NOTIFICATION_CC, email_cc ); mailer = email_open( email_cc, subject ); publishNotifyEmail( mailer, buf, proc ); email_close( mailer ); } else { dprintf( D_FULLDEBUG, "%s is FALSE, not sending email copy\n", ATTR_ALLOW_NOTIFICATION_CC ); } free( email_cc ); email_cc = NULL; } /* If user loaded program incorrectly, always send a message. */ if( MainSymbolExists == TRUE ) { switch( proc->notification ) { case NOTIFY_NEVER: return; case NOTIFY_ALWAYS: break; case NOTIFY_COMPLETE: if( proc->status == COMPLETED ) { break; } else { return; } case NOTIFY_ERROR: if( (proc->status == COMPLETED) && (WTERMSIG(JobStatus)!= 0) ) { break; } else { return; } default: dprintf(D_ALWAYS, "Condor Job %d.%d has a notification of %d\n", proc->id.cluster, proc->id.proc, proc->notification ); } } mailer = email_user_open(JobAd, subject); if( mailer == NULL ) { dprintf(D_ALWAYS, "Shadow: Cannot notify user( %s, %s, %s )\n", subject, proc->owner, "w" ); return; } publishNotifyEmail( mailer, buf, proc ); email_close(mailer); }