Best Python code snippet using avocado_python
lv_utils.py
Source:lv_utils.py
...47 vg_size = ramdisk_vg_size48 vg_ramdisk_dir = os.path.join(ramdisk_basedir, vg_name)49 ramdisk_filename = os.path.join(vg_ramdisk_dir,50 ramdisk_sparse_filename)51 vg_ramdisk_cleanup(ramdisk_filename,52 vg_ramdisk_dir, vg_name, "")53 result = ""54 if not os.path.exists(vg_ramdisk_dir):55 os.mkdir(vg_ramdisk_dir)56 try:57 logging.info("Mounting tmpfs")58 result = process.run("mount -t tmpfs tmpfs " + vg_ramdisk_dir)59 logging.info("Converting and copying /dev/zero")60 cmd = ("dd if=/dev/zero of=" + ramdisk_filename +61 " bs=1M count=1 seek=" + vg_size)62 result = process.run(cmd, verbose=True)63 logging.info("Finding free loop device")64 result = process.run("losetup --find", verbose=True)65 except process.CmdError, ex:66 logging.error(ex)67 vg_ramdisk_cleanup(ramdisk_filename,68 vg_ramdisk_dir, vg_name, "")69 raise ex70 loop_device = result.stdout.rstrip()71 try:72 logging.info("Creating loop device")73 result = process.run("losetup " + loop_device + " " + ramdisk_filename)74 logging.info("Creating physical volume %s", loop_device)75 result = process.run("pvcreate " + loop_device)76 logging.info("Creating volume group %s", vg_name)77 result = process.run("vgcreate " + vg_name + " " + loop_device)78 except process.CmdError, ex:79 logging.error(ex)80 vg_ramdisk_cleanup(ramdisk_filename, vg_ramdisk_dir, vg_name,81 loop_device)82 raise ex83 logging.info(result.stdout.rstrip())84def vg_ramdisk_cleanup(ramdisk_filename, vg_ramdisk_dir,85 vg_name, loop_device):86 """87 Inline cleanup function in case of test error.88 """89 result = process.run("vgremove " + vg_name, ignore_status=True)90 if result.exit_status == 0:91 logging.info(result.stdout.rstrip())92 else:93 logging.debug("%s -> %s", result.command, result.stderr)94 result = process.run("pvremove " + loop_device, ignore_status=True)95 if result.exit_status == 0:96 logging.info(result.stdout.rstrip())97 else:98 logging.debug("%s -> %s", result.command, result.stderr)...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!