How to use iscsi_login method in autotest

Best Python code snippet using autotest_python

neo2lun_http.py

Source:neo2lun_http.py Github

copy

Full Screen

...70 #time.sleep(1)71 subprocess.Popen('iscsiadm -m session -u',shell=True)72 #print('logout all iscsi session')73 subprocess.Popen('iscsiadm -m session',shell=True)74def iscsi_login(ip,targetname):75 cmd='iscsiadm -m discovery -t st -p '+str(ip)+'|grep '+targetname+"|awk 'BEGIN{ORS=\"\"}{print $2}'"76 return_code=subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE)77 re=return_code.stdout.readlines()78 if len(re) < 1 : 79 print("Not find Target : %s --> has some errors. CMD:%s " %(targetname,cmd))80 exit(1)81 print(str(''.join(re)))82 time.sleep(1)83 cmd2='iscsiadm -m node -T '+str(''.join(re))+ ' -p ' +str(ip)+' -l'84 print(cmd2)85 subprocess.Popen(cmd2,shell=True)86def get_iscsi_dev():87 cmd='lsblk |grep disk|grep -v " 8:"|grep -v "leo"'+"|awk '{print $1}'"88 return_code=subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE)89 re=return_code.stdout.readlines()90 print(''.join(re))91if __name__ == '__main__':92 url="http://13.10.12.31" #managerd节点93 iscsitarget='13.10.12.30' #连接的 target server94 loginurl=url+'/login.do'95 header={'User-Agent':'Apache-HttpClient/4.5.3 (Java/1.8.0_131)','Content-Type':'application/x-www-form-urlencoded'}96 logininfo={'username':'admin','password':'admin'}97 #layout='rep';repnum='2';disknum='' #leoraid,xd,rep98 layout='xd';repnum='1';disknum='2' #leoraid,xd,rep99 size=150100 blksize=['512']101 spannum=['1','2','4','8','16']102 # spansize=['65536','131072','262144','67108864','134217728','536870912'] #spansize=[64K,128K,256K,64M,128M,512M]103 spansize=['131072','262144','33554432','67108864','134217728']104 targetname='pytest'+layout+disknum+repnum #无需更改105 #退出当前所有session106# iscsi_u()107 #添加target108 add_target(loginurl,logininfo,targetname,layout,repnum,disknum)109 #添加lun110 add_lun(targetname,loginurl,logininfo,spannum,spansize,blksize,size)111# print("wait 20s... target,lun creating");time.sleep(20)112 113# iscsi_login(iscsitarget,targetname)...

Full Screen

Full Screen

47e9353a31a563146ab345be563b2d9a5f310f65-<_login>-fix.py

Source:47e9353a31a563146ab345be563b2d9a5f310f65-<_login>-fix.py Github

copy

Full Screen

1def _login(self, storage_type, storage):2 if (storage_type == 'iscsi'):3 hosts_service = self._connection.system_service().hosts_service()4 host_id = get_id_by_name(hosts_service, self._module.params['host'])...

Full Screen

Full Screen

47e9353a31a563146ab345be563b2d9a5f310f65-<_login>-bug.py

Source:47e9353a31a563146ab345be563b2d9a5f310f65-<_login>-bug.py Github

copy

Full Screen

1def _login(self, storage_type, storage):2 if (storage_type == 'iscsi'):3 hosts_service = self._connection.system_service().hosts_service()4 host = search_by_name(hosts_service, self._module.params['host'])...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful