def modify_iscsi_configuration(fileName, chap_userName, chap_passwd): # starting of updating iscsid.conf file for CHAP authentication... searchText1 = 'node.session.auth.authmethod' sourceText1 = get_sourceText(fileName, searchText1) sourceText1 = verify_sourceText(sourceText1) # sourceText should be present to replace replaceText1 = 'node.session.auth.authmethod = CHAP' replace_text(fileName, sourceText1, replaceText1) searchText2 = 'node.session.auth.username' sourceText2 = get_sourceText(fileName, searchText2) sourceText2 = verify_sourceText(sourceText2) # sourceText should be present to replace replaceText2 = 'node.session.auth.username = %s' % (chap_userName) replace_text(fileName, sourceText2, replaceText2) searchText3 = 'node.session.auth.password' sourceText3 = get_sourceText(fileName, searchText3) sourceText3 = verify_sourceText(sourceText3) # sourceText should be present to replace replaceText3 = 'node.session.auth.password = %s' % (chap_passwd) replace_text(fileName, sourceText3, replaceText3) #Make system to read newly updated file executeCmd('service iscsid restart') #in some old machines above command will nor work, try with different command executeCmd('/sbin/iscsid restart')
def mount_iscsi(device, vol_name): #this method will work only when you create a partion to your iscsi LUN executeCmd('mkdir -p mount/%s' %(vol_name)) mount_result = executeCmd('mount /dev/%s1 mount/%s' %(device, vol_name)) if mount_result[0] == 'PASSED': logging.debug('mounted %s at mount/%s successfully', vol_name, vol_name) return ['PASSED', ''] logging.error('Not able to mount iscsi LUN: %s', mount_result) return ['FAILED', mount_result]
def toCreateExt4FileSystem(volumeToBeFormated, fs_extension): dict1 = getDiskAllocatedToISCSI('20.10.83.8', 'Account1iscsivol1') for i in dict1: if i == volumeToBeFormated: print dict1[i] executeCmd("fdisk /dev/%s < fdisk_response_file" % (dict1[i])) executeCmd("mkfs.%s /dev/%s1" % (fs_extension, dict[i])) #print "mkfs.%s /dev/%s1" %(fs_extension,dict[i]) return "The extension is created successfully"
def mount_nfs_volume(volume): executeCmd('mkdir -p /mnt/%s' % (volume['mountPoint'])) mountResult = executeCmd('mount -t nfs %s:/%s /mnt/%s' \ %(volume['TSMIPAddress'], volume['mountPoint'], volume['mountPoint'])) if mountResult[0] == 'PASSED': print 'NFS volume \"%s\" mounted successfully' % (volume['name']) return 'PASSED' else: print 'NFS volume \"%s\" failed to mount' % (volume['name']) return 'FAILED'
def ping_machine(ip): pingvalue = executeCmd('ping -c 1 %s' % (ip)) count = 1 if pingvalue[0] == 'PASSED': logging.debug('Able to ping IP: %s', ip) return ['PASSED', ''] while pingvalue[0] == 'FAILED': if count == 15: print '%s is unreachable' % ip logging.error('Node with IP %s is unreachable', ip) return ['FAILED', 'Node is unreachable'] pingvalue = executeCmd('ping -c 1 %s' % (ip)) count = count + 1 time.sleep(2)
def umount_nfs_volume(volume): mountCheck = executeCmd('mount | grep %s' % (volume['mountPoint'])) if mountCheck[0] == 'PASSED': umountResult = executeCmd('umount /mnt/%s' % (volume['mountPoint'])) if umountResult[0] == 'PASSED': print 'Volume \"%s\" umounted successfully' % (volume['name']) return ['PASSED', ''] else: print umountResult[1] print 'Volume \"%s\" failed to umount' % (volume['name']) return ['FAILED', umountResult[1]] else: print 'Volume \"%s\" is not mounted' % (volume['name']) return ['PASSED', 'Volume is not mounted']
def excecute_vdbench(volume): ##volume is dictionary logging.info('.....inside excecute_vdbench method....') logging.info(' overwriting the file fileconfig with std path') executeCmd('yes | cp -rf vdbench/templates/fileconfig vdbench/fileconfig') output = getoutput('mount | grep %s | awk \'{print $3}\'' %(volume['mountPoint'])) old_str = 'mountDirectory' new_str = output[0].rstrip('\n') path = 'vdbench12/fileconfig' logging.info('Replacing the std path with volume mountpoint') res = executeCmd("sed -i 's/%s/%s/' %s " %(old_str.replace('/', '\/'),\ new_str.replace('/', '\/'), path )) logging.info('executing vdbench command') out = os.system('./vdbench/vdbench -f vdbench/fileconfig -o vdbench/output &') logging.debug('vdbench command result:%s', out)
def executeVdbenchFile(volume, vdbfile): ##volume is dictionary logging.info('.....inside excecute_vdbench method....') logging.info(' overwriting the file fileconfig with std path') executeCmd('yes | cp -rf vdbench/templates/%s vdbench/%s' %(vdbfile, volume['name'])) output = getoutput('mount | grep %s | awk \'{print $3}\'' %(volume['mountPoint'])) old_str = 'mountDirectory' new_str = output[0].rstrip('\n') path = 'vdbench/%s' %volume['name'] logging.info('Replacing the std path with volume mountpoint') res = executeCmd("sed -i 's/%s/%s/' %s " %(old_str.replace('/', '\/'), new_str.replace('/', '\/'), path )) logging.info('executing vdbench....') out = os.system('./vdbench/vdbench -f vdbench/%s -o vdbench/output &' %volume['name']) #out = os.system('./vdbench12/vdbench -f vdbench12/fileconfig &') return out
def writingVDBfile(x, volume): output = getoutput('mount | grep %s | awk \'{print $3}\'' %(volume['mountPoint'])) old_str = 'mountDirectory%s' %x new_str = output[0].rstrip('\n') path = 'vdbench/%s' %vdbNewFile logging.info('Replacing the std path with volume mountpoint') res = executeCmd("sed -i 's/%s/%s/' %s " %(old_str.replace('/', '\/'), new_str.replace('/', '\/'), path ))
def iscsi_login_logout(vol_iqn, vsm_ip, action): #action can be login and logout logging.info('inside the iscsi_login_logout method...') cmd = 'iscsiadm -m node --targetname %s --portal %s:3260 --%s' \ %(vol_iqn, vsm_ip, action) logging.debug('executing command: %s', cmd) result = executeCmd(cmd) logging.debug('iscsi %s result: %s', action, result) return result
def execute_mkfs(device, version): #device where you want to write filesystem e.g sda, sdb, sdc #version means here for filesystem e.g. ext3, ext4 etc #for using this method make sure fdisk_response_file should be there logging.debug('creating the partion on device %s', device) cmd = 'fdisk /dev/%s < fdisk_response_file' %(device) logging.debug('command: %s', cmd) result = executeCmd(cmd) logging.debug('result for making partion: %s', result) logging.debug('writing %s on device %s', version, device) time.sleep(2) result = executeCmd('echo y | mkfs.%s /dev/%s1' %(version, device)) if result[0] == 'PASSED': logging.debug('filesystem has been written successfully') result = ['PASSED', ''] else: logging.error('Not able to write filesystem Error: %s', result) result = ['FAILED', result] return result
def writingVDBfile(volume, vdbFile, vol_size): executeCmd('yes | cp -rf vdbench/templates/%s vdbench/%s' % (vdbFile, volume['name'])) logging.info('copying vdbench/templates/%s file to vdbench as "%s"', \ vdbFile, volume['name']) output = getoutput('mount | grep %s | awk \'{print $3}\'' % (volume['mountPoint'])) old_str = 'mountDirectory' new_str = output[0].rstrip('\n') old_size = getoutput("cat vdbench/%s | grep ',size=' | cut -d '=' -f 7" \ %(volume['name'])) old_size = old_size[0].strip('\n') vdb_path = 'vdbench/%s' % volume['name'] res = executeCmd("sed -i 's/%s/%s/' %s " \ %(old_str.replace('/', '\/'), new_str.replace('/', '\/'), vdb_path)) res = executeCmd("sed -i 's/%s/%s/' %s " \ %(old_size.replace('/', '\/'), vol_size.replace('/', '\/'), vdb_path)) logging.info('executing vdbench....') out = os.system('./vdbench/vdbench -f vdbench/%s -o vdbench/output &' \ %(volume['name']))
def make_iscsid_conf_original(backup_filename, fileName): #replacing iscsid.conf file with oriognal file... cmd = 'yes | cp %s %s' % (backup_filename, fileName) replace_backup_file = executeCmd(cmd) if replace_backup_file[0] == 'PASSED': print 'backup has been replaced successfully' logging.debug('iscsid.conf has been revert back to original file') else: print 'Not able to replace backup file' logging.error('Not able to revert iscsid.confi to original file, '\ 'please update it manually, Error: %s', replace_backup_file[1]) print replace_backup_file[1]
def verify_pool_import(poolName, NODE2_IP, PASSWD): logging.debug('pool import at peer Node would take some time, '\ 'sleeping for 25 seconds') time.sleep(25) logging.debug('executing zpool list at Node:%s', NODE2_IP) getControllerInfo(NODE2_IP, PASSWD, 'zpool list', 'listpool.txt') import_result = executeCmd('cat listpool.txt | grep %s' % (poolName)) if import_result[0] == 'PASSED': logging.debug('pool %s imported successfully at peer Node:%s', \ poolName, NODE2_IP) return logging.debug('pool is not imported till 25 seconds after reboot the Node') logging.debug('sleeping for another 10 seconds') time.sleep(10) logging.debug('executing zpool list at Node:%s', NODE2_IP) getControllerInfo(NODE2_IP, PASSWD, 'zpool list', 'listpool.txt') import_result = executeCmd('cat listpool.txt | grep %s' % (poolName)) if import_result[0] == 'PASSED': logging.debug('pool %s imported successfully at peer Node:%s', \ poolName, NODE2_IP) return logging.debug('pool is not imported till 35 seconds after reboot the Node') logging.debug('sleeping for another 10 seconds') time.sleep(10) logging.debug('executing zpool list at Node:%s', NODE2_IP) getControllerInfo(NODE2_IP, PASSWD, 'zpool list', 'listpool.txt') import_result = executeCmd('cat listpool.txt | grep %s' % (poolName)) if import_result[0] == 'PASSED': logging.debug('pool %s imported successfully at peer Node:%s', \ poolName, NODE2_IP) return logging.error('pool %s import failed at peer Node:%s', poolName, NODE2_IP) is_blocked(startTime, FOOTER_MSG, BLOCKED_MSG)
def take_backup(fileName, backup_filename): #taking backup of '/etc/iscsi/iscsid.conf' file... backup_filename = 'backup_%s' % (fileName.split('/')[-1]) cmd = 'yes | cp %s %s' % (fileName, backup_filename) take_backup = executeCmd(cmd) if take_backup[0] == 'PASSED': print 'backup has been taken successfully' logging.debug('Successfully taken bakup of iscsid.conf') else: print 'Not able to take backup' print take_backup[1] logging.error('iSCSI login with CHAP method test case is blocked Not '\ 'able to take backup of iscsid.conf, Error: %s', take_backup[1]) is_blocked(startTime, FOOTER_MSG, BLOCKED_MSG)
def umount_share(volume): umount = umountVolume_new(volume) if 'FAILED' in umount[0] and 'device is busy' in umount[1]: print 'Unmount is failing as device is busy, hence unmounting forcefully' logging.info('unmount is failing hence unmounting forcefully') umount_output = executeCmd('umount -l mount/%s' \ %(volume['mountPoint'])) if umount_output[0] == 'PASSED': logging.debug('Forceful unmount passed for volume "%s"', \ volume['name']) else: logging.debug('Forcefull umount failed due to: %s', \ umount_output[1]) elif 'FAILED' in umount[0]: logging.debug('Unmount failed for the volume "%s" due to: %s', \ volume['name'], umount[1]) else: print umount[1] logging.debug('Volume "%s" umounted successfully', volume['name'])
def kill_process(process_name): logging.debug('inside kill_process...') pid = getoutput('ps -aux |grep %s |awk \'{print $2}\'' % (process_name)) logging.debug('process going to be killed...: %s', pid) processlist = [] for process in pid: p1 = process.rstrip('\n') processlist.append(p1) #print processlist logging.debug('%s process ids...: %s', process_name, processlist) cmd = 'kill -9' for proc in processlist: cmd = cmd + ' %s' % (proc) res = executeCmd(cmd) if res[0] == 'PASSED' or 'No such process' in str(res[1]): print 'process is killed' logging.debug('process are killed') else: print 'process are not killed' logging.debug('one or more process is not killed, Error: %s', \ res[1])
def copy_file(file_to_copy, dstntn_dir): #dstntn_dir is destination_directory logging.debug('inside copy_file method...') logging.debug('taking md5sum of %s...', file_to_copy) out = getoutput('md5sum %s' %(file_to_copy))[0] md5_of_src_file = out.split(' ')[0] logging.debug('md5sum at source of %s: %s', file_to_copy, md5_of_src_file) copy_result = executeCmd('cp %s %s/' %(file_to_copy, dstntn_dir)) if copy_result[0] == 'FAILED': logging.error('Not able to copy file at directory %s', dstntn_dir) return ['FAILED', ''] logging.debug('copied file to mounted directory successfully') out = (getoutput('md5sum %s/%s' %(dstntn_dir, file_to_copy)))[0] md5_of_dstns_file = out.split(' ')[0] logging.debug('md5sum at destination of %s: %s', file_to_copy, md5_of_dstns_file) if str(md5_of_src_file) == str(md5_of_dstns_file): logging.debug('md5sum check is passed') result = ['PASSED', md5_of_src_file] else: result = ['FAILED', 'md5sum is not same at source and destination'] logging.error('Integrity check is failed: %s', result) return result
def create_snapshot(stdurl, vol_id, vol_name, snp_name, node_ip, passwd): logging.debug('Inside create_snapshot method...') querycommand = 'command=createStorageSnapshot&id=%s&name=%s' \ %(vol_id, snp_name) resp_create_snapshot = sendrequest(stdurl, querycommand) createSnpResp = json.loads(resp_create_snapshot.text) if 'errortext' in str(createSnpResp): errormsg = createSnpResp['createStorageSnapshotResponse'].get( 'errortext') logging.debug('Not able create snapshot %s, %s', snp_name, errormsg) return ['FAILED', ''] logging.debug('createStorageSnapshot executed successfully') getControllerInfo(node_ip, passwd, 'zfs list -t snapshot | grep %s' \ %(snp_name), 'snp_result.txt') out = executeCmd('cat snp_result.txt | grep %s@%s > snp_result2.txt' \ %(vol_name, snp_name)) if out[0] == 'FAILED': logging.debug('Snapshot %s is not created at Controller', snp_name) return ['FAILED', ''] logging.debug('snapshot %s created successfully at Controller', snp_name) return ['PASSED', '']
def UseFileInMountPoint(volume): output = getoutput('mount | grep %s | awk \'{print $3}\'' \ %(volume['mountPoint'])) mount_point = output[0].strip('\n') exe_vdb = executeVdbenchFile(volume, VdbFile) time.sleep(20) #sleeping for 30s before trying to umount the volume on which vdbench is running logging.info('Now unmounting the mountPoint which is in use') check_vdbench = is_vdbench_alive(volume['name']) if check_vdbench: umount_output = executeCmd('umount mount/%s' %(volume['mountPoint'])) if umount_output[0] == 'FAILED': print 'expected result : %s' %(umount_output[1]) logging.debug('expected result: %s', umount_output[1]) umountFail = True return ['PASSED', umountFail] else: print 'Unexpected Result: Unmount happened when file in '\ 'mountPoint is in use' kill_process(volume['name']) return ['FAILED', 'Unmount happened when file in mountPoint is in use'] else: return ['FAILED', 'Vdbench stopped, MountPoint not in use']
def checkMetaSize(ip, passwd, PoolName): type = "meta" executeCmd("python enableDedup.py") executeCmd("python copyData.py %s %s %s" % (sys.argv[1], PoolName, 'testfile')) time.sleep(60) poolUsedSize1 = getControllerInfo( ip, passwd, "zpool iostat -v %s | grep %s | awk '{print $2}'" % (PoolName, PoolName), "output.txt") metaUsedSize1 = getControllerInfo( ip, passwd, "zpool iostat -v %s | grep -A 1 %s | grep raidz1 | awk '{print $2}'" % (PoolName, type), "output.txt") print poolUsedSize1.split('M')[0] print metaUsedSize1.split('M')[0] #for x in range (1, 40): for x in range(1, 11): executeCmd("python copyData.py %s %s %s" % (sys.argv[1], PoolName, 'testfile%s' % (x))) time.sleep(60) poolUsedSize2 = getControllerInfo( ip, passwd, "zpool iostat -v %s | grep %s | awk '{print $2}'" % (PoolName, PoolName), "output.txt") metaUsedSize2 = getControllerInfo( ip, passwd, "zpool iostat -v %s | grep -A 1 %s | grep raidz1 | awk '{print $2}'" % (PoolName, type), "output.txt") print poolUsedSize2.split('M')[0] print metaUsedSize2.split('M')[0] if ((float(poolUsedSize1.split('M')[0]) == float( poolUsedSize2.split('M')[0])) and (float(metaUsedSize2.split('M')[0]) > float( metaUsedSize1.split('M')[0]))): return ("PASSED", "") else: return ("FAILED", "")
logging.debug('vdbench has successfully created 1 GB file of the') logging.debug('going to stop vdbench after 10 seconds...') time.sleep(10) break check_vdbench = is_vdbench_alive(volname) if check_vdbench: continue else: logging.debug('vdbench has stopped unexpectedly....') break kill_vdbench() logging.info('waiting for 10s') time.sleep(10) umount_output = executeCmd('umount -l mount/%s' % (volume['mountPoint'])) if umount_output[0] == 'FAILED': logging.error('Not able to umount %s, still go ahead and delete '\ 'the NFS share', volname) else: logging.debug('NFS share %s umounted successfully', volname) delete_result = delete_volume(volid, stdurl) endTime = ctime() if delete_result[0] == 'FAILED': logAndresult(testcase, 'FAILED', delete_result[1], startTime, endTime) logging.debug('Volume "%s" deleted successfully', volname) logging.info('volume provision was successful for "%s times"', n) endTime = ctime() resultCollection('%s, testcase is' %testcase, ['PASSED',' '], \
querycommand = 'command=createStorageSnapshot&id=%s&name=%s' %(tsm_dataset_id, Name) resp_tsm_create_snp = sendrequest(stdurl, querycommand) filesave("logs/create_tsm_snapshot.txt", "w",resp_tsm_create_snp) tsmSnpResp = json.loads(resp_tsm_create_snp.text) if 'errortext' in str(tsmSnpResp): endTime = ctime() errorstatus = str(tsmSnpResp['createStorageSnapshotResponse']['errortext']) resultCollection("Result for snapshot \"%s\" creation on TSM %s is: " %(Name, config['tsmName%d' %(x)]), ['FAILED', errorstatus], startTime, endTime) else: getControllerInfo(IP, passwd, 'zfs list -t snapshot | grep %s' %(Name), "tsm_snapshot_result.txt") ## verifying snapshot for cifs volumes for p in range(1, int(config['Number_of_CIFSVolumes'])+1): cifsresult = executeCmd('cat tsm_snapshot_result.txt | grep %s@%s > tsm_snapshot_result2.txt' %(config['volCifsDatasetname%d' %(p)], Name)) if cifsresult[0] == 'FAILED': tsmFlag = 0 endTime = ctime() resultCollection("Result for snapshot \"%s\" creation on volume %s is: " %(Name, config['volCifsDatasetname%d' %(p)]), cifsresult, startTime, endTime) ## verifying snapshot for nfs volumes for q in range(1, int(config['Number_of_NFSVolumes'])+1): nfsresult = executeCmd('cat tsm_snapshot_result.txt | grep %s@%s > tsm_snapshot_result2.txt' %(config['volDatasetname%d' %(q)], Name)) if nfsresult[0] == 'FAILED': tsmFlag = 0 endTime = ctime() resultCollection("Result for snapshot \"%s\" creation on volume %s is: " %(Name, config['volDatasetname%d' %(q)]), nfsresult, startTime, endTime) ## verifying snapshot for iscsi volumes for r in range(1, int(config['Number_of_ISCSIVolumes'])+1):
count = 1 while ping_result[0] == 'FAILED': if count == 4: logging.error('Node %s did not come up after 15 minutes, So can not '\ 'make it available ', NODE1_IP) node_online = False break logging.debug('Still Node %s did not come UP, sleeping for 3 more minutes',\ NODE1_IP) time.sleep(180) count = count + 1 ping_result = ping_machine(NODE1_IP) logging.debug('ungracefull HA test case(iSCSI) completed, executing '\ 'umount and logout iSCSI LUN') umount_result = executeCmd('umount /dev/%s1' % (iscsi_device)) if umount_result[0] == 'FAILED': logging.error('Not able to umount /dev/%s1, still go ahead and logout '\ 'the iSCSI LUN, since test case is complete', iscsi_device) else: logging.debug('LUN /dev/%s1 umounted successfully', iscsi_device) logout_result = iscsi_login_logout(iqn, VSM_IP, 'logout') if logout_result[0] == 'FAILED': logging.error('Not able to logged out iSCSI LUN, still go ahead and '\ 'set auth group to None, since test case is complete') else: logging.debug('iSCSI LUN logged out successfully') remove_configuration = False if node_online: #There might be few chances to Node come up, and suddenly we move it...
cmd = 'sysctl vfs.zfs.disable_zvol_compression=0' comressionOn = getControllerInfo(IP, password, cmd, 'CompressionOn.txt') print cmd elif sys.argv[3] == 'off': cmd = 'sysctl vfs.zfs.disable_zvol_compression=1' comressionOff = getControllerInfo(IP, password, cmd, 'CompressionOff.txt') print cmd else: print 'Fourth parameter is wrong please provide as \"on/off\" only' exit() ############### NFS EXECUTION STARTS ############### if nfsFlag == 1 or allFlag == 1: for x in range(1, int(config['Number_of_NFSVolumes']) + 1): startTime = ctime() r1 = executeCmd(' rm -rf mount/%s/* ' % (config['volMountpoint%d' % (x)])) time.sleep(5) r2 = executeCmd('umount mount/%s' % (config['volMountpoint%d' % (x)])) r4 = executeCmd('mkdir -p mount/%s ' % (config['volMountpoint%d' % (x)])) ############### Mount ############### executeCmd('mount -t nfs %s:/%s mount/%s' % (config['volIPAddress%d' % (x)], config['volMountpoint%d' % (x)], config['volMountpoint%d' % (x)])) output = executeCmd('mount | grep %s' % (config['volMountpoint%d' % (x)])) endTime = ctime() #resultCollection("Mount of NFS Volume %s" %(config['volDatasetname%d' %(x)]), output,startTime, endTime) print "mounting NFS volume %s is " % (config['volMountpoint%d' % (x)]), output[0]
time.sleep(10) mountDetails = mountPointDetails('-h', mount_point) Used1 = mountDetails[2].strip('G') logging.debug('Before increasing size, used space of iscsi lun is: %s', Used1) logging.info('Increasing space of Iscsi volume') quota = '5G' quota1 = quota.rstrip('G') edit_quota = edit_vol_quota(volid, quota, stdurl) if edit_quota[0] == 'FAILED': logAndresult(testcase, 'FAILED', edit_quota[1], startTime, endTime) logging.debug('Successfully updated quota of volume "%s" from %s to %s'\ ,volname, vol_quota, quota) umount_output = executeCmd('umount -l /dev/%s1' %device) if umount_output[0] == 'FAILED': logging.error('Not able to umount %s, still go ahead and delete '\ 'the Iscsi volume', volname) else: logging.debug('Iscsi volume %s umounted successfully', volname) logout_result = iscsi_login_logout(iqn, tsmIP, 'logout') if logout_result[0] == 'FAILED': logging.error('%s', logout_result[1]) logging.debug('%s', logout_result[1]) #after icreasing space relogging to lun logging.info('Remounting Iscsi lun after quota update') mnt_iscsi = iscsi_remount_flow(volname, tsmIP, vol_iqn, vol_mntPoint, 'ext3') endTime = ctime()
indianTime = datetime.datetime.now() # getting the test case name tcName = sys.argv[0] tcName = tcName.split('.py')[0] # creating log file with test case name logFile = tcName + '.log' # Initialization for Logging location logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s',\ filename='logs/'+logFile,filemode='a',level=logging.DEBUG) # Clear the log file before execution starts executeCmd('> logs/%s' % (logFile)) # Initialization for few common global variables startTime = ctime() HEADER_MSG = 'Testcase "%s" is started' % (tcName) FOOTER_MSG = 'Testcase "%s" is completed' % (tcName) BLOCKED_MSG = 'Testcase "%s" is blocked' % (tcName) EXECUTE_SYNATX = 'python %s.py conf.txt nfs/iscsi' % (tcName) logging.info('%s', HEADER_MSG) # Check for correct usage of script check_mendatory_arguments(sys.argv, 3, EXECUTE_SYNATX, FOOTER_MSG, \ BLOCKED_MSG, startTime)
EC1_Username = conf['EC1_Username'] EC1_Password = conf['EC1_Password'] Node1_IP = conf['Node1_IP'] Node1_Username = conf['Node1_Username'] Node1_Password = conf['Node1_Password'] Node2_IP = conf['Node2_IP'] Node2_Username = conf['Node2_Username'] Node2_Password = conf['Node2_Password'] BuildPath = conf['Build_Path'] # Clear the log file before execution starts executeCmd('> /logs/automation_execution.log') # Initialization for Logging location tcName = sys.argv[0] tcName = tcName.split('.py')[0] logFile = tcName + '.log' logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s',\ filename='logs/'+logFile,filemode='a',level=logging.DEBUG) def gen_build_number(path): '''Function for genbuild dir''' return (path.split("/")[6].split("_")[2].split(".")[0]) def patch_dir_prepare(box_ip, box_user, box_pwd, num, path): package_name = path.split("/")[6]
filename3 = "copy3.txt" if len(sys.argv) == 3: filename1 = sys.argv[2] if len(sys.argv) == 4: filename1 = sys.argv[2] filename2 = sys.argv[3] if len(sys.argv) == 5: filename1 = sys.argv[2] filename2 = sys.argv[3] filename3 = sys.argv[4] for x in range(1, int(config['Number_of_CIFSVolumes']) + 1): startTime = ctime() executeCmd('mkdir -p mount/cifs1/%s' % (config['volCifsMountpoint%d' % (x)])) executeCmd('mkdir -p mount/cifs2/%s' % (config['volCifsMountpoint%d' % (x)])) executeCmd('mkdir -p mount/cifs3/%s' % (config['volCifsMountpoint%d' % (x)])) ### Mount executeCmd( ' mount -t cifs //%s/%s mount/cifs1/%s -o username=%suser -o password=%suser' % (config['volCifsIPAddress%d' % (x)], config['volCifsMountpoint%d' % (x)], config['volCifsMountpoint%d' % (x)], config['volCifsAccountName%d' % (x)], config['volCifsAccountName%d' % (x)])) executeCmd(
elif sys.argv[x].lower() == "%s" % ("cifs"): cifsFlag = 1 elif sys.argv[x].lower() == "%s" % ("fc"): fcFlag = 1 elif sys.argv[x].lower() == "%s" % ("iscsi"): iscsiFlag = 1 elif sys.argv[x].lower() == "%s" % ("all"): allFlag == 1 else: print "Argument is not correct.. Correct way as below" print "python executeExpand.py config.txt NFS" print "python executeExpand.py config.txt ALL" print "python executeExpand.py config.txt NFS CIFS ISCSI" exit() executeCmd('umount -a -t cifs -l') executeCmd('umount -a') for x in range(1, int(config['Number_of_ISCSIVolumes']) + 1): executeCmd('iscsiadm -m discovery -t st -p %s:3260' % (config['voliSCSIIPAddress%d' % (x)])) iqnname = getoutput( 'iscsiadm -m discovery -t st -p %s:3260 | grep %s | awk {\'print $2\'}' % (config['voliSCSIIPAddress%d' % (x)], config['voliSCSIMountpoint%d' % (x)])) print iqnname if iqnname == []: continue output = executeCmd( 'iscsiadm -m node --targetname "%s" --portal "%s:3260" --logout | grep Logout' % (iqnname[0].strip(), config['voliSCSIIPAddress%d' % (x)]))