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 deleteVSM(): querycommand = 'command=listTsm' resp_listTsm = sendrequest(stdurl, querycommand) filesave("logs/listTSM.txt", "w", resp_listTsm) data = json.loads(resp_listTsm.text) tsms = data["listTsmResponse"].get("listTsm") if tsms == None: print 'There are no tsms' else: for tsm in tsms: tsm_id = tsm['id'] tsm_name = tsm['name'] querycommand = 'command=deleteTsm&id=%s&forcedelete=true' % ( tsm_id) resp_delete_tsm = sendrequest(stdurl, querycommand) data = json.loads(resp_delete_tsm.text) if 'errorcode' in str(data): errormsg = str(data['deleteTsmResponse']['errortext']) print errormsg else: print "Deleted the TSM", tsm_name time.sleep(1)
import time from cbrequest import sendrequest, filesave, timetrack, queryAsyncJobResult, configFile config = configFile(sys.argv) stdurl = 'https://%s/client/api?apikey=%s&response=%s&' % ( config['host'], config['apikey'], config['response']) ######## To Add an Account for TSM -- Begins print "Account Creation Begins" timetrack("Account Creation Begins") for x in range(1, int(config['Number_of_Accounts']) + 1): querycommand = 'command=createAccount&name=%s&description=%s' % ( config['accountName%d' % (x)], config['accountDescription%d' % (x)]) resp_createAccount = sendrequest(stdurl, querycommand) filesave("logs/AccountCreation.txt", "w", resp_createAccount) data = json.loads(resp_createAccount.text) if not 'errorcode' in data['createaccountresponse']: print "%s is created" % (config['accountName%d' % (x)]) account_id = data["createaccountresponse"]["account2"]["id"] #creating Account User Authentication name = "%sAUTH" % (config['accountName%d' % (x)]) user = "******" % (config['accountName%d' % (x)]) password = user time.sleep(2) querycommand = 'command=addCIFSAuthGroup&accountid=%s&name=%s&comment=%s&username=%s&password=%s&fullname=%s' % ( account_id, name, "Comment", user, password, "fullname") resp_tsmcifsauthgroupresponse = sendrequest(stdurl, querycommand) filesave("logs/AccountUserCreation.txt", "w", resp_tsmcifsauthgroupresponse) data = json.loads(resp_tsmcifsauthgroupresponse.text)
from cbrequest import sendrequest, filesave, configFile config = configFile(sys.argv) print "%s" %(config['host']) stdurl = 'https://%s/client/api?apikey=%s&response=%s&' %(config['host'], config['apikey'], config['response']) #querycommand = 'command=%s' %(config['command']) ######## To Make A NFS Volume Begins here print "NFS Volume Creation Begins" ###Stage 1 to 7 , prior to this first 3 commands are for listing. for x in range(1, int(config['Number_of_NFSVolumes'])+1): #for x in range (1, NoofNFSVolumes+1): querycommand = 'command=listHAPool' resp_listHAPool = sendrequest(stdurl,querycommand) filesave("logs/CurrentHAPoolList.txt","w",resp_listHAPool) data = json.loads(resp_listHAPool.text) hapools = data["listHAPoolResponse"]["hapool"] for hapool in hapools: if hapool['name'] == "%s" %(config['volPoolName%d' %(x)]): pool_id = hapool['id'] break #print "Poolid =" ,pool_id querycommand = 'command=listAccount' resp_listAccount = sendrequest(stdurl, querycommand) filesave("logs/CurrentAccountList.txt", "w", resp_listAccount) data = json.loads(resp_listAccount.text) accounts = data["listAccountResponse"]["account"] for account in accounts:
import fileinput import subprocess import sys import time from time import ctime from cbrequest import sendrequest, filesave, filesave1, timetrack, queryAsyncJobResult, resultCollection, configFile, executeCmd, createSFTPConnection, getControllerInfo if len(sys.argv) < 3: print "Enter in following Format:python PoolDedup.py configfile on/off" exit() dedupvalue = sys.argv[2] config = configFile(sys.argv) stdurl = 'https://%s/client/api?apikey=%s&response=%s&' % ( config['host'], config['apikey'], config['response']) querycommand = 'command=listHAPool' resp_listHAPool = sendrequest(stdurl, querycommand) filesave("logs/listHAPool.txt", "w", resp_listHAPool) data = json.loads(resp_listHAPool.text) hapools = data["listHAPoolResponse"]["hapool"] for hapool in hapools: pool_id = hapool['id'] pool_name = hapool['name'] for x in range(1, int(config['Number_of_Pools']) + 1): if pool_name == "%s" % (config['poolName%d' % (x)]): id = pool_id querycommand = 'command=updateHAPool&id=%s&deduplication=%s&' % ( id, dedupvalue) startTime = ctime() resp_updateHAPool = sendrequest(stdurl, querycommand) filesave("logs/updateHAPool.txt", "w", resp_updateHAPool) data = json.loads(resp_updateHAPool.text) if "errortext" in data['updateHAPoolResponse']:
(x)]) iops = 0 print subVolName ### Adding Qosgroup querycommand = 'command=addQosGroup&tsmid=%s&name=%s&latency=%s&blocksize=%s&tpcontrol=%s&throughput=%s&iopscontrol=%s&iops=%s&graceallowed=%s&memlimit=%s&networkspeed=%s' % ( tsm_id, subVolName, config['volCifsLatency%d' % (x)], config['volCifsBlocksize%d' % (x)], config['volCifsTpcontrol%d' % (x)], config['volCifsThroughput%d' % (x)], config['volCifsIopscontrol%d' % (x)], iops, config['volCifsGraceallowed%d' % (x)], config['volCifsMemlimit%d' % (x)], config['volCifsNetworkspeed%d' % (x)]) resp_addQosGroup = sendrequest(stdurl, querycommand) filesave("logs/AddQosGroup.txt", "w", resp_addQosGroup) addQoSResp = json.loads(resp_addQosGroup.text) if 'errorcode' in str(addQoSResp): endTime = ctime() errormsg = str( addQoSResp['addqosgroupresponse']['errortext']) resultCollection( 'Failed to addQoSGroup due to \"%s\"' % (errormsg), ['FAILED', ''], startTime, endTime) exit() qosGroupId = addQoSResp['addqosgroupresponse']['qosgroup'][ 'id'] # calling ceateVolume command querycommand = 'command=createVolume&qosgroupid=%s&tsmid=%s&name=%s"asize=%s&datasetid=%s&deduplication=%s&compression=%s&sync=%s&recordsize=%s&blocklength=%s&mountpoint=%s&protocoltype=%s&' % ( qosGroupId, tsm_id, subVolName, config['volCifsQuotasize%d' %
deleteSnp = 1 else: print bcolors.FAIL + 'PARAMETER ERROR: '+ bcolors.ENDC + bcolors.WARNING + 'Fourth parameter should be \"create or delete\"...' + bcolors.ENDC exit() # exit() stdurl = 'https://%s/client/api?apikey=%s&response=%s&' %(config['host'], config['apikey'], config['response']) result = getControllerInfo('20.10.48.140', 'test', 'zfs list -t snapshot', "tsm_snapshot_result.txt") print result exit() querycommand = 'command=listFileSystem' resp_listFileSystem = sendrequest(stdurl, querycommand) filesave("logs/ListFileSystem.txt", "w", resp_listFileSystem) data = json.loads(resp_listFileSystem.text) filesystems = data["listFilesystemResponse"]["filesystem"] if tsmFlag == 1: #print tsmFlag querycommand = 'command=listTsm' resp_listTsm = sendrequest(stdurl, querycommand) filesave("logs/ListTsm.txt", "w", resp_listTsm) dataTsm = json.loads(resp_listTsm.text) tsms = dataTsm['listTsmResponse']['listTsm'] for x in range(1, int(config['Number_of_TSMs'])+1): startTime = ctime() for listTsm in tsms: tsmid = None if listTsm['name'] == "%s" %(config['tsmName%d' %(x)]):
exit() volIops = sys.argv[3] graceAllowed = "false" if len(sys.argv) == 5: if sys.argv[4] == "true": graceAllowed = "true" else: graceAllowed = "false" ###### To Increase the IOPS #####List Filesystem querycommand = 'command=listFileSystem' resp_listFileSystem = sendrequest(stdurl, querycommand) filesave("logs/ListFileSystem.txt", "w", resp_listFileSystem) data = json.loads(resp_listFileSystem.text) filesystems = data ["listFilesystemResponse"]["filesystem"] for filesystem in filesystems: filesystem_id = filesystem['groupid'] filesystem_name = filesystem['name'] ###NFS if nfsFlag == 1 or allFlag == 1: for x in range(1, int(config['Number_of_NFSVolumes'])+1): if filesystem_name == "%s" %(config['volDatasetname%d' %(x)]): id = filesystem_id querycommand='command=updateQosGroup&id=%s&iops=%s&graceallowed=%s' %(id, volIops, graceAllowed) resp_updateNFS = sendrequest(stdurl, querycommand) filesave("logs/resp_updateNFS.txt", "w", resp_listFileSystem) print ">>>> NFS >>>>updated %s" %(filesystem_name) ###CIFS
stdurl = 'https://%s/client/api?apikey=%s&response=%s&' %(config['host'], config['apikey'], config['response']) type = sys.argv[2] ip = sys.argv[3] passwd = sys.argv[4] startTime = ctime() if type == 'all': component = 'hardware' elif type == 'disks': component = 'storage' else: print 'Second argument should be all/disks' exit() querycommand = 'command=listController' resp_listcontroller = sendrequest(stdurl, querycommand) filesave("logs/ListController.txt", "w", resp_listcontroller) data = json.loads(resp_listcontroller.text) if 'controller' in data["listControllerResponse"]: controllers = data["listControllerResponse"]["controller"] elif 'errorcode' in data["listControllerResponse"]: endTime = ctime() errormsg = data["listControllerResponse"]['errortext'] resultCollection('Not able to list Controllers', ['BLOCKED', errormsg], startTime, endTime) exit() else: endTime = ctime() print "There are no Nodes" resultCollection('There is no controller available, further %s refress test case skipped' %(component), ['BLOCKED', ''], startTime, endTime) exit() flag = 1 for controller in controllers:
if iqn == "system_iqn": iqn = getoutput( 'cat /etc/iscsi/initiatorname.iscsi | grep iqn | cut -d "=" -f 2') iqn = iqn[0].strip() ###get clients ip if ip == "system_ip": ip = getoutput( 'ifconfig eth0 | grep "inet addr:" | cut -d ":" -f 2 | awk \'{ print $1}\'' ) ip = ip[0].strip() ### list of accounts querycommand = 'command=listAccount' resp_listAccount = sendrequest(stdurl, querycommand) filesave("logs/ListAccount.txt", "w", resp_listAccount) data = json.loads(resp_listAccount.text) #print data accounts = data['listAccountResponse']['account'] for x in range(1, int(config['Number_of_Accounts']) + 1): startTime = ctime() for account in accounts: if account['name'] == "%s" % (config['accountName%d' % (x)]): acc_id = account['id'] initname = init + "%d" % (x) ### creating iscsi initiator group querycommand = 'command=addiSCSIInitiator&accountid=%s&name=%s&initiatorgroup=%s&netmask=%s' % ( acc_id, initname, iqn, ip + "%2F8") resp_tsmiSCSIInitiatorResponse = sendrequest(stdurl, querycommand) filesave("logs/tsmiSCSIInitiatorResponse.txt", "w",
negativeFlag = 1 else: print "Argument is not correct.. Correct way as below" print " python ISCSIVolume.py config.txt" print " python ISCSIVolume.py config.txt negative" ######## To Make A iSCSI Volume Begins here print "ISCSI Volume Creation Begins" ###Stage 1 to 6 , prior to this first 3 commands are for listing. for x in range(1, int(config['Number_of_ISCSIVolumes']) + 1): startTime = ctime() #for x in range (1, NoofISCSIVolumes+1): querycommand = 'command=listHAPool' resp_listHAPool = sendrequest(stdurl, querycommand) filesave("logs/CurrentHAPoolList.txt", "w", resp_listHAPool) data = json.loads(resp_listHAPool.text) hapools = data["listHAPoolResponse"]["hapool"] for hapool in hapools: if hapool['name'] == "%s" % (config['voliSCSIPoolName%d' % (x)]): pool_id = hapool['id'] break #print "Poolid =" ,pool_id querycommand = 'command=listAccount' resp_listAccount = sendrequest(stdurl, querycommand) filesave("logs/CurrentAccountList.txt", "w", resp_listAccount) data = json.loads(resp_listAccount.text) accounts = data["listAccountResponse"]["account"] for account in accounts: if account['name'] == "%s" % (config['voliSCSIAccountName%d' % (x)]): account_id = account['id']
'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)])) ### Its comman url for all the api calls stdurl = 'https://%s/client/api?apikey=%s&response=%s&' % ( config['host'], config['apikey'], config['response']) ### command for list filesystem querycommand = 'command=listFileSystem' resp_listFileSystem = sendrequest(stdurl, querycommand) filesave("logs/ListFileSystem.txt", "w", resp_listFileSystem) data = json.loads(resp_listFileSystem.text) filesystems = data["listFilesystemResponse"]["filesystem"] ### NFS protocol if nfsFlag == 1 or allFlag == 1: for x in range(1, int(config['Number_of_NFSVolumes']) + 1): startTime = ctime() for i in range(1, int(No_of_Clones) + 1): cloneName = prefixName + '%s' % (config['volDatasetname%d' % (x)]) + '%d' % (i) for filesystem in filesystems: filesystem_id = None if filesystem['name'] == cloneName: filesystem_id = filesystem['id'] if filesystem_id is not None:
import sys import md5 from time import ctime from cbrequest import sendrequest, filesave, timetrack, queryAsyncJobResult, configFile, resultCollection config = configFile(sys.argv) stdurl = 'https://%s/client/api?apikey=%s&response=%s&' % ( config['host'], config['apikey'], config['response']) for x in range(1, int(config['Number_of_HAAdmins']) + 1): startTime = ctime() ### List HAClusters querycommand = 'command=listHACluster' resp_listHACluster = sendrequest(stdurl, querycommand) filesave("logs/CurrentHAList.txt", "w", resp_listHACluster) data = json.loads(resp_listHACluster.text) clusters = data["listHAClusterResponse"]["hacluster"] clusters_list_id = "" for cluster in clusters: for y in range(1, int(config['noOfHAAssociated%d' % (x)]) + 1): if "%s" % (config['haAssociatedName%d%d' % (y, x)]) == cluster['name']: clusters_list_id += "clusterslist=" clusters_list_id += cluster['id'] clusters_list_id += "&" print cluster['name'] print cluster['id'] print clusters_list_id ### List HAClusters
import json import sys from cbrequest import sendrequest, filesave, timetrack, queryAsyncJobResult, configFile config = configFile(sys.argv) stdurl = 'https://%s/client/api?apikey=%s&response=%s&' % ( config['host'], config['apikey'], config['response']) ###listTSM'S for x in range(1, int(config['Number_of_TSMs']) + 1): querycommand = 'command=listTsm' resp_listTsm = sendrequest(stdurl, querycommand) filesave("logs/listTsm.txt", "w", resp_listTsm) data = json.loads(resp_listTsm.text) tsms = data['listTsmResponse']['listTsm'] for tsm in tsms: tsm_name1 = tsm['name'] tsm_name2 = config["tsmName%d" % (x)] tsm_id = tsm['id'] Acc_name = tsm['accountname'] acc_id = tsm['accountid'] if tsm_name1 == tsm_name2: break AUTH_Name1 = "%sAUTH" % (Acc_name) querycommand = 'command=listTsmCifsService&tsmid=%s' % (tsm_id) resp_cifsService = sendrequest(stdurl, querycommand) filesave("logs/resp_cifsService.txt", "w", resp_cifsService) data = json.loads(resp_cifsService.text) cifsServices = data['listTsmcifsServiceResponse']['cifsService'] for cifsService in cifsServices:
from time import ctime from cbrequest import sendrequest, filesave, timetrack, queryAsyncJobResult, configFile, resultCollection config = configFile(sys.argv) stdurl = 'https://%s/client/api?apikey=%s&response=%s&' % ( config['host'], config['apikey'], config['response']) ########To Add Node #########To List the Current Number of Sites print "Node Creation Begins" timetrack("Node Creation Begins") for x in range(1, int(config['Number_of_Nodes']) + 1): startTime = ctime() querycommand = 'command=listSite' resp_listSite = sendrequest(stdurl, querycommand) filesave("logs/CurrentSitesList.txt", "w", resp_listSite) data = json.loads(resp_listSite.text) sites = data["listSiteResponse"]["site"] site = [ y for y in sites if y["name"] == "%s" % (config['nodeSiteName%d' % (x)]) ].pop(0) site_id = site["id"] #if site else None ###To List the Current Number of HA querycommand = 'command=listHACluster' resp_listHACluster = sendrequest(stdurl, querycommand) filesave("logs/CurrentHAClustersList.txt", "w", resp_listHACluster) data = json.loads(resp_listHACluster.text) haclusters = data["listHAClusterResponse"]["hacluster"] hacluster = [
print bcolors.WARNING + "python cloneDataset.py config.txt <storage_protocol(nfs/cifs/fc/iscsi/all)> snapshot_name No_of_Clones Node_IP Password prefix_name(Optional)" + bcolors.ENDC exit() No_of_Clones = sys.argv[3] IP = sys.argv[4] passwd = sys.argv[5] if len(sys.argv) == 7: prefixName = sys.argv[6] stdurl = 'https://%s/client/api?apikey=%s&response=%s&' % ( config['host'], config['apikey'], config['response']) querycommand = 'command=listFileSystem' resp_listFileSystem = sendrequest(stdurl, querycommand) filesave("logs/ListFileSystem.txt", "w", resp_listFileSystem) data = json.loads(resp_listFileSystem.text) filesystems = data["listFilesystemResponse"]["filesystem"] ### Cifs if cifsFlag == 1 or allFlag == 1: for x in range(1, int(config['Number_of_CIFSVolumes']) + 1): for i in range(1, int(No_of_Clones) + 1): startTime = ctime() for filesystem in filesystems: filesystem_id = None cloneName = prefixName + '%s' % ( config['volCifsDatasetname%d' % (x)]) + '%d' % (i) if filesystem['name'] == cloneName: filesystem_id = filesystem['id'] filesystem_name = filesystem['name']
if len(sys.argv) < 4: print "Argument is not correct.. Correct way as below" print "python staticIPAdd.py config.txt NodeIP NodePassword" exit() IP = sys.argv[2] Password = sys.argv[3] ###TO list the clusters print "%s" % (config['Number_of_Clusters']) for x in range(1, int(config['Number_of_Laggs']) + 1): cluster_id = "" querycommand = 'command=listHACluster' resp_listHACluster = sendrequest(stdurl, querycommand) filesave("logs/listHACluster.txt", "w", resp_listHACluster) data = json.loads(resp_listHACluster.text) clusters = data['listHAClusterResponse']['count'] cluster_list = data['listHAClusterResponse']['hacluster'] for listHACluster in cluster_list: if listHACluster['name'] == config['laggClusterName%d' % x]: cluster_id = data['listHAClusterResponse']['hacluster'][0]['id'] print "ClusterID = %s" % (cluster_id) break querycommand = 'command=listSharedNICs&clusterid=%s' % (cluster_id) resp_listSharedNICs = sendrequest(stdurl, querycommand) data = json.loads(resp_listSharedNICs.text) sharedNICid = data['listSharedNICsResponse']['nic'] filesave("logs/listSharedNICs.txt", "w", resp_listSharedNICs) nic_id = ""
import sys from time import ctime from cbrequest import sendrequest, filesave, timetrack, queryAsyncJobResult, configFile, resultCollection, queryAsyncJobResultNegative config = configFile(sys.argv) stdurl = 'https://%s/client/api?apikey=%s&response=%s&' % ( config['host'], config['apikey'], config['response']) def all_same(items): return all(x == "127.0.0.1" for x in items) querycommand = 'command=listTsm' resp_listTsm = sendrequest(stdurl, querycommand) filesave("logs/listTsm.txt", "w", resp_listTsm) data = json.loads(resp_listTsm.text) tsms = data['listTsmResponse']['listTsm'] dnslist = list() startTime = ctime() for x in range(1, int(config['Number_of_TSMs']) + 1): for tsm in tsms: tsm_name = tsm['name'] tsm_id = tsm['id'] acc_id = tsm['accountid'] if tsm_name == "%s" % config["tsmName%d" % (x)]: querycommand = 'command=listTsmDNSSettings&tsmid=%s' % (tsm_id) resp_TsmDnsSettings = sendrequest(stdurl, querycommand) filesave("logs/resp_TsmDnsSettings.txt", "w", resp_TsmDnsSettings) data = json.loads(resp_TsmDnsSettings.text)
from cbrequest import sendrequest, filesave, configFile config = configFile(sys.argv) stdurl = 'https://%s/client/api?apikey=%s&response=%s&' % ( config['host'], config['apikey'], config['response']) ######## To Make A iSCSI Volume Begins here print "ISCSI Volume Creation Begins" ###Stage 1 to 6 , prior to this first 3 commands are for listing. for x in range(1, int(config['Number_of_ISCSIVolumes']) + 1): #for x in range (1, NoofISCSIVolumes+1): querycommand = 'command=listHAPool' resp_listHAPool = sendrequest(stdurl, querycommand) filesave("logs/CurrentHAPoolList.txt", "w", resp_listHAPool) data = json.loads(resp_listHAPool.text) hapools = data["listHAPoolResponse"]["hapool"] for hapool in hapools: if hapool['name'] == "%s" % (config['voliSCSIPoolName%d' % (x)]): pool_id = hapool['id'] break #print "Poolid =" ,pool_id querycommand = 'command=listAccount' resp_listAccount = sendrequest(stdurl, querycommand) filesave("logs/CurrentAccountList.txt", "w", resp_listAccount) data = json.loads(resp_listAccount.text) accounts = data["listAccountResponse"]["account"] for account in accounts: if account['name'] == "%s" % (config['voliSCSIAccountName%d' % (x)]):
stdurl = 'https://%s/client/api?apikey=%s&response=%s&' %(config['host'], config['apikey'], config['response']) wwpn_list= "" for x in range(1, int(config['Number_Of_FC_Initiator_group'])+1): for y in range(1, int(config['fcNoOfWWPN%d' %(x)])+1): ### separating WWPN's with ',' -> replacing it with %2C as encoding in URL wwpn_list+= config['fcWWPN%d%d' % (y,x)] wwpn_list+="%2C" print wwpn_list ### listing the Accounts querycommand = 'command=listAccount' resp_listAccount = sendrequest(stdurl, querycommand) filesave("logs/CurrentAccountList.txt", "w", resp_listAccount) data = json.loads(resp_listAccount.text) accounts = data["listAccountResponse"]["account"] for account in accounts: if account['name'] == "%s" %(config['fcAccountName%d' %(x)]): account_id = account['id'] break ## Add Fc initiator group querycommand = 'command=addFCInitiator&accountid=%s&wwpn=%s&name=%s' %(account_id ,wwpn_list,config['fcInitName%d' %(x)]) resp_Add_FC_Initiator = sendrequest(stdurl, querycommand) filesave("logs/AddFCInitiator.txt", "w", resp_listAccount) data = json.loads(resp_Add_FC_Initiator.text)
global poolrengiops poolrengiops = getControllerInfo(nodeip, nodepasswd, poolrengcmd1, "output.txt") print "poolrengremainediops= " + poolrengiops poolrengcmd2 = " reng list | grep -A 9 %s | grep 'Renegade throughput remainder' | awk '{print$4}'" % ( fullpoolname) print poolrengcmd2 global poolrengthroughput poolrengthroughput = getControllerInfo(nodeip, nodepasswd, poolrengcmd2, "output.txt") print "poolrengremained throughput=" + poolrengthroughput querycommand = 'command=listFileSystem' resp_listFileSystem = sendrequest(stdurl, querycommand) filesave("logs/ListFileSystem.txt", "w", resp_listFileSystem) data = json.loads(resp_listFileSystem.text) filesystems = data["listFilesystemResponse"]["filesystem"] for filesystem in filesystems: filesystem_id = filesystem['id'] filesystem_name = filesystem['name'] ###NFS if nfsFlag == 1 or allFlag == 1: for x in range(1, int(config['Number_of_NFSVolumes']) + 1): if filesystem_name == "%s" % (config['volDatasetname%d' % (x)]): id = filesystem_id startTime = ctime() poolname = "%s" % (config['volPoolName%d' % (x)]) print poolname fullpoolname = poolname + '_' iopscontrolled = "%s" % (config['volIopscontrol%d' % (x)])
if len(sys.argv) < 4: print "Argument is not correct.. Correct way as below" print "python vlanDelete.py config.txt NodeIP NodePassword" exit() IP = sys.argv[2] Password = sys.argv[3] ###TO list the clusters print "%s" % (config['Number_of_Clusters']) for x in range(1, int(config['Number_of_Vlans']) + 1): startTime = ctime() cluster_id = "" querycommand = 'command=listHACluster' resp_listHACluster = sendrequest(stdurl, querycommand) filesave("logs/listHACluster.txt", "w", resp_listHACluster) data = json.loads(resp_listHACluster.text) clusters = data['listHAClusterResponse']['count'] cluster_list = data['listHAClusterResponse']['hacluster'] for listHACluster in cluster_list: if listHACluster['name'] == config['vlanClusterName%d' % x]: cluster_id = data['listHAClusterResponse']['hacluster'][0]['id'] print "ClusterID = %s" % (cluster_id) break querycommand = 'command=listSharedNICs&clusterid=%s' % cluster_id resp_listSharedNICs = sendrequest(stdurl, querycommand) data = json.loads(resp_listSharedNICs.text) sharedNICid = data['listSharedNICsResponse']['nic'] filesave("logs/listSharedNICs.txt", "w", resp_listSharedNICs)
exit() snapshotName = sys.argv[3] No_of_Clones = sys.argv[4] IP = sys.argv[5] passwd = sys.argv[6] if len(sys.argv) == 8: prefixName = sys.argv[7] stdurl = 'https://%s/client/api?apikey=%s&response=%s&' % ( config['host'], config['apikey'], config['response']) querycommand = 'command=listFileSystem' resp_listFileSystem = sendrequest(stdurl, querycommand) filesave("logs/ListFileSystem.txt", "w", resp_listFileSystem) data = json.loads(resp_listFileSystem.text) filesystems = data["listFilesystemResponse"]["filesystem"] ### Cifs if cifsFlag == 1 or allFlag == 1: for x in range(1, int(config['Number_of_CIFSVolumes']) + 1): startTime = ctime() for filesystem in filesystems: filesystem_id = None if filesystem['name'] == "%s" % (config['volCifsDatasetname%d' % (x)]): filesystem_id = filesystem['id'] filesystem_name = filesystem['name'] if filesystem_id is not None: for i in range(1, int(No_of_Clones) + 1):
print "Argument is not correct.. Correct way as below" print "python tpAlert.py config.txt type x" print "where type is volume/pool and x is the severity of TP alert 1 for error 2 for critical and 3 for warning and 4 for info" exit() x = sys.argv[3] print x startTime = ctime() stdurl = 'https://%s/client/api?apikey=%s&response=%s&' % ( config['host'], config['apikey'], config['response']) #########List All Alerts querycommand = 'command=listAlerts' resp_listAlerts = sendrequest(stdurl, querycommand) filesave("logs/ListAlerts.txt", "w", resp_listAlerts) data = json.loads(resp_listAlerts.text) #### Finding TP Alert for volume if volumeFlag == 1: alerts = data["listalertsresponse"]["alert"] print alerts for alert in alerts: if "space" in alert['subject'] and alert[ 'description'] == "Volume Capacity": if alert['severity'] == int(x): print "Thin provisioning alert for volume, severity is %s" % x endTime = ctime() resultCollection(alert['subject'], ["PASSED", ""], startTime, endTime)
import json import sys from cbrequest import sendrequest, filesave, timetrack, queryAsyncJobResult, configFile config = configFile(sys.argv) stdurl = 'https://%s/client/api?apikey=%s&response=%s&' % ( config['host'], config['apikey'], config['response']) initname = sys.argv[2] #### Set the iSCSI Initiator to All querycommand = 'command=listFileSystem' resp_listFileSystem = sendrequest(stdurl, querycommand) filesave("logs/ListFileSystem.txt", "w", resp_listFileSystem) data = json.loads(resp_listFileSystem.text) filesystems = data["listFilesystemResponse"]["filesystem"] for x in range(1, int(config['Number_of_ISCSIVolumes']) + 1): for filesystem in filesystems: filesystem_id = filesystem['id'] filesystem_name = filesystem['name'] if filesystem_name == "%s" % (config['voliSCSIDatasetname%d' % (x)]): querycommand = 'command=listVolumeiSCSIService&storageid=%s' % ( filesystem_id) resp_listVolumeiSCSIService = sendrequest(stdurl, querycommand) filesave("logs/listVolumeiSCSIService.txt", "w", resp_listVolumeiSCSIService) data1 = json.loads(resp_listVolumeiSCSIService.text) iscsi_service_id = data1["listVolumeiSCSIServiceResponse"][ "iSCSIService"][0]["id"] ag_id = data1["listVolumeiSCSIServiceResponse"]["iSCSIService"][0][ "ag_id"]
import json import sys import md5 from time import ctime from cbrequest import sendrequest, filesave, timetrack, queryAsyncJobResult, configFile, resultCollection config = configFile(sys.argv); stdurl = 'https://%s/client/api?apikey=%s&response=%s&' %(config['host'], config['apikey'], config['response']) for x in range(1, int(config['Number_of_SiteAdmins'])+1): startTime = ctime() querycommand = 'command=listSite' resp_listSite = sendrequest(stdurl, querycommand) filesave("logs/CurrentSitesList.txt", "w", resp_listSite) data = json.loads(resp_listSite.text) sites = data["listSiteResponse"]["site"] sites_list_id = "" for site in sites: for y in range (1, int(config['noOfSitesAssociated%d' %(x)])+1): if "%s" %(config['siteAssociatedName%d%d' %(y,x)]) == site['name']: sites_list_id += "siteslist=" sites_list_id += site['id'] sites_list_id += "&" print sites_list_id ###To create a site-admin m = md5.new() m.update("%s" %(config['siteAdminPassword%d' %(x)]))
import json import sys from cbrequest import sendrequest, filesave, timetrack, queryAsyncJobResult, configFile, filesave1 config = configFile(sys.argv) stdurl = 'https://%s/client/api?apikey=%s&response=%s&' % ( config['host'], config['apikey'], config['response']) ### To list number of Nodes querycommand = 'command=listController' resp_listController = sendrequest(stdurl, querycommand) filesave("logs/CurrentNodes.txt", "w", resp_listController) data = json.loads(resp_listController.text) #version = data["listControllerResponse"]["version"] controllers = data["listControllerResponse"]["controller"] for controller in controllers: version = controller['version'] break filesave1("installed_version", "w", version) print "Installed Version= ", version
from time import ctime from cbrequest import sendrequest, filesave, timetrack, queryAsyncJobResult, configFile, executeCmd, getoutput, resultCollection config = configFile(sys.argv) stdurl = 'https://%s/client/api?apikey=%s&response=%s&' % ( config['host'], config['apikey'], config['response']) if len(sys.argv) < 2: print "Argument is not correct.. Correct way as below" print " python createAuthgrp.py config.txt" exit() ### list of accounts querycommand = 'command=listAccount' resp_listAccount = sendrequest(stdurl, querycommand) filesave("logs/ListAccount.txt", "w", resp_listAccount) data = json.loads(resp_listAccount.text) #print data accounts = data['listAccountResponse']['account'] for x in range(1, int(config['Number_of_Accounts']) + 1): startTime = ctime() for account in accounts: if account['name'] == "%s" % (config['accountName%d' % (x)]): acc_id = account['id'] authgrp_name = "AuthGrp" + "%d" % (x) comment = "Auth%20Group%20Info." querycommand = 'command=addiSCSIAuthGroup&accountid=%s&name=%s&comment=%s&chapusername=ChapUser&chappassword=ChapPassword&mutualchapusername=MutualUser&mutualchappassword=MutualPassword' % ( acc_id, authgrp_name, comment) resp_tsmiSCSIAuthGroupResponse = sendrequest(stdurl, querycommand) filesave("logs/tsmiSCSIAuthGroupResponse.txt", "w",
import json from cbrequest import sendrequest, filesave, timetrack, queryAsyncJobResult, configfilefun import sys config = configfilefun(sys.argv) stdurl = 'https://%s/client/api?apikey=%s&response=%s&' % ( config['host'], config['apikey'], config['response']) #########To Add the Sites print "Site Creation Begins" timetrack("Site Creation Begins") for x in range(1, int(config['Number_of_Sites']) + 1): querycommand = 'command=createSite&location=%s&name=%s&description=%s' % ( config['siteLocation%d' % (x)], config['siteName%d' % (x)], config['siteDescription%d' % (x)]) resp_createSite = sendrequest(stdurl, querycommand) filesave("logs/AddSiteList.txt", "w", resp_createSite) print "Site %d Creation Begins" % (x) timetrack("Site Creation Done") print "Site Creation Done"
OKGREEN = '\033[92m' WARNING = '\033[93m' FAIL = '\033[91m' ENDC = '\033[0m' if len(sys.argv) < 3: print bcolors.WARNING + "python changeNfsThread.py snapshot.txt Number_of_Threads" + bcolors.ENDC exit() config = configFile(sys.argv); No_of_threads = sys.argv[2] print No_of_threads stdurl = 'https://%s/client/api?apikey=%s&response=%s&' %(config['host'], config['apikey'], config['response']) querycommand = 'command=listTsm' resp_listTsm = sendrequest(stdurl, querycommand) filesave("logs/ListTsm.txt", "w", resp_listTsm) dataTsm = json.loads(resp_listTsm.text) tsms = dataTsm['listTsmResponse']['listTsm'] for x in range(1, int(config['Number_of_TSMs'])+1): startTime = ctime() for listTsm in tsms: tsmid = None if listTsm['name'] == "%s" %(config['tsmName%d' %(x)]): tsmid = listTsm['id'] print tsmid if tsmid is not None: querycommand = 'command=updateTsmNfsOptions&nfsworkerthreads=%s&tsmid=%s' %(No_of_threads, tsmid) change_NFSThread_resp = sendrequest(stdurl, querycommand) filesave("logs/changeNFSThreads.txt", "w", change_NFSThread_resp) changeThreadResp = json.loads(change_NFSThread_resp.text) if 'errortext' in str(changeThreadResp):