def _configure(self, size, wwn): self._check_self() size = convert_human_to_bytes(size) # convert to 4k pages size = round(float(size)/4096) if size == 0: size = 1 self._control("rd_pages=%d" % size) self._enable() if wwn: self.wwn = generate_wwn('unit_serial')
def _configure(self, dev, size, wwn, buffered_mode): self._check_self() rdev = os.path.realpath(dev) if not os.path.isdir(os.path.dirname(rdev)): raise RTSLibError("The dev parameter must be a path to a " + "file inside an existing directory, " + "not %s." % str(os.path.dirname(dev))) if os.path.isdir(rdev): raise RTSLibError("The dev parameter must be a path to a " + "file or block device not a directory:" + "%s." % dev) block_type = get_block_type(rdev) if block_type is None and not is_disk_partition(rdev): if os.path.exists(rdev) and not os.path.isfile(dev): raise RTSLibError("Device %s is neither a file, " % dev + "a disk partition or a block device.") # It is a file if size is None: raise RTSLibError("The size parameter is mandatory " + "when using a file.") size = convert_human_to_bytes(size) self._control("fd_dev_name=%s,fd_dev_size=%d" % (dev, size)) else: # it is a block device or a disk partition if size is not None: raise RTSLibError("You cannot specify a size for a " + "block device.") if block_type != 0 and block_type is not None: raise RTSLibError("Device %s is a block device, " % dev + "but not of TYPE_DISK.") if is_dev_in_use(rdev): raise RTSLibError("Cannot configure StorageObject " + "because device " + "%s is already in use." % dev) if is_disk_partition(rdev): size = get_disk_size(rdev) print "fd_dev_name=%s,fd_dev_size=%d" % (dev, size) self._control("fd_dev_name=%s,fd_dev_size=%d" % (dev, size)) else: self._control("fd_dev_name=%s" % dev) self._set_udev_path(dev) if buffered_mode: self._set_buffered_mode() self._enable() if wwn: self.wwn = generate_wwn('unit_serial')
def _configure(self, size, wwn, nullio): self._check_self() size = convert_human_to_bytes(size) # convert to 4k pages size = round(float(size) / 4096) if size == 0: size = 1 self._control("rd_pages=%d" % size) if nullio: self._control("rd_nullio=1") self._enable() self.wwn = wwn self.restore_pr_aptpl()
def _configure(self, dev, size, wwn, buffered_mode): self._check_self() rdev = os.path.realpath(dev) if not os.path.isdir(os.path.dirname(rdev)): raise RTSLibError("The dev parameter must be a path to a " + "file inside an existing directory, " + "not %s." % str(os.path.dirname(dev))) if os.path.isdir(rdev): raise RTSLibError("The dev parameter must be a path to a " + "file or block device not a directory:" + "%s." % dev) block_type = get_block_type(rdev) if block_type is None and not is_disk_partition(rdev): if os.path.exists(rdev) and not os.path.isfile(dev): raise RTSLibError("Device %s is neither a file, " % dev + "a disk partition or a block device.") # It is a file if size is None: raise RTSLibError("The size parameter is mandatory " + "when using a file.") size = convert_human_to_bytes(size) self._control("fd_dev_name=%s,fd_dev_size=%d" % (dev, size)) else: # it is a block device or a disk partition if size is not None: raise RTSLibError("You cannot specify a size for a " + "block device.") if block_type != 0 and block_type is not None: raise RTSLibError("Device %s is a block device, " % dev + "but not of TYPE_DISK.") if is_dev_in_use(rdev): raise RTSLibError("Cannot configure StorageObject " + "because device " + "%s is already in use." % dev) if is_disk_partition(rdev): size = get_disk_size(rdev) self._control("fd_dev_name=%s,fd_dev_size=%d" % (dev, size)) else: self._control("fd_dev_name=%s" % dev) self._set_udev_path(dev) if buffered_mode: self._set_buffered_mode() self._enable() if wwn: self.wwn = generate_wwn('unit_serial')
def _configure(self, size, wwn, nullio): self._check_self() size = convert_human_to_bytes(size) # convert to 4k pages size = round(float(size) / 4096) if size == 0: size = 1 self._control("rd_pages=%d" % size) if nullio: self._control("rd_nullio=1") self._enable() if wwn: self.wwn = generate_wwn('unit_serial')
def _configure(self, size, wwn, nullio): self._check_self() size = convert_human_to_bytes(size) # convert to 4k pages size = round(float(size)/4096) if size == 0: size = 1 self._control("rd_pages=%d" % size) if nullio: self._control("rd_nullio=1") self._enable() self.wwn = wwn self.restore_pr_aptpl()