コード例 #1
0
def _get_ftpHost_by_vmName(vmName):
    '''
    by a given vmName, return associated ftpHost. mappings are located in the config.py file
    Arg: vmName: str -> the virtual machine name.
    '''
    connectionInfo = _get_connectionInfo_by_vmName(vmName)
    ftphost = ftpHostFactory.create_ftpHost(hostname=connectionInfo[0], port=connectionInfo[1], user=connectionInfo[2],password=connectionInfo[3], remoteFolder=connectionInfo[4])
    return ftphost
コード例 #2
0
def get_backups_from_ftp_servers():
    '''
    rebuilds a new dump file by scanning all ftp server's defined in the configuration config.py file.
    Args: dumpFilePath: str -> the path of the dumpfile
    '''

    result = {}
    ftpConnections = get_all_ftp_connections()
    for server in ftpConnections:
        ftpWrapper = ftpHostFactory.create_ftpHost(server, port=ftpConnections[server][0],
            user=ftpConnections[server][1], password=ftpConnections[server][2],remoteFolder=ftpConnections[server][3])

        try:
            ftpWrapper.connect_to_host()
            backupsInFtpHost = backupManager.getBackupsFromFtpServer(ftpWrapper)
            ftpWrapper.disconnect_from_host()
            backupManager.merge_first_backup_into_second_backup(backupsInFtpHost, result)
        except Exception, ex :
            logging.error("an error occurred in trying to get read backups from host {0}. Please make sure the ftp "
                          "connection to the host is correct!. the error is: {1}.  Quitting..".format(ftpWrapper.hostname, str(ex)))
            sys.exit()