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 iscsi_get_quota(tsm_ip, vol_iqn, vol_mntPoint): discover_lun = discover_iscsi_lun(tsm_ip, vol_iqn) if discover_lun[0] == 'FAILED': return ['FAILED', discover_lun[1]] logging.debug('IQN of discovered lun is "%s"', discover_lun[1]) lun_login = iscsi_login_logout(discover_lun[1], tsm_ip, 'login') if lun_login[0] == "FAILED": return ["FAILED", lun_login[1]] time.sleep(3) result = getDiskAllocatedToISCSI(tsm_ip, vol_mntPoint) if result[0] == 'PASSED' and vol_mntPoint in str(result[1]): logging.debug('iscsi logged device... %s', result[1][vol_mntPoint]) device = result[1][vol_mntPoint] else: return ['FAILED', 'Not able to get logged in device'] time.sleep(5) #Getting device size and converting into GB quota = getoutput('fdisk -l | grep /dev/%s: | awk {\'print $5\'}' % (device)) quota1 = int(quota[0]) / (1024 * 1024 * 1024) return ['PASSED', quota1]
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) iscsi_device = verify_getDiskAllocatedToISCSI(result, mnt_point) result = execute_mkfs(iscsi_device, 'ext3') verify_execute_mkfs(result) mount_result = mount_iscsi(iscsi_device, volumeDict['name']) verify_mount(mount_result) #mount_dir = 'mount/%s' %(volumeDict['name']) mount_dir = {'name': volumeDict['name'], 'mountPoint': volumeDict['name']} logging.info('...executing vdbench....') executeVdbenchFile(mount_dir, 'filesystem_iscsi') time.sleep(20) logging.info('verifying the IOPS before Node goes to reset...') iops_datapath = poolName + '/' + accName + tsm_name + '/' + volumeDict['name'] verify_IOPS(NODE1_IP, PASSWD, iops_datapath) logging.debug('going to move node to reset...') getControllerInfo(NODE1_IP, PASSWD, 'reboot', 'reboot.txt')
ilogin = iscsi_login_logout(iqnName, tsmIP, 'login') if result[0] == 'PASSED': logging.debug('Login successfully for iSCSI LUN %s', volname) else: endTime = ctime() logAndresult(testcase, 'FAILED', result[1], startTime, endTime) endTime = ctime() resultCollection('%s, testcase is' %testcase, ['PASSED', ' '], \ startTime, endTime) resultCollectionNew('"%s" testcase ends....' %testcase, ['', '\n']) logging.debug('getting iSCSI LUN logged device...') time.sleep(2) result = getDiskAllocatedToISCSI(tsmIP, volume['mountPoint']) print result logging.debug('iSCSI LUN logged in device: %s', result) #-------------------------------------------------------------------------- #removing configurations ilogout = iscsi_login_logout(iqnName, tsmIP, 'logout') logging.info('Setting initiator group to "None"') setNone = assign_iniator_gp_to_LUN(stdurl, volid, account_id, 'None') if setNone[0] == 'FAILED': logging.error('Not able to set auth group to None, do not delete volume') exit() else: logging.debug('Initiator group is set to "none"')
if login_result[0] == 'FAILED' and 'already' in str(login_result[1]): print 'iscsi LUN with iqn: %s already logged-in' % discoverIqn elif login_result[0] == 'FAILED': print 'Not able to login iSCSI LUN with iqn: %s' % (discoverIqn) logging.debug('Testcase AMSx-WLAx-NSWx-ISCSI-IORx-TC_CONTINUOUS_ISTGTCONTROL_REFRESH is '\ 'blocked, not able to login iSCSI LUN, Error: %s', login_result[1]) is_blocked(startTime, FOOTER_MSG, BLOCKED_MSG) else: print 'iscsi LUN with iqn: %s logged-in successfully' % discoverIqn # sleeping for 2 seconds before getting assigned device to newly... # ...logged-in iscsi LUJN time.sleep(2) # getting the device assigned to newly logged-in iSCSI LUN device = getDiskAllocatedToISCSI(VSM_IP, volMntPoint) if device[0] == 'PASSED' and volMntPoint in str(device[1]): logging.debug('iscsi logged device... %s', device[1][volMntPoint]) device = device[1][volMntPoint] else: print 'Not able to get iSCSI logged-in device' logging.debug('Testcase AMSx-WLAx-NSWx-ISCSI-IORx-TC_CONTINUOUS_ISTGTCONTROL_REFRESH is '\ 'blocked, not able to get assigned device for iSCSI LUN') is_blocked(startTime, FOOTER_MSG, BLOCKED_MSG) # writing ext4 in iSCSI logged-in device mkfsResult = execute_mkfs(device, 'ext3') if mkfsResult[0] == 'FAILED': print 'Not able to write filesystem' logging.debug('Testcase AMSx-WLAx-NSWx-ISCSI-IORx-TC_CONTINUOUS_ISTGTCONTROL_REFRESH is '\ 'blocked, not able to write filesystem on device %s', device)
vl = vol_list[1][0] old_attri = {'iops': vl.get('iops'), 'quota':vl.get('quota'), \ 'compression': vl.get('compression'), 'sync': vl.get('sync'), \ 'readonly': vl.get('readonly'), 'grace': vl.get('graceallowed')} result = assign_iniator_gp_to_LUN(stdurl, volid, accId, 'ALL') verify_add_auth_gp(result) logging.debug('getting iqn for volume %s', volname) iqn = discover_iscsi_lun(tsm_ip, vol_iqn) iqn = verify_iqn(iqn) logging.debug('iqn for discovered iSCSI LUN... %s', iqn) login_result = iscsi_login_logout(iqn, tsm_ip, 'login') verify_iscsi_login(login_result, volname) time.sleep(5) mountpoint = accName + volname result = getDiskAllocatedToISCSI(tsm_ip, mountpoint) device = verify_getDiskAllocatedToISCSI(result, mountpoint) mkfs_result = execute_mkfs(device, 'ext3') verify_execute_mkfs(mkfs_result) mount_result = mount_iscsi(device, volname) verify_mount(mount_result) mount_dir = {'name': volname, 'mountPoint': volname} qos_datapath = poolName + '/' + accName + tsm_name + '/' + volname logging.info('Running vdbench by using file') exe = executeVdbenchFile(mount_dir, 'filesystem_iscsi') time.sleep(5) check_vdbench = is_vdbench_alive(volname) if check_vdbench: logging.info('vdbench is running')