if not os.path.exists(device): sys.stderr.write("device %s not found\n" % sys.argv[3]) sys.exit(2) try: if not stat.S_ISBLK(os.stat(device).st_mode): sys.stderr.write("%s is not a block device\n" % sys.argv[3]) sys.exit(3) except OSError, e: Utils.log("unable to get device %s mode: %s" % (device, str(e))) sys.stderr.write("unable to get device %s mode\n" % sys.argv[3]) sys.exit(-2) if fsType in ['ext3', 'ext4', 'ext4dev']: deviceSize = DiskUtils.getProcPartitions()[deviceName]['Size'] if deviceSize >= SIZE_TB_16: Utils.log("device %s, size %s is greater than %s size for fstype %s" % (device, deviceSize, SIZE_TB_16, fsType)) sys.stderr.write("size of device %s is unsupported for fstype %s\n" % (sys.argv[3], fsType)) sys.exit(4) if DiskUtils.isDataDiskPartitionFormatted(device): sys.stderr.write("device %s already formatted\n" % sys.argv[3]) sys.exit(5) if os.path.exists(mountPoint): if not os.path.isdir(mountPoint): sys.stderr.write("mount point %s exists but not a directory" % mountPoint) sys.exit(6) procMounts = Utils.readFile("/proc/mounts") if procMounts.find(" %s " % mountPoint) != -1:
if not os.path.exists(device): sys.stderr.write("device %s not found\n" % sys.argv[3]) sys.exit(2) try: if not stat.S_ISBLK(os.stat(device).st_mode): sys.stderr.write("%s is not a block device\n" % sys.argv[3]) sys.exit(3) except OSError, e: Utils.log("unable to get device %s mode: %s" % (device, str(e))) sys.stderr.write("unable to get device %s mode\n" % sys.argv[3]) sys.exit(-2) if fsType in ['ext3', 'ext4', 'ext4dev']: deviceSize = DiskUtils.getProcPartitions()[deviceName]['Size'] if deviceSize >= SIZE_TB_16: Utils.log( "device %s, size %s is greater than %s size for fstype %s" % (device, deviceSize, SIZE_TB_16, fsType)) sys.stderr.write( "size of device %s is unsupported for fstype %s\n" % (sys.argv[3], fsType)) sys.exit(4) if DiskUtils.isDataDiskPartitionFormatted(device): sys.stderr.write("device %s already formatted\n" % sys.argv[3]) sys.exit(5) if os.path.exists(mountPoint): if not os.path.isdir(mountPoint):