Ejemplo n.º 1
0
def create_notify_message(
    jobdict,
    args_list,
    status,
    statusfile,
    configuration,
):
    """Helper to create notifications"""

    header = ''
    txt = ''
    jobid = jobdict['JOB_ID']
    job_retries = jobdict.get('RETRIES', configuration.job_retries)
    var_dict = {
        'jobid': jobid,
        'retries': job_retries,
        'out_dir': job_output_dir,
        'site': configuration.short_title
    }

    entity_mapper = {
        'vgridmember': 'member',
        'vgridowner': 'owner',
        'vgridresource': 'resource',
        'resourceowner': 'owner'
    }
    accept_mapper = {'vgridaccept': 'vgrid', 'resourceaccept': 'resource'}
    reject_mapper = {'vgridreject': 'vgrid', 'resourcereject': 'resource'}

    frame_template = """---

%s

---
"""
    if not jobdict.get('EMAIL_SENDER', None):
        txt += """
*** IMPORTANT: direct replies to this automated message will NOT be read! ***
"""

    if status == 'SUCCESS':
        header = '%s JOB finished' % configuration.short_title
        var_dict['generated_links'] = generate_https_urls(
            configuration,
            '%(auto_base)s/%(auto_bin)s/jobstatus.py?job_id=%(jobid)s;flags=i',
            var_dict)
        txt += \
            '''
Your %(site)s job with JOB ID %(jobid)s has finished and
full status is available at:
%(generated_links)s

The job commands and their exit codes:
''' % var_dict
        try:
            status_fd = open(statusfile, 'r')
            txt += str(status_fd.read())
            status_fd.close()
        except Exception, err:
            txt += 'Could not be read (Internal error?): %s' % err
        var_dict['generated_stdout'] = generate_https_urls(
            configuration,
            '%(auto_base)s/cert_redirect/%(out_dir)s/%(jobid)s/%(jobid)s.stdout',
            var_dict)
        var_dict['generated_stderr'] = generate_https_urls(
            configuration,
            '%(auto_base)s/cert_redirect/%(out_dir)s/%(jobid)s/%(jobid)s.stderr',
            var_dict)
        txt += \
            '''
Link to stdout file (might not be available):
%(generated_stdout)s

Link to stderr file (might not be available):
%(generated_stderr)s
''' % var_dict
Ejemplo n.º 2
0
As '%s' on %s:
cd ~/mig/server
./createuser.py -i '%s' -u '%s'"""\
         % (mig_user, configuration.server_fqdn, cert_id, req_path)
    command_user_delete = \
        """
As '%s' user on %s:
cd ~/mig/server
./deleteuser.py -i '%s'"""\
         % (mig_user, configuration.server_fqdn, cert_id)

    user_dict['command_user_create'] = command_user_create
    user_dict['command_user_delete'] = command_user_delete
    user_dict['site'] = configuration.short_title
    user_dict['vgrid_label'] = configuration.site_vgrid_label
    user_dict['vgridman_links'] = generate_https_urls(
        configuration, '%(auto_base)s/%(auto_bin)s/vgridman.py', {})
    email_header = '%s sign up request for %s' % \
                   (configuration.short_title, cert_id)
    email_msg = \
        """
Received an existing certificate sign up request with certificate data
 * Distinguished Name: %(distinguished_name)s
 * Full Name: %(full_name)s
 * Organization: %(organization)s
 * State: %(state)s
 * Country: %(country)s
 * Email: %(email)s
 * Comment: %(comment)s
 * Expire: %(expire)s

Command to create user on %(site)s server:
Ejemplo n.º 3
0
            configuration,
            '%(auto_base)s/cert_redirect/%(out_dir)s/%(jobid)s/%(jobid)s.stderr',
            var_dict)
        txt += \
            '''
Link to stdout file (might not be available):
%(generated_stdout)s

Link to stderr file (might not be available):
%(generated_stderr)s
''' % var_dict
    elif status == 'FAILED':

        header = '%s JOB Failed' % configuration.short_title
        var_dict['generated_links'] = generate_https_urls(
            configuration,
            '%(auto_base)s/%(auto_bin)s/jobstatus.py?job_id=%(jobid)s;flags=i',
            var_dict)
        txt += \
            '''
The job with JOB ID %(jobid)s has failed after %(retries)s retries!
This may be due to internal errors, but full status is available at:
%(generated_links)s

Please contact the %(site)s team if the problem occurs multiple times.
''' % var_dict
    elif status == 'EXPIRED':
        header = '%s JOB Expired' % configuration.short_title
        var_dict['generated_links'] = generate_https_urls(
            configuration,
            '%(auto_base)s/%(auto_bin)s/jobstatus.py?job_id=%(jobid)s;flags=i',
            var_dict)