Exemple #1
0
def main(client_id, user_arguments_dict):
    """Main function used by front end"""

    (configuration, logger, output_objects, op_name) = \
        initialize_main_variables(client_id, op_header=False, op_title=False,
                                  op_menu=client_id)
    defaults = signature()[1]
    (validate_status, accepted) = validate_input(user_arguments_dict,
            defaults, output_objects, allow_rejects=False)
    if not validate_status:
        return (accepted, returnvalues.CLIENT_ERROR)

    action = accepted['action'][-1]
    sandboxkey = accepted['sandboxkey'][-1]
    exe_name = accepted['exe_name'][-1]

    status = returnvalues.OK

    # Web format for cert access and no header for SID access
    if client_id:
        output_objects.append({'object_type': 'title', 'text'
                               : 'SSS script download'})
        output_objects.append({'object_type': 'header', 'text'
                               : 'SSS script download'})
    else:
        output_objects.append({'object_type': 'start'})

    if not configuration.site_enable_sandboxes:
        output_objects.append({'object_type': 'text', 'text':
                               '''Sandbox resources are disabled on this site.
Please contact the Grid admins %s if you think they should be enabled.
''' % configuration.admin_email})
        return (output_objects, returnvalues.OK)

    (result, unique_resource_name) = get_resource_name(sandboxkey, logger)
    if not result:
        msg = unique_resource_name
    elif action == 'get_frontend_script':
        (result, msg) = get_frontend_script(unique_resource_name, logger)
    elif action == 'get_master_node_script':
        (result, msg) = get_master_node_script(unique_resource_name,
                                               exe_name, logger)
    else:
        result = False
        msg = 'Unknown action: %s' % action

    if not result:
        status = returnvalues.ERROR

    # Status code line followed by raw output
    if not client_id:
        output_objects.append({'object_type': 'script_status', 'text': ''})
        output_objects.append({'object_type': 'binary', 'data': '%s' % status[0]})
    output_objects.append({'object_type': 'binary', 'data': msg})
    return (output_objects, status)
Exemple #2
0
    o.reply_and_exit(o.ERROR)

# Make sure that we're called with HTTPS.

if str(os.getenv('HTTPS')) != 'on':
    o.out('Please use HTTPS with session id for authenticating job requests!'
          )
    cgiscript_header()
    o.reply_and_exit(o.ERROR)

action = fieldstorage.getfirst('action', None)
debug = fieldstorage.getfirst('debug', None)
if action == 'get_frontend_script':
    (status, msg) = get_ps3_resource()
    if status:
        (status, msg) = get_frontend_script(msg, logger)
elif action == 'get_master_node_script':
    (status, msg) = get_ps3_resource()
    if status:
        (status, msg) = get_master_node_script(msg, 'localhost', logger)
elif action == 'get_resourcename':
    (status, msg) = get_ps3_resource()
else:
    status = False
    msg = 'Unknown action: %s' % action

# Get a resource for the connection client.

o.out(msg)
if status:
    o.reply_and_exit(o.OK)
Exemple #3
0
def main(client_id, user_arguments_dict):
    """Main function used by front end"""

    (configuration, logger, output_objects, op_name) = \
        initialize_main_variables(client_id, op_header=False, op_title=False,
                                  op_menu=client_id)
    defaults = signature()[1]
    (validate_status, accepted) = validate_input(user_arguments_dict,
                                                 defaults,
                                                 output_objects,
                                                 allow_rejects=False)
    if not validate_status:
        return (accepted, returnvalues.CLIENT_ERROR)

    action = accepted['action'][-1]
    sandboxkey = accepted['sandboxkey'][-1]
    exe_name = accepted['exe_name'][-1]

    status = returnvalues.OK

    # Web format for cert access and no header for SID access
    if client_id:
        output_objects.append({
            'object_type': 'title',
            'text': 'SSS script download'
        })
        output_objects.append({
            'object_type': 'header',
            'text': 'SSS script download'
        })
    else:
        output_objects.append({'object_type': 'start'})

    if not configuration.site_enable_sandboxes:
        output_objects.append({
            'object_type':
            'text',
            'text':
            '''Sandbox resources are disabled on this site.
Please contact the site admins %s if you think they should be enabled.
''' % configuration.admin_email
        })
        return (output_objects, returnvalues.OK)

    (result, unique_resource_name) = get_resource_name(sandboxkey, logger)
    if not result:
        msg = unique_resource_name
    elif action == 'get_frontend_script':
        (result, msg) = get_frontend_script(unique_resource_name, logger)
    elif action == 'get_master_node_script':
        (result, msg) = get_master_node_script(unique_resource_name, exe_name,
                                               logger)
    else:
        result = False
        msg = 'Unknown action: %s' % action

    if not result:
        status = returnvalues.ERROR

    # Status code line followed by raw output
    if not client_id:
        output_objects.append({'object_type': 'script_status', 'text': ''})
        output_objects.append({
            'object_type': 'binary',
            'data': '%s' % status[0]
        })
    output_objects.append({'object_type': 'binary', 'data': msg})
    return (output_objects, status)
Exemple #4
0
    o.out('You must use HTTP GET!')
    o.reply_and_exit(o.ERROR)

# Make sure that we're called with HTTPS.

if str(os.getenv('HTTPS')) != 'on':
    o.out('Please use HTTPS with session id for authenticating job requests!')
    cgiscript_header()
    o.reply_and_exit(o.ERROR)

action = fieldstorage.getfirst('action', None)
debug = fieldstorage.getfirst('debug', None)
if action == 'get_frontend_script':
    (status, msg) = get_ps3_resource(configuration)
    if status:
        (status, msg) = get_frontend_script(msg, logger)
elif action == 'get_master_node_script':
    (status, msg) = get_ps3_resource(configuration)
    if status:
        (status, msg) = get_master_node_script(msg, 'localhost', logger)
elif action == 'get_resourcename':
    (status, msg) = get_ps3_resource(configuration)
else:
    status = False
    msg = 'Unknown action: %s' % action

# Get a resource for the connection client.

o.out(msg)
if status:
    o.reply_and_exit(o.OK)