How to use get_disk_mountpoint method in avocado

Best Python code snippet using avocado_python


Source:fedora-admin-cluster Github


Full Screen

...517 # find system disk518 for index in root_point:519 sys_disk.append("/dev/" + disk_label[index])520 return sys_disk521def get_disk_mountpoint(disk_name, node=None):522 # success return 0,disk error !0,errorinfo523 disk = Disk(disk_name)524 if not disk_name or disk_name == "":525 Error(610, "disk name is none")526 return 1, "disk name is none"527 # run command get disk mount info528 # info like this : NAME="/dev/sdb1" TYPE="part" MOUNTPOINT="/var/lib/icfs/osd/icfs-0"529 if node:530 flag, mountinfo = run_command(node=node, comm='lsblk %s -P -o name,type,mountpoint' % disk_name)531 else:532 flag, mountinfo = run_command(comm="lsblk %s -P -o name,type,mountpoint" % disk_name)533 # handel return info534 if flag != 0:535 return flag, mountinfo536 else:537 infos = mountinfo.splitlines()538 for info in infos:539 diskinfo = info.split()540 name = diskinfo[0].split("=")[1].replace("\"", "")541 mtype = diskinfo[1].split("=")[1].replace("\"", "")542 mountpoint = diskinfo[2].split("=")[1].replace("\"", "")543 if mtype == "disk":544 if mountpoint != "":545 disk.mountPoint = mountpoint546 disk.isMounted = True547 if mtype == "part":548 disk_part = Disk("/dev/" + name)549 disk_part.type = mtype550 if mountpoint != "":551 disk_part.isMounted = True552 disk.isMounted |= True553 disk_part.mountPoint = mountpoint554 disk.partList.append(disk_part)555 return 0, disk556def get_all_data_disk(node=None):557 # get date disk list ,return disk_list,error_list558 flag, disk_info = run_command(comm="ls /sys/block/", node=node)559 if flag == 0:560 disk_info_list = disk_info.splitlines()561 # disk name : sd*(sata) hd*(ide) vd*(virtio)562 disk_info_list = ["/dev/" + i for i in disk_info_list if re.match("^(sd|hd|vd).*$", i)]563 else:564 Error(714, disk_info)565 return 0, 0566 # remove system disk567 sys_disk = find_sys_disk(node)568 for sys_disk_name in sys_disk:569 try:570 disk_info_list.remove(sys_disk_name)571 except Exception:572 pass573 # print "can't find disk : " + sys_disk_name574 # get all data disk mount info575 disk_list = []576 error_list = []577 for disk_name in disk_info_list:578 error, disk = get_disk_mountpoint(disk_name, node)579 if not error:580 disk_list.append(disk)581 else:582 error_list.append("NODE:%s ; DISKNAME:%s ; ERRORCODE:%s ; ERRORINFO:%s " % (node, disk_name, error, disk))583 return disk_list, error_list584def zeroing(dev):585 lba_size = 4096586 size = 33 * lba_size587 with open(dev, 'wb') as f:588, os.SEEK_END)589 f.write(size * b'\0')590 f.close()591def _get_parttion_info(node, part_dic):592 code = 0...

Full Screen

Full Screen Github


Full Screen

...190 dev, fs_dir, _, _, _, _ = mount_line.split()191 if fs_dir == dir_path:192 return dev193 return None194def get_disk_mountpoint(device):195 """196 get mountpoint on which given disk is mounted197 :param device: disk/device name198 :type device: str199 :return: return directory name on which disk is mounted200 :rtype: str201 """202 with open("/proc/mounts") as mounts: # pylint: disable=W1514203 for mount_line in mounts.readlines():204 dev, fs_dir, _, _, _, _ = mount_line.split()205 if dev == device:206 return fs_dir...

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:


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

Run avocado 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?