def testLocalToOneRemoteHost(self): tempFolder = "localToOneRemote" filePaths = {} checkPathList = [] sourceFilesPathList = getFiles(self.localSourceFolder) for sourceFilePath in sourceFilesPathList: sourceFileName = basename(sourceFilePath) targetFilePath = join(self.remoteTargetFolder1, tempFolder, sourceFileName) filePaths[sourceFilePath] = targetFilePath checkPathList.append(self.hostsRefs[0] + ":" + targetFilePath) self.fileTransfer.transferFilesTo(filePaths, self.remoteHostName1, self.remoteUserName1, self.remotePassword1, gatewayHosts=self.gatewayHosts, numberTrials=self.numberTrials, forceOperation=self.forceOperation, operationId=self.operationId) passTest = len( self.fileTransfer.checkFiles(checkPathList, self.hostPasswords, gatewayHosts=self.gatewayHosts, numberTrials=self.numberTrials, forceOperation=self.forceOperation, operationId=self.operationId)) == 0 ft.removeRemoteFolder(self.remoteHostName1, self.remoteUserName1, self.remotePassword1, join(self.remoteTargetFolder1, tempFolder)) self.assertTrue(passTest)
def testLocalToOneRemoteHost(self): tempFolder = "localToOneRemote" filePaths = {} checkPathList = [] sourceFilesPathList = getFiles(self.localSourceFolder) for sourceFilePath in sourceFilesPathList: sourceFileName = basename(sourceFilePath) targetFilePath = join(self.remoteTargetFolder1, tempFolder, sourceFileName) filePaths[sourceFilePath] = targetFilePath checkPathList.append(self.hostsRefs[0] + ":" + targetFilePath) self.fileTransfer.transferFilesTo(filePaths, self.remoteHostName1, self.remoteUserName1, self.remotePassword1, gatewayHosts=self.gatewayHosts, numberTrials=self.numberTrials, forceOperation=self.forceOperation, operationId=self.operationId) passTest = len(self.fileTransfer.checkFiles(checkPathList, self.hostPasswords, gatewayHosts=self.gatewayHosts, numberTrials=self.numberTrials, forceOperation=self.forceOperation, operationId=self.operationId)) == 0 ft.removeRemoteFolder(self.remoteHostName1, self.remoteUserName1, self.remotePassword1, join(self.remoteTargetFolder1, tempFolder)) self.assertTrue(passTest)
def testLocalToSeveralRemoteHosts(self): tempFolder = "localToSeveralRemote" filePaths = {} sourceFilesPathList = getFiles(self.localSourceFolder) for sourceFilePath in sourceFilesPathList: sourceFileName = basename(sourceFilePath) targetFilePath1 = join(self.remoteTargetFolder1, tempFolder, sourceFileName) targetFilePath2 = join(self.remoteTargetFolder2, tempFolder, sourceFileName) targetFilePathList = [] targetFilePathList.append(self.hostsRefs[0] + ":" + targetFilePath1) targetFilePathList.append(self.hostsRefs[1] + ":" + targetFilePath2) filePaths[sourceFilePath] = targetFilePathList self.fileTransfer.transferFiles(filePaths, self.hostPasswords, gatewayHosts=self.gatewayHosts, numberTrials=self.numberTrials, forceOperation=self.forceOperation, operationId=self.operationId) checkPathList = ft.getFilePathList(filePaths) passTest = len(self.fileTransfer.checkFiles(checkPathList, self.hostPasswords, gatewayHosts=self.gatewayHosts, numberTrials=self.numberTrials, forceOperation=self.forceOperation, operationId=self.operationId)) == 0 # self.fileTransfer.deleteFiles(checkPathList, self.hostPasswords, gatewayHosts=self.gatewayHosts, numberTrials=self.numberTrials, forceOperation=self.forceOperation, operationId=self.operationId) ft.removeRemoteFolder(self.remoteHostName1, self.remoteUserName1, self.remotePassword1, join(self.remoteTargetFolder1, tempFolder)) ft.removeRemoteFolder(self.remoteHostName2, self.remoteUserName2, self.remotePassword2, join(self.remoteTargetFolder2, tempFolder)) self.assertTrue(passTest)
def testAll(self): tempFolder = "allTransfer" filePaths = {} sourceFilesPathList = getFiles(self.localSourceFolder) remoteSourceFilePathList1 = ft.getRemoteFolderFiles(self.remoteHostName1, self.remoteUserName1, self.remotePassword1, self.remoteSourceFolder1) remoteSourceFilePathList2 = ft.getRemoteFolderFiles(self.remoteHostName2, self.remoteUserName2, self.remotePassword2, self.remoteSourceFolder2) localUserName = getLocalUserName() localHostname = getLocalHostName() for sourceFilePath in sourceFilesPathList: sourceFileName = basename(sourceFilePath) targetFilePath1 = join(self.remoteTargetFolder1, tempFolder, sourceFileName) targetFilePath2 = join(self.remoteTargetFolder2, tempFolder, sourceFileName) targetFilePath3 = join (self.localTargetFolder, tempFolder, sourceFileName) targetFilePathList = [] targetFilePathList.append(self.hostsRefs[0] + ":" + targetFilePath1) targetFilePathList.append(self.hostsRefs[1] + ":" + targetFilePath2) targetFilePathList.append(localUserName + "@" + localHostname + ":" + targetFilePath3) filePaths[sourceFilePath] = targetFilePathList for remoteSourceFilePath in remoteSourceFilePathList1: targetFilePathList = [] targetFilePathList.append(join(self.localTargetFolder, tempFolder, "test1", basename(remoteSourceFilePath))) filePaths[self.hostsRefs[0] + ":" + remoteSourceFilePath] = targetFilePathList for remoteSourceFilePath in remoteSourceFilePathList2: targetFilePathList = [] targetFilePathList.append(join(self.localTargetFolder, tempFolder, "test2", basename(remoteSourceFilePath))) filePaths[self.hostsRefs[1] + ":" + remoteSourceFilePath] = targetFilePathList self.fileTransfer.transferFiles(filePaths, self.hostPasswords, gatewayHosts=self.gatewayHosts, numberTrials=self.numberTrials, forceOperation=self.forceOperation, operationId=self.operationId) checkPathList = ft.getFilePathList(filePaths) passTest = len(self.fileTransfer.checkFiles(checkPathList, self.hostPasswords, gatewayHosts=self.gatewayHosts, numberTrials=self.numberTrials, forceOperation=self.forceOperation, operationId=self.operationId)) == 0 # self.fileTransfer.deleteFiles(checkPathList, self.hostPasswords, gatewayHosts=self.gatewayHosts, numberTrials=self.numberTrials, forceOperation=self.forceOperation, operationId=self.operationId) cleanPath(join(self.localTargetFolder, tempFolder)) ft.removeRemoteFolder(self.remoteHostName1, self.remoteUserName1, self.remotePassword1, join(self.remoteTargetFolder1, tempFolder)) ft.removeRemoteFolder(self.remoteHostName2, self.remoteUserName2, self.remotePassword2, join(self.remoteTargetFolder2, tempFolder)) self.assertTrue(passTest)