예제 #1
0
def rsync_file(files):
    '''
    Support for both individual file input or csv format
    These files are to be rsynced over from the yum-master
    '''
    rsync = '/usr/bin/rsync'
    rsync_user = '******'
    rsync_args = [
        '-qaplH', '--password-file=/root/rsync_yum_password', '--delete-delay',
        '--delay-updates'
    ]
    to_update_list = []

    if len(files) > 0:
        rpms = files.split(',')
        for rpm in rpms:
            remote_file = rpm[
                1:]  #remove the '/' at the start, data0 is the rsync exposed module
            rsync_url = "%s@%s::%s" % (rsync_user, yum_master,
                                       remote_file.strip())
            local_file = rpm

            #flatten out the command to run, sum() expects all args to be lists,
            cmd = sum([[rsync], rsync_args, [rsync_url], [local_file]], [])

            if pkgutils.run_cmd(cmd, action_logger) == True:
                status = "SUCCESS"
                #rsync completed successfully, we add this to our updaterepo list
                if os.path.dirname(local_file) not in to_update_list:
                    if os.path.basename(os.path.dirname(local_file)) == 'RPMS':
                        to_update_list.append(os.path.dirname(local_file))
            else:
                status = "FAIL"

    #append to our to_update_list we run createrepo on this list
    if len(to_update_list) > 0:
        pkgutils.updaterepos(to_update_list, action_logger)

    # Log and send the response
    log_and_format_response_msg("rsync", files, status)
예제 #2
0
def rsync_file(files):
    '''
    Support for both individual file input or csv format
    These files are to be rsynced over from the yum-master
    '''
    rsync      = '/usr/bin/rsync'
    rsync_user = '******'
    rsync_args = [ '-qaplH',
                   '--password-file=/root/rsync_yum_password',
                   '--delete-delay',
                   '--delay-updates'
                 ]
    to_update_list=[]

    if len(files) > 0:
        rpms = files.split(',')
        for rpm in rpms:
            remote_file = rpm[1:]  #remove the '/' at the start, data0 is the rsync exposed module
            rsync_url   = "%s@%s::%s" % (rsync_user, yum_master, remote_file.strip())
            local_file  = rpm

            #flatten out the command to run, sum() expects all args to be lists,
            cmd = sum([ [rsync], rsync_args, [rsync_url], [local_file] ], [])

            if pkgutils.run_cmd(cmd, action_logger) == True :
                status="SUCCESS"
                #rsync completed successfully, we add this to our updaterepo list
                if os.path.dirname(local_file) not in to_update_list:
                    if os.path.basename(os.path.dirname(local_file)) == 'RPMS':
                        to_update_list.append(os.path.dirname(local_file))
            else:
                status="FAIL"

    #append to our to_update_list we run createrepo on this list
    if len(to_update_list) > 0:
        pkgutils.updaterepos(to_update_list, action_logger)
    
    # Log and send the response 
    log_and_format_response_msg("rsync", files, status)
예제 #3
0
def check_file(files):
    # Support for both individual file input or csv format
    nay = '\033[91m[N]\033[0m'
    my_files = file.split(',')
    resp = []
    status = 'SUCCESS'

    for each_f in my_files:
        if not each_f:
            continue
        if os.path.exists(each_f):
            cmd = ["/usr/bin/sha1sum", "-b", each_f ]
            sum = pkgutils.run_cmd(cmd, action_logger, cmd_out=True)
            events_logger.info(sum)
            #get the sha1sum, pick the first 8 chars
            sum = sum.split()[0].strip()[:8]
            resp.append("\033[94m[%s]\033[0m%s" % (sum, os.path.basename(each_f)))
        else:
            resp.append(nay + os.path.basename(each_f))

    if len(resp) > 0:
        log_and_format_response_msg("check", ','.join(resp), status)
예제 #4
0
def check_file(files):
    # Support for both individual file input or csv format
    nay = '\033[91m[N]\033[0m'
    my_files = file.split(',')
    resp = []
    status = 'SUCCESS'

    for each_f in my_files:
        if not each_f:
            continue
        if os.path.exists(each_f):
            cmd = ["/usr/bin/sha1sum", "-b", each_f]
            sum = pkgutils.run_cmd(cmd, action_logger, cmd_out=True)
            events_logger.info(sum)
            #get the sha1sum, pick the first 8 chars
            sum = sum.split()[0].strip()[:8]
            resp.append("\033[94m[%s]\033[0m%s" %
                        (sum, os.path.basename(each_f)))
        else:
            resp.append(nay + os.path.basename(each_f))

    if len(resp) > 0:
        log_and_format_response_msg("check", ','.join(resp), status)