Exemple #1
0
            'link',
            'destination':
            'resadmin.py?unique_resource_name=%s' % unique_resource_name,
            'class':
            'adminlink iconspace',
            'title':
            'Administrate resource',
            'text':
            'Manage resource',
        })
        return True
    elif configuration.auto_add_resource:
        resource_name = user_vars['HOSTURL']
        logger.info('Auto creating resource %s from %s' %
                    (resource_id, pending_file))
        (create_status, msg) = create_resource(configuration, client_id,
                                               resource_name, pending_file)
        if not create_status:
            output_objects.append({
                'object_type': 'error_text',
                'text': 'Resource creation failed:'
            })
            output_objects.append({'object_type': 'html_form', 'text': msg})
            return False
        output += '''Your resource was added as %s.%s
<hr />''' % (resource_name, msg)
    else:
        logger.info('Parsing conf %s for %s' % (pending_file, resource_id))
        (run_status, msg) = confparser.run(configuration, pending_file,
                                           resource_id, '')
        if not run_status:
            logger.error(msg)
Exemple #2
0
def create_oneclick_resource(
    sandboxkey,
    cputime,
    configuration,
    logger,
    ):

    resource_name = 'oneclick'

    # create a resource configuration string that we can write to a file

    exe_name = 'jvm'
    res_conf_string = \
        """\
::MIGUSER::
N/A

::HOSTURL::
oneclick

::HOSTIDENTIFIER::
$HOSTIDENTIFIER

::RESOURCEHOME::
N/A

::SCRIPTLANGUAGE::
java

::SSHPORT::
-1

::MEMORY::
128

::DISK::
10

::CPUCOUNT::
1

::SANDBOX::
True

::SANDBOXKEY::
%s    
    
::ARCHITECTURE::
X86

::PLATFORM::
ONE-CLICK

::NODECOUNT::
1

::HOSTKEY::
N/A

::FRONTENDNODE::
N/A

::FRONTENDLOG::
N/A

::EXECONFIG::
name=%s
nodecount=1
cputime=%s
execution_precondition=N/A
prepend_execute=N/A
exehostlog=N/A
joblog=N/A
execution_user=N/A
execution_node=N/A
execution_dir=N/A
start_command=N/A
status_command=N/A
stop_command=N/A
clean_command=N/A
continuous=False
shared_fs=False
vgrid=%s
    """\
         % (sandboxkey, exe_name, cputime, default_vgrid)

    # write the conf string to a temporary conf file
    # create_resource removes the tempfile automatically

    tmp_file = tempfile.NamedTemporaryFile(delete=False)
    tmp_file.write(res_conf_string)
    tmp_file.close()
    pending_file = tmp_file.name

    (status, id_msg) = create_resource(configuration, sandboxkey,
                                       resource_name, pending_file)
    if not status:
        return (False, '%s (%s)' % (id_msg, pending_file))

    # Create PGID file in resource_home

    resource_identifier = id_msg
    unique_resource_name = resource_name + '.' + str(resource_identifier)
                
    exe_pgid_file = configuration.resource_home + unique_resource_name\
         + os.sep + 'EXE_%s.PGID' % exe_name
    try:
        fd = open(exe_pgid_file, 'w')
        fd.write('stopped')
        fd.close()
    except Exception, exc:
        return (False, str(exc))
Exemple #3
0
def create_sss_resource(
    sandboxkey,
    cputime,
    memory,
    hd_size,
    net_bw,
    vgrid_list,
    configuration,
    logger,
    ):

    resource_name = 'sandbox'
    unique_host_name = "%s.%s" % (resource_name, "$HOSTIDENTIFIER")

    # create a resource configuration string that we can write to a file

    exe_name = 'localhost'
    res_conf_string = \
                        """\
::MIGUSER::
mig

::HOSTURL::
%s

::HOSTIDENTIFIER::
$HOSTIDENTIFIER

::RESOURCEHOME::
/opt/mig/MiG/mig_frontend/

::SCRIPTLANGUAGE::
sh

::SSHPORT::
22

::MEMORY::
%s

::DISK::
%s

::MAXDOWNLOADBANDWIDTH::
%s

::MAXUPLOADBANDWIDTH::
%s

::CPUCOUNT::
1

::SANDBOX::
True

::SANDBOXKEY::
%s

::ARCHITECTURE::
X86

::NODECOUNT::
1

::RUNTIMEENVIRONMENT::


::HOSTKEY::
N/A

::FRONTENDNODE::
localhost

::FRONTENDLOG::
/opt/mig/MiG/mig_frontend/frontendlog

::EXECONFIG::
name=%s
nodecount=1
cputime=%d
execution_precondition=''
prepend_execute=""
exehostlog=/opt/mig/MiG/mig_exe/exechostlog
joblog=/opt/mig/MiG/mig_exe/joblog
execution_user=mig
execution_node=localhost
execution_dir=/opt/mig/MiG/mig_exe/
start_command=cd /opt/mig/MiG/mig_exe/; chmod 700 master_node_script_%s.sh; ./master_node_script_%s.sh
status_command=exit \\\\\`ps -o pid= -g $mig_exe_pgid | wc -l \\\\\`
stop_command=kill -9 -$mig_exe_pgid
clean_command=true
continuous=False
shared_fs=True
vgrid=%s

"""\
    % (
        resource_name,
        memory,
        int(hd_size) / 1000,
        net_bw,
        str(int(net_bw) / 2),
        sandboxkey,
        exe_name,
        cputime,
        unique_host_name,
        unique_host_name,
        ', '.join(vgrid_list),
        )


    # write the conf string to a temporary conf file
    # create_resource removes the tempfile automatically

    tmp_file = tempfile.NamedTemporaryFile(delete=False)
    tmp_file.write(res_conf_string)
    tmp_file.close()
    pending_file = tmp_file.name

    (status, id_msg) = create_resource(configuration, sandboxkey,
                                       resource_name, pending_file)
    if not status:
        return (False, '%s (%s)' % (id_msg, pending_file))

    # Create PGID file in resource_home

    resource_identifier = id_msg
    unique_resource_name = resource_name + '.' + str(resource_identifier)
                
    exe_pgid_file = configuration.resource_home + unique_resource_name\
         + os.sep + 'EXE_%s.PGID' % exe_name
    try:
        fd = open(exe_pgid_file, 'w')
        fd.write('stopped')
        fd.close()
    except Exception, exc:
        return (False, str(exc))
Exemple #4
0
                               'Updated %s resource configuration!' % \
                               unique_resource_name})
        output_objects.append({'object_type': 'link',
                               'destination':
                               'resadmin.py?unique_resource_name=%s' % \
                               unique_resource_name,
                               'class': 'adminlink',
                               'title': 'Administrate resource',
                               'text': 'Manage resource',
                               })
        return True
    elif configuration.auto_add_resource:
        resource_name = user_vars['HOSTURL']
        logger.info('Auto creating resource %s from %s' % (resource_id,
                                                           pending_file))
        (create_status, msg) = create_resource(configuration, client_id,
                                               resource_name, pending_file)
        if not create_status:
            output_objects.append({'object_type': 'text', 'error_text':
                               'Resource creation failed: %s' % msg})
            return False
        output += '''Your resource was added as %s.%s
<hr />''' % (resource_name, msg)
    else:
        logger.info('Parsing conf %s for %s' % (pending_file, resource_id))
        (status, msg) = confparser.run(pending_file, resource_id, '')
        if not status:
            logger.error(msg)
            output_objects.append({'object_type': 'error_text', 'text':
                               'Failed to parse new configuration: %s' % msg})
            try:
                os.remove(pending_file)
Exemple #5
0
def create_oneclick_resource(
    sandboxkey,
    cputime,
    configuration,
    logger,
):

    resource_name = 'oneclick'

    # create a resource configuration string that we can write to a file

    exe_name = 'jvm'
    res_conf_string = \
        """\
::MIGUSER::
NA

::HOSTURL::
oneclick

::HOSTIDENTIFIER::
%s

::RESOURCEHOME::
NA

::SCRIPTLANGUAGE::
java

::SSHPORT::
22

::MEMORY::
128

::DISK::
10

::CPUCOUNT::
1

::SANDBOX::
True

::SANDBOXKEY::
%s    
    
::ARCHITECTURE::
X86

::PLATFORM::
ONE-CLICK

::NODECOUNT::
1

::HOSTKEY::


::FRONTENDNODE::
NA

::FRONTENDLOG::
NA

::EXECONFIG::
name=%s
nodecount=1
cputime=%s
execution_precondition=
prepend_execute=
exehostlog=NA
joblog=NA
execution_user=NA
execution_node=NA
execution_dir=NA
start_command=NA
status_command=NA
stop_command=NA
clean_command=NA
continuous=False
shared_fs=False
vgrid=%s
    """% (keyword_auto, sandboxkey, exe_name, cputime, default_vgrid)

    # write the conf string to a temporary conf file
    # create_resource removes the tempfile automatically

    tmp_file = tempfile.NamedTemporaryFile(delete=False)
    tmp_file.write(res_conf_string)
    tmp_file.close()
    pending_file = tmp_file.name

    (status, id_msg) = create_resource(configuration, sandboxkey,
                                       resource_name, pending_file)
    if not status:
        return (False, '%s (%s)' % (id_msg, pending_file))

    # Create PGID file in resource_home

    resource_identifier = id_msg
    unique_resource_name = resource_name + '.' + str(resource_identifier)

    exe_pgid_file = configuration.resource_home + unique_resource_name\
         + os.sep + 'EXE_%s.PGID' % exe_name
    try:
        fd = open(exe_pgid_file, 'w')
        fd.write('stopped')
        fd.close()
    except Exception, exc:
        return (False, str(exc))
Exemple #6
0
def create_sss_resource(
    sandboxkey,
    cputime,
    memory,
    hd_size,
    net_bw,
    vgrid_list,
    configuration,
    logger,
):

    resource_name = 'sandbox'
    unique_host_name = "%s.%s" % (resource_name, keyword_auto)

    # create a resource configuration string that we can write to a file

    exe_name = 'localhost'
    res_conf_string = \
                        """\
::MIGUSER::
mig

::HOSTURL::
%s

::HOSTIDENTIFIER::
%s

::RESOURCEHOME::
/opt/mig/MiG/mig_frontend/

::SCRIPTLANGUAGE::
sh

::SSHPORT::
22

::MEMORY::
%s

::DISK::
%s

::MAXDOWNLOADBANDWIDTH::
%s

::MAXUPLOADBANDWIDTH::
%s

::CPUCOUNT::
1

::SANDBOX::
True

::SANDBOXKEY::
%s

::ARCHITECTURE::
X86

::NODECOUNT::
1

::RUNTIMEENVIRONMENT::


::HOSTKEY::


::FRONTENDNODE::
localhost

::FRONTENDLOG::
/opt/mig/MiG/mig_frontend/frontendlog

::EXECONFIG::
name=%s
nodecount=1
cputime=%d
execution_precondition=''
prepend_execute=""
exehostlog=/opt/mig/MiG/mig_exe/exechostlog
joblog=/opt/mig/MiG/mig_exe/joblog
execution_user=mig
execution_node=localhost
execution_dir=/opt/mig/MiG/mig_exe/
start_command=cd /opt/mig/MiG/mig_exe/; chmod 700 master_node_script_%s.sh; ./master_node_script_%s.sh
status_command=exit \\\\\`ps -o pid= -g $mig_exe_pgid | wc -l \\\\\`
stop_command=kill -9 -$mig_exe_pgid
clean_command=true
continuous=False
shared_fs=True
vgrid=%s

"""\
    % (
        resource_name,
        keyword_auto,
        memory,
        int(hd_size) / 1000,
        net_bw,
        str(int(net_bw) / 2),
        sandboxkey,
        exe_name,
        cputime,
        unique_host_name,
        unique_host_name,
        ', '.join(vgrid_list),
        )

    # write the conf string to a temporary conf file
    # create_resource removes the tempfile automatically

    tmp_file = tempfile.NamedTemporaryFile(delete=False)
    tmp_file.write(res_conf_string)
    tmp_file.close()
    pending_file = tmp_file.name

    (status, id_msg) = create_resource(configuration, sandboxkey,
                                       resource_name, pending_file)
    if not status:
        return (False, '%s (%s)' % (id_msg, pending_file))

    # Create PGID file in resource_home

    resource_identifier = id_msg
    unique_resource_name = resource_name + '.' + str(resource_identifier)

    exe_pgid_file = configuration.resource_home + unique_resource_name\
         + os.sep + 'EXE_%s.PGID' % exe_name
    try:
        fd = open(exe_pgid_file, 'w')
        fd.write('stopped')
        fd.close()
    except Exception, exc:
        return (False, str(exc))