def getiSCSIDevice(volName, vsm_id, POOL_IOPS, vsm_dataset_id, STDURL): volumeDict = {'name': volName, 'tsmid': vsm_id, 'datasetid': \ vsm_dataset_id, 'protocoltype': 'ISCSI', 'iops': POOL_IOPS, \ 'quotasize': '20G'} result = create_volume(volumeDict, STDURL) verify_create_volume(result) logging.info('listing volume...') volumes = listVolumeWithTSMId_new(STDURL, vsm_id) if volumes[0] == 'FAILED': logging.error('Testcase %s is blocked due to' \ ': %s', tcName, volumes[1]) is_blocked(startTime, FOOTER_MSG, BLOCKED_MSG) volumes = volumes[1] vol_id, vol_iqn, account_id, mnt_point = get_vol_id( volumes, volumeDict['name']) logging.debug('volume_id: %s, aacount_id: %s, mountpoint: %s and vol_iqn: %s', \ vol_id, account_id, mnt_point, vol_iqn) add_auth_group = assign_iniator_gp_to_LUN(STDURL, vol_id, account_id, 'ALL') verify_add_auth_gp(add_auth_group, 'ALL') logging.debug('getting iqn for volume %s', volumeDict['name']) iqn = discover_iscsi_lun(VSM_IP, vol_iqn) iqn = verify_iqn(iqn) logging.debug('iqn for discovered iSCSI LUN... %s', iqn) login_result = iscsi_login_logout(iqn, VSM_IP, 'login') verify_iscsi_operation(login_result, volumeDict['name'], 'login') time.sleep(2) result = getDiskAllocatedToISCSI(VSM_IP, mnt_point) iscsiDevice = verify_getDiskAllocatedToISCSI(result, mnt_point) return iscsiDevice, vol_id, account_id, mnt_point, iqn
def addVol_client_Mount(vol, stdurl, tsmID, tsmName, ClientIP): startTime = ctime() result = create_volume(vol, stdurl) if result[0] == 'FAILED': endTime = ctime() print result[1] logAndresult(testcase, 'BLOCKED', result[1], startTime, endTime) else: print "Volume '%s' created successfully" % (vol['name']) startTime = ctime() logging.info('Listing volumes in the TSM "%s" w.r.t its TSM ID', tsmName) volList = listVolumeWithTSMId_new(stdurl, tsmID) if volList[0] == 'PASSED': logging.info('Volumes present in the TSM "%s"', tsmName) else: endTime = ctime() print 'Not able to list Volumes in TSM "%s" due to: ' \ %(tsmName) + volList[1] logAndresult(testcase, 'BLOCKED', volList[1], startTime, endTime) volume_name = vol['name'] get_volInfo = get_volume_info(volList[1], volume_name) volname, volid, vol_mntPoint = get_volInfo[1], get_volInfo[2], get_volInfo[ 3] logging.debug('volname: %s, volid: %s, vol_mntPoint: %s',\ volname, volid, vol_mntPoint) startTime = ctime() addClient = addNFSclient(stdurl, volid, ClientIP) if addClient[0] == 'PASSED': print 'Added NFS client "%s" to volume "%s"' % (ClientIP, volname) logging.info('Added NFS client "%s" to volume "%s"', \ ClientIP, volname) else: endTime = ctime() logAndresult(testcase, 'BLOCKED', addClient[1], startTime, endTime) volume = {'TSMIPAddress' : tsmIP, 'mountPoint': vol_mntPoint,\ 'name' : volname} startTime = ctime() logging.info("Mounting NFS Share '%s'", volname) nfsMount = mountNFS(volume) if nfsMount == 'PASSED': logging.info('Mounted Nfs Share "%s" successfully', volume['name']) else: endTime = ctime() msg = 'failed to mount NFS share "%s"' % volume['name'] logAndresult(testcase, 'FAILED', msg, startTime, endTime) return [volume, volid]
tsmID = get_tsmInfo[0] tsmName = get_tsmInfo[1] datasetID = get_tsmInfo[2] logging.debug('tsm_name: %s, tsm_id: %s, dataset_id: %s',\ tsmName, tsmID, datasetID) else: endTime = ctime() print 'Not able to list Tsm "%s" due to: ' \ %(tsmIP) + tsmList[1] logAndresult(testcase, 'BLOCKED', tsmList[1], startTime, endTime) vol = {'name': 'nfsMountUmount', 'tsmid': tsmID, 'datasetid': datasetID, \ 'protocoltype': 'NFS', 'iops': 100} startTime = ctime() result = create_volume(vol, stdurl) if result[0] == 'FAILED': endTime = ctime() print result[1] logAndresult(testcase, 'BLOCKED', result[1], startTime, endTime) else: print "Volume '%s' created successfully" % (vol['name']) startTime = ctime() logging.info('Listing volumes in the TSM "%s" w.r.t its TSM ID', tsmName) volList = listVolumeWithTSMId_new(stdurl, tsmID) if volList[0] == 'PASSED': logging.info('Volumes present in the TSM "%s"', tsmName) else: endTime = ctime() print 'Not able to list Volumes in TSM "%s" due to: ' \
logging.debug('tsm id: %s', tsm_id) logging.debug('datasetid: %s', datasetid) logging.debug('mount/umount 100 NFS volumes test case is blocked.') is_blocked(startTime, FOOTER_MSG, BLOCKED_MSG) else: TSM_IDs[x - 1] = tsm_id DATASET_IDs[x - 1] = datasetid #------------------------------------------------------------------------------ ###volume creation------------------------------------------------------------- for x in range(1, 6): for y in range(1, 21): volDict = {'name': 'T100%sv%s' %(x, y), 'tsmid': TSM_IDs[x-1], \ 'iops': 100, 'datasetid': DATASET_IDs[x-1], \ 'protocoltype': 'NFS'} result = create_volume(volDict, STDURL) verify_create_volume(result) #------------------------------------------------------------------------------ ###getting volumes id and mountpoint-------------------------------------------- for x in range(1, 6): volumes = listVolumeWithTSMId_new(STDURL, TSM_IDs[x - 1]) if volumes[0] == 'PASSED': volumes = volumes[1] else: print 'Not able to list the volumes...' logging.error('Not able to list volumes %s', volumes[1]) logging.debug('mount/umount 100 NFS volumes test case is blocked...') is_blocked(startTime, FOOTER_MSG, BLOCKED_MSG) update_volid_mntpoint(volumes) #------------------------------------------------------------------------------
# Extract the vsm_id & vsm_dataset_id from info obtained above vsm_id = vsminfo[0].get('id') vsm_dataset_id = vsminfo[0].get('datasetid') # Provide variables for Volume1 & Volume2 creation (from conf & hardcode) in dict format vol1_dict = {'name': VOL1_NAME, 'quotasize': '500G', 'tsmid': vsm_id, 'iops': VOL1_IOPS, \ 'datasetid': vsm_dataset_id, 'protocoltype': 'NFS'} vol2_dict = {'name': VOL2_NAME, 'quotasize': '500G', 'tsmid': vsm_id, 'iops': VOL2_IOPS, \ 'datasetid': vsm_dataset_id, 'protocoltype': 'NFS'} # Create Volume1 & Volume2 using the vsm_ids and params specified result = create_volume(vol1_dict, STDURL) verify_create_volume(result) result = create_volume(vol2_dict, STDURL) verify_create_volume(result) # Get the info for the Volume created above (this list method response contains id, etc.., not create, so needed) volumes = listVolumeWithTSMId_new(STDURL, vsm_id) if volumes[0] == 'FAILED': logging.error('Testcase %s is blocked due to' \ ': %s', tcName,volumes[1]) is_blocked(startTime, FOOTER_MSG, BLOCKED_MSG) volumes = volumes[1] # Extract the vol_id & vol_mnt_pt for both volumes from info obtained above
else: endTime = ctime() print 'Not able to list TSMs due to: ' + tsm_list[1] logAndresult(testcase, 'BLOCKED', tsm_list[1], startTime, endTime) logging.info('Getting tsm_name, tsm_id, and dataset_id...') #get_tsmInfo = get_tsm_info(list_tsm[1]) -- ERROR get_tsmInfo = get_tsm_info(tsm_list[1]) tsm_id, tsm_name, dataset_id = get_tsmInfo[0], get_tsmInfo[1], get_tsmInfo[2] logging.debug('tsm_name: %s, tsm_id: %s, dataset_id: %s',\ tsm_name, tsm_id, dataset_id) volume1 = {'name': 'NFS%sPrtcl'%prtcl, 'tsmid': tsm_id, \ 'datasetid': dataset_id, 'protocoltype': 'NFS'} startTime = ctime() create_vol = create_volume(volume1, stdurl) if create_vol[0] == 'FAILED': endTime = ctime() logAndresult(testcase, 'BLOCKED', create_vol[1], startTime, endTime) else: print "Volume '%s' created successfully" % (volume1['name']) logging.info('Listing volumes in the TSM "%s" w.r.t its TSM ID', tsm_name) vol_list = listVolumeWithTSMId_new(stdurl, tsm_id) if vol_list[0] == 'PASSED': logging.info('Volumes present in the TSM "%s"', tsm_name) else: endTime = ctime() logAndresult(testcase, 'BLOCKED', vol_list[1], startTime, endTime) volume_name = volume1['name']
for tsm in tsms: if tsm['name'] == tsm_params['name']: logging.info("fetching Dataset id and TSM id ") dataset_id = tsm['datasetid'] tsm_id = tsm['id'] logging.info("sucessfully updated Dataset id and TSM id ") for y in range(1, 21): logging.info("processing forloop to create volumes") volume = {'name': '%sNFS%d' %(tsm_params['name'], y), 'tsmid':\ tsm_id, 'datasetid': dataset_id,'protocoltype': 'NFS'} # calling method to create volume logging.info("creation of volume begins") result_vol = create_volume(volume, stdurl) if result_vol[0] == 'FAILED': print("Adding NFS client FAILED %s " % result_vol) logging.error("FAILED TO ADD VOLUMES %s " % result_vol) exit() elif result_vol[0] == 'PASSED': print("Adding NFS client PASSED %s " % result_vol) logging.info("SUCESSFULLY CREATED VOLUMES") #Listing filesystem to add NFS clients to all querycommand = 'command=listFileSystem&tsmid=%s' % ( tsm_id) logging.info(" " % result_vol) resp_listVolume = sendrequest(stdurl, querycommand) data1 = json.loads(resp_listVolume.text)
tsm_id = tsm_list[1][0].get('id') tsm_name = tsm_list[1][0].get('name') dataset_id = tsm_list[1][0].get('datasetid') vsmAccName = tsm_list[1][0].get('accountname') node_ip = tsm_list[1][0].get('controlleripaddress') logging.info('Got TSM ID and Dataset ID "%s" "%s" of "%s"', tsm_id, dataset_id, tsm_name) if IopsEnable_Flag == 1: logging.info('Creating dictionary for creating volume') volume1 = {'name': 'IscsiIopsVol1', 'tsmid': tsm_id, 'datasetid': dataset_id,\ 'protocoltype': 'ISCSI', 'iopscontrol':'true', 'tpcontrol':'false','iops':1000} logging.info('Dictionary created') logging.debug('%s', volume1) logging.info('creating volume "%s"', volume1['name']) create_vol = create_volume(volume1, stdurl) print create_vol[0] logging.debug('%s', create_vol) if 'FAILED' in create_vol: errormsg = 'Not able to create vol due to:' + create_vol[1] print errormsg logging.debug('%s', create_vol[1]) logging.debug( '-------Ending script because Failed to create volume------') endTime = ctime() resultCollection('creation of volume failed', ['BLOCKED', ''], startTime, endTime) exit() logging.info('Listing volumes in the TSM "%s" w.r.t its TSM ID', tsm_name) vol_list = listVolumeWithTSMId_new(stdurl, tsm_id) if 'PASSED' in vol_list: