Esempio n. 1
0
def backup_paraview_links(configuration, vgrid_list):
    """Backup paraview_links in configuration.paraview_home"""

    status = True
    logger = configuration.logger

    logger.info('==============================================')
    logger.info('Backing up paraview links')
    logger.info('==============================================')

    for vgrid in vgrid_list:
        logger.info('----------------------------------------------')
        logger.info('vgrid: %s' % vgrid)
        logger.info('----------------------------------------------')
        paraview_link_src_filepath = \
            os.path.join(configuration.vgrid_home,
                         os.path.join(configuration.paraview_home,
                         os.path.join('worker', vgrid)))
        if os.path.exists(paraview_link_src_filepath):
            paraview_link_dest_filepath = '%s.preview.%s.bck' \
                % (paraview_link_src_filepath,
                   time.strftime('%d%m%y-%H%M%S', time.gmtime()))
            logger.info("srcfile: '%s'" % paraview_link_src_filepath)
            logger.info("destfile: '%s'" % paraview_link_dest_filepath)
            move(paraview_link_src_filepath, paraview_link_dest_filepath)
        else:
            logger.warning("Missing paraview link: '%s'" %
                           paraview_link_src_filepath)

    return status
Esempio n. 2
0
def backup_imagesettings_files(configuration, vgrid_list):
    """Backup imagesetting dict in configuration.vgrid_home"""

    status = True
    logger = configuration.logger

    logger.info('==============================================')
    logger.info('Backing up imagesettings files')
    logger.info('==============================================')

    for vgrid in vgrid_list:
        logger.info('----------------------------------------------')
        logger.info('vgrid: %s' % vgrid)
        logger.info('----------------------------------------------')
        imagesettings_src_filepath = \
            os.path.join(configuration.vgrid_home, os.path.join(vgrid,
                         configuration.vgrid_imagesettings))
        if os.path.exists(imagesettings_src_filepath):
            imagesettings_dest_filepath = '%s.preview.%s.bck' \
                % (imagesettings_src_filepath,
                   time.strftime('%d%m%y-%H%M%S', time.gmtime()))
            logger.info("srcfile: '%s'" % imagesettings_src_filepath)
            logger.info("destfile: '%s'" % imagesettings_dest_filepath)
            move(imagesettings_src_filepath, imagesettings_dest_filepath)
        else:
            logger.warning("Missing imagesettings file: '%s'" %
                           imagesettings_src_filepath)

    return status
Esempio n. 3
0
        msg += \
            'Failed to apply hostidentifier to configfile. Failure: %s'\
             % err
        return (False, msg)

    unique_resource_name = resource_name + '.' + str(resource_identifier)
    (status, run_msg) = run(configuration, tmpfile, unique_resource_name)
    msg += '\n' + run_msg
    if not status:
        return (False, msg)

    # truncate old conf with new accepted file

    try:
        move(tmpfile, new_configfile)
    except Exception, err:
        msg += '\nAccepted config, but failed to save it! Failed: %s'\
             % err
        return (False, msg)

    mark_resource_modified(configuration, unique_resource_name)
    mark_vgrid_modified(configuration, unique_resource_name)

    try:
        os.remove(pending_file)
    except Exception, err:
        pass
    msg += '\nNew configfile successfully applied.'
    return (True, msg)
Esempio n. 4
0
        # Move automatically takes place relative to upload tmp dir
        for (rel_path, chunk_tuple) in upload_files:
            real_path = os.path.abspath(os.path.join(base_dir, rel_path))
            dest_path = os.path.abspath(os.path.join(
                base_dir, current_dir, os.path.basename(rel_path)))
            if not valid_user_path(dest_path, base_dir, True):
                logger.error('%s tried to %s move to restricted path %s ! (%s)'
                             % (client_id, op_name, dest_path, current_dir))
                output_objects.append(
                    {'object_type': 'error_text', 'text'
                     : "Invalid destination (%s expands to an illegal path)" \
                     % current_dir})
                moved = False
            else:
                try: 
                    move(real_path, dest_path)
                    moved = True
                except Exception, exc:
                    logger.error('could not move %s to %s: %s' % (real_path,
                                                              dest_path, exc))
                    moved = False
            uploaded.append({'object_type': 'uploadfile', rel_path: moved})
        logger.info('move done: %s' % ' '.join([i[0] for i in upload_files]))
        return (output_objects, status)
    elif action != 'put':
        output_objects.append({'object_type': 'error_text', 'text'
                              : 'Invalid action: %s!' % action})
        return (output_objects, returnvalues.CLIENT_ERROR)

    # Handle actual uploads (action == 'put')
        
Esempio n. 5
0
        msg += \
            'Failed to apply hostidentifier to configfile. Failure: %s'\
             % err
        return (False, msg)

    unique_resource_name = resource_name + '.' + str(resource_identifier)
    (status, run_msg) = run(tmpfile, unique_resource_name)
    msg += '\n' + run_msg
    if not status:
        return (False, msg)

    # truncate old conf with new accepted file

    try:
        move(tmpfile, new_configfile)
    except Exception, err:
        msg += '\nAccepted config, but failed to save it! Failed: %s'\
             % err
        return (False, msg)

    mark_resource_modified(configuration, unique_resource_name)
    mark_vgrid_modified(configuration, unique_resource_name)

    try:
        os.remove(pending_file)
    except Exception, err:
        pass
    msg += '\nNew configfile successfully applied.'
    return (True, msg)
Esempio n. 6
0
     output_objects.append({
         'object_type':
         'error_text',
         'text':
         'cannot move "%s": inside a read-only location!' % rel_dst
     })
     moved = False
 else:
     try:
         gdp_iolog(configuration, client_id, environ['REMOTE_ADDR'],
                   'modified', [rel_dst])
         if not makedirs_rec(
                 dest_dir, configuration, accept_existing=True):
             raise IOError("failed to create dest_dir: %s" %
                           dest_dir)
         move(abs_src_path, dest_path)
         moved = True
     except Exception, exc:
         if not isinstance(exc, GDPIOLogError):
             gdp_iolog(configuration,
                       client_id,
                       environ['REMOTE_ADDR'],
                       'modified', [rel_dst],
                       failed=True,
                       details=exc)
         logger.error('could not move %s to %s: %s' %
                      (abs_src_path, dest_path, exc))
         moved = False
 file_entry = {'object_type': 'uploadfile', rel_path: moved}
 if moved:
     file_entry['name'] = rel_dst