def _configure(self, dev, size, wwn, write_back): self._check_self() block_type = get_blockdev_type(dev) if block_type is None: # a file if os.path.exists(os.path.realpath(dev)) and not os.path.isfile(dev): raise RTSLibError("Path not to a file or block device") if size is None: raise RTSLibError("Path is to a file, size needed") self._control("fd_dev_name=%s,fd_dev_size=%d" % (dev, size)) else: # a block device # size is ignored but we can't raise an exception because # dump() saves it and thus restore() will call us with it. if block_type != 0: raise RTSLibError("Device is not a TYPE_DISK block device") if is_dev_in_use(dev): raise RTSLibError("Device %s is already in use" % dev) self._control("fd_dev_name=%s" % dev) if write_back: self.set_attribute("emulate_write_cache", 1) self._control("fd_buffered_io=%d" % write_back) self._set_udev_path(dev) self._enable() super(FileIOStorageObject, self)._configure(wwn)
def _configure(self, dev, wwn, readonly): self._check_self() if get_blockdev_type(dev) != 0: raise RTSLibError("Device %s is not a TYPE_DISK block device" % dev) if is_dev_in_use(dev): raise RTSLibError("Cannot configure StorageObject because " + "device %s is already in use" % dev) self._set_udev_path(dev) self._control("udev_path=%s" % dev) self._control("readonly=%d" % readonly) self._enable() super(BlockStorageObject, self)._configure(wwn)
def _configure(self, dev, wwn, readonly, write_back): self._check_self() if get_blockdev_type(dev) != 0: raise RTSLibError("Device is not a TYPE_DISK block device.") if is_dev_in_use(dev): raise RTSLibError("Cannot configure StorageObject because " + "device %s is already in use." % dev) self._set_udev_path(dev) self._control("udev_path=%s" % dev) self._control("readonly=%d" % readonly) self._enable() if write_back: self.set_attribute("emulate_write_cache", 1) super(BlockStorageObject, self)._configure(wwn)
def _is_block(self): return get_blockdev_type(self.udev_path) is not None