wasp_general.os.linux package¶
Submodules¶
wasp_general.os.linux.lvm module¶
-
class
wasp_general.os.linux.lvm.WLVMInfo(command, fields_count, lvm_entity, sudo=False)[source]¶ Bases:
objectBasic class for actual LVM information. This class creates
WLVMInfoCommandobject which may be called on an object creation (it depends on constructor parameters)
-
class
wasp_general.os.linux.lvm.WLVMInfoCommand(command, fields_count, cmd_timeout=None, sudo=False)[source]¶ Bases:
objectThis is a helper, with which it is easier to call for pvdisplay, vgdisplay or lvdisplay program.
This class uses subprocess.check_output method for a program calling. And when non-zero code is returned by the program, an subprocess.CalledProcessError exception is raised. There is a timeout for a program to be complete. If a program wasn’t completed for that period of time, subprocess.TimeoutExpired exception is raised
-
class
wasp_general.os.linux.lvm.WLogicalVolume(logical_volume, sudo=False)[source]¶ Bases:
wasp_general.os.linux.lvm.WLVMInfoClass represent a logical volume
-
create_snapshot(snapshot_size, snapshot_suffix)[source]¶ Create snapshot for this logical volume.
Parameters: - snapshot_size – size of newly created snapshot volume. This size is a fraction of the source logical volume space (of this logical volume)
- snapshot_suffix – suffix for logical volume name (base part is the same as the original volume name)
Returns: WLogicalVolume
-
device_number()[source]¶ Return tuple of major and minor device number of logical volume
Returns: tuple of int
-
classmethod
logical_volume(file_path, sudo=False)[source]¶ Return logical volume that stores the given path
Parameters: - file_path – target path to search
- sudo – same as ‘sudo’ in
WLogicalVolume.__init__()
Returns: WLogicalVolume or None (if file path is outside current mount points)
-
snapshot_allocation()[source]¶ Return allocated size (fraction of total snapshot volume space). If this is not a snapshot volume, than RuntimeError exception is raised.
Returns: float
-
-
class
wasp_general.os.linux.lvm.WPhysicalVolume(physical_volume, sudo=False)[source]¶ Bases:
wasp_general.os.linux.lvm.WLVMInfoClass represent a physical volume
-
allocated_extents()[source]¶ Return allocated number of physical extents (may have 0 value if this volume is not allocated to any)
Returns: int
-
extent_size()[source]¶ Return physical extent size in kilobytes (may have 0 value if this volume is not allocated to any)
Returns: int
-
free_extents()[source]¶ Return free number of physical extents (may have 0 value if this volume is not allocated to any)
Returns: int
-
-
class
wasp_general.os.linux.lvm.WVolumeGroup(volume_group, sudo=False)[source]¶ Bases:
wasp_general.os.linux.lvm.WLVMInfoClass represent a volume group
-
allocated_extents()[source]¶ Return allocated number of physical extents for this volume group
Returns: int
-
maximum_logical_volumes()[source]¶ Return maximum number of logical volumes (0 - for unlimited)
Returns: int
-
maximum_physical_volumes()[source]¶ Return maximum number of physical volumes (0 - for unlimited)
Returns: int
-
wasp_general.os.linux.mounts module¶
-
class
wasp_general.os.linux.mounts.WMountPoint(mount_record)[source]¶ Bases:
objectThis class supply information about system mount points. It allows to find mount point by a custom file path.
-
classmethod
mount(device, mount_directory, fs=None, options=None, cmd_timeout=None, sudo=False)[source]¶ Mount a device to mount directory
Parameters: - device – device to mount
- mount_directory – target directory where the given device will be mounted to
- fs – optional, filesystem on the specified device. If specifies - overrides OS filesystem detection with this value.
- options – specifies mount options (OS/filesystem dependent)
- cmd_timeout – if specified - timeout with which this mount command should be evaluated (if command isn’t complete within the given timeout - an exception will be raised)
- sudo – whether to use sudo to run mount command
Returns: None
-
classmethod
mount_point(file_path)[source]¶ Return mount point that, where the given path is reside on
Parameters: file_path – target path to search Returns: WMountPoint or None (if file path is outside current mount points)
-
options()[source]¶ Return a mount point options (options with which this point was mounted)
Returns: tuple of str
-
classmethod
umount(device_or_directory, cmd_timeout=None, sudo=False)[source]¶ Unmount device (or mount directory)
Parameters: - device_or_directory – device name or mount directory to unmount
- cmd_timeout – if specified - timeout with which this unmount command should be evaluated (if command isn’t complete within the given timeout - an exception will be raised)
- sudo – whether to use sudo to run mount command
Returns: None
-
classmethod