def deleteVolume(): #########Delete File Systems querycommand = 'command=listFileSystem' resp_listFileSystem = sendrequest(stdurl, querycommand) filesave("logs/ListFileSystem.txt", "w", resp_listFileSystem) data = json.loads(resp_listFileSystem.text) filesystems = data["listFilesystemResponse"].get("filesystem") if filesystems == None: print 'There are no volumes' else: for filesystem in filesystems: filesystem_id = filesystem['id'] filesystem_name = filesystem['name'] acct_id = filesystem.get('accountid') init_grp = filesystem.get('initiatorgroup') if init_grp == 'ALL': assign_iniator_gp_to_LUN(stdurl, filesystem_id, acct_id, 'None') time.sleep(1) querycommand = 'command=deleteFileSystem&id=%s&forcedelete=true' % ( filesystem_id) resp_delete_volume = sendrequest(stdurl, querycommand) data = json.loads(resp_delete_volume.text) if 'errorcode' in str(data): errormsg = str( data['deleteFileSystemResponse'].get('errortext')) print 'Not able to delete volume %s, due to%s' % ( filesystem_name, errormsg) else: deleteJobId = data['deleteFileSystemResponse'].get('jobid') delete_volume_status = queryAsyncJobResult(stdurl, deleteJobId) if delete_volume_status[0] == 'PASSED': print 'Volume %s deleted successfully' % (filesystem_name) else: print 'Not able to delete volume %s' % (filesystem_name)
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
result = get_node_ip(STDURL, controllerid) NODE1_IP = verify_get_node_ip(result) NODE2_IP = get_node2_ip(NODE1_IP, STDURL) volumeDict = {'name': 'ungrceHAiSCSI1', 'tsmid': tsm_id, 'datasetid': \ dataset_id, 'protocoltype': 'ISCSI', 'iops': 500} result = create_volume(volumeDict, STDURL) verify_create_volume(result) logging.info('listing volume...') volumes = listVolumeWithTSMId_new(STDURL, tsm_id) volumes = verify_list_volumes(volumes) 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) 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'])
volList = listVolumeWithTSMId_new(stdurl, tsmID) endTime = ctime() if volList[0] == 'FAILED': logAndresult(testcase, 'BLOCKED', volList[1], startTime, endTime) get_volInfo = get_volume_info(volList[1], volname) volid, vol_mntPoint, vol_iqn = get_volInfo[2], get_volInfo[3], get_volInfo[4] vol_quota = get_volInfo[6] logging.debug('volname: %s, volid: %s, vol_mntPoint: %s, vol_Iqn: %s',\ volname, volid, vol_mntPoint, vol_iqn) logging.debug('vol_quota: %s', vol_quota) startTime = ctime() init_grp = assign_iniator_gp_to_LUN(stdurl, volid, account_id, 'ALL') endTime = ctime() if init_grp[0] == 'FAILED': #logAndresult(testcase, 'BLOCKED', init_grp[1], startTime, endTime) pass logging.debug('Iscsi Initiator group is set to "ALL" for the volume') volume = {'TSMIPAddress' : tsmIP, 'mountPoint': volname, 'name' : volname} mnt_iscsi = iscsi_mount_flow(volname, tsmIP, vol_iqn, vol_mntPoint, 'ext3') endTime = ctime() if mnt_iscsi[0] == 'FAILED': logAndresult(testcase, 'BLOCKED', mnt_iscsi[1], startTime, endTime) logging.debug('%s', mnt_iscsi[1]) device, iqn = mnt_iscsi[3], mnt_iscsi[2]
vol_info = get_volume_info(volumes, VOL_NAME) if vol_info[0] == 'FAILED': print 'Not able to get volume properties...' logging.error('Testcase AMSx-WLAx-NSWx-ISCSI-IORx-TC_CONTINUOUS_ISTGTCONTROL_REFRESH is '\ 'blocked due to %s', vol_info[1]) is_blocked(startTime, FOOTER_MSG, BLOCKED_MSG) # Assigning vol properties to variables volId = vol_info[2] volMntPoint = vol_info[3] volIqn = vol_info[4] volGrpID = vol_info[5] # Updating iSCSI auth group to ALL, So client can access the iSCSI LUN addAuthGroupResult = assign_iniator_gp_to_LUN(STDURL, volId, account_id, 'ALL') if addAuthGroupResult[0] == 'FAILED': logging.error('Testcase AMSx-WLAx-NSWx-ISCSI-IORx-TC_CONTINUOUS_ISTGTCONTROL_REFRESH is '\ 'blocked, not able to assign auth group due to: %s', \ addAuthGroupResult[1]) is_blocked(startTime, FOOTER_MSG, BLOCKED_MSG) # discover iSCSI LUN and getting iqn for the same discovered LUN discoverIqn = discover_iscsi_lun(VSM_IP, volIqn) if discoverIqn[0] == 'FAILED': print 'Not able to discover iSCSI LUN' logging.debug('Testcase AMSx-WLAx-NSWx-ISCSI-IORx-TC_CONTINUOUS_ISTGTCONTROL_REFRESH is '\ 'blocked, getting iqn as None for discovered iSCSI LUN') is_blocked(startTime, FOOTER_MSG, BLOCKED_MSG) discoverIqn = discoverIqn[1] logging.debug('iqn for discovered iSCSI LUN: %s', discoverIqn)
logging.error('iSCSI login with CHAP method test case is failed Error:%s', \ login_result[1]) resultCollection('iSCSI login with CHAP method test case is', \ ['FAILED', ''], startTime, endTime) if LUN_logged: logging.debug('getting iSCSI LUN legged device...') time.sleep(2) result = getDiskAllocatedToISCSI(VSM_IP, mnt_point) print result logging.debug('iSCSI LUN logged in device: %s', result) #--------------------------------------------------------------------- #updating iscsid.conf to original file-------------------------------- make_iscsid_conf_original(backup_filename, fileName) #removing configuration----------------------------------------------- logging.debug('iSCSI login CHAP execution done, removing configuration...') if LUN_logged: iscsi_login_logout(iqn, VSM_IP, 'logout') result = assign_iniator_gp_to_LUN(STDURL, vol_id, account_id, 'None') if result[0] == 'PASSED': logging.debug('Go and delete the volume') delete_volume(vol_id, STDURL) get_logger_footer('iSCSI login with CHAP method test case is completed') else: logging.error('Not able to set auth group to None, do not delete volume') get_logger_footer('iSCSI login with CHAP method test case is completed') #configuration removed-------------------------------------------------------
%(tsm_name) + volList[1] logAndresult(testcase, 'BLOCKED', volList[1], startTime, endTime) volume_name = volume['name'] get_volInfo = get_volume_info(vol_list[1], volume_name) volname, volid, vol_iqn, group_id = get_volInfo[1], get_volInfo[2], \ get_volInfo[4], get_volInfo[5] logging.debug('volname: %s, volid: %s, vol_iqn: %s, vol_grpID: %s',\ volname, volid, vol_iqn, group_id) 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)
logAndresult(testcase, 'BLOCKED', volList[1], startTime, endTime) volume_name = vol['name'] get_volInfo = get_volume_info(volList[1], volume_name) volname, volid, vol_mntPoint, iqnName = get_volInfo[1], get_volInfo[2], \ get_volInfo[3], get_volInfo[4] logging.debug('volname: %s, volid: %s, vol_mntPoint: %s, vol_IqnName: %s',\ volname, volid, vol_mntPoint, iqnName) volume = {'TSMIPAddress' : tsmIP, 'mountPoint': vol_mntPoint,\ 'name' : volname} #---------------------------------------------------------------------- #-------------iscsi details---------------------------- #set initator grp to created grp.... setInitGroup = assign_iniator_gp_to_LUN(stdurl, volid, account_id, initGrpName) if setInitGroup[0] == 'FAILED': endTime = ctime() logAndresult(testcase, 'FAILED', setInitGroup[1], startTime, endTime) else: logging.debug('Successfully updated initiator group "%s" for '\ 'volume "%s"', initGrpName, volname) print "sucessfully updated iscsi initiator group '%s' for '%s' "\ "volume" %(initGrpName, volname) #discover, login.... startTime = ctime() discover = discover_iscsi_lun(tsmIP, iqnName) if discover[0] == 'FAILED': endTime = ctime() logAndresult(testcase, 'FAILED', discover[1], startTime, endTime)
logging.debug('%s', vol_list[1]) logging.debug( '-------Ending script because Failed to list volume-----') endTime = ctime() resultCollection('Listing of volume Blocked the testcase', \ ['BLOCKED',''], startTime, endTime) exit() for vol in vol_list[1]: if vol['name'] == volume1['name']: iops_volid = vol.get('id') iops_volname = vol.get('name') iopsgroup_id = vol.get('groupid') iops_vol_iqn = vol.get('iqnname') logging.info('Got IopsVolume ID = "%s" and Group ID = "%s" of "%s"', \ iops_volid, iopsgroup_id, iops_volname) result = assign_iniator_gp_to_LUN(stdurl, iops_volid, accId, 'ALL') verify_add_auth_gp(result) logging.debug('getting iqn for volume %s', iops_volname) iqn = discover_iscsi_lun(tsm_ip, iops_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, iops_volname) time.sleep(5) mountpoint = accName + iops_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, iops_volname) verify_mount(mount_result)
%(tsm_name) + vol_list[1] print errormsg logging.debug('%s', vol_list[1]) logging.debug('-------Ending script because Failed to list volume-----') endTime = ctime() resultCollection('Listing of volume Blocked the testcase', ['BLOCKED',''],\ startTime, endTime) exit() volid = vol_list[1][0].get('id') volname = vol_list[1][0].get('name') group_id = vol_list[1][0].get('groupid') vol_iqn = vol_list[1][0].get('iqnname') logging.info('Got IopsVolume ID = "%s" and Group ID = "%s" of "%s"',\ volid, group_id, volname) ########### 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)